Skip to content

Commit a5ffd7b

Browse files
lxbszidryomov
authored andcommitted
ceph: pass ino# instead of old_dentry if it's disconnected
When exporting the kceph to NFS it may pass a DCACHE_DISCONNECTED dentry for the link operation. Then it will parse this dentry as a snapdir, and the mds will fail the link request as -EROFS. MDS allow clients to pass a ino# instead of a path. Link: https://tracker.ceph.com/issues/59515 Signed-off-by: Xiubo Li <xiubli@redhat.com> Reviewed-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
1 parent aaf67de commit a5ffd7b

2 files changed

Lines changed: 16 additions & 3 deletions

File tree

fs/ceph/dir.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,15 +1050,18 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir,
10501050
struct ceph_mds_request *req;
10511051
int err;
10521052

1053+
if (dentry->d_flags & DCACHE_DISCONNECTED)
1054+
return -EINVAL;
1055+
10531056
err = ceph_wait_on_conflict_unlink(dentry);
10541057
if (err)
10551058
return err;
10561059

10571060
if (ceph_snap(dir) != CEPH_NOSNAP)
10581061
return -EROFS;
10591062

1060-
dout("link in dir %p old_dentry %p dentry %p\n", dir,
1061-
old_dentry, dentry);
1063+
dout("link in dir %p %llx.%llx old_dentry %p:'%pd' dentry %p:'%pd'\n",
1064+
dir, ceph_vinop(dir), old_dentry, old_dentry, dentry, dentry);
10621065
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LINK, USE_AUTH_MDS);
10631066
if (IS_ERR(req)) {
10641067
d_drop(dentry);
@@ -1067,6 +1070,12 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir,
10671070
req->r_dentry = dget(dentry);
10681071
req->r_num_caps = 2;
10691072
req->r_old_dentry = dget(old_dentry);
1073+
/*
1074+
* The old_dentry maybe a DCACHE_DISCONNECTED dentry, then we
1075+
* will just pass the ino# to MDSs.
1076+
*/
1077+
if (old_dentry->d_flags & DCACHE_DISCONNECTED)
1078+
req->r_ino2 = ceph_vino(d_inode(old_dentry));
10701079
req->r_parent = dir;
10711080
ihold(dir);
10721081
set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags);

fs/ceph/mds_client.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2570,6 +2570,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
25702570
u64 ino1 = 0, ino2 = 0;
25712571
int pathlen1 = 0, pathlen2 = 0;
25722572
bool freepath1 = false, freepath2 = false;
2573+
struct dentry *old_dentry = NULL;
25732574
int len;
25742575
u16 releases;
25752576
void *p, *end;
@@ -2587,7 +2588,10 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
25872588
}
25882589

25892590
/* If r_old_dentry is set, then assume that its parent is locked */
2590-
ret = set_request_path_attr(NULL, req->r_old_dentry,
2591+
if (req->r_old_dentry &&
2592+
!(req->r_old_dentry->d_flags & DCACHE_DISCONNECTED))
2593+
old_dentry = req->r_old_dentry;
2594+
ret = set_request_path_attr(NULL, old_dentry,
25912595
req->r_old_dentry_dir,
25922596
req->r_path2, req->r_ino2.ino,
25932597
&path2, &pathlen2, &ino2, &freepath2, true);

0 commit comments

Comments
 (0)