diff options
Diffstat (limited to 'libglusterfs/src')
| -rw-r--r-- | libglusterfs/src/fd.c | 27 | ||||
| -rw-r--r-- | libglusterfs/src/syncop-utils.c | 2 | 
2 files changed, 19 insertions, 10 deletions
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c index 688357327c0..eb1e83b87a3 100644 --- a/libglusterfs/src/fd.c +++ b/libglusterfs/src/fd.c @@ -468,16 +468,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; @@ -525,11 +521,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); @@ -543,6 +542,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, @@ -554,11 +554,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 ; diff --git a/libglusterfs/src/syncop-utils.c b/libglusterfs/src/syncop-utils.c index ce60ef0c153..4e8849f06f8 100644 --- a/libglusterfs/src/syncop-utils.c +++ b/libglusterfs/src/syncop-utils.c @@ -59,6 +59,8 @@ syncop_dirfd (xlator_t *subvol, loc_t *loc, fd_t **fd, int pid)                          uuid_utoa (loc->gfid));                  goto out;  #endif /* GF_LINUX_HOST_OS */ +        } else { +                fd_bind (dirfd);          }  out:          if (ret == 0)  | 
