Commit a5ffd7b6 authored by Xiubo Li's avatar Xiubo Li Committed by Ilya Dryomov

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/59515Signed-off-by: default avatarXiubo Li <xiubli@redhat.com>
Reviewed-by: default avatarIlya Dryomov <idryomov@gmail.com>
Signed-off-by: default avatarIlya Dryomov <idryomov@gmail.com>
parent aaf67de7
...@@ -1050,6 +1050,9 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir, ...@@ -1050,6 +1050,9 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir,
struct ceph_mds_request *req; struct ceph_mds_request *req;
int err; int err;
if (dentry->d_flags & DCACHE_DISCONNECTED)
return -EINVAL;
err = ceph_wait_on_conflict_unlink(dentry); err = ceph_wait_on_conflict_unlink(dentry);
if (err) if (err)
return err; return err;
...@@ -1057,8 +1060,8 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir, ...@@ -1057,8 +1060,8 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir,
if (ceph_snap(dir) != CEPH_NOSNAP) if (ceph_snap(dir) != CEPH_NOSNAP)
return -EROFS; return -EROFS;
dout("link in dir %p old_dentry %p dentry %p\n", dir, dout("link in dir %p %llx.%llx old_dentry %p:'%pd' dentry %p:'%pd'\n",
old_dentry, dentry); dir, ceph_vinop(dir), old_dentry, old_dentry, dentry, dentry);
req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LINK, USE_AUTH_MDS); req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_LINK, USE_AUTH_MDS);
if (IS_ERR(req)) { if (IS_ERR(req)) {
d_drop(dentry); d_drop(dentry);
...@@ -1067,6 +1070,12 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir, ...@@ -1067,6 +1070,12 @@ static int ceph_link(struct dentry *old_dentry, struct inode *dir,
req->r_dentry = dget(dentry); req->r_dentry = dget(dentry);
req->r_num_caps = 2; req->r_num_caps = 2;
req->r_old_dentry = dget(old_dentry); req->r_old_dentry = dget(old_dentry);
/*
* The old_dentry maybe a DCACHE_DISCONNECTED dentry, then we
* will just pass the ino# to MDSs.
*/
if (old_dentry->d_flags & DCACHE_DISCONNECTED)
req->r_ino2 = ceph_vino(d_inode(old_dentry));
req->r_parent = dir; req->r_parent = dir;
ihold(dir); ihold(dir);
set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags);
......
...@@ -2570,6 +2570,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, ...@@ -2570,6 +2570,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
u64 ino1 = 0, ino2 = 0; u64 ino1 = 0, ino2 = 0;
int pathlen1 = 0, pathlen2 = 0; int pathlen1 = 0, pathlen2 = 0;
bool freepath1 = false, freepath2 = false; bool freepath1 = false, freepath2 = false;
struct dentry *old_dentry = NULL;
int len; int len;
u16 releases; u16 releases;
void *p, *end; void *p, *end;
...@@ -2587,7 +2588,10 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, ...@@ -2587,7 +2588,10 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session,
} }
/* If r_old_dentry is set, then assume that its parent is locked */ /* If r_old_dentry is set, then assume that its parent is locked */
ret = set_request_path_attr(NULL, req->r_old_dentry, if (req->r_old_dentry &&
!(req->r_old_dentry->d_flags & DCACHE_DISCONNECTED))
old_dentry = req->r_old_dentry;
ret = set_request_path_attr(NULL, old_dentry,
req->r_old_dentry_dir, req->r_old_dentry_dir,
req->r_path2, req->r_ino2.ino, req->r_path2, req->r_ino2.ino,
&path2, &pathlen2, &ino2, &freepath2, true); &path2, &pathlen2, &ino2, &freepath2, true);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment