Article 5SQHH Why filesystem locks inode->i_rwsem in write progress but do not locks it in read?

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?latest?d=yIl2AUoC8zA latest?i=RGkBhSu6x3c:nnh5QOQdIDw:F7zBnMy latest?i=RGkBhSu6x3c:nnh5QOQdIDw:V_sGLiP latest?d=qj6IDK7rITs latest?i=RGkBhSu6x3c:nnh5QOQdIDw:gIN9vFw
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments