summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2009-06-30 13:50:54 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-06-30 16:10:34 -0700
commit9d16a33e6171adf7512df839af6f6ffbab96799c (patch)
treea20be7488436058810e0f38298b84d4497f2f9a9
parent193b0e696fb7612998e23e21628023e9fffd08ee (diff)
enhancement in write-behind
Write calls should not be pushed to background only when the mandatory locking is enabled, in all other cases (eg: O_SYNC, O_DIRECT etc), we should not be 'caching' any data, but the calls can be pushed to the background. Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
-rw-r--r--xlators/performance/write-behind/src/write-behind.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index 81fcde5aea5..f1f1604e912 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -1103,12 +1103,11 @@ int32_t
wb_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
int32_t op_errno, fd_t *fd)
{
- int32_t flags = 0;
+ long flags = 0;
wb_file_t *file = NULL;
wb_conf_t *conf = this->private;
- if (op_ret != -1)
- {
+ if (op_ret != -1) {
file = wb_file_create (this, fd);
if (file == NULL) {
STACK_UNWIND (frame, -1, ENOMEM, fd);
@@ -1125,14 +1124,13 @@ wb_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
file->disabled = 1;
/* If O_DIRECT then, we disable chaching */
- if (frame->local)
- {
- flags = *((int32_t *)frame->local);
+ if (frame->local) {
+ flags = (long)frame->local;
if (((flags & O_DIRECT) == O_DIRECT)
|| ((flags & O_RDONLY) == O_RDONLY)
|| (((flags & O_SYNC) == O_SYNC)
- && conf->enable_O_SYNC == _gf_true)) {
- file->disabled = 1;
+ && conf->enable_O_SYNC == _gf_true)) {
+ file->window_size = 0;
}
}
@@ -1148,13 +1146,7 @@ int32_t
wb_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
fd_t *fd)
{
- frame->local = CALLOC (1, sizeof(int32_t));
- if (frame->local == NULL) {
- STACK_UNWIND (frame, -1, ENOMEM, NULL);
- return 0;
- }
-
- *((int32_t *)frame->local) = flags;
+ frame->local = (void *)(long)flags;
STACK_WIND (frame,
wb_open_cbk,
@@ -1170,10 +1162,11 @@ wb_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, fd_t *fd, inode_t *inode,
struct stat *buf)
{
+ long flags = 0;
wb_file_t *file = NULL;
+ wb_conf_t *conf = this->private;
- if (op_ret != -1)
- {
+ if (op_ret != -1) {
file = wb_file_create (this, fd);
if (file == NULL) {
STACK_UNWIND (frame, -1, ENOMEM, fd, inode, buf);
@@ -1185,8 +1178,17 @@ wb_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
*/
if ((fd->inode->st_mode & S_ISGID)
&& !(fd->inode->st_mode & S_IXGRP))
- {
file->disabled = 1;
+
+ /* If O_DIRECT then, we disable chaching */
+ if (frame->local) {
+ flags = (long)frame->local;
+ if (((flags & O_DIRECT) == O_DIRECT)
+ || ((flags & O_RDONLY) == O_RDONLY)
+ || (((flags & O_SYNC) == O_SYNC)
+ && (conf->enable_O_SYNC == _gf_true))) {
+ file->window_size = 0;
+ }
}
LOCK_INIT (&file->lock);
@@ -1201,6 +1203,8 @@ int32_t
wb_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
mode_t mode, fd_t *fd)
{
+ frame->local = (void *)(long)flags;
+
STACK_WIND (frame,
wb_create_cbk,
FIRST_CHILD(this),