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);

再次感谢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值