700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > linux proc文件 write的原子性 linux - Linux中writev()系统调用的原子性 - 堆栈内存溢出...

linux proc文件 write的原子性 linux - Linux中writev()系统调用的原子性 - 堆栈内存溢出...

时间:2020-11-20 16:21:53

相关推荐

linux proc文件 write的原子性 linux - Linux中writev()系统调用的原子性 - 堆栈内存溢出...

在fs.h找到它:

static inline void file_start_write(struct file *file)

{

if (!S_ISREG(file_inode(file)->i_mode))

return;

__sb_start_write(file_inode(file)->i_sb, SB_FREEZE_WRITE, true);

}

然后在super.c:

/*

* This is an internal function, please use sb_start_{write,pagefault,intwrite}

* instead.

*/

int __sb_start_write(struct super_block *sb, int level, bool wait)

{

bool force_trylock = false;

int ret = 1;

#ifdef CONFIG_LOCKDEP

/*

* We want lockdep to tell us about possible deadlocks with freezing

* but it's it bit tricky to properly instrument it. Getting a freeze

* protection works as getting a read lock but there are subtle

* problems. XFS for example gets freeze protection on internal level

* twice in some cases, which is OK only because we already hold a

* freeze protection also on higher level. Due to these cases we have

* to use wait == F (trylock mode) which must not fail.

*/

if (wait) {

int i;

for (i = 0; i < level - 1; i++)

if (percpu_rwsem_is_held(sb->s_writers.rw_sem + i)) {

force_trylock = true;

break;

}

}

#endif

if (wait && !force_trylock)

percpu_down_read(sb->s_writers.rw_sem + level-1);

else

ret = percpu_down_read_trylock(sb->s_writers.rw_sem + level-1);

WARN_ON(force_trylock & !ret);

return ret;

}

EXPORT_SYMBOL(__sb_start_write);

再次感谢。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。