From: YunfeiGuan Date: Wed, 3 Jan 2018 03:43:07 +0000 (+0800) Subject: ceph-fuse: ::rmdir() uses a deleted memory structure of dentry leads a core X-Git-Tag: v13.0.2~585^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F19672%2Fhead;p=ceph.git ceph-fuse: ::rmdir() uses a deleted memory structure of dentry leads a core we should add the dentry ref immediately after "get_or_create" in case of the ref be put to zero. Fixes: http://tracker.ceph.com/issues/22536 Signed-off-by: YunfeiGuan --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 1c2d66002ea..79aa9ed3206 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -12053,8 +12053,9 @@ int Client::_rmdir(Inode *dir, const char *name, const UserPerm& perms) if (dir->snapid != CEPH_NOSNAP && dir->snapid != CEPH_SNAPDIR) { return -EROFS; } - - MetaRequest *req = new MetaRequest(dir->snapid == CEPH_SNAPDIR ? CEPH_MDS_OP_RMSNAP:CEPH_MDS_OP_RMDIR); + + int op = dir->snapid == CEPH_SNAPDIR ? CEPH_MDS_OP_RMSNAP : CEPH_MDS_OP_RMDIR; + MetaRequest *req = new MetaRequest(op); filepath path; dir->make_nosnap_relative_path(path); path.push_dentry(name); @@ -12070,15 +12071,20 @@ int Client::_rmdir(Inode *dir, const char *name, const UserPerm& perms) int res = get_or_create(dir, name, &de); if (res < 0) goto fail; + if (op == CEPH_MDS_OP_RMDIR) + req->set_dentry(de); + else + de->get(); + res = _lookup(dir, name, 0, &in, perms); if (res < 0) goto fail; - if (req->get_op() == CEPH_MDS_OP_RMDIR) { + if (op == CEPH_MDS_OP_RMDIR) { req->set_inode(dir); - req->set_dentry(de); req->set_other_inode(in.get()); } else { unlink(de, true, true); + de->put(); req->set_other_inode(in.get()); }