diff options
| author | Mohit Agrawal <moagrawa@redhat.com> | 2018-02-10 12:25:15 +0530 | 
|---|---|---|
| committer | jiffin tony Thottan <jthottan@redhat.com> | 2018-04-06 12:47:34 +0000 | 
| commit | 479bea17e75d8e75a8901d01b3fd3627bfd8991c (patch) | |
| tree | 650a420f504ef22ea2f13fbfba63f73ca860c663 /xlators/storage/posix/src/posix.c | |
| parent | 0e3206c6a8ef36737e5b303580b87a87f6dc1c8e (diff) | |
glusterfsd: Memleak in glusterfsd process while  brick mux is on
Problem: At the time of stopping the volume while brick multiplex is
         enabled memory is not cleanup from all server side xlators.
Solution: To cleanup memory for all server side xlators call fini
          in glusterfs_handle_terminate after send GF_EVENT_CLEANUP
          notification to top xlator.
> BUG: 1544090
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
> (cherry picked from commit 7c3cc485054e4ede1efb358552135b432fb7047a)
>Note: Run all test-cases in separate build (https://review.gluster.org/19574)
>      with same patch after enable brick mux forcefully, all test cases are
>      passed.
BUG: 1549473
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Change-Id: Ia10dc7f2605aa50f2b90b3fe4eb380ba9299e2fc
Diffstat (limited to 'xlators/storage/posix/src/posix.c')
| -rw-r--r-- | xlators/storage/posix/src/posix.c | 55 | 
1 files changed, 32 insertions, 23 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index e0e40b12da1..f4b760a53cb 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -172,6 +172,8 @@ posix_forget (xlator_t *this, inode_t *inode)          struct posix_private   *priv_posix  = NULL;          priv_posix = (struct posix_private *) this->private; +        if (!priv_posix) +                return 0;          ret = inode_ctx_del (inode, this, &ctx_uint);          if (!ctx_uint) @@ -226,6 +228,7 @@ posix_lookup (call_frame_t *frame, xlator_t *this,          VALIDATE_OR_GOTO (frame, out);          VALIDATE_OR_GOTO (this, out);          VALIDATE_OR_GOTO (loc, out); +        VALIDATE_OR_GOTO (this->private, out);          priv = this->private; @@ -1279,6 +1282,8 @@ posix_releasedir (xlator_t *this,          }          priv = this->private; +        if (!priv) +                goto out;          pthread_mutex_lock (&priv->janitor_lock);          { @@ -2076,6 +2081,7 @@ posix_unlink (call_frame_t *frame, xlator_t *this,          VALIDATE_OR_GOTO (frame, out);          VALIDATE_OR_GOTO (this, out); +        VALIDATE_OR_GOTO (this->private, out);          VALIDATE_OR_GOTO (loc, out);          SET_FS_ID (frame->root->uid, frame->root->gid); @@ -3819,6 +3825,8 @@ posix_release (xlator_t *this, fd_t *fd)                          "pfd->dir is %p (not NULL) for file fd=%p",                          pfd->dir, fd);          } +        if (!priv) +                goto out;          pthread_mutex_lock (&priv->janitor_lock);          { @@ -4004,6 +4012,7 @@ posix_setxattr (call_frame_t *frame, xlator_t *this,          VALIDATE_OR_GOTO (frame, out);          VALIDATE_OR_GOTO (this, out); +        VALIDATE_OR_GOTO (this->private, out);          VALIDATE_OR_GOTO (loc, out);          VALIDATE_OR_GOTO (dict, out); @@ -4584,6 +4593,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,          VALIDATE_OR_GOTO (frame, out);          VALIDATE_OR_GOTO (this, out);          VALIDATE_OR_GOTO (loc, out); +        VALIDATE_OR_GOTO (this->private, out);          SET_FS_ID (frame->root->uid, frame->root->gid);          MAKE_INODE_HANDLE (real_path, this, loc, NULL); @@ -4691,6 +4701,7 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,                  goto done;          }          if (loc->inode && name && (XATTR_IS_PATHINFO (name))) { +                VALIDATE_OR_GOTO (this->private, out);                  if (LOC_HAS_ABSPATH (loc))                          MAKE_REAL_PATH (rpath, this, loc->path);                  else @@ -6943,9 +6954,6 @@ notify (xlator_t *this,          void *data,          ...)  { -        struct posix_private *priv = NULL; - -        priv = this->private;          switch (event)          {          case GF_EVENT_PARENT_UP: @@ -6954,26 +6962,6 @@ notify (xlator_t *this,                  default_notify (this, GF_EVENT_CHILD_UP, data);          }          break; -        case GF_EVENT_CLEANUP: -                if (priv->health_check) { -                        priv->health_check_active = _gf_false; -                        pthread_cancel (priv->health_check); -                        priv->health_check = 0; -                } -                if (priv->janitor) { -                        (void) gf_thread_cleanup_xint (priv->janitor); -                        priv->janitor = 0; -                } -                if (priv->fsyncer) { -                        (void) gf_thread_cleanup_xint (priv->fsyncer); -                        priv->fsyncer = 0; -                } -                if (priv->mount_lock) { -                        (void) sys_closedir (priv->mount_lock); -                        priv->mount_lock = NULL; -                } - -        break;          default:                  /* */                  break; @@ -7825,10 +7813,31 @@ fini (xlator_t *this)          if (!priv)                  return;          this->private = NULL; +        if (priv->health_check) { +                priv->health_check_active = _gf_false; +                pthread_cancel (priv->health_check); +                priv->health_check = 0; +        } +        if (priv->janitor) { +                (void) gf_thread_cleanup_xint (priv->janitor); +                priv->janitor = 0; +        } +        if (priv->fsyncer) { +                (void) gf_thread_cleanup_xint (priv->fsyncer); +                priv->fsyncer = 0; +        }          /*unlock brick dir*/          if (priv->mount_lock)                  (void) sys_closedir (priv->mount_lock); + +        GF_FREE (priv->base_path); +        LOCK_DESTROY (&priv->lock); +        pthread_mutex_destroy (&priv->janitor_lock); +        pthread_mutex_destroy (&priv->fsync_mutex); +        GF_FREE (priv->hostname); +        GF_FREE (priv->trash_path);          GF_FREE (priv); +          return;  }  struct xlator_dumpops dumpops = {  | 
