Skip to content

Commit bf636ed

Browse files
author
Al Viro
committed
ceph_d_revalidate(): use stable parent inode passed by caller
No need to mess with the boilerplate for obtaining what we already have. Note that ceph is one of the "will want a path from filesystem root if we want to talk to server" cases, so the name of the last component is of little use - it is passed to fscrypt_d_revalidate() and it's used to deal with (also crypt-related) case in request marshalling, when encrypted name turns out to be too long. The former is not a problem, but the latter is racy; that part will be handled in the next commit. Reviewed-by: Jeff Layton <[email protected]> Reviewed-by: Viacheslav Dubeyko <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent da19202 commit bf636ed

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

fs/ceph/dir.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,30 +1940,19 @@ static int dir_lease_is_valid(struct inode *dir, struct dentry *dentry,
19401940
/*
19411941
* Check if cached dentry can be trusted.
19421942
*/
1943-
static int ceph_d_revalidate(struct inode *parent_dir, const struct qstr *name,
1943+
static int ceph_d_revalidate(struct inode *dir, const struct qstr *name,
19441944
struct dentry *dentry, unsigned int flags)
19451945
{
19461946
struct ceph_mds_client *mdsc = ceph_sb_to_fs_client(dentry->d_sb)->mdsc;
19471947
struct ceph_client *cl = mdsc->fsc->client;
19481948
int valid = 0;
1949-
struct dentry *parent;
1950-
struct inode *dir, *inode;
1949+
struct inode *inode;
19511950

1952-
valid = fscrypt_d_revalidate(parent_dir, name, dentry, flags);
1951+
valid = fscrypt_d_revalidate(dir, name, dentry, flags);
19531952
if (valid <= 0)
19541953
return valid;
19551954

1956-
if (flags & LOOKUP_RCU) {
1957-
parent = READ_ONCE(dentry->d_parent);
1958-
dir = d_inode_rcu(parent);
1959-
if (!dir)
1960-
return -ECHILD;
1961-
inode = d_inode_rcu(dentry);
1962-
} else {
1963-
parent = dget_parent(dentry);
1964-
dir = d_inode(parent);
1965-
inode = d_inode(dentry);
1966-
}
1955+
inode = d_inode_rcu(dentry);
19671956

19681957
doutc(cl, "%p '%pd' inode %p offset 0x%llx nokey %d\n",
19691958
dentry, dentry, inode, ceph_dentry(dentry)->offset,
@@ -2039,9 +2028,6 @@ static int ceph_d_revalidate(struct inode *parent_dir, const struct qstr *name,
20392028
doutc(cl, "%p '%pd' %s\n", dentry, dentry, valid ? "valid" : "invalid");
20402029
if (!valid)
20412030
ceph_dir_clear_complete(dir);
2042-
2043-
if (!(flags & LOOKUP_RCU))
2044-
dput(parent);
20452031
return valid;
20462032
}
20472033

0 commit comments

Comments
 (0)