diff options
| author | Soumya Koduri <skoduri@redhat.com> | 2016-05-25 14:38:31 +0530 | 
|---|---|---|
| committer | Niels de Vos <ndevos@redhat.com> | 2016-07-01 02:36:46 -0700 | 
| commit | 01d1bee0321e1a0bf83f34130404440dc17a73d0 (patch) | |
| tree | 27fdb61b66afc73d4e95f31b5f8224c2f8ac352d /api | |
| parent | 82f77991679c05d93c01888bb79c571c7fa9142f (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.
Upstream refernce :
>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>
>(cherry picked from commit 763ed1017b0011934ad2414d7396c46e528ea5b3)
Change-Id: I119874ffb63fb4aa18f846ba1fdbe77874b66a54
BUG: 1350787
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Signed-off-by: Jiffin Tony Thottan <jthottan@redhat.com>
Reviewed-on: http://review.gluster.org/14820
Smoke: Gluster Build System <jenkins@build.gluster.org>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'api')
| -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 af58691bd8b..1c5546ec427 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);  | 
