summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2015-10-29 17:04:38 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-01-21 21:31:59 -0800
commit424825a649ea0cd9bd4955fbfe9d5ba472e6bc38 (patch)
tree1941204296e340a7103679a0eae7b20173fd0e16 /xlators/storage
parent317eea0e182f45c0ccd14b1e83c832ba435ee283 (diff)
features/shard: Implement fallocate FOP
Backport of: http://review.gluster.org/13196 Change-Id: Iab0c41319af42210c871a3ed6cf52a987c5d88d7 BUG: 1299712 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/13259 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/storage')
-rw-r--r--xlators/storage/posix/src/posix.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 8132f57ffdb..600ebf3f0fa 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -636,12 +636,13 @@ out:
}
static int32_t
-posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
- off_t offset, size_t len, struct iatt *statpre,
- struct iatt *statpost)
+posix_do_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
+ int32_t flags, off_t offset, size_t len,
+ struct iatt *statpre, struct iatt *statpost, dict_t *xdata)
{
- struct posix_fd *pfd = NULL;
- int32_t ret = -1;
+ int32_t ret = -1;
+ struct posix_fd *pfd = NULL;
+ gf_boolean_t locked = _gf_false;
DECLARE_OLD_FS_ID_VAR;
@@ -657,6 +658,11 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
goto out;
}
+ if (dict_get (xdata, GLUSTERFS_WRITE_UPDATE_ATOMIC)) {
+ locked = _gf_true;
+ LOCK(&fd->inode->lock);
+ }
+
ret = posix_fdstat (this, pfd->fd, statpre);
if (ret == -1) {
ret = -errno;
@@ -665,7 +671,7 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
goto out;
}
- ret = sys_fallocate(pfd->fd, flags, offset, len);
+ ret = sys_fallocate (pfd->fd, flags, offset, len);
if (ret == -1) {
ret = -errno;
goto out;
@@ -680,6 +686,10 @@ posix_do_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
}
out:
+ if (locked) {
+ UNLOCK (&fd->inode->lock);
+ locked = _gf_false;
+ }
SET_TO_OLD_FS_ID ();
return ret;
@@ -857,8 +867,8 @@ _posix_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t keep_siz
flags = FALLOC_FL_KEEP_SIZE;
#endif /* FALLOC_FL_KEEP_SIZE */
- ret = posix_do_fallocate(frame, this, fd, flags, offset, len,
- &statpre, &statpost);
+ ret = posix_do_fallocate (frame, this, fd, flags, offset, len,
+ &statpre, &statpost, xdata);
if (ret < 0)
goto err;
@@ -883,8 +893,8 @@ posix_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
struct iatt statpre = {0,};
struct iatt statpost = {0,};
- ret = posix_do_fallocate(frame, this, fd, flags, offset, len,
- &statpre, &statpost);
+ ret = posix_do_fallocate (frame, this, fd, flags, offset, len,
+ &statpre, &statpost, xdata);
if (ret < 0)
goto err;