Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs/proc: Don't lock root inode when creating "self" and "thread-self"

proc_setup_self() and proc_setup_thread_self() are only called from
proc_fill_super() which is before the filesystem is "live". So there is
no need to lock the root directory when adding "self" and "thread-self".
This is clear from simple_fill_super() which provides similar
functionality for other filesystems and does not lock anything.

The locking is not harmful, except that it may be confusing to a reader.
As part of an effort to centralise all locking for directories for
name-based operations (prior to changing some locking rules), it is
simplest to remove the locking here.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: NeilBrown <neil@brown.name>
Link: https://patch.msgid.link/20260224222542.3458677-3-neilb@ownmail.net
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

NeilBrown and committed by
Christian Brauner
9ab68389 c025a533

-6
-3
fs/proc/self.c
··· 35 35 36 36 int proc_setup_self(struct super_block *s) 37 37 { 38 - struct inode *root_inode = d_inode(s->s_root); 39 38 struct dentry *self; 40 39 int ret = -ENOMEM; 41 40 42 - inode_lock(root_inode); 43 41 self = d_alloc_name(s->s_root, "self"); 44 42 if (self) { 45 43 struct inode *inode = new_inode(s); ··· 53 55 } 54 56 dput(self); 55 57 } 56 - inode_unlock(root_inode); 57 58 58 59 if (ret) 59 60 pr_err("proc_fill_super: can't allocate /proc/self\n");
-3
fs/proc/thread_self.c
··· 35 35 36 36 int proc_setup_thread_self(struct super_block *s) 37 37 { 38 - struct inode *root_inode = d_inode(s->s_root); 39 38 struct dentry *thread_self; 40 39 int ret = -ENOMEM; 41 40 42 - inode_lock(root_inode); 43 41 thread_self = d_alloc_name(s->s_root, "thread-self"); 44 42 if (thread_self) { 45 43 struct inode *inode = new_inode(s); ··· 53 55 } 54 56 dput(thread_self); 55 57 } 56 - inode_unlock(root_inode); 57 58 58 59 if (ret) 59 60 pr_err("proc_fill_super: can't allocate /proc/thread-self\n");