summaryrefslogtreecommitdiffstats
path: root/xlators/performance/write-behind/src
diff options
context:
space:
mode:
authorRaghavendra G <raghavendra@gluster.com>2011-04-24 22:45:31 +0000
committerAnand Avati <avati@gluster.com>2011-04-29 06:59:41 -0700
commit1f06da6875d8ecff5efa2b6db387ef6084bb68a1 (patch)
tree4413eeee7b1714ee6423e1e44da883d782b513de /xlators/performance/write-behind/src
parent77f485dc30e5cd81d63cb7a92dc77b3ace69d40d (diff)
performance/write-behind: initialize lock in wb-file before wb-file is set in fd-ctx.branchpoint-3.2
- Consider a combination of fuse->quick-read->read-ahead->wb->client. quick-read can do open-behind (open is returned as success even before it is issued to backend) and hence the fd can already be in the list of open fds of the inode. A flush call on some other fd opened on the same inode, will result in ra_flush issuing flush calls to all the fds opened on the same inode. This can result in wb_flush trying to hold a lock on non-initialized lock there by causing memory corruption. Signed-off-by: Raghavendra G <raghavendra@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2679 (Crash in GlusterFS 3.0.5 in GSP) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2679
Diffstat (limited to 'xlators/performance/write-behind/src')
-rw-r--r--xlators/performance/write-behind/src/write-behind.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index cdc88969976..4b8e0d188bf 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -322,6 +322,8 @@ wb_file_create (xlator_t *this, fd_t *fd, int32_t flags)
file->window_conf = conf->window_size;
file->flags = flags;
+ LOCK_INIT (&file->lock);
+
fd_ctx_set (fd, this, (uint64_t)(long)file);
out:
@@ -1367,19 +1369,21 @@ wb_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
goto out;
}
- /* If O_DIRECT then, we disable chaching */
- if (((flags & O_DIRECT) == O_DIRECT)
- || ((flags & O_ACCMODE) == O_RDONLY)
- || (((flags & O_SYNC) == O_SYNC)
- && conf->enable_O_SYNC == _gf_true)) {
- file->window_conf = 0;
- }
+ LOCK (&file->lock);
+ {
+ /* If O_DIRECT then, we disable chaching */
+ if (((flags & O_DIRECT) == O_DIRECT)
+ || ((flags & O_ACCMODE) == O_RDONLY)
+ || (((flags & O_SYNC) == O_SYNC)
+ && conf->enable_O_SYNC == _gf_true)) {
+ file->window_conf = 0;
+ }
- if (wbflags & GF_OPEN_NOWB) {
- file->disabled = 1;
+ if (wbflags & GF_OPEN_NOWB) {
+ file->disabled = 1;
+ }
}
-
- LOCK_INIT (&file->lock);
+ UNLOCK (&file->lock);
}
out:
@@ -1443,17 +1447,19 @@ wb_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
- /* If O_DIRECT then, we disable chaching */
- if (frame->local) {
- if (((flags & O_DIRECT) == O_DIRECT)
- || ((flags & O_ACCMODE) == O_RDONLY)
- || (((flags & O_SYNC) == O_SYNC)
- && (conf->enable_O_SYNC == _gf_true))) {
- file->window_conf = 0;
+ LOCK (&file->lock);
+ {
+ /* If O_DIRECT then, we disable chaching */
+ if (frame->local) {
+ if (((flags & O_DIRECT) == O_DIRECT)
+ || ((flags & O_ACCMODE) == O_RDONLY)
+ || (((flags & O_SYNC) == O_SYNC)
+ && (conf->enable_O_SYNC == _gf_true))) {
+ file->window_conf = 0;
+ }
}
}
-
- LOCK_INIT (&file->lock);
+ UNLOCK (&file->lock);
}
frame->local = NULL;