diff options
author | Soumya Koduri <skoduri@redhat.com> | 2016-05-25 14:38:31 +0530 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2016-07-03 04:16:01 -0700 |
commit | 851ea76c04a8139ef307070550f8b4461a819bc6 (patch) | |
tree | 8ba50e657b1654e29236bbc75375a676fff92558 /api | |
parent | 6a1559ff8057e5c2a992a990cfb630932e6928d2 (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.
This is backport of below mainline patch -
http://review.gluster.org/14532
> 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: 1351877
Signed-off-by: Soumya Koduri <skoduri@redhat.com>
Reviewed-by: Kaleb S KEITHLEY <kkeithle@redhat.com>
Reviewed-on: http://review.gluster.org/14840
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
Reviewed-by: Niels de Vos <ndevos@redhat.com>
Smoke: Gluster Build System <jenkins@build.gluster.org>
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); |