Skip to content

Commit f340b3d

Browse files
hongnanlitytso
authored andcommitted
fs/ext4: fix comments mentioning i_mutex
inode->i_mutex has been replaced with inode->i_rwsem long ago. Fix comments still mentioning i_mutex. Signed-off-by: hongnanli <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 8fca8a2 commit f340b3d

File tree

8 files changed

+20
-20
lines changed

8 files changed

+20
-20
lines changed

fs/ext4/acl.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ ext4_acl_to_disk(const struct posix_acl *acl, size_t *size)
139139
/*
140140
* Inode operation get_posix_acl().
141141
*
142-
* inode->i_mutex: don't care
142+
* inode->i_rwsem: don't care
143143
*/
144144
struct posix_acl *
145145
ext4_get_acl(struct inode *inode, int type, bool rcu)
@@ -183,7 +183,7 @@ ext4_get_acl(struct inode *inode, int type, bool rcu)
183183
/*
184184
* Set the access or default ACL of an inode.
185185
*
186-
* inode->i_mutex: down unless called from ext4_new_inode
186+
* inode->i_rwsem: down unless called from ext4_new_inode
187187
*/
188188
static int
189189
__ext4_set_acl(handle_t *handle, struct inode *inode, int type,
@@ -271,8 +271,8 @@ ext4_set_acl(struct user_namespace *mnt_userns, struct inode *inode,
271271
/*
272272
* Initialize the ACLs of a new inode. Called from ext4_new_inode.
273273
*
274-
* dir->i_mutex: down
275-
* inode->i_mutex: up (access to inode is still exclusive)
274+
* dir->i_rwsem: down
275+
* inode->i_rwsem: up (access to inode is still exclusive)
276276
*/
277277
int
278278
ext4_init_acl(handle_t *handle, struct inode *inode, struct inode *dir)

fs/ext4/ext4.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ struct ext4_inode_info {
10281028

10291029
/*
10301030
* Extended attributes can be read independently of the main file
1031-
* data. Taking i_mutex even when reading would cause contention
1031+
* data. Taking i_rwsem even when reading would cause contention
10321032
* between readers of EAs and writers of regular file data, so
10331033
* instead we synchronize on xattr_sem when reading or changing
10341034
* EAs.
@@ -3407,7 +3407,7 @@ do { \
34073407
#define EXT4_FREECLUSTERS_WATERMARK 0
34083408
#endif
34093409

3410-
/* Update i_disksize. Requires i_mutex to avoid races with truncate */
3410+
/* Update i_disksize. Requires i_rwsem to avoid races with truncate */
34113411
static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
34123412
{
34133413
WARN_ON_ONCE(S_ISREG(inode->i_mode) &&
@@ -3418,7 +3418,7 @@ static inline void ext4_update_i_disksize(struct inode *inode, loff_t newsize)
34183418
up_write(&EXT4_I(inode)->i_data_sem);
34193419
}
34203420

3421-
/* Update i_size, i_disksize. Requires i_mutex to avoid races with truncate */
3421+
/* Update i_size, i_disksize. Requires i_rwsem to avoid races with truncate */
34223422
static inline int ext4_update_inode_size(struct inode *inode, loff_t newsize)
34233423
{
34243424
int changed = 0;

fs/ext4/ext4_jbd2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ static inline int ext4_free_data_revoke_credits(struct inode *inode, int blocks)
491491
/*
492492
* This function controls whether or not we should try to go down the
493493
* dioread_nolock code paths, which makes it safe to avoid taking
494-
* i_mutex for direct I/O reads. This only works for extent-based
494+
* i_rwsem for direct I/O reads. This only works for extent-based
495495
* files, and it doesn't work if data journaling is enabled, since the
496496
* dioread_nolock code uses b_private to pass information back to the
497497
* I/O completion handler, and this conflicts with the jbd's use of

fs/ext4/extents.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ static int ext4_ext_trunc_restart_fn(struct inode *inode, int *dropped)
9797
* Drop i_data_sem to avoid deadlock with ext4_map_blocks. At this
9898
* moment, get_block can be called only for blocks inside i_size since
9999
* page cache has been already dropped and writes are blocked by
100-
* i_mutex. So we can safely drop the i_data_sem here.
100+
* i_rwsem. So we can safely drop the i_data_sem here.
101101
*/
102102
BUG_ON(EXT4_JOURNAL(inode) == NULL);
103103
ext4_discard_preallocations(inode, 0);
@@ -4574,7 +4574,7 @@ static long ext4_zero_range(struct file *file, loff_t offset,
45744574

45754575
flags = EXT4_GET_BLOCKS_CREATE_UNWRIT_EXT;
45764576

4577-
/* Wait all existing dio workers, newcomers will block on i_mutex */
4577+
/* Wait all existing dio workers, newcomers will block on i_rwsem */
45784578
inode_dio_wait(inode);
45794579

45804580
/* Preallocate the range including the unaligned edges */
@@ -4740,7 +4740,7 @@ long ext4_fallocate(struct file *file, int mode, loff_t offset, loff_t len)
47404740
goto out;
47414741
}
47424742

4743-
/* Wait all existing dio workers, newcomers will block on i_mutex */
4743+
/* Wait all existing dio workers, newcomers will block on i_rwsem */
47444744
inode_dio_wait(inode);
47454745

47464746
ret = ext4_alloc_file_blocks(file, lblk, max_blocks, new_size, flags);
@@ -5573,7 +5573,7 @@ static int ext4_insert_range(struct inode *inode, loff_t offset, loff_t len)
55735573
* stuff such as page-cache locking consistency, bh mapping consistency or
55745574
* extent's data copying must be performed by caller.
55755575
* Locking:
5576-
* i_mutex is held for both inodes
5576+
* i_rwsem is held for both inodes
55775577
* i_data_sem is locked for write for both inodes
55785578
* Assumptions:
55795579
* All pages from requested range are locked for both inodes

fs/ext4/indirect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ static int ext4_ind_trunc_restart_fn(handle_t *handle, struct inode *inode,
696696
* Drop i_data_sem to avoid deadlock with ext4_map_blocks. At this
697697
* moment, get_block can be called only for blocks inside i_size since
698698
* page cache has been already dropped and writes are blocked by
699-
* i_mutex. So we can safely drop the i_data_sem here.
699+
* i_rwsem. So we can safely drop the i_data_sem here.
700700
*/
701701
BUG_ON(EXT4_JOURNAL(inode) == NULL);
702702
ext4_discard_preallocations(inode, 0);

fs/ext4/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ static int ext4_write_begin(struct file *file, struct address_space *mapping,
12231223
/*
12241224
* __block_write_begin may have instantiated a few blocks
12251225
* outside i_size. Trim these off again. Don't need
1226-
* i_size_read because we hold i_mutex.
1226+
* i_size_read because we hold i_rwsem.
12271227
*
12281228
* Add inode to orphan list in case we crash before
12291229
* truncate finishes
@@ -3972,7 +3972,7 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length)
39723972

39733973
}
39743974

3975-
/* Wait all existing dio workers, newcomers will block on i_mutex */
3975+
/* Wait all existing dio workers, newcomers will block on i_rwsem */
39763976
inode_dio_wait(inode);
39773977

39783978
/*
@@ -4122,7 +4122,7 @@ int ext4_truncate(struct inode *inode)
41224122
/*
41234123
* There is a possibility that we're either freeing the inode
41244124
* or it's a completely new inode. In those cases we might not
4125-
* have i_mutex locked because it's not necessary.
4125+
* have i_rwsem locked because it's not necessary.
41264126
*/
41274127
if (!(inode->i_state & (I_NEW|I_FREEING)))
41284128
WARN_ON(!inode_is_locked(inode));
@@ -5264,7 +5264,7 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
52645264
* transaction are already on disk (truncate waits for pages under
52655265
* writeback).
52665266
*
5267-
* Called with inode->i_mutex down.
5267+
* Called with inode->i_rwsem down.
52685268
*/
52695269
int ext4_setattr(struct user_namespace *mnt_userns, struct dentry *dentry,
52705270
struct iattr *attr)

fs/ext4/migrate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ int ext4_ext_migrate(struct inode *inode)
485485
* when we add extents we extent the journal
486486
*/
487487
/*
488-
* Even though we take i_mutex we can still cause block
488+
* Even though we take i_rwsem we can still cause block
489489
* allocation via mmap write to holes. If we have allocated
490490
* new blocks we fail migrate. New block allocation will
491491
* clear EXT4_STATE_EXT_MIGRATE flag. The flag is updated

fs/ext4/orphan.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ static int ext4_orphan_file_add(handle_t *handle, struct inode *inode)
9393
* At filesystem recovery time, we walk this list deleting unlinked
9494
* inodes and truncating linked inodes in ext4_orphan_cleanup().
9595
*
96-
* Orphan list manipulation functions must be called under i_mutex unless
96+
* Orphan list manipulation functions must be called under i_rwsem unless
9797
* we are just creating the inode or deleting it.
9898
*/
9999
int ext4_orphan_add(handle_t *handle, struct inode *inode)
@@ -119,7 +119,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
119119
/*
120120
* Orphan handling is only valid for files with data blocks
121121
* being truncated, or files being unlinked. Note that we either
122-
* hold i_mutex, or the inode can not be referenced from outside,
122+
* hold i_rwsem, or the inode can not be referenced from outside,
123123
* so i_nlink should not be bumped due to race
124124
*/
125125
ASSERT((S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||

0 commit comments

Comments
 (0)