summaryrefslogtreecommitdiffstats
path: root/xlators/storage
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2016-01-13 16:19:15 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2016-01-22 22:02:32 -0800
commite67712c06b64fb659824b3f79164f2789693acee (patch)
treebe6c735bb977bd8c486a80649a9237773c140192 /xlators/storage
parentea94b2b8767e0d477a672355d758e0e8393362ee (diff)
features/shard: Implement zerofill FOP
Change-Id: Iabb89a502cc560edd7fe3755623c74a2ccb853d5 BUG: 1261841 Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com> Reviewed-on: http://review.gluster.org/13234 Smoke: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: Pranith Kumar Karampuri <pkarampu@redhat.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.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index e834fc09752..b0c23716a64 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -809,12 +809,13 @@ err:
}
static int32_t
-posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
- off_t offset, off_t len, struct iatt *statpre,
- struct iatt *statpost)
+posix_do_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ off_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;
@@ -830,6 +831,11 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
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;
@@ -837,7 +843,8 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
"pre-operation fstat failed on fd = %p", fd);
goto out;
}
- ret = _posix_do_zerofill(pfd->fd, offset, len, pfd->flags & O_DIRECT);
+
+ ret = _posix_do_zerofill (pfd->fd, offset, len, pfd->flags & O_DIRECT);
if (ret < 0) {
ret = -errno;
gf_msg (this->name, GF_LOG_ERROR, errno, P_MSG_ZEROFILL_FAILED,
@@ -845,6 +852,7 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
pfd->fd, len);
goto out;
}
+
if (pfd->flags & (O_SYNC|O_DSYNC)) {
ret = sys_fsync (pfd->fd);
if (ret) {
@@ -865,6 +873,10 @@ posix_do_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd,
}
out:
+ if (locked) {
+ UNLOCK (&fd->inode->lock);
+ locked = _gf_false;
+ }
SET_TO_OLD_FS_ID ();
return ret;
@@ -932,8 +944,8 @@ posix_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
struct iatt statpre = {0,};
struct iatt statpost = {0,};
- ret = posix_do_zerofill(frame, this, fd, offset, len,
- &statpre, &statpost);
+ ret = posix_do_zerofill (frame, this, fd, offset, len,
+ &statpre, &statpost, xdata);
if (ret < 0)
goto err;