]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: don't take extra target inode reference in ll_link 11440/head
authorJeff Layton <jlayton@redhat.com>
Sat, 15 Oct 2016 23:31:46 +0000 (19:31 -0400)
committerJeff Layton <jlayton@redhat.com>
Sat, 15 Oct 2016 23:31:46 +0000 (19:31 -0400)
For the life of me, I can't figure out where this reference is ever put.
We usually take a reference like this when there is an Inode **
parameter that we'll return to the caller. ll_link doesn't have one of
those, so as best I can tell this reference is just leaked.

Zheng however says that FUSE will eventually put this reference via
ll_forget. I still don't quite get how that works, but the other callers
clearly do not handle this correctly. Change the code to only make the
fuse code take this extra reference.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
src/client/Client.cc
src/client/fuse_ll.cc

index 5de2b22cbbc2b35d9176addf47c624077b648a89..57fe4a5b4aac34fcc26cc30da19581ef69198cc5 100644 (file)
@@ -11441,7 +11441,6 @@ int Client::ll_link(Inode *in, Inode *newparent, const char *newname,
   if (r == 0) {
     assert(target);
     fill_stat(target, attr);
-    _ll_get(target.get());
   }
 out:
   return r;
index 16089a2ea992938dcbd1fecd49dbee5f1bb522d5..97bca93935a228bd80f5a5fce71967feebadaecf 100644 (file)
@@ -522,9 +522,16 @@ static void fuse_ll_link(fuse_req_t req, fuse_ino_t ino, fuse_ino_t newparent,
     fuse_reply_entry(req, &fe);
   } else {
     fuse_reply_err(req, -r);
+
+    /*
+     * Many ll operations in libcephfs return an extra inode reference, but
+     * ll_link currently does not. Still, FUSE needs one for the new dentry,
+     * so we commandeer the reference taken earlier when ll_link is successful.
+     * On error however, we must put that reference.
+     */
+    cfuse->iput(in);
   }
 
-  cfuse->iput(in); // iputs required
   cfuse->iput(nin);
 }