diff options
Diffstat (limited to 'xlators/performance')
-rw-r--r-- | xlators/performance/quick-read/src/quick-read.c | 28 | ||||
-rw-r--r-- | xlators/performance/read-ahead/src/read-ahead.c | 78 | ||||
-rw-r--r-- | xlators/performance/stat-prefetch/src/stat-prefetch.c | 6 | ||||
-rw-r--r-- | xlators/performance/write-behind/src/write-behind.c | 113 |
4 files changed, 84 insertions, 141 deletions
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c index 7db1e686f7d..6c9a0f0e5b5 100644 --- a/xlators/performance/quick-read/src/quick-read.c +++ b/xlators/performance/quick-read/src/quick-read.c @@ -82,47 +82,25 @@ static int32_t qr_loc_fill (loc_t *loc, inode_t *inode, char *path) { int32_t ret = -1; - char *parent = NULL; - char *path_copy = NULL; GF_VALIDATE_OR_GOTO_WITH_ERROR ("quick-read", loc, out, errno, EINVAL); GF_VALIDATE_OR_GOTO_WITH_ERROR ("quick-read", inode, out, errno, EINVAL); GF_VALIDATE_OR_GOTO_WITH_ERROR ("quick-read", path, out, errno, EINVAL); - GF_VALIDATE_OR_GOTO_WITH_ERROR ("quick-read", inode->table, out, errno, - EINVAL); loc->inode = inode_ref (inode); - loc->path = gf_strdup (path); - - path_copy = gf_strdup (path); - if (path_copy == NULL) { - ret = -1; - goto out; - } + uuid_copy (loc->gfid, inode->gfid); - parent = dirname (path_copy); - - loc->parent = inode_from_path (inode->table, parent); - if (loc->parent == NULL) { - ret = -1; - errno = EINVAL; - gf_log ("quick-read", GF_LOG_WARNING, - "cannot search parent inode for path (%s)", path); + loc->path = gf_strdup (path); + if (!loc->path) goto out; - } - loc->name = strrchr (loc->path, '/'); ret = 0; out: if (ret == -1) { qr_loc_wipe (loc); } - if (path_copy) { - GF_FREE (path_copy); - } - return ret; } diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c index 6d7641e6909..37f34f2eb91 100644 --- a/xlators/performance/read-ahead/src/read-ahead.c +++ b/xlators/performance/read-ahead/src/read-ahead.c @@ -489,12 +489,8 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, fd_ctx_get (fd, this, &tmp_file); file = (ra_file_t *)(long)tmp_file; - if (file == NULL) { - op_errno = EBADF; - gf_log (this->name, GF_LOG_WARNING, - "readv received on fd (%p) with no" - " file set in its context", fd); - goto unwind; + if (!file || file->disabled) { + goto disabled; } if (file->offset != offset) { @@ -520,14 +516,6 @@ ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, flush_region (frame, file, 0, file->pages.prev->offset + 1); } - if (file->disabled) { - STACK_WIND (frame, ra_readv_disabled_cbk, - FIRST_CHILD (frame->this), - FIRST_CHILD (frame->this)->fops->readv, - file->fd, size, offset); - return 0; - } - local = (void *) GF_CALLOC (1, sizeof (*local), gf_ra_mt_ra_local_t); if (!local) { op_errno = ENOMEM; @@ -562,6 +550,13 @@ unwind: STACK_UNWIND_STRICT (readv, frame, -1, op_errno, NULL, 0, NULL, NULL); return 0; + +disabled: + STACK_WIND (frame, ra_readv_disabled_cbk, + FIRST_CHILD (frame->this), + FIRST_CHILD (frame->this)->fops->readv, + fd, size, offset); + return 0; } @@ -600,16 +595,10 @@ ra_flush (call_frame_t *frame, xlator_t *this, fd_t *fd) fd_ctx_get (fd, this, &tmp_file); file = (ra_file_t *)(long)tmp_file; - if (file == NULL) { - op_errno = EBADF; - gf_log (this->name, GF_LOG_WARNING, - "flush received on fd (%p) with no" - " file set in its context", fd); - goto unwind; + if (file) { + flush_region (frame, file, 0, file->pages.prev->offset+1); } - flush_region (frame, file, 0, file->pages.prev->offset+1); - STACK_WIND (frame, ra_flush_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->flush, fd); return 0; @@ -634,16 +623,10 @@ ra_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync) fd_ctx_get (fd, this, &tmp_file); file = (ra_file_t *)(long)tmp_file; - if (file == NULL) { - op_errno = EBADF; - gf_log (this->name, GF_LOG_WARNING, - "fsync received on fd (%p) with no" - " file set in its context", fd); - goto unwind; + if (file) { + flush_region (frame, file, 0, file->pages.prev->offset+1); } - flush_region (frame, file, 0, file->pages.prev->offset+1); - STACK_WIND (frame, ra_fsync_cbk, FIRST_CHILD (this), FIRST_CHILD (this)->fops->fsync, fd, datasync); return 0; @@ -659,28 +642,16 @@ ra_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret, int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf) { - fd_t *fd = NULL; ra_file_t *file = NULL; - uint64_t tmp_file = 0; GF_ASSERT (frame); - fd = frame->local; - - fd_ctx_get (fd, this, &tmp_file); - file = (ra_file_t *)(long)tmp_file; + file = frame->local; - if (file == NULL) { - gf_log (this->name, GF_LOG_WARNING, - "no read-ahead context set in fd (%p)", fd); - op_errno = EBADF; - op_ret = -1; - goto out; + if (file) { + flush_region (frame, file, 0, file->pages.prev->offset+1); } - flush_region (frame, file, 0, file->pages.prev->offset+1); - -out: frame->local = NULL; STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf); return 0; @@ -701,20 +672,13 @@ ra_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, fd_ctx_get (fd, this, &tmp_file); file = (ra_file_t *)(long)tmp_file; - if (file == NULL) { - op_errno = EBADF; - gf_log (this->name, GF_LOG_WARNING, "writev received on fd with" - "no file set in its context"); - goto unwind; + if (file) { + flush_region (frame, file, 0, file->pages.prev->offset+1); + frame->local = file; + /* reset the read-ahead counters too */ + file->expected = file->page_count = 0; } - flush_region (frame, file, 0, file->pages.prev->offset+1); - - /* reset the read-ahead counters too */ - file->expected = file->page_count = 0; - - frame->local = fd; - STACK_WIND (frame, ra_writev_cbk, FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev, diff --git a/xlators/performance/stat-prefetch/src/stat-prefetch.c b/xlators/performance/stat-prefetch/src/stat-prefetch.c index 563da9e7267..73cc3a955d8 100644 --- a/xlators/performance/stat-prefetch/src/stat-prefetch.c +++ b/xlators/performance/stat-prefetch/src/stat-prefetch.c @@ -19,6 +19,7 @@ #include "stat-prefetch.h" #include "statedump.h" +#include "fd.h" #define GF_SP_CACHE_BUCKETS 1 #define GF_SP_CACHE_ENTRIES_EXPECTED (128 * 1024) //1048576 @@ -667,9 +668,6 @@ out: } -fd_t * -_fd_ref (fd_t *fd); - void sp_remove_caches_from_all_fds_opened (xlator_t *this, inode_t *inode, char *name) @@ -705,7 +703,7 @@ sp_remove_caches_from_all_fds_opened (xlator_t *this, inode_t *inode, INIT_LIST_HEAD (&wrapper->list); - wrapper->fd = _fd_ref (fd); + wrapper->fd = __fd_ref (fd); list_add_tail (&wrapper->list, &head); } } diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c index 1555a79a75b..52e03872026 100644 --- a/xlators/performance/write-behind/src/write-behind.c +++ b/xlators/performance/write-behind/src/write-behind.c @@ -832,17 +832,20 @@ wb_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd) GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind); GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind); + if ((!IA_ISDIR (fd->inode->ia_type)) && fd_ctx_get (fd, this, &tmp_file)) { - gf_log (this->name, GF_LOG_WARNING, - "write behind file pointer is" - " not stored in context of fd(%p), returning EBADFD", - fd); - op_errno = EBADFD; - goto unwind; + file = wb_file_create (this, fd, 0); + } else { + file = (wb_file_t *)(long)tmp_file; + if ((!IA_ISDIR (fd->inode->ia_type)) && (file == NULL)) { + gf_log (this->name, GF_LOG_WARNING, + "wb_file not found for fd %p", fd); + op_errno = EBADFD; + goto unwind; + } } - file = (wb_file_t *)(long)tmp_file; local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t); if (local == NULL) { @@ -1115,18 +1118,20 @@ wb_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset) GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind); GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind); + if ((!IA_ISDIR (fd->inode->ia_type)) && fd_ctx_get (fd, this, &tmp_file)) { - gf_log (this->name, GF_LOG_WARNING, - "write behind file pointer is" - " not stored in context of fd(%p), returning EBADFD", - fd); - op_errno = EBADFD; - goto unwind; + file = wb_file_create (this, fd, 0); + } else { + file = (wb_file_t *)(long)tmp_file; + if ((!IA_ISDIR (fd->inode->ia_type)) && (file == NULL)) { + gf_log (this->name, GF_LOG_WARNING, + "wb_file not found for fd %p", fd); + op_errno = EBADFD; + goto unwind; + } } - file = (wb_file_t *)(long)tmp_file; - local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t); if (local == NULL) { op_errno = ENOMEM; @@ -2091,21 +2096,15 @@ wb_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector, if ((!IA_ISDIR (fd->inode->ia_type)) && fd_ctx_get (fd, this, &tmp_file)) { - gf_log (this->name, GF_LOG_WARNING, - "write behind file pointer is" - " not stored in context of fd(%p), returning EBADFD", - fd); - - op_errno = EBADFD; - goto unwind; - } - - file = (wb_file_t *)(long)tmp_file; - if ((!IA_ISDIR (fd->inode->ia_type)) && (file == NULL)) { - gf_log (this->name, GF_LOG_WARNING, - "wb_file not found for fd %p", fd); - op_errno = EBADFD; - goto unwind; + file = wb_file_create (this, fd, 0); + } else { + file = (wb_file_t *)(long)tmp_file; + if ((!IA_ISDIR (fd->inode->ia_type)) && (file == NULL)) { + gf_log (this->name, GF_LOG_WARNING, + "wb_file not found for fd %p", fd); + op_errno = EBADFD; + goto unwind; + } } if (file != NULL) { @@ -2265,16 +2264,17 @@ wb_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, if ((!IA_ISDIR (fd->inode->ia_type)) && fd_ctx_get (fd, this, &tmp_file)) { - gf_log (this->name, GF_LOG_WARNING, - "write behind file pointer is" - " not stored in context of fd(%p), returning EBADFD", - fd); - op_errno = EBADFD; - goto unwind; + file = wb_file_create (this, fd, 0); + } else { + file = (wb_file_t *)(long)tmp_file; + if ((!IA_ISDIR (fd->inode->ia_type)) && (file == NULL)) { + gf_log (this->name, GF_LOG_WARNING, + "wb_file not found for fd %p", fd); + op_errno = EBADFD; + goto unwind; + } } - file = (wb_file_t *)(long)tmp_file; - local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t); if (local == NULL) { op_errno = ENOMEM; @@ -2449,19 +2449,20 @@ wb_flush (call_frame_t *frame, xlator_t *this, fd_t *fd) conf = this->private; + if ((!IA_ISDIR (fd->inode->ia_type)) && fd_ctx_get (fd, this, &tmp_file)) { - gf_log (this->name, GF_LOG_WARNING, - "write behind file pointer is" - " not stored in context of fd(%p), returning EBADFD", - fd); - - op_errno = EBADFD; - goto unwind; + file = wb_file_create (this, fd, 0); + } else { + file = (wb_file_t *)(long)tmp_file; + if ((!IA_ISDIR (fd->inode->ia_type)) && (file == NULL)) { + gf_log (this->name, GF_LOG_WARNING, + "wb_file not found for fd %p", fd); + op_errno = EBADFD; + goto unwind; + } } - file = (wb_file_t *)(long)tmp_file; - if (file != NULL) { local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t); if (local == NULL) { @@ -2593,18 +2594,20 @@ wb_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync) GF_VALIDATE_OR_GOTO_WITH_ERROR (frame->this->name, fd, unwind, op_errno, EINVAL); + if ((!IA_ISDIR (fd->inode->ia_type)) && fd_ctx_get (fd, this, &tmp_file)) { - gf_log (this->name, GF_LOG_WARNING, - "write behind file pointer is" - " not stored in context of fd(%p), returning EBADFD", - fd); - op_errno = EBADFD; - goto unwind; + file = wb_file_create (this, fd, 0); + } else { + file = (wb_file_t *)(long)tmp_file; + if ((!IA_ISDIR (fd->inode->ia_type)) && (file == NULL)) { + gf_log (this->name, GF_LOG_WARNING, + "wb_file not found for fd %p", fd); + op_errno = EBADFD; + goto unwind; + } } - file = (wb_file_t *)(long)tmp_file; - local = GF_CALLOC (1, sizeof (*local), gf_wb_mt_wb_local_t); if (local == NULL) { op_errno = ENOMEM; |