diff options
| author | Soumya Koduri <skoduri@redhat.com> | 2016-05-25 14:38:31 +0530 | 
|---|---|---|
| committer | Kaleb KEITHLEY <kkeithle@redhat.com> | 2016-06-28 04:22:11 -0700 | 
| commit | 763ed1017b0011934ad2414d7396c46e528ea5b3 (patch) | |
| tree | bbc6bc34746553fa554302dadf3850bc9810f824 /api/src | |
| parent | 61d72b3d91f2655b04de4ef29262f738a8cf7369 (diff) | |
gfapi/handleops: Avoid using glfd during create
To avoid leaking glfd while creating a file using handleops and
since application shall not be interested in it, use the 'fd'
object directly which can be un'refed post create.
Change-Id: I119874ffb63fb4aa18f846ba1fdbe77874b66a54
BUG: 1339553
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Reviewed-on: http://review.gluster.org/14532
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.org>
Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'api/src')
| -rw-r--r-- | api/src/glfs-handleops.c | 32 | 
1 files changed, 9 insertions, 23 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index b9da2cc0993..373560a00d8 100644 --- a/api/src/glfs-handleops.c +++ b/api/src/glfs-handleops.c @@ -708,7 +708,7 @@ pub_glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,                    int flags, mode_t mode, struct stat *stat)  {          int                 ret = -1; -        struct glfs_fd     *glfd = NULL; +        fd_t               *fd = NULL;          xlator_t           *subvol = NULL;          inode_t            *inode = NULL;          loc_t               loc = {0, }; @@ -737,6 +737,7 @@ pub_glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,          /* get/refresh the in arg objects inode in correlation to the xlator */          inode = glfs_resolve_inode (fs, subvol, parent);          if (!inode) { +                ret = -1;                  errno = ESTALE;                  goto out;          } @@ -758,24 +759,17 @@ pub_glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,          GLFS_LOC_FILL_PINODE (inode, loc, ret, errno, out, path); -        glfd = glfs_fd_new (fs); -        if (!glfd) { -                 ret = -1; -                 errno = ENOMEM; -                 goto out; -        } - -        glfd->fd = fd_create (loc.inode, getpid()); -        if (!glfd->fd) { +        fd = fd_create (loc.inode, getpid()); +        if (!fd) {                  ret = -1;                  errno = ENOMEM;                  goto out;          } -        glfd->fd->flags = flags; +        fd->flags = flags;          /* fop/op */ -        ret = syncop_create (subvol, &loc, flags, mode, glfd->fd, -                             &iatt, xattr_req, NULL); +        ret = syncop_create (subvol, &loc, flags, mode, fd, &iatt, +                             xattr_req, NULL);          DECODE_SYNCOP_ERR (ret);          /* populate out args */ @@ -791,10 +785,6 @@ pub_glfs_h_creat (struct glfs *fs, struct glfs_object *parent, const char *path,                  ret = glfs_create_object (&loc, &object);          } -        glfd->fd->flags = flags; -        fd_bind (glfd->fd); -        glfs_fd_bind (glfd); -  out:          if (ret && object != NULL) {                  /* Release the held reference */ @@ -810,12 +800,8 @@ out:          if (xattr_req)                  dict_unref (xattr_req); -        if (ret && glfd) { -                GF_REF_PUT (glfd); -                glfd = NULL; -        } else if (glfd) { -                glfd->state = GLFD_OPEN; -        } +        if (fd) +                fd_unref(fd);          glfs_subvol_done (fs, subvol);  | 
