Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 45c076c5 authored by Tejun Heo's avatar Tejun Heo Committed by Greg Kroah-Hartman
Browse files

sysfs: use ilookup5() instead of ilookup5_nowait()



As inode creation is protected by sysfs_mutex, ilookup5_nowait()
always either fails to find at all or finds one which is fully
initialized, so using ilookup5_nowait() or ilookup5() doesn't make any
difference.  Switch to ilookup5() as it's planned to be removed.  This
change also makes lookup return value handling a bit simpler.

This change was suggested by Al Viro.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Cc: Al Viro <viro@hera.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 8a89efd1
Loading
Loading
Loading
Loading
+8 −9
Original line number Original line Diff line number Diff line
@@ -370,17 +370,17 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
	memset(acxt, 0, sizeof(*acxt));
	memset(acxt, 0, sizeof(*acxt));
	acxt->parent_sd = parent_sd;
	acxt->parent_sd = parent_sd;


	/* Lookup parent inode.  inode initialization and I_NEW
	/* Lookup parent inode.  inode initialization is protected by
	 * clearing are protected by sysfs_mutex.  By grabbing it and
	 * sysfs_mutex, so inode existence can be determined by
	 * looking up with _nowait variant, inode state can be
	 * looking up inode while holding sysfs_mutex.
	 * determined reliably.
	 */
	 */
	mutex_lock(&sysfs_mutex);
	mutex_lock(&sysfs_mutex);


	inode = ilookup5_nowait(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
	inode = ilookup5(sysfs_sb, parent_sd->s_ino, sysfs_ilookup_test,
			 parent_sd);
			 parent_sd);
	if (inode) {
		WARN_ON(inode->i_state & I_NEW);


	if (inode && !(inode->i_state & I_NEW)) {
		/* parent inode available */
		/* parent inode available */
		acxt->parent_inode = inode;
		acxt->parent_inode = inode;


@@ -393,8 +393,7 @@ void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
			mutex_lock(&inode->i_mutex);
			mutex_lock(&inode->i_mutex);
			mutex_lock(&sysfs_mutex);
			mutex_lock(&sysfs_mutex);
		}
		}
	} else
	}
		iput(inode);
}
}


/**
/**