From e67712c06b64fb659824b3f79164f2789693acee Mon Sep 17 00:00:00 2001 From: Krutika Dhananjay Date: Wed, 13 Jan 2016 16:19:15 +0530 Subject: features/shard: Implement zerofill FOP Change-Id: Iabb89a502cc560edd7fe3755623c74a2ccb853d5 BUG: 1261841 Signed-off-by: Krutika Dhananjay Reviewed-on: http://review.gluster.org/13234 Smoke: Gluster Build System Reviewed-by: Pranith Kumar Karampuri Tested-by: Pranith Kumar Karampuri NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System --- xlators/storage/posix/src/posix.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'xlators/storage/posix/src/posix.c') 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; -- cgit