From 490d8805f0d9b4e58258505d678f0e75e089aa26 Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Tue, 10 Jan 2012 17:42:24 -0500 Subject: Honor O_SYNC etc. properly. Change-Id: I3dd90fe230386ad5571c5e639f27460e3d003f0e BUG: 773100 Signed-off-by: Jeff Darcy Reviewed-on: http://review.gluster.com/2626 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- .../performance/write-behind/src/write-behind.c | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'xlators/performance/write-behind') diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index be7da2f44c..a8b1c0c3cf 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -1344,6 +1344,29 @@ out: return 0; } +void +wb_disable_all (xlator_t *this, fd_t *origfd) +{ + inode_t *inode = NULL; + fd_t *otherfd = NULL; + uint64_t tmp_file = 0; + + inode = origfd->inode; + LOCK(&inode->lock); + list_for_each_entry (otherfd, &inode->fd_list, inode_list) { + if (otherfd == origfd) { + continue; + } + if (fd_ctx_get(otherfd,this,&tmp_file)) { + continue; + } + gf_log(this->name,GF_LOG_DEBUG, + "disabling wb on %p because %p is O_SYNC", + otherfd, origfd); + ((wb_file_t *)(long)tmp_file)->disabled = 1; + } + UNLOCK(&inode->lock); +} int32_t wb_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, @@ -1382,10 +1405,13 @@ wb_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, || ((flags & O_ACCMODE) == O_RDONLY) || (((flags & O_SYNC) == O_SYNC) && conf->enable_O_SYNC == _gf_true)) { - file->window_conf = 0; + gf_log(this->name,GF_LOG_DEBUG, + "disabling wb on %p", fd); + file->disabled = 1; + wb_disable_all(this,fd); } - if (wbflags & GF_OPEN_NOWB) { + else if (wbflags & GF_OPEN_NOWB) { file->disabled = 1; } } -- cgit