From 2c748b731f233588b97d375ce92a5ae56612d764 Mon Sep 17 00:00:00 2001 From: Ravishankar N Date: Fri, 5 Aug 2016 11:22:18 +0000 Subject: posix: honour fsync flags in posix_do_zerofill Backport of http://review.gluster.org/#/c/15100/ commit fe1054110ac54750ca0333a727d83b14a98e165e introduced fallocate + FALLOC_FL_ZERO_RANGE to do posix_do_zerofill but did not do an fsync if O_SYNC or O_DSYNC fd flags were set. Prashant Pai pointed out performing fallocate(2) does not remove the necessity to do fsyncs if durability is desired: http://linux-fsdevel.vger.kernel.narkive.com/bDmrAUlh/fallocate-falloc-fl-punch-hole So fixed it to honour the fd flags. Change-Id: I27ae90b429185d0af29a5e632c4a8b242075a899 BUG: 1364497 Signed-off-by: Ravishankar N (cherry picked from commit cf51bc699646359be92969024a52c225e7ee55a1) Reviewed-on: http://review.gluster.org/15103 Smoke: Gluster Build System Reviewed-by: Prashanth Pai CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Pranith Kumar Karampuri --- xlators/storage/posix/src/posix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'xlators') diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index bce074b4fd1..e453dd27ab9 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -858,7 +858,7 @@ posix_do_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, flags = FALLOC_FL_ZERO_RANGE; ret = sys_fallocate (pfd->fd, flags, offset, len); if (ret == 0) - goto done; + goto fsync; ret = _posix_do_zerofill (pfd->fd, offset, len, pfd->flags & O_DIRECT); if (ret < 0) { @@ -869,6 +869,7 @@ posix_do_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, goto out; } +fsync: if (pfd->flags & (O_SYNC|O_DSYNC)) { ret = sys_fsync (pfd->fd); if (ret) { @@ -880,7 +881,6 @@ posix_do_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset, } } -done: ret = posix_fdstat (this, pfd->fd, statpost); if (ret == -1) { ret = -errno; -- cgit