Skip to content

Commit be14824

Browse files
Christoph HellwigAl Viro
Christoph Hellwig
authored and
Al Viro
committed
fs: take dcache_lock inside __d_path
All callers take dcache_lock just around the call to __d_path, so take the lock into it in preparation of getting rid of dcache_lock. Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent 85fe402 commit be14824

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

fs/dcache.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -1994,7 +1994,7 @@ static int prepend_path(const struct path *path, struct path *root,
19941994
* Returns a pointer into the buffer or an error code if the
19951995
* path was too long.
19961996
*
1997-
* "buflen" should be positive. Caller holds the dcache_lock.
1997+
* "buflen" should be positive.
19981998
*
19991999
* If path is not reachable from the supplied root, then the value of
20002000
* root is changed (without modifying refcounts).
@@ -2006,10 +2006,12 @@ char *__d_path(const struct path *path, struct path *root,
20062006
int error;
20072007

20082008
prepend(&res, &buflen, "\0", 1);
2009+
spin_lock(&dcache_lock);
20092010
error = prepend_path(path, root, &res, &buflen);
2011+
spin_unlock(&dcache_lock);
2012+
20102013
if (error)
20112014
return ERR_PTR(error);
2012-
20132015
return res;
20142016
}
20152017

fs/seq_file.c

-2
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,7 @@ int seq_path_root(struct seq_file *m, struct path *path, struct path *root,
462462
if (size) {
463463
char *p;
464464

465-
spin_lock(&dcache_lock);
466465
p = __d_path(path, root, buf, size);
467-
spin_unlock(&dcache_lock);
468466
res = PTR_ERR(p);
469467
if (!IS_ERR(p)) {
470468
char *end = mangle_path(buf, p, esc);

security/apparmor/path.c

-2
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ static int d_namespace_path(struct path *path, char *buf, int buflen,
7272
path_get(&root);
7373
}
7474

75-
spin_lock(&dcache_lock);
7675
tmp = root;
7776
res = __d_path(path, &tmp, buf, buflen);
78-
spin_unlock(&dcache_lock);
7977

8078
*name = res;
8179
/* handle error conditions - and still allow a partial path to

security/tomoyo/realpath.c

-2
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,8 @@ char *tomoyo_realpath_from_path(struct path *path)
127127
/* If we don't have a vfsmount, we can't calculate. */
128128
if (!path->mnt)
129129
break;
130-
spin_lock(&dcache_lock);
131130
/* go to whatever namespace root we are under */
132131
pos = __d_path(path, &ns_root, buf, buf_len);
133-
spin_unlock(&dcache_lock);
134132
/* Prepend "/proc" prefix if using internal proc vfs mount. */
135133
if (!IS_ERR(pos) && (path->mnt->mnt_flags & MNT_INTERNAL) &&
136134
(path->mnt->mnt_sb->s_magic == PROC_SUPER_MAGIC)) {

0 commit comments

Comments
 (0)