Skip to content

Commit

Permalink
[PATCH] configfs: Consolidate locking around configfs_detach_prep() i…
Browse files Browse the repository at this point in the history
…n 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>
  • Loading branch information
Louis Rilling authored and Mark Fasheh committed Aug 22, 2008
1 parent 9780eb6 commit de6bf18
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions fs/configfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -1311,16 +1311,18 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
* Ensure that no racing symlink() will make detach_prep() fail while
* the new link is temporarily attached
*/
mutex_lock(&configfs_symlink_mutex);
spin_lock(&configfs_dirent_lock);
do {
struct mutex *wait_mutex;

mutex_lock(&configfs_symlink_mutex);
spin_lock(&configfs_dirent_lock);
ret = configfs_detach_prep(dentry, &wait_mutex);
if (ret) {
if (ret)
configfs_detach_rollback(dentry);
spin_unlock(&configfs_dirent_lock);
mutex_unlock(&configfs_symlink_mutex);
spin_unlock(&configfs_dirent_lock);
mutex_unlock(&configfs_symlink_mutex);

if (ret) {
if (ret != -EAGAIN) {
config_item_put(parent_item);
return ret;
Expand All @@ -1329,13 +1331,8 @@ static int configfs_rmdir(struct inode *dir, struct dentry *dentry)
/* Wait until the racing operation terminates */
mutex_lock(wait_mutex);
mutex_unlock(wait_mutex);

mutex_lock(&configfs_symlink_mutex);
spin_lock(&configfs_dirent_lock);
}
} while (ret == -EAGAIN);
spin_unlock(&configfs_dirent_lock);
mutex_unlock(&configfs_symlink_mutex);

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

0 comments on commit de6bf18

Please sign in to comment.