diff options
| author | Pranith Kumar K <pkarampu@redhat.com> | 2015-06-02 16:39:35 +0530 | 
|---|---|---|
| committer | Raghavendra G <rgowdapp@redhat.com> | 2015-10-05 23:11:02 -0700 | 
| commit | c3dd76e9da783d879258cde17680f7d8747506f8 (patch) | |
| tree | a839bcfd5de5375f83f9bad5bb8f8f316ebe5a3d /libglusterfs/src/fd.c | |
| parent | df06d94fae1e4a5e93f00c26d4b377bd8d1bd352 (diff) | |
fd: Do fd_bind on successful open
- fd_unref should decrement fd->inode->fd_count only if it is present in the
inode's fd list.
- successful open/opendir should perform fd_bind.
 >Change-Id: I81dd04f330e2fee86369a6dc7147af44f3d49169
 >BUG: 1207735
 >Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
 >Reviewed-on: http://review.gluster.org/11044
 >Reviewed-by: Anoop C S <anoopcs@redhat.com>
 >Tested-by: NetBSD Build System <jenkins@build.gluster.org>
 >Tested-by: Gluster Build System <jenkins@build.gluster.com>
 >Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
BUG: 1259697
Change-Id: I73b79dd3519aa085fb84dde74b321511cbccce1a
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: http://review.gluster.org/12100
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'libglusterfs/src/fd.c')
| -rw-r--r-- | libglusterfs/src/fd.c | 27 | 
1 files changed, 17 insertions, 10 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c index 25cea496d73..d4a6e6a40bb 100644 --- a/libglusterfs/src/fd.c +++ b/libglusterfs/src/fd.c @@ -474,16 +474,12 @@ __fd_unref (fd_t *fd)          --fd->refcount; -        if (fd->refcount == 0) { -                list_del_init (&fd->inode_list); -        } -          return fd;  }  static void -fd_destroy (fd_t *fd) +fd_destroy (fd_t *fd, gf_boolean_t bound)  {          xlator_t    *xl = NULL;          int          i = 0; @@ -531,11 +527,14 @@ fd_destroy (fd_t *fd)          LOCK_DESTROY (&fd->lock);          GF_FREE (fd->_ctx); -        LOCK (&fd->inode->lock); -        { -                fd->inode->fd_count--; +        if (bound) { +                /*Decrease the count only after close happens on file*/ +                LOCK (&fd->inode->lock); +                { +                        fd->inode->fd_count--; +                } +                UNLOCK (&fd->inode->lock);          } -        UNLOCK (&fd->inode->lock);          inode_unref (fd->inode);          fd->inode = NULL;          fd_lk_ctx_unref (fd->lk_ctx); @@ -549,6 +548,7 @@ void  fd_unref (fd_t *fd)  {          int32_t refcount = 0; +        gf_boolean_t bound = _gf_false;          if (!fd) {                  gf_msg_callingfn ("fd", GF_LOG_ERROR, EINVAL, @@ -560,11 +560,18 @@ fd_unref (fd_t *fd)          {                  __fd_unref (fd);                  refcount = fd->refcount; +                if (refcount == 0) { +                        if (!list_empty (&fd->inode_list)) { +                                list_del_init (&fd->inode_list); +                                bound = _gf_true; +                        } +                } +          }          UNLOCK (&fd->inode->lock);          if (refcount == 0) { -                fd_destroy (fd); +                fd_destroy (fd, bound);          }          return ;  | 
