Why filesystem locks inode->i_rwsem in write progress but do not locks it in read?
by helloty from LinuxQuestions.org on (#5SQHH)
I am learning filesystem. And the lock mechanism in the filesystem confuses me a lot. I found that both in EXT4 and F2FS. The ext4/f2fs _file_write_iter function calls inode_lock to lock inode->i_rwsem at the beginning and inode_unlock at the end which means concurrently writes to the same file would be serialized. But both ext4/f2f2 _file_read_iter calls generic_file_read_iter() provided by VFS. And the generic_file_read_iter() does not lock the inode->i_rwsem.
As I understand now, concurrent writes to the same file will be serialized but reads/writes from/to the same file can be interleaving. Am I right?
If my understanding is correct, why is it designed like that? Why not serialize read and write?
As I understand now, concurrent writes to the same file will be serialized but reads/writes from/to the same file can be interleaving. Am I right?
If my understanding is correct, why is it designed like that? Why not serialize read and write?