summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/performance/read-ahead/src/read-ahead.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c
index 4f38229025f..7250a9d5996 100644
--- a/xlators/performance/read-ahead/src/read-ahead.c
+++ b/xlators/performance/read-ahead/src/read-ahead.c
@@ -68,8 +68,6 @@ ra_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto unwind;
}
- ret = fd_ctx_set (fd, this, (uint64_t)(long)file);
-
/* If O_DIRECT open, we disable caching on it */
if ((fd->flags & O_DIRECT) || ((fd->flags & O_ACCMODE) == O_WRONLY))
@@ -104,9 +102,16 @@ ra_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
file->page_count = 1;
}
+ ret = fd_ctx_set (fd, this, (uint64_t)(long)file);
+ if (ret == -1) {
+ ra_file_destroy (file);
+ op_ret = -1;
+ op_errno = ENOMEM;
+ }
+
+unwind:
frame->local = NULL;
-unwind:
STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd);
return 0;
@@ -138,8 +143,6 @@ ra_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto unwind;
}
- ret = fd_ctx_set (fd, this, (uint64_t)(long)file);
-
/* If O_DIRECT open, we disable caching on it */
if ((fd->flags & O_DIRECT) || ((fd->flags & O_ACCMODE) == O_WRONLY))
@@ -167,6 +170,13 @@ ra_create_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
file->page_size = conf->page_size;
pthread_mutex_init (&file->file_lock, NULL);
+ ret = fd_ctx_set (fd, this, (uint64_t)(long)file);
+ if (ret == -1) {
+ ra_file_destroy (file);
+ op_ret = -1;
+ op_errno = ENOMEM;
+ }
+
unwind:
STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf,
preparent, postparent);