Skip to content

Commit de6bf18

Browse files
Louis RillingMark Fasheh
authored andcommitted
[PATCH] configfs: Consolidate locking around configfs_detach_prep() in configfs_rmdir()
It appears that configfs_rmdir() can protect configfs_detach_prep() retries with less calls to {spin,mutex}_{lock,unlock}, and a cleaner code. This patch does not change any behavior, except that it removes two useless lock/unlock pairs having nothing inside to protect and providing a useless barrier. Signed-off-by: Louis Rilling <louis.rilling@kerlabs.com> Signed-off-by: Joel Becker <Joel.Becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
1 parent 9780eb6 commit de6bf18

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

‎fs/configfs/dir.c‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,16 +1311,18 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
13111311
* Ensure that no racing symlink() will make detach_prep() fail while
13121312
* the new link is temporarily attached
13131313
*/
1314-
mutex_lock(&configfs_symlink_mutex);
1315-
spin_lock(&configfs_dirent_lock);
13161314
do {
13171315
struct mutex *wait_mutex;
13181316

1317+
mutex_lock(&configfs_symlink_mutex);
1318+
spin_lock(&configfs_dirent_lock);
13191319
ret = configfs_detach_prep(dentry, &wait_mutex);
1320-
if (ret) {
1320+
if (ret)
13211321
configfs_detach_rollback(dentry);
1322-
spin_unlock(&configfs_dirent_lock);
1323-
mutex_unlock(&configfs_symlink_mutex);
1322+
spin_unlock(&configfs_dirent_lock);
1323+
mutex_unlock(&configfs_symlink_mutex);
1324+
1325+
if (ret) {
13241326
if (ret != -EAGAIN) {
13251327
config_item_put(parent_item);
13261328
return ret;
@@ -1329,13 +1331,8 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
13291331
/* Wait until the racing operation terminates */
13301332
mutex_lock(wait_mutex);
13311333
mutex_unlock(wait_mutex);
1332-
1333-
mutex_lock(&configfs_symlink_mutex);
1334-
spin_lock(&configfs_dirent_lock);
13351334
}
13361335
} while (ret == -EAGAIN);
1337-
spin_unlock(&configfs_dirent_lock);
1338-
mutex_unlock(&configfs_symlink_mutex);
13391336

13401337
/* Get a working ref for the duration of this function */
13411338
item = configfs_get_config_item(dentry);

0 commit comments

Comments
 (0)