Skip to content

Commit 541795c

Browse files
author
Al Viro
committed
ceph_d_revalidate(): propagate stable name down into request encoding
Currently get_fscrypt_altname() requires ->r_dentry->d_name to be stable and it gets that in almost all cases. The only exception is ->d_revalidate(), where we have a stable name, but it's passed separately - dentry->d_name is not stable there. Propagate it down to get_fscrypt_altname() as a new field of struct ceph_mds_request - ->r_dname, to be used instead ->r_dentry->d_name when non-NULL. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent bf636ed commit 541795c

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

fs/ceph/dir.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,6 +1998,8 @@ static int ceph_d_revalidate(struct inode *dir, const struct qstr *name,
19981998
req->r_parent = dir;
19991999
ihold(dir);
20002000

2001+
req->r_dname = name;
2002+
20012003
mask = CEPH_STAT_CAP_INODE | CEPH_CAP_AUTH_SHARED;
20022004
if (ceph_security_xattr_wanted(dir))
20032005
mask |= CEPH_CAP_XATTR_SHARED;

fs/ceph/mds_client.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2621,6 +2621,7 @@ static u8 *get_fscrypt_altname(const struct ceph_mds_request *req, u32 *plen)
26212621
{
26222622
struct inode *dir = req->r_parent;
26232623
struct dentry *dentry = req->r_dentry;
2624+
const struct qstr *name = req->r_dname;
26242625
u8 *cryptbuf = NULL;
26252626
u32 len = 0;
26262627
int ret = 0;
@@ -2641,8 +2642,10 @@ static u8 *get_fscrypt_altname(const struct ceph_mds_request *req, u32 *plen)
26412642
if (!fscrypt_has_encryption_key(dir))
26422643
goto success;
26432644

2644-
if (!fscrypt_fname_encrypted_size(dir, dentry->d_name.len, NAME_MAX,
2645-
&len)) {
2645+
if (!name)
2646+
name = &dentry->d_name;
2647+
2648+
if (!fscrypt_fname_encrypted_size(dir, name->len, NAME_MAX, &len)) {
26462649
WARN_ON_ONCE(1);
26472650
return ERR_PTR(-ENAMETOOLONG);
26482651
}
@@ -2657,7 +2660,7 @@ static u8 *get_fscrypt_altname(const struct ceph_mds_request *req, u32 *plen)
26572660
if (!cryptbuf)
26582661
return ERR_PTR(-ENOMEM);
26592662

2660-
ret = fscrypt_fname_encrypt(dir, &dentry->d_name, cryptbuf, len);
2663+
ret = fscrypt_fname_encrypt(dir, name, cryptbuf, len);
26612664
if (ret) {
26622665
kfree(cryptbuf);
26632666
return ERR_PTR(ret);

fs/ceph/mds_client.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ struct ceph_mds_request {
299299
struct inode *r_target_inode; /* resulting inode */
300300
struct inode *r_new_inode; /* new inode (for creates) */
301301

302+
const struct qstr *r_dname; /* stable name (for ->d_revalidate) */
303+
302304
#define CEPH_MDS_R_DIRECT_IS_HASH (1) /* r_direct_hash is valid */
303305
#define CEPH_MDS_R_ABORTED (2) /* call was aborted */
304306
#define CEPH_MDS_R_GOT_UNSAFE (3) /* got an unsafe reply */

0 commit comments

Comments
 (0)