From 23956dea83a1f803e6e874ed739fc64c93ab5c9b Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Sat, 15 Oct 2016 19:31:46 -0400 Subject: [PATCH] client: don't take extra target inode reference in ll_link 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 --- src/client/Client.cc | 1 - src/client/fuse_ll.cc | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 5de2b22cbbc2b..57fe4a5b4aac3 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -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; diff --git a/src/client/fuse_ll.cc b/src/client/fuse_ll.cc index 16089a2ea9929..97bca93935a22 100644 --- a/src/client/fuse_ll.cc +++ b/src/client/fuse_ll.cc @@ -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); } -- 2.39.5