diff options
author | Jan Kara <jack@suse.com> | 2015-12-07 14:35:49 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2015-12-07 14:35:49 -0500 |
commit | e74031fd7ed0989da8a80364b4d269a57e9c164a (patch) | |
tree | 82a6520202b1e4637fbfebd7088058bd42c2e5cd | |
parent | 011278485ecc3cd2a3954b5d4c73101d919bf1fa (diff) |
ext4: document lock ordering
We have enough locks that it's probably worth documenting the lock
ordering rules we have in ext4.
Signed-off-by: Jan Kara <jack@suse.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | fs/ext4/super.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 493370e6590e..486e869bd583 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -80,6 +80,36 @@ static void ext4_destroy_lazyinit_thread(void); | |||
80 | static void ext4_unregister_li_request(struct super_block *sb); | 80 | static void ext4_unregister_li_request(struct super_block *sb); |
81 | static void ext4_clear_request_list(void); | 81 | static void ext4_clear_request_list(void); |
82 | 82 | ||
83 | /* | ||
84 | * Lock ordering | ||
85 | * | ||
86 | * Note the difference between i_mmap_sem (EXT4_I(inode)->i_mmap_sem) and | ||
87 | * i_mmap_rwsem (inode->i_mmap_rwsem)! | ||
88 | * | ||
89 | * page fault path: | ||
90 | * mmap_sem -> sb_start_pagefault -> i_mmap_sem (r) -> transaction start -> | ||
91 | * page lock -> i_data_sem (rw) | ||
92 | * | ||
93 | * buffered write path: | ||
94 | * sb_start_write -> i_mutex -> mmap_sem | ||
95 | * sb_start_write -> i_mutex -> transaction start -> page lock -> | ||
96 | * i_data_sem (rw) | ||
97 | * | ||
98 | * truncate: | ||
99 | * sb_start_write -> i_mutex -> EXT4_STATE_DIOREAD_LOCK (w) -> i_mmap_sem (w) -> | ||
100 | * i_mmap_rwsem (w) -> page lock | ||
101 | * sb_start_write -> i_mutex -> EXT4_STATE_DIOREAD_LOCK (w) -> i_mmap_sem (w) -> | ||
102 | * transaction start -> i_data_sem (rw) | ||
103 | * | ||
104 | * direct IO: | ||
105 | * sb_start_write -> i_mutex -> EXT4_STATE_DIOREAD_LOCK (r) -> mmap_sem | ||
106 | * sb_start_write -> i_mutex -> EXT4_STATE_DIOREAD_LOCK (r) -> | ||
107 | * transaction start -> i_data_sem (rw) | ||
108 | * | ||
109 | * writepages: | ||
110 | * transaction start -> page lock(s) -> i_data_sem (rw) | ||
111 | */ | ||
112 | |||
83 | #if !defined(CONFIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT2) | 113 | #if !defined(CONFIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT2) |
84 | static struct file_system_type ext2_fs_type = { | 114 | static struct file_system_type ext2_fs_type = { |
85 | .owner = THIS_MODULE, | 115 | .owner = THIS_MODULE, |