Skip to content

Commit dbd4540

Browse files
author
Al Viro
committed
kill lock_two_inodes()
There's only one caller left (lock_two_nondirectories()), and it needs less complexity. Fold lock_two_inodes() in there and simplify. Reviewed-by: Jan Kara <jack@suse.cz> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 22e111e commit dbd4540

File tree

2 files changed

+6
-45
lines changed

2 files changed

+6
-45
lines changed

fs/inode.c

Lines changed: 6 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,48 +1087,6 @@ void discard_new_inode(struct inode *inode)
10871087
}
10881088
EXPORT_SYMBOL(discard_new_inode);
10891089

1090-
/**
1091-
* lock_two_inodes - lock two inodes (may be regular files but also dirs)
1092-
*
1093-
* Lock any non-NULL argument. The caller must make sure that if he is passing
1094-
* in two directories, one is not ancestor of the other. Zero, one or two
1095-
* objects may be locked by this function.
1096-
*
1097-
* @inode1: first inode to lock
1098-
* @inode2: second inode to lock
1099-
* @subclass1: inode lock subclass for the first lock obtained
1100-
* @subclass2: inode lock subclass for the second lock obtained
1101-
*/
1102-
void lock_two_inodes(struct inode *inode1, struct inode *inode2,
1103-
unsigned subclass1, unsigned subclass2)
1104-
{
1105-
if (!inode1 || !inode2) {
1106-
/*
1107-
* Make sure @subclass1 will be used for the acquired lock.
1108-
* This is not strictly necessary (no current caller cares) but
1109-
* let's keep things consistent.
1110-
*/
1111-
if (!inode1)
1112-
swap(inode1, inode2);
1113-
goto lock;
1114-
}
1115-
1116-
/*
1117-
* If one object is directory and the other is not, we must make sure
1118-
* to lock directory first as the other object may be its child.
1119-
*/
1120-
if (S_ISDIR(inode2->i_mode) == S_ISDIR(inode1->i_mode)) {
1121-
if (inode1 > inode2)
1122-
swap(inode1, inode2);
1123-
} else if (!S_ISDIR(inode1->i_mode))
1124-
swap(inode1, inode2);
1125-
lock:
1126-
if (inode1)
1127-
inode_lock_nested(inode1, subclass1);
1128-
if (inode2 && inode2 != inode1)
1129-
inode_lock_nested(inode2, subclass2);
1130-
}
1131-
11321090
/**
11331091
* lock_two_nondirectories - take two i_mutexes on non-directory objects
11341092
*
@@ -1144,7 +1102,12 @@ void lock_two_nondirectories(struct inode *inode1, struct inode *inode2)
11441102
WARN_ON_ONCE(S_ISDIR(inode1->i_mode));
11451103
if (inode2)
11461104
WARN_ON_ONCE(S_ISDIR(inode2->i_mode));
1147-
lock_two_inodes(inode1, inode2, I_MUTEX_NORMAL, I_MUTEX_NONDIR2);
1105+
if (inode1 > inode2)
1106+
swap(inode1, inode2);
1107+
if (inode1)
1108+
inode_lock(inode1);
1109+
if (inode2 && inode2 != inode1)
1110+
inode_lock_nested(inode2, I_MUTEX_NONDIR2);
11481111
}
11491112
EXPORT_SYMBOL(lock_two_nondirectories);
11501113

fs/internal.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
196196
int dentry_needs_remove_privs(struct mnt_idmap *, struct dentry *dentry);
197197
bool in_group_or_capable(struct mnt_idmap *idmap,
198198
const struct inode *inode, vfsgid_t vfsgid);
199-
void lock_two_inodes(struct inode *inode1, struct inode *inode2,
200-
unsigned subclass1, unsigned subclass2);
201199

202200
/*
203201
* fs-writeback.c

0 commit comments

Comments
 (0)