Patchwork [BUG:1397,02/12] nfs3: Dont ref dir fd_t used in hard fh resolution

login
register
Submitter Shehjar Tikoo
Date 2010-08-31 12:20:27
Message ID <1283257237-18659-2-git-send-email-shehjart@gluster.com>
Download mbox | patch
Permalink /patch/4417/
State Accepted
Delegated to: Anand Avati
Headers show

Comments

Shehjar Tikoo - 2010-08-31 12:20:27
From: Shehjar Tikoo <shehjart@gluster.com>

..because the extra ref was under the mistaken assumption that
directory fd_t will be cached even during hard fh resolution and
that is not the case.

Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
---
 xlators/nfs/server/src/nfs3-helpers.c |   16 +++++++++-------
 xlators/nfs/server/src/nfs3.c         |    6 ++----
 2 files changed, 11 insertions(+), 11 deletions(-)

Patch

diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c
index 116d145..dae2d6a 100644
--- a/xlators/nfs/server/src/nfs3-helpers.c
+++ b/xlators/nfs/server/src/nfs3-helpers.c
@@ -2704,14 +2704,16 @@  nfs3_fh_resolve_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                         cs->resolvedloc.path);
 
         nfs_user_root_create (&nfu);
-        /* This function can be called in a recursive code path, so if another
-         * directory was opened in an earlier call, we must unref through this
-         * reference before opening another fd_t.
+        /* Keep this directory fd_t around till we have either:
+         * a. found the entry,
+         * b. exhausted all the entries,
+         * c. decide to step into a child directory.
+         *
+         * This decision is made in nfs3_fh_resolve_check_response.
          */
-        if (cs->resolve_dir_fd)
-                fd_unref (cs->resolve_dir_fd);
-
-        cs->resolve_dir_fd = fd_ref (fd);
+        cs->resolve_dir_fd = fd;
+        gf_log (GF_NFS3, GF_LOG_TRACE, "resolve new fd refed: 0x%lx, ref: %d",
+                (long)cs->resolve_dir_fd, cs->resolve_dir_fd->refcount);
         ret = nfs_readdirp (cs->nfsx, cs->vol, &nfu, fd, GF_NFS3_DTPREF, 0,
                             nfs3_fh_resolve_readdir_cbk, cs);
 
diff --git a/xlators/nfs/server/src/nfs3.c b/xlators/nfs/server/src/nfs3.c
index bbbbca8..420badd 100644
--- a/xlators/nfs/server/src/nfs3.c
+++ b/xlators/nfs/server/src/nfs3.c
@@ -199,13 +199,11 @@  nfs3_call_state_wipe (nfs3_call_state_t *cs)
 
         nfs3 = cs->nfs3state;
         if (cs->fd) {
-                gf_log (GF_NFS3, GF_LOG_TRACE, "fd ref: %d", cs->fd->refcount);
+                gf_log (GF_NFS3, GF_LOG_TRACE, "fd 0x%lx ref: %d",
+                        (long)cs->fd, cs->fd->refcount);
                 fd_unref (cs->fd);
         }
 
-        if (cs->resolve_dir_fd)
-                fd_unref (cs->resolve_dir_fd);
-
         if (cs->resolventry)
                 GF_FREE (cs->resolventry);