generic_file_buffered_write()

简单处理后,把重担交给了generic_perform_write()

mm/filemap.c:

2667 generic_file_buffered_write(struct kiocb *iocb, const struct iovec *iov,
2668         unsigned long nr_segs, loff_t pos, loff_t *ppos,
2669         size_t count, ssize_t written)              
2670 { 
//@nr_segs:最早从do_sync_write()传下来时等于1,在ocfs2_file_aio_write()中调用
//generic_segment_checks(&nr_segs),即对struct iovec向量进行检查,看是否每个分量
//都是access_ok()?   
//@count: number of bytes to write
//@written: 从ocfs2_file_aio_write()传下来等于0
2671     struct file *file = iocb->ki_filp;
2672     ssize_t status;     
2673     struct iov_iter i;
2674      
//初始化iovec迭代器,逻辑很简单
2675     iov_iter_init(&i, iov, nr_segs, count, written);
//here we go!
2676     status = generic_perform_write(file, &i, pos);
2677                                                       
2678     if (likely(status >= 0)) {
2679         written += status;
2680         *ppos = pos + status;
2681     }
2682         
2683     return written ? written : status;
2684 }




你可能感兴趣的:(generic_file_buffered_write())