summaryrefslogtreecommitdiffstats
path: root/xlators/performance
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/performance')
-rw-r--r--xlators/performance/decompounder/src/decompounder.c1182
-rw-r--r--xlators/performance/io-cache/src/io-cache.c3023
-rw-r--r--xlators/performance/io-cache/src/ioc-inode.c300
-rw-r--r--xlators/performance/io-cache/src/page.c1436
-rw-r--r--xlators/performance/io-threads/src/io-threads.c1968
-rw-r--r--xlators/performance/md-cache/src/md-cache.c5261
-rw-r--r--xlators/performance/nl-cache/src/nl-cache-helper.c1725
-rw-r--r--xlators/performance/nl-cache/src/nl-cache.c1263
-rw-r--r--xlators/performance/open-behind/src/open-behind.c1788
-rw-r--r--xlators/performance/quick-read/src/quick-read.c2372
-rw-r--r--xlators/performance/read-ahead/src/page.c857
-rw-r--r--xlators/performance/read-ahead/src/read-ahead.c1840
-rw-r--r--xlators/performance/readdir-ahead/src/readdir-ahead.c1793
-rw-r--r--xlators/performance/symlink-cache/src/symlink-cache.c508
-rw-r--r--xlators/performance/write-behind/src/write-behind.c4742
15 files changed, 14685 insertions, 15373 deletions
diff --git a/xlators/performance/decompounder/src/decompounder.c b/xlators/performance/decompounder/src/decompounder.c
index 2bc73efdfd3..8bc390923e0 100644
--- a/xlators/performance/decompounder/src/decompounder.c
+++ b/xlators/performance/decompounder/src/decompounder.c
@@ -13,943 +13,821 @@
#include "compound-fop-utils.h"
void
-dc_local_cleanup (dc_local_t *local)
+dc_local_cleanup(dc_local_t *local)
{
- compound_args_cbk_cleanup (local->compound_rsp);
- return;
+ compound_args_cbk_cleanup(local->compound_rsp);
+ return;
}
int32_t
-dc_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf,
- dict_t *xdata)
+dc_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *buf, dict_t *xdata)
{
-
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (stat, frame, op_ret,
- op_errno, buf, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(stat, frame, op_ret, op_errno, buf,
+ xdata);
+ return 0;
}
int32_t
-dc_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, const char *path,
- struct iatt *buf, dict_t *xdata)
+dc_readlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, const char *path,
+ struct iatt *buf, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (readlink, frame, op_ret, op_errno,
- path, buf, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(readlink, frame, op_ret, op_errno, path,
+ buf, xdata);
+ return 0;
}
-
int32_t
-dc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+dc_mknod_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (mknod, frame, op_ret, op_errno,
- inode, buf, preparent,
- postparent, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(mknod, frame, op_ret, op_errno, inode,
+ buf, preparent, postparent, xdata);
+ return 0;
}
-
int32_t
-dc_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+dc_mkdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (mkdir, frame, op_ret, op_errno,
- inode, buf, preparent, postparent,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(mkdir, frame, op_ret, op_errno, inode,
+ buf, preparent, postparent, xdata);
+ return 0;
}
-
int32_t
-dc_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *preparent,
- struct iatt *postparent,
- dict_t *xdata)
+dc_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *preparent, struct iatt *postparent,
+ dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (unlink, frame, op_ret, op_errno,
- preparent, postparent, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(unlink, frame, op_ret, op_errno,
+ preparent, postparent, xdata);
+ return 0;
}
-
int32_t
-dc_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *preparent,
- struct iatt *postparent,
- dict_t *xdata)
+dc_rmdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *preparent, struct iatt *postparent,
+ dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (rmdir, frame, op_ret, op_errno,
- preparent, postparent, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(rmdir, frame, op_ret, op_errno,
+ preparent, postparent, xdata);
+ return 0;
}
-
int32_t
-dc_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+dc_symlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *buf, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (symlink, frame, op_ret, op_errno,
- inode, buf, preparent, postparent,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(symlink, frame, op_ret, op_errno, inode,
+ buf, preparent, postparent, xdata);
+ return 0;
}
-
int32_t
-dc_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf,
- struct iatt *preoldparent,
- struct iatt *postoldparent,
- struct iatt *prenewparent,
- struct iatt *postnewparent,
- dict_t *xdata)
+dc_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *buf, struct iatt *preoldparent,
+ struct iatt *postoldparent, struct iatt *prenewparent,
+ struct iatt *postnewparent, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (rename, frame, op_ret, op_errno,
- buf, preoldparent, postoldparent,
- prenewparent, postnewparent,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(rename, frame, op_ret, op_errno, buf,
+ preoldparent, postoldparent,
+ prenewparent, postnewparent, xdata);
+ return 0;
}
-
int32_t
-dc_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf,
- struct iatt *preparent,
- struct iatt *postparent,
- dict_t *xdata)
+dc_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (link, frame, op_ret, op_errno,
- inode, buf, preparent, postparent,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(link, frame, op_ret, op_errno, inode,
+ buf, preparent, postparent, xdata);
+ return 0;
}
-
int32_t
-dc_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+dc_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (truncate, frame, op_ret, op_errno,
- prebuf, postbuf, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(truncate, frame, op_ret, op_errno,
+ prebuf, postbuf, xdata);
+ return 0;
}
-
int32_t
-dc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
+dc_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, fd_t *fd, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (open, frame, op_ret, op_errno,
- fd, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(open, frame, op_ret, op_errno, fd,
+ xdata);
+ return 0;
}
-
int32_t
-dc_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iovec *vector,
- int32_t count,
- struct iatt *stbuf,
- struct iobref *iobref,
- dict_t *xdata)
+dc_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iovec *vector, int32_t count,
+ struct iatt *stbuf, struct iobref *iobref, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (readv, frame, op_ret, op_errno,
- vector, count, stbuf, iobref, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(readv, frame, op_ret, op_errno, vector,
+ count, stbuf, iobref, xdata);
+ return 0;
}
-
int32_t
-dc_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,
+dc_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,
dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (writev, frame, op_ret, op_errno,
- prebuf, postbuf, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(writev, frame, op_ret, op_errno, prebuf,
+ postbuf, xdata);
+ return 0;
}
-
int32_t
-dc_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct statvfs *buf,
- dict_t *xdata)
+dc_statfs_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct statvfs *buf, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (statfs, frame, op_ret, op_errno,
- buf, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(statfs, frame, op_ret, op_errno, buf,
+ xdata);
+ return 0;
}
-
int32_t
-dc_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_flush_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (flush, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(flush, frame, op_ret, op_errno, xdata);
+ return 0;
}
-
int32_t
-dc_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf,
+dc_fsync_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf,
dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fsync, frame, op_ret, op_errno,
- prebuf, postbuf, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fsync, frame, op_ret, op_errno, prebuf,
+ postbuf, xdata);
+ return 0;
}
-
int32_t
-dc_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (setxattr, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(setxattr, frame, op_ret, op_errno,
+ xdata);
+ return 0;
}
-
int32_t
-dc_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *dict,
- dict_t *xdata)
+dc_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (getxattr, frame, op_ret, op_errno,
- dict, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(getxattr, frame, op_ret, op_errno, dict,
+ xdata);
+ return 0;
}
-
int32_t
-dc_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (removexattr, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(removexattr, frame, op_ret, op_errno,
+ xdata);
+ return 0;
}
int32_t
-dc_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd,
- dict_t *xdata)
+dc_opendir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (opendir, frame, op_ret, op_errno,
- fd, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(opendir, frame, op_ret, op_errno, fd,
+ xdata);
+ return 0;
}
-
int32_t
-dc_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_fsyncdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fsyncdir, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fsyncdir, frame, op_ret, op_errno,
+ xdata);
+ return 0;
}
-
int32_t
-dc_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_access_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (access, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(access, frame, op_ret, op_errno, xdata);
+ return 0;
}
-
int32_t
-dc_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 iatt *buf,
- struct iatt *preparent,
- struct iatt *postparent,
- dict_t *xdata)
+dc_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 iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (create, frame, op_ret, op_errno,
- fd, inode, buf, preparent,
- postparent, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(create, frame, op_ret, op_errno, fd,
+ inode, buf, preparent, postparent,
+ xdata);
+ return 0;
}
-
int32_t
-dc_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+dc_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (ftruncate, frame, op_ret, op_errno,
- prebuf, postbuf, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(ftruncate, frame, op_ret, op_errno,
+ prebuf, postbuf, xdata);
+ return 0;
}
-
int32_t
-dc_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf,
- dict_t *xdata)
+dc_fstat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *buf, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fstat, frame, op_ret, op_errno,
- buf, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fstat, frame, op_ret, op_errno, buf,
+ xdata);
+ return 0;
}
-
int32_t
-dc_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct gf_flock *lock,
- dict_t *xdata)
+dc_lk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct gf_flock *lock, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (lk, frame, op_ret, op_errno,
- lock, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(lk, frame, op_ret, op_errno, lock,
+ xdata);
+ return 0;
}
-
int32_t
-dc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf,
- dict_t *xdata,
- struct iatt *postparent)
+dc_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf, dict_t *xdata,
+ struct iatt *postparent)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (lookup, frame, op_ret, op_errno,
- inode, buf, xdata, postparent);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(lookup, frame, op_ret, op_errno, inode,
+ buf, xdata, postparent);
+ return 0;
}
-
int32_t
-dc_readdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
- dict_t *xdata)
+dc_readdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
+ dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (readdir, frame, op_ret, op_errno,
- entries, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(readdir, frame, op_ret, op_errno,
+ entries, xdata);
+ return 0;
}
+int32_t
+dc_inodelk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
+{
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(inodelk, frame, op_ret, op_errno,
+ xdata);
+ return 0;
+}
int32_t
-dc_inodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+dc_finodelk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (inodelk, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(finodelk, frame, op_ret, op_errno,
+ xdata);
+ return 0;
}
-
int32_t
-dc_finodelk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_entrylk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (finodelk, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(entrylk, frame, op_ret, op_errno,
+ xdata);
+ return 0;
}
-
int32_t
-dc_entrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+dc_fentrylk_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (entrylk, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fentrylk, frame, op_ret, op_errno,
+ xdata);
+ return 0;
}
-
int32_t
-dc_fentrylk_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_xattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fentrylk, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(xattrop, frame, op_ret, op_errno, dict,
+ xdata);
+ return 0;
}
-
int32_t
-dc_xattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *dict,
- dict_t *xdata)
+dc_fxattrop_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (xattrop, frame, op_ret, op_errno,
- dict, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fxattrop, frame, op_ret, op_errno, dict,
+ xdata);
+ return 0;
}
-
int32_t
-dc_fxattrop_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *dict,
- dict_t *xdata)
+dc_fgetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fxattrop, frame, op_ret, op_errno,
- dict, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fgetxattr, frame, op_ret, op_errno,
+ dict, xdata);
+ return 0;
}
-
int32_t
-dc_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *dict,
- dict_t *xdata)
+dc_fsetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fgetxattr, frame, op_ret, op_errno,
- dict, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fsetxattr, frame, op_ret, op_errno,
+ xdata);
+ return 0;
}
-
int32_t
-dc_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_rchecksum_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, uint32_t weak_cksum,
+ uint8_t *strong_cksum, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fsetxattr, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(rchecksum, frame, op_ret, op_errno,
+ weak_cksum, strong_cksum, xdata);
+ return 0;
}
-
int32_t
-dc_rchecksum_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, uint32_t weak_cksum,
- uint8_t *strong_cksum, dict_t *xdata)
+dc_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *statpre,
+ struct iatt *statpost, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (rchecksum, frame, op_ret, op_errno,
- weak_cksum, strong_cksum, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(setattr, frame, op_ret, op_errno,
+ statpre, statpost, xdata);
+ return 0;
}
-
int32_t
-dc_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+dc_fsetattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *statpre,
struct iatt *statpost, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (setattr, frame, op_ret, op_errno,
- statpre, statpost, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fsetattr, frame, op_ret, op_errno,
+ statpre, statpost, xdata);
+ return 0;
}
-
int32_t
-dc_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *statpre,
- struct iatt *statpost, dict_t *xdata)
+dc_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
+ dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fsetattr, frame, op_ret, op_errno,
- statpre, statpost, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(readdirp, frame, op_ret, op_errno,
+ entries, xdata);
+ return 0;
}
-
int32_t
-dc_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
- dict_t *xdata)
+dc_fremovexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (readdirp, frame, op_ret, op_errno,
- entries, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fremovexattr, frame, op_ret, op_errno,
+ xdata);
+ return 0;
}
-
int32_t
-dc_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *pre,
+ struct iatt *post, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fremovexattr, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(fallocate, frame, op_ret, op_errno, pre,
+ post, xdata);
+ return 0;
}
-
int32_t
-dc_fallocate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *pre,
- struct iatt *post, dict_t *xdata)
+dc_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *pre,
+ struct iatt *post, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (fallocate, frame, op_ret, op_errno,
- pre, post, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(discard, frame, op_ret, op_errno, pre,
+ post, xdata);
+ return 0;
}
-
int32_t
-dc_discard_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+dc_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *pre,
struct iatt *post, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (discard, frame, op_ret, op_errno,
- pre, post, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(zerofill, frame, op_ret, op_errno, pre,
+ post, xdata);
+ return 0;
}
-
int32_t
-dc_zerofill_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *pre,
- struct iatt *post, dict_t *xdata)
+dc_ipc_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (zerofill, frame, op_ret, op_errno,
- pre, post, xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(ipc, frame, op_ret, op_errno, xdata);
+ return 0;
}
-
int32_t
-dc_ipc_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+dc_seek_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, off_t offset, dict_t *xdata)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (ipc, frame, op_ret, op_errno,
- xdata);
- return 0;
+ DC_FOP_RESPONSE_STORE_AND_WIND_NEXT(seek, frame, op_ret, op_errno, offset,
+ xdata);
+ return 0;
}
-
int32_t
-dc_seek_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, off_t offset, dict_t *xdata)
+dc_compound_fop_wind(call_frame_t *frame, xlator_t *this)
{
- DC_FOP_RESPONSE_STORE_AND_WIND_NEXT (seek, frame, op_ret, op_errno,
- offset, xdata);
- return 0;
-}
+ dc_local_t *local = frame->local;
+ compound_args_t *c_req = local->compound_req;
+ compound_args_cbk_t *c_rsp = local->compound_rsp;
+ int counter = local->counter;
+ default_args_t *curr_fop = &c_req->req_list[counter];
+ int op_ret = 0;
+ int op_errno = ENOMEM;
-int32_t
-dc_compound_fop_wind (call_frame_t *frame, xlator_t *this)
-{
- dc_local_t *local = frame->local;
- compound_args_t *c_req = local->compound_req;
- compound_args_cbk_t *c_rsp = local->compound_rsp;
- int counter = local->counter;
- default_args_t *curr_fop = &c_req->req_list[counter];
- int op_ret = 0;
- int op_errno = ENOMEM;
+ if (local->counter == local->length)
+ goto done;
- if (local->counter == local->length)
- goto done;
+ c_rsp->enum_list[counter] = c_req->enum_list[counter];
- c_rsp->enum_list[counter] = c_req->enum_list[counter];
-
- switch (c_req->enum_list[counter]) {
+ switch (c_req->enum_list[counter]) {
case GF_FOP_STAT:
- STACK_WIND (frame, dc_stat_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->stat,
- &curr_fop->loc, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_stat_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->stat, &curr_fop->loc,
+ curr_fop->xdata);
+ break;
case GF_FOP_READLINK:
- STACK_WIND (frame, dc_readlink_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readlink,
- &curr_fop->loc, curr_fop->size,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_readlink_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readlink, &curr_fop->loc,
+ curr_fop->size, curr_fop->xdata);
+ break;
case GF_FOP_MKNOD:
- STACK_WIND (frame, dc_mknod_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->mknod,
- &curr_fop->loc, curr_fop->mode, curr_fop->rdev,
- curr_fop->umask, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_mknod_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mknod, &curr_fop->loc,
+ curr_fop->mode, curr_fop->rdev, curr_fop->umask,
+ curr_fop->xdata);
+ break;
case GF_FOP_MKDIR:
- STACK_WIND (frame, dc_mkdir_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir,
- &curr_fop->loc, curr_fop->mode,
- curr_fop->umask, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_mkdir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mkdir, &curr_fop->loc,
+ curr_fop->mode, curr_fop->umask, curr_fop->xdata);
+ break;
case GF_FOP_UNLINK:
- STACK_WIND (frame, dc_unlink_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->unlink,
- &curr_fop->loc, curr_fop->xflag, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_unlink_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->unlink, &curr_fop->loc,
+ curr_fop->xflag, curr_fop->xdata);
+ break;
case GF_FOP_RMDIR:
- STACK_WIND (frame, dc_rmdir_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir,
- &curr_fop->loc, curr_fop->flags, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_rmdir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->rmdir, &curr_fop->loc,
+ curr_fop->flags, curr_fop->xdata);
+ break;
case GF_FOP_SYMLINK:
- STACK_WIND (frame, dc_symlink_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->symlink,
- curr_fop->linkname, &curr_fop->loc,
- curr_fop->umask, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_symlink_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->symlink, curr_fop->linkname,
+ &curr_fop->loc, curr_fop->umask, curr_fop->xdata);
+ break;
case GF_FOP_RENAME:
- STACK_WIND (frame, dc_rename_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->rename,
- &curr_fop->loc, &curr_fop->loc2, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_rename_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->rename, &curr_fop->loc,
+ &curr_fop->loc2, curr_fop->xdata);
+ break;
case GF_FOP_LINK:
- STACK_WIND (frame, dc_link_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->link,
- &curr_fop->loc, &curr_fop->loc2, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_link_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->link, &curr_fop->loc,
+ &curr_fop->loc2, curr_fop->xdata);
+ break;
case GF_FOP_TRUNCATE:
- STACK_WIND (frame, dc_truncate_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->truncate,
- &curr_fop->loc, curr_fop->offset, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate, &curr_fop->loc,
+ curr_fop->offset, curr_fop->xdata);
+ break;
case GF_FOP_OPEN:
- STACK_WIND (frame, dc_open_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->open,
- &curr_fop->loc, curr_fop->flags, curr_fop->fd,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_open_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open, &curr_fop->loc,
+ curr_fop->flags, curr_fop->fd, curr_fop->xdata);
+ break;
case GF_FOP_READ:
- STACK_WIND (frame, dc_readv_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv,
- curr_fop->fd, curr_fop->size, curr_fop->offset,
- curr_fop->flags, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_readv_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv, curr_fop->fd,
+ curr_fop->size, curr_fop->offset, curr_fop->flags,
+ curr_fop->xdata);
+ break;
case GF_FOP_WRITE:
- STACK_WIND (frame, dc_writev_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev,
- curr_fop->fd, curr_fop->vector, curr_fop->count,
- curr_fop->offset, curr_fop->flags, curr_fop->iobref,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_writev_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->writev, curr_fop->fd,
+ curr_fop->vector, curr_fop->count, curr_fop->offset,
+ curr_fop->flags, curr_fop->iobref, curr_fop->xdata);
+ break;
case GF_FOP_STATFS:
- STACK_WIND (frame, dc_statfs_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->statfs,
- &curr_fop->loc, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_statfs_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->statfs, &curr_fop->loc,
+ curr_fop->xdata);
+ break;
case GF_FOP_FLUSH:
- STACK_WIND (frame, dc_flush_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->flush,
- curr_fop->fd, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_flush_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->flush, curr_fop->fd,
+ curr_fop->xdata);
+ break;
case GF_FOP_FSYNC:
- STACK_WIND (frame, dc_fsync_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsync,
- curr_fop->fd, curr_fop->datasync, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fsync_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsync, curr_fop->fd,
+ curr_fop->datasync, curr_fop->xdata);
+ break;
case GF_FOP_SETXATTR:
- STACK_WIND (frame, dc_setxattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->setxattr,
- &curr_fop->loc, curr_fop->xattr, curr_fop->flags,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_setxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setxattr, &curr_fop->loc,
+ curr_fop->xattr, curr_fop->flags, curr_fop->xdata);
+ break;
case GF_FOP_GETXATTR:
- STACK_WIND (frame, dc_getxattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->getxattr,
- &curr_fop->loc, curr_fop->name, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_getxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->getxattr, &curr_fop->loc,
+ curr_fop->name, curr_fop->xdata);
+ break;
case GF_FOP_REMOVEXATTR:
- STACK_WIND (frame, dc_removexattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->removexattr,
- &curr_fop->loc, curr_fop->name, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_removexattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->removexattr, &curr_fop->loc,
+ curr_fop->name, curr_fop->xdata);
+ break;
case GF_FOP_OPENDIR:
- STACK_WIND (frame, dc_opendir_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->opendir,
- &curr_fop->loc, curr_fop->fd, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_opendir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->opendir, &curr_fop->loc,
+ curr_fop->fd, curr_fop->xdata);
+ break;
case GF_FOP_FSYNCDIR:
- STACK_WIND (frame, dc_fsyncdir_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsyncdir,
- curr_fop->fd, curr_fop->datasync, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fsyncdir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsyncdir, curr_fop->fd,
+ curr_fop->datasync, curr_fop->xdata);
+ break;
case GF_FOP_ACCESS:
- STACK_WIND (frame, dc_access_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->access,
- &curr_fop->loc, curr_fop->mask, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_access_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->access, &curr_fop->loc,
+ curr_fop->mask, curr_fop->xdata);
+ break;
case GF_FOP_CREATE:
- STACK_WIND (frame, dc_create_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->create,
- &curr_fop->loc, curr_fop->flags, curr_fop->mode,
- curr_fop->umask, curr_fop->fd, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_create_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->create, &curr_fop->loc,
+ curr_fop->flags, curr_fop->mode, curr_fop->umask,
+ curr_fop->fd, curr_fop->xdata);
+ break;
case GF_FOP_FTRUNCATE:
- STACK_WIND (frame, dc_ftruncate_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->ftruncate,
- curr_fop->fd, curr_fop->offset, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_ftruncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ftruncate, curr_fop->fd,
+ curr_fop->offset, curr_fop->xdata);
+ break;
case GF_FOP_FSTAT:
- STACK_WIND (frame, dc_fstat_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fstat,
- curr_fop->fd, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fstat_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fstat, curr_fop->fd,
+ curr_fop->xdata);
+ break;
case GF_FOP_LK:
- STACK_WIND (frame, dc_lk_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->lk,
- curr_fop->fd,
- curr_fop->cmd, &curr_fop->lock, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_lk_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lk, curr_fop->fd, curr_fop->cmd,
+ &curr_fop->lock, curr_fop->xdata);
+ break;
case GF_FOP_LOOKUP:
- STACK_WIND (frame, dc_lookup_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup,
- &curr_fop->loc, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_lookup_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, &curr_fop->loc,
+ curr_fop->xdata);
+ break;
case GF_FOP_READDIR:
- STACK_WIND (frame, dc_readdir_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdir,
- curr_fop->fd, curr_fop->size, curr_fop->offset,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_readdir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdir, curr_fop->fd,
+ curr_fop->size, curr_fop->offset, curr_fop->xdata);
+ break;
case GF_FOP_INODELK:
- STACK_WIND (frame, dc_inodelk_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->inodelk,
- curr_fop->volume, &curr_fop->loc,
- curr_fop->cmd, &curr_fop->lock, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_inodelk_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->inodelk, curr_fop->volume,
+ &curr_fop->loc, curr_fop->cmd, &curr_fop->lock,
+ curr_fop->xdata);
+ break;
case GF_FOP_FINODELK:
- STACK_WIND (frame, dc_finodelk_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->finodelk,
- curr_fop->volume, curr_fop->fd,
- curr_fop->cmd, &curr_fop->lock, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_finodelk_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->finodelk, curr_fop->volume,
+ curr_fop->fd, curr_fop->cmd, &curr_fop->lock,
+ curr_fop->xdata);
+ break;
case GF_FOP_ENTRYLK:
- STACK_WIND (frame, dc_entrylk_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->entrylk,
- curr_fop->volume, &curr_fop->loc,
- curr_fop->name, curr_fop->entrylkcmd,
- curr_fop->entrylktype, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_entrylk_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->entrylk, curr_fop->volume,
+ &curr_fop->loc, curr_fop->name, curr_fop->entrylkcmd,
+ curr_fop->entrylktype, curr_fop->xdata);
+ break;
case GF_FOP_FENTRYLK:
- STACK_WIND (frame, dc_fentrylk_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fentrylk,
- curr_fop->volume, curr_fop->fd,
- curr_fop->name, curr_fop->entrylkcmd,
- curr_fop->entrylktype, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fentrylk_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fentrylk, curr_fop->volume,
+ curr_fop->fd, curr_fop->name, curr_fop->entrylkcmd,
+ curr_fop->entrylktype, curr_fop->xdata);
+ break;
case GF_FOP_XATTROP:
- STACK_WIND (frame, dc_xattrop_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->xattrop,
- &curr_fop->loc, curr_fop->optype, curr_fop->xattr,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_xattrop_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->xattrop, &curr_fop->loc,
+ curr_fop->optype, curr_fop->xattr, curr_fop->xdata);
+ break;
case GF_FOP_FXATTROP:
- STACK_WIND (frame, dc_fxattrop_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fxattrop,
- curr_fop->fd, curr_fop->optype, curr_fop->xattr,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fxattrop_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fxattrop, curr_fop->fd,
+ curr_fop->optype, curr_fop->xattr, curr_fop->xdata);
+ break;
case GF_FOP_FGETXATTR:
- STACK_WIND (frame, dc_fgetxattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fgetxattr,
- curr_fop->fd, curr_fop->name, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fgetxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fgetxattr, curr_fop->fd,
+ curr_fop->name, curr_fop->xdata);
+ break;
case GF_FOP_FSETXATTR:
- STACK_WIND (frame, dc_fsetxattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsetxattr,
- curr_fop->fd, curr_fop->xattr, curr_fop->flags,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fsetxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsetxattr, curr_fop->fd,
+ curr_fop->xattr, curr_fop->flags, curr_fop->xdata);
+ break;
case GF_FOP_RCHECKSUM:
- STACK_WIND (frame, dc_rchecksum_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->rchecksum,
- curr_fop->fd, curr_fop->offset, curr_fop->size,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_rchecksum_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->rchecksum, curr_fop->fd,
+ curr_fop->offset, curr_fop->size, curr_fop->xdata);
+ break;
case GF_FOP_SETATTR:
- STACK_WIND (frame, dc_setattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->setattr,
- &curr_fop->loc, &curr_fop->stat, curr_fop->valid,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_setattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setattr, &curr_fop->loc,
+ &curr_fop->stat, curr_fop->valid, curr_fop->xdata);
+ break;
case GF_FOP_FSETATTR:
- STACK_WIND (frame, dc_fsetattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsetattr,
- curr_fop->fd, &curr_fop->stat, curr_fop->valid,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fsetattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsetattr, curr_fop->fd,
+ &curr_fop->stat, curr_fop->valid, curr_fop->xdata);
+ break;
case GF_FOP_READDIRP:
- STACK_WIND (frame, dc_readdirp_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdirp,
- curr_fop->fd, curr_fop->size, curr_fop->offset,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_readdirp_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp, curr_fop->fd,
+ curr_fop->size, curr_fop->offset, curr_fop->xdata);
+ break;
case GF_FOP_FREMOVEXATTR:
- STACK_WIND (frame, dc_fremovexattr_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fremovexattr,
- curr_fop->fd, curr_fop->name, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fremovexattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fremovexattr, curr_fop->fd,
+ curr_fop->name, curr_fop->xdata);
+ break;
case GF_FOP_FALLOCATE:
- STACK_WIND (frame, dc_fallocate_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fallocate,
- curr_fop->fd, curr_fop->flags, curr_fop->offset,
- curr_fop->size, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_fallocate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fallocate, curr_fop->fd,
+ curr_fop->flags, curr_fop->offset, curr_fop->size,
+ curr_fop->xdata);
+ break;
case GF_FOP_DISCARD:
- STACK_WIND (frame, dc_discard_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->discard,
- curr_fop->fd, curr_fop->offset, curr_fop->size,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_discard_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->discard, curr_fop->fd,
+ curr_fop->offset, curr_fop->size, curr_fop->xdata);
+ break;
case GF_FOP_ZEROFILL:
- STACK_WIND (frame, dc_zerofill_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->zerofill,
- curr_fop->fd, curr_fop->offset, curr_fop->size,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_zerofill_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->zerofill, curr_fop->fd,
+ curr_fop->offset, curr_fop->size, curr_fop->xdata);
+ break;
case GF_FOP_IPC:
- STACK_WIND (frame, dc_ipc_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->ipc,
- curr_fop->cmd, curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_ipc_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ipc, curr_fop->cmd,
+ curr_fop->xdata);
+ break;
case GF_FOP_SEEK:
- STACK_WIND (frame, dc_seek_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->seek,
- curr_fop->fd, curr_fop->offset, curr_fop->what,
- curr_fop->xdata);
- break;
+ STACK_WIND(frame, dc_seek_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->seek, curr_fop->fd,
+ curr_fop->offset, curr_fop->what, curr_fop->xdata);
+ break;
default:
- return -ENOTSUP;
- }
- return 0;
+ return -ENOTSUP;
+ }
+ return 0;
done:
- DC_STACK_UNWIND (frame, op_ret, op_errno, c_rsp, NULL);
- return 0;
+ DC_STACK_UNWIND(frame, op_ret, op_errno, c_rsp, NULL);
+ return 0;
}
int32_t
-dc_compound (call_frame_t *frame, xlator_t *this, void *data, dict_t *xdata)
+dc_compound(call_frame_t *frame, xlator_t *this, void *data, dict_t *xdata)
{
- compound_args_t *compound_req = NULL;
- compound_args_cbk_t *compound_rsp = NULL;
- int ret = 0;
- int op_errno = ENOMEM;
- dc_local_t *local = NULL;
+ compound_args_t *compound_req = NULL;
+ compound_args_cbk_t *compound_rsp = NULL;
+ int ret = 0;
+ int op_errno = ENOMEM;
+ dc_local_t *local = NULL;
- compound_req = data;
+ compound_req = data;
- GF_ASSERT_AND_GOTO_WITH_ERROR (this, compound_req, out, op_errno,
- EINVAL);
+ GF_ASSERT_AND_GOTO_WITH_ERROR(this, compound_req, out, op_errno, EINVAL);
- local = mem_get0 (this->local_pool);
- if (!local)
- goto out;
+ local = mem_get0(this->local_pool);
+ if (!local)
+ goto out;
- frame->local = local;
+ frame->local = local;
- local->compound_rsp = compound_args_cbk_alloc (compound_req->fop_length,
- NULL);
- if (!local->compound_rsp)
- goto out;
+ local->compound_rsp = compound_args_cbk_alloc(compound_req->fop_length,
+ NULL);
+ if (!local->compound_rsp)
+ goto out;
- compound_rsp = local->compound_rsp;
+ compound_rsp = local->compound_rsp;
- local->length = compound_req->fop_length;
- local->counter = 0;
- local->compound_req = compound_req;
+ local->length = compound_req->fop_length;
+ local->counter = 0;
+ local->compound_req = compound_req;
- if (!local->length) {
- op_errno = EINVAL;
- goto out;
- }
+ if (!local->length) {
+ op_errno = EINVAL;
+ goto out;
+ }
- ret = dc_compound_fop_wind (frame, this);
- if (ret < 0) {
- op_errno = -ret;
- goto out;
- }
- return 0;
+ ret = dc_compound_fop_wind(frame, this);
+ if (ret < 0) {
+ op_errno = -ret;
+ goto out;
+ }
+ return 0;
out:
- DC_STACK_UNWIND (frame, -1, op_errno, compound_rsp, NULL);
- return 0;
+ DC_STACK_UNWIND(frame, -1, op_errno, compound_rsp, NULL);
+ return 0;
}
-struct xlator_cbks cbks = {
-};
+struct xlator_cbks cbks = {};
struct volume_options options[] = {
- { .key = {NULL} },
+ {.key = {NULL}},
};
struct xlator_fops fops = {
- .compound = dc_compound,
+ .compound = dc_compound,
};
int32_t
-mem_acct_init (xlator_t *this)
+mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- if (!this)
- return ret;
+ if (!this)
+ return ret;
- ret = xlator_mem_acct_init (this, gf_dc_mt_end + 1);
+ ret = xlator_mem_acct_init(this, gf_dc_mt_end + 1);
- return ret;
+ return ret;
}
int32_t
-init (xlator_t *this)
+init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- if (!this->children) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- DC_MSG_VOL_MISCONFIGURED, "Decompounder must have"
- " a subvol.");
- goto out;
- }
+ if (!this->children) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, DC_MSG_VOL_MISCONFIGURED,
+ "Decompounder must have"
+ " a subvol.");
+ goto out;
+ }
- if (!this->parents) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- DC_MSG_VOL_MISCONFIGURED, "Volume is dangling.");
- goto out;
- }
+ if (!this->parents) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, DC_MSG_VOL_MISCONFIGURED,
+ "Volume is dangling.");
+ goto out;
+ }
- this->local_pool = mem_pool_new (dc_local_t, 128);
- if (!this->local_pool) {
- goto out;
- }
+ this->local_pool = mem_pool_new(dc_local_t, 128);
+ if (!this->local_pool) {
+ goto out;
+ }
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
int32_t
-fini (xlator_t *this)
+fini(xlator_t *this)
{
- if (!this)
- return 0;
-
- if (this->local_pool) {
- mem_pool_destroy (this->local_pool);
- this->local_pool = NULL;
- }
+ if (!this)
return 0;
+
+ if (this->local_pool) {
+ mem_pool_destroy(this->local_pool);
+ this->local_pool = NULL;
+ }
+ return 0;
}
diff --git a/xlators/performance/io-cache/src/io-cache.c b/xlators/performance/io-cache/src/io-cache.c
index 7156b426b04..843fc36396a 100644
--- a/xlators/performance/io-cache/src/io-cache.c
+++ b/xlators/performance/io-cache/src/io-cache.c
@@ -22,19 +22,18 @@
int ioc_log2_page_size;
uint32_t
-ioc_get_priority (ioc_table_t *table, const char *path);
+ioc_get_priority(ioc_table_t *table, const char *path);
struct volume_options options[];
-
static uint32_t
-ioc_hashfn (void *data, int len)
+ioc_hashfn(void *data, int len)
{
- off_t offset;
+ off_t offset;
- offset = *(off_t *) data;
+ offset = *(off_t *)data;
- return (offset >> ioc_log2_page_size);
+ return (offset >> ioc_log2_page_size);
}
/* TODO: This function is not used, uncomment when we find a
@@ -80,20 +79,22 @@ ioc_get_inode (dict_t *dict, char *name)
*/
int32_t
-ioc_inode_need_revalidate (ioc_inode_t *ioc_inode)
+ioc_inode_need_revalidate(ioc_inode_t *ioc_inode)
{
- int8_t need_revalidate = 0;
- struct timeval tv = {0,};
- ioc_table_t *table = NULL;
+ int8_t need_revalidate = 0;
+ struct timeval tv = {
+ 0,
+ };
+ ioc_table_t *table = NULL;
- table = ioc_inode->table;
+ table = ioc_inode->table;
- gettimeofday (&tv, NULL);
+ gettimeofday(&tv, NULL);
- if (time_elapsed (&tv, &ioc_inode->cache.tv) >= table->cache_timeout)
- need_revalidate = 1;
+ if (time_elapsed(&tv, &ioc_inode->cache.tv) >= table->cache_timeout)
+ need_revalidate = 1;
- return need_revalidate;
+ return need_revalidate;
}
/*
@@ -104,211 +105,203 @@ ioc_inode_need_revalidate (ioc_inode_t *ioc_inode)
* assumes lock is held
*/
int64_t
-__ioc_inode_flush (ioc_inode_t *ioc_inode)
+__ioc_inode_flush(ioc_inode_t *ioc_inode)
{
- ioc_page_t *curr = NULL, *next = NULL;
- int64_t destroy_size = 0;
- int64_t ret = 0;
+ ioc_page_t *curr = NULL, *next = NULL;
+ int64_t destroy_size = 0;
+ int64_t ret = 0;
- list_for_each_entry_safe (curr, next, &ioc_inode->cache.page_lru,
- page_lru) {
- ret = __ioc_page_destroy (curr);
+ list_for_each_entry_safe(curr, next, &ioc_inode->cache.page_lru, page_lru)
+ {
+ ret = __ioc_page_destroy(curr);
- if (ret != -1)
- destroy_size += ret;
- }
+ if (ret != -1)
+ destroy_size += ret;
+ }
- return destroy_size;
+ return destroy_size;
}
void
-ioc_inode_flush (ioc_inode_t *ioc_inode)
+ioc_inode_flush(ioc_inode_t *ioc_inode)
{
- int64_t destroy_size = 0;
+ int64_t destroy_size = 0;
- ioc_inode_lock (ioc_inode);
- {
- destroy_size = __ioc_inode_flush (ioc_inode);
- }
- ioc_inode_unlock (ioc_inode);
+ ioc_inode_lock(ioc_inode);
+ {
+ destroy_size = __ioc_inode_flush(ioc_inode);
+ }
+ ioc_inode_unlock(ioc_inode);
- if (destroy_size) {
- ioc_table_lock (ioc_inode->table);
- {
- ioc_inode->table->cache_used -= destroy_size;
- }
- ioc_table_unlock (ioc_inode->table);
+ if (destroy_size) {
+ ioc_table_lock(ioc_inode->table);
+ {
+ ioc_inode->table->cache_used -= destroy_size;
}
+ ioc_table_unlock(ioc_inode->table);
+ }
- return;
+ return;
}
int32_t
-ioc_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *preop, struct iatt *postop, dict_t *xdata)
+ioc_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *preop,
+ struct iatt *postop, dict_t *xdata)
{
- STACK_UNWIND_STRICT (setattr, frame, op_ret, op_errno, preop, postop,
- xdata);
- return 0;
+ STACK_UNWIND_STRICT(setattr, frame, op_ret, op_errno, preop, postop, xdata);
+ return 0;
}
int32_t
-ioc_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- struct iatt *stbuf, int32_t valid, dict_t *xdata)
+ioc_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf,
+ int32_t valid, dict_t *xdata)
{
- uint64_t ioc_inode = 0;
+ uint64_t ioc_inode = 0;
- inode_ctx_get (loc->inode, this, &ioc_inode);
+ inode_ctx_get(loc->inode, this, &ioc_inode);
- if (ioc_inode
- && ((valid & GF_SET_ATTR_ATIME)
- || (valid & GF_SET_ATTR_MTIME)))
- ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
+ if (ioc_inode &&
+ ((valid & GF_SET_ATTR_ATIME) || (valid & GF_SET_ATTR_MTIME)))
+ ioc_inode_flush((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND (frame, ioc_setattr_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->setattr, loc, stbuf, valid, xdata);
+ STACK_WIND(frame, ioc_setattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setattr, loc, stbuf, valid, xdata);
- return 0;
+ return 0;
}
int32_t
-ioc_inode_update (xlator_t *this, inode_t *inode, char *path,
- struct iatt *iabuf)
+ioc_inode_update(xlator_t *this, inode_t *inode, char *path, struct iatt *iabuf)
{
- ioc_table_t *table = NULL;
- uint64_t tmp_ioc_inode = 0;
- ioc_inode_t *ioc_inode = NULL;
- uint32_t weight = 0xffffffff;
- gf_boolean_t cache_still_valid = _gf_false;
+ ioc_table_t *table = NULL;
+ uint64_t tmp_ioc_inode = 0;
+ ioc_inode_t *ioc_inode = NULL;
+ uint32_t weight = 0xffffffff;
+ gf_boolean_t cache_still_valid = _gf_false;
- if (!this || !inode)
- goto out;
+ if (!this || !inode)
+ goto out;
- table = this->private;
+ table = this->private;
- LOCK (&inode->lock);
- {
- (void) __inode_ctx_get (inode, this, &tmp_ioc_inode);
- ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
+ LOCK(&inode->lock);
+ {
+ (void)__inode_ctx_get(inode, this, &tmp_ioc_inode);
+ ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
- if (!ioc_inode) {
- weight = ioc_get_priority (table, path);
+ if (!ioc_inode) {
+ weight = ioc_get_priority(table, path);
- ioc_inode = ioc_inode_create (table, inode,
- weight);
+ ioc_inode = ioc_inode_create(table, inode, weight);
- (void) __inode_ctx_put (inode, this,
- (uint64_t)(long)ioc_inode);
- }
+ (void)__inode_ctx_put(inode, this, (uint64_t)(long)ioc_inode);
}
- UNLOCK (&inode->lock);
+ }
+ UNLOCK(&inode->lock);
- ioc_inode_lock (ioc_inode);
- {
- if (ioc_inode->cache.mtime == 0) {
- ioc_inode->cache.mtime = iabuf->ia_mtime;
- ioc_inode->cache.mtime_nsec = iabuf->ia_mtime_nsec;
- }
-
- ioc_inode->ia_size = iabuf->ia_size;
+ ioc_inode_lock(ioc_inode);
+ {
+ if (ioc_inode->cache.mtime == 0) {
+ ioc_inode->cache.mtime = iabuf->ia_mtime;
+ ioc_inode->cache.mtime_nsec = iabuf->ia_mtime_nsec;
}
- ioc_inode_unlock (ioc_inode);
- cache_still_valid = ioc_cache_still_valid (ioc_inode, iabuf);
+ ioc_inode->ia_size = iabuf->ia_size;
+ }
+ ioc_inode_unlock(ioc_inode);
- if (!cache_still_valid) {
- ioc_inode_flush (ioc_inode);
- }
+ cache_still_valid = ioc_cache_still_valid(ioc_inode, iabuf);
- ioc_table_lock (ioc_inode->table);
- {
- list_move_tail (&ioc_inode->inode_lru,
- &table->inode_lru[ioc_inode->weight]);
- }
- ioc_table_unlock (ioc_inode->table);
+ if (!cache_still_valid) {
+ ioc_inode_flush(ioc_inode);
+ }
+
+ ioc_table_lock(ioc_inode->table);
+ {
+ list_move_tail(&ioc_inode->inode_lru,
+ &table->inode_lru[ioc_inode->weight]);
+ }
+ ioc_table_unlock(ioc_inode->table);
out:
- return 0;
+ return 0;
}
-
int32_t
-ioc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *stbuf, dict_t *xdata, struct iatt *postparent)
+ioc_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *stbuf, dict_t *xdata, struct iatt *postparent)
{
- ioc_local_t *local = NULL;
+ ioc_local_t *local = NULL;
- if (op_ret != 0)
- goto out;
+ if (op_ret != 0)
+ goto out;
- local = frame->local;
- if (local == NULL) {
- op_ret = -1;
- op_errno = EINVAL;
- goto out;
- }
+ local = frame->local;
+ if (local == NULL) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ goto out;
+ }
- if (!this || !this->private) {
- op_ret = -1;
- op_errno = EINVAL;
- goto out;
- }
+ if (!this || !this->private) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ goto out;
+ }
- ioc_inode_update (this, inode, (char *)local->file_loc.path, stbuf);
+ ioc_inode_update(this, inode, (char *)local->file_loc.path, stbuf);
out:
- if (frame->local != NULL) {
- local = frame->local;
- loc_wipe (&local->file_loc);
- }
+ if (frame->local != NULL) {
+ local = frame->local;
+ loc_wipe(&local->file_loc);
+ }
- STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, stbuf,
- xdata, postparent);
- return 0;
+ STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, stbuf, xdata,
+ postparent);
+ return 0;
}
int32_t
-ioc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
- dict_t *xdata)
+ioc_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- ioc_local_t *local = NULL;
- int32_t op_errno = -1, ret = -1;
+ ioc_local_t *local = NULL;
+ int32_t op_errno = -1, ret = -1;
- local = mem_get0 (this->local_pool);
- if (local == NULL) {
- op_errno = ENOMEM;
- gf_msg (this->name, GF_LOG_ERROR, 0,
- IO_CACHE_MSG_NO_MEMORY, "out of memory");
- goto unwind;
- }
+ local = mem_get0(this->local_pool);
+ if (local == NULL) {
+ op_errno = ENOMEM;
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ goto unwind;
+ }
- ret = loc_copy (&local->file_loc, loc);
- if (ret != 0) {
- op_errno = ENOMEM;
- gf_msg (this->name, GF_LOG_ERROR, 0,
- IO_CACHE_MSG_NO_MEMORY, "out of memory");
- goto unwind;
- }
+ ret = loc_copy(&local->file_loc, loc);
+ if (ret != 0) {
+ op_errno = ENOMEM;
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ goto unwind;
+ }
- frame->local = local;
+ frame->local = local;
- STACK_WIND (frame, ioc_lookup_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->lookup, loc, xdata);
+ STACK_WIND(frame, ioc_lookup_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, loc, xdata);
- return 0;
+ return 0;
unwind:
- if (local != NULL) {
- loc_wipe (&local->file_loc);
- mem_put (local);
- }
+ if (local != NULL) {
+ loc_wipe(&local->file_loc);
+ mem_put(local);
+ }
- STACK_UNWIND_STRICT (lookup, frame, -1, op_errno, NULL, NULL,
- NULL, NULL);
+ STACK_UNWIND_STRICT(lookup, frame, -1, op_errno, NULL, NULL, NULL, NULL);
- return 0;
+ return 0;
}
/*
@@ -320,31 +313,31 @@ unwind:
*
*/
int32_t
-ioc_forget (xlator_t *this, inode_t *inode)
+ioc_forget(xlator_t *this, inode_t *inode)
{
- uint64_t ioc_inode = 0;
+ uint64_t ioc_inode = 0;
- inode_ctx_get (inode, this, &ioc_inode);
+ inode_ctx_get(inode, this, &ioc_inode);
- if (ioc_inode)
- ioc_inode_destroy ((ioc_inode_t *)(long)ioc_inode);
+ if (ioc_inode)
+ ioc_inode_destroy((ioc_inode_t *)(long)ioc_inode);
- return 0;
+ return 0;
}
static int32_t
ioc_invalidate(xlator_t *this, inode_t *inode)
{
- uint64_t ioc_addr = 0;
- ioc_inode_t *ioc_inode = NULL;
+ uint64_t ioc_addr = 0;
+ ioc_inode_t *ioc_inode = NULL;
- inode_ctx_get(inode, this, (uint64_t *) &ioc_addr);
- ioc_inode = (void *) ioc_addr;
+ inode_ctx_get(inode, this, (uint64_t *)&ioc_addr);
+ ioc_inode = (void *)ioc_addr;
- if (ioc_inode)
- ioc_inode_flush(ioc_inode);
+ if (ioc_inode)
+ ioc_inode_flush(ioc_inode);
- return 0;
+ return 0;
}
/*
@@ -359,105 +352,102 @@ ioc_invalidate(xlator_t *this, inode_t *inode)
*
*/
int32_t
-ioc_cache_validate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *stbuf,
- dict_t *xdata)
+ioc_cache_validate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *stbuf,
+ dict_t *xdata)
{
- ioc_local_t *local = NULL;
- ioc_inode_t *ioc_inode = NULL;
- size_t destroy_size = 0;
- struct iatt *local_stbuf = NULL;
-
- local = frame->local;
- ioc_inode = local->inode;
- local_stbuf = stbuf;
-
- if ((op_ret == -1) ||
- ((op_ret >= 0) && !ioc_cache_still_valid(ioc_inode, stbuf))) {
- gf_msg_debug (ioc_inode->table->xl->name, 0,
- "cache for inode(%p) is invalid. flushing all pages",
- ioc_inode);
- /* NOTE: only pages with no waiting frames are flushed by
- * ioc_inode_flush. page_fault will be generated for all
- * the pages which have waiting frames by ioc_inode_wakeup()
- */
- ioc_inode_lock (ioc_inode);
- {
- destroy_size = __ioc_inode_flush (ioc_inode);
- if (op_ret >= 0) {
- ioc_inode->cache.mtime = stbuf->ia_mtime;
- ioc_inode->cache.mtime_nsec
- = stbuf->ia_mtime_nsec;
- }
- }
- ioc_inode_unlock (ioc_inode);
- local_stbuf = NULL;
- }
-
- if (destroy_size) {
- ioc_table_lock (ioc_inode->table);
- {
- ioc_inode->table->cache_used -= destroy_size;
- }
- ioc_table_unlock (ioc_inode->table);
+ ioc_local_t *local = NULL;
+ ioc_inode_t *ioc_inode = NULL;
+ size_t destroy_size = 0;
+ struct iatt *local_stbuf = NULL;
+
+ local = frame->local;
+ ioc_inode = local->inode;
+ local_stbuf = stbuf;
+
+ if ((op_ret == -1) ||
+ ((op_ret >= 0) && !ioc_cache_still_valid(ioc_inode, stbuf))) {
+ gf_msg_debug(ioc_inode->table->xl->name, 0,
+ "cache for inode(%p) is invalid. flushing all pages",
+ ioc_inode);
+ /* NOTE: only pages with no waiting frames are flushed by
+ * ioc_inode_flush. page_fault will be generated for all
+ * the pages which have waiting frames by ioc_inode_wakeup()
+ */
+ ioc_inode_lock(ioc_inode);
+ {
+ destroy_size = __ioc_inode_flush(ioc_inode);
+ if (op_ret >= 0) {
+ ioc_inode->cache.mtime = stbuf->ia_mtime;
+ ioc_inode->cache.mtime_nsec = stbuf->ia_mtime_nsec;
+ }
+ }
+ ioc_inode_unlock(ioc_inode);
+ local_stbuf = NULL;
+ }
+
+ if (destroy_size) {
+ ioc_table_lock(ioc_inode->table);
+ {
+ ioc_inode->table->cache_used -= destroy_size;
}
+ ioc_table_unlock(ioc_inode->table);
+ }
- if (op_ret < 0)
- local_stbuf = NULL;
+ if (op_ret < 0)
+ local_stbuf = NULL;
- ioc_inode_lock (ioc_inode);
- {
- gettimeofday (&ioc_inode->cache.tv, NULL);
- }
- ioc_inode_unlock (ioc_inode);
+ ioc_inode_lock(ioc_inode);
+ {
+ gettimeofday(&ioc_inode->cache.tv, NULL);
+ }
+ ioc_inode_unlock(ioc_inode);
- ioc_inode_wakeup (frame, ioc_inode, local_stbuf);
+ ioc_inode_wakeup(frame, ioc_inode, local_stbuf);
- /* any page-fault initiated by ioc_inode_wakeup() will have its own
- * fd_ref on fd, safe to unref validate frame's private copy
- */
- fd_unref (local->fd);
+ /* any page-fault initiated by ioc_inode_wakeup() will have its own
+ * fd_ref on fd, safe to unref validate frame's private copy
+ */
+ fd_unref(local->fd);
- STACK_DESTROY (frame->root);
+ STACK_DESTROY(frame->root);
- return 0;
+ return 0;
}
int32_t
-ioc_wait_on_inode (ioc_inode_t *ioc_inode, ioc_page_t *page)
+ioc_wait_on_inode(ioc_inode_t *ioc_inode, ioc_page_t *page)
{
- ioc_waitq_t *waiter = NULL, *trav = NULL;
- uint32_t page_found = 0;
- int32_t ret = 0;
+ ioc_waitq_t *waiter = NULL, *trav = NULL;
+ uint32_t page_found = 0;
+ int32_t ret = 0;
- trav = ioc_inode->waitq;
+ trav = ioc_inode->waitq;
- while (trav) {
- if (trav->data == page) {
- page_found = 1;
- break;
- }
- trav = trav->next;
+ while (trav) {
+ if (trav->data == page) {
+ page_found = 1;
+ break;
}
+ trav = trav->next;
+ }
- if (!page_found) {
- waiter = GF_CALLOC (1, sizeof (ioc_waitq_t),
- gf_ioc_mt_ioc_waitq_t);
- if (waiter == NULL) {
- gf_msg (ioc_inode->table->xl->name, GF_LOG_ERROR,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY,
- "out of memory");
- ret = -ENOMEM;
- goto out;
- }
-
- waiter->data = page;
- waiter->next = ioc_inode->waitq;
- ioc_inode->waitq = waiter;
+ if (!page_found) {
+ waiter = GF_CALLOC(1, sizeof(ioc_waitq_t), gf_ioc_mt_ioc_waitq_t);
+ if (waiter == NULL) {
+ gf_msg(ioc_inode->table->xl->name, GF_LOG_ERROR, ENOMEM,
+ IO_CACHE_MSG_NO_MEMORY, "out of memory");
+ ret = -ENOMEM;
+ goto out;
}
+ waiter->data = page;
+ waiter->next = ioc_inode->waitq;
+ ioc_inode->waitq = waiter;
+ }
+
out:
- return ret;
+ return ret;
}
/*
@@ -469,74 +459,74 @@ out:
*
*/
int32_t
-ioc_cache_validate (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
- ioc_page_t *page)
+ioc_cache_validate(call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
+ ioc_page_t *page)
{
- call_frame_t *validate_frame = NULL;
- ioc_local_t *validate_local = NULL;
- ioc_local_t *local = NULL;
- int32_t ret = 0;
-
- local = frame->local;
- validate_local = mem_get0 (THIS->local_pool);
- if (validate_local == NULL) {
- ret = -1;
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- gf_msg (ioc_inode->table->xl->name, GF_LOG_ERROR,
- 0, IO_CACHE_MSG_NO_MEMORY, "out of memory");
- goto out;
- }
-
- validate_frame = copy_frame (frame);
- if (validate_frame == NULL) {
- ret = -1;
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- mem_put (validate_local);
- gf_msg (ioc_inode->table->xl->name, GF_LOG_ERROR,
- 0, IO_CACHE_MSG_NO_MEMORY, "out of memory");
- goto out;
- }
-
- validate_local->fd = fd_ref (fd);
- validate_local->inode = ioc_inode;
- validate_frame->local = validate_local;
-
- STACK_WIND (validate_frame, ioc_cache_validate_cbk,
- FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->fstat, fd, NULL);
+ call_frame_t *validate_frame = NULL;
+ ioc_local_t *validate_local = NULL;
+ ioc_local_t *local = NULL;
+ int32_t ret = 0;
+
+ local = frame->local;
+ validate_local = mem_get0(THIS->local_pool);
+ if (validate_local == NULL) {
+ ret = -1;
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ gf_msg(ioc_inode->table->xl->name, GF_LOG_ERROR, 0,
+ IO_CACHE_MSG_NO_MEMORY, "out of memory");
+ goto out;
+ }
+
+ validate_frame = copy_frame(frame);
+ if (validate_frame == NULL) {
+ ret = -1;
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ mem_put(validate_local);
+ gf_msg(ioc_inode->table->xl->name, GF_LOG_ERROR, 0,
+ IO_CACHE_MSG_NO_MEMORY, "out of memory");
+ goto out;
+ }
+
+ validate_local->fd = fd_ref(fd);
+ validate_local->inode = ioc_inode;
+ validate_frame->local = validate_local;
+
+ STACK_WIND(validate_frame, ioc_cache_validate_cbk, FIRST_CHILD(frame->this),
+ FIRST_CHILD(frame->this)->fops->fstat, fd, NULL);
out:
- return ret;
+ return ret;
}
static uint32_t
-is_match (const char *path, const char *pattern)
+is_match(const char *path, const char *pattern)
{
- int32_t ret = 0;
+ int32_t ret = 0;
- ret = fnmatch (pattern, path, FNM_NOESCAPE);
+ ret = fnmatch(pattern, path, FNM_NOESCAPE);
- return (ret == 0);
+ return (ret == 0);
}
uint32_t
-ioc_get_priority (ioc_table_t *table, const char *path)
+ioc_get_priority(ioc_table_t *table, const char *path)
{
- uint32_t priority = 1;
- struct ioc_priority *curr = NULL;
+ uint32_t priority = 1;
+ struct ioc_priority *curr = NULL;
- if (list_empty(&table->priority_list) || !path)
- return priority;
+ if (list_empty(&table->priority_list) || !path)
+ return priority;
- priority = 0;
- list_for_each_entry (curr, &table->priority_list, list) {
- if (is_match (path, curr->pattern))
- priority = curr->priority;
- }
+ priority = 0;
+ list_for_each_entry(curr, &table->priority_list, list)
+ {
+ if (is_match(path, curr->pattern))
+ priority = curr->priority;
+ }
- return priority;
+ return priority;
}
/*
@@ -551,69 +541,68 @@ ioc_get_priority (ioc_table_t *table, const char *path)
*
*/
int32_t
-ioc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
- int32_t op_errno, fd_t *fd, dict_t *xdata)
+ioc_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, fd_t *fd, dict_t *xdata)
{
- uint64_t tmp_ioc_inode = 0;
- ioc_local_t *local = NULL;
- ioc_table_t *table = NULL;
- ioc_inode_t *ioc_inode = NULL;
+ uint64_t tmp_ioc_inode = 0;
+ ioc_local_t *local = NULL;
+ ioc_table_t *table = NULL;
+ ioc_inode_t *ioc_inode = NULL;
+
+ local = frame->local;
+ if (!this || !this->private) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ table = this->private;
+
+ if (op_ret != -1) {
+ inode_ctx_get(fd->inode, this, &tmp_ioc_inode);
+ ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
- local = frame->local;
- if (!this || !this->private) {
- op_ret = -1;
- op_errno = EINVAL;
- goto out;
+ // TODO: see why inode context is NULL and handle it.
+ if (!ioc_inode) {
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL,
+ IO_CACHE_MSG_ENFORCEMENT_FAILED,
+ "inode context is NULL (%s)", uuid_utoa(fd->inode->gfid));
+ goto out;
}
- table = this->private;
-
- if (op_ret != -1) {
- inode_ctx_get (fd->inode, this, &tmp_ioc_inode);
- ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
-
- //TODO: see why inode context is NULL and handle it.
- if (!ioc_inode) {
- gf_msg (this->name, GF_LOG_ERROR,
- EINVAL, IO_CACHE_MSG_ENFORCEMENT_FAILED,
- "inode context is NULL (%s)",
- uuid_utoa (fd->inode->gfid));
- goto out;
- }
+ ioc_table_lock(ioc_inode->table);
+ {
+ list_move_tail(&ioc_inode->inode_lru,
+ &table->inode_lru[ioc_inode->weight]);
+ }
+ ioc_table_unlock(ioc_inode->table);
- ioc_table_lock (ioc_inode->table);
- {
- list_move_tail (&ioc_inode->inode_lru,
- &table->inode_lru[ioc_inode->weight]);
- }
- ioc_table_unlock (ioc_inode->table);
+ ioc_inode_lock(ioc_inode);
+ {
+ if ((table->min_file_size > ioc_inode->ia_size) ||
+ ((table->max_file_size > 0) &&
+ (table->max_file_size < ioc_inode->ia_size))) {
+ fd_ctx_set(fd, this, 1);
+ }
+ }
+ ioc_inode_unlock(ioc_inode);
- ioc_inode_lock (ioc_inode);
- {
- if ((table->min_file_size > ioc_inode->ia_size)
- || ((table->max_file_size > 0)
- && (table->max_file_size < ioc_inode->ia_size))) {
- fd_ctx_set (fd, this, 1);
- }
- }
- ioc_inode_unlock (ioc_inode);
-
- /* If O_DIRECT open, we disable caching on it */
- if ((local->flags & O_DIRECT)){
- /* O_DIRECT is only for one fd, not the inode
- * as a whole
- */
- fd_ctx_set (fd, this, 1);
- }
+ /* If O_DIRECT open, we disable caching on it */
+ if ((local->flags & O_DIRECT)) {
+ /* O_DIRECT is only for one fd, not the inode
+ * as a whole
+ */
+ fd_ctx_set(fd, this, 1);
}
+ }
out:
- mem_put (local);
- frame->local = NULL;
+ mem_put(local);
+ frame->local = NULL;
- STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd, xdata);
+ STACK_UNWIND_STRICT(open, frame, op_ret, op_errno, fd, xdata);
- return 0;
+ return 0;
}
/*
@@ -630,189 +619,177 @@ out:
*
*/
int32_t
-ioc_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 iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+ioc_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 iatt *buf, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
{
- ioc_local_t *local = NULL;
- ioc_table_t *table = NULL;
- ioc_inode_t *ioc_inode = NULL;
- uint32_t weight = 0xffffffff;
- const char *path = NULL;
- int ret = -1;
-
- local = frame->local;
- if (!this || !this->private) {
- op_ret = -1;
- op_errno = EINVAL;
- goto out;
- }
-
- table = this->private;
- path = local->file_loc.path;
-
- if (op_ret != -1) {
- /* assign weight */
- weight = ioc_get_priority (table, path);
-
- ioc_inode = ioc_inode_create (table, inode, weight);
-
- ioc_inode_lock (ioc_inode);
- {
- ioc_inode->cache.mtime = buf->ia_mtime;
- ioc_inode->cache.mtime_nsec = buf->ia_mtime_nsec;
- ioc_inode->ia_size = buf->ia_size;
-
- if ((table->min_file_size > ioc_inode->ia_size)
- || ((table->max_file_size > 0)
- && (table->max_file_size < ioc_inode->ia_size))) {
- ret = fd_ctx_set (fd, this, 1);
- if (ret)
- gf_msg (this->name, GF_LOG_WARNING,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY,
- "%s: failed to set fd ctx",
- local->file_loc.path);
- }
- }
- ioc_inode_unlock (ioc_inode);
-
- inode_ctx_put (fd->inode, this,
- (uint64_t)(long)ioc_inode);
-
- /* If O_DIRECT open, we disable caching on it */
- if (local->flags & O_DIRECT) {
- /*
- * O_DIRECT is only for one fd, not the inode
- * as a whole */
- ret = fd_ctx_set (fd, this, 1);
- if (ret)
- gf_msg (this->name, GF_LOG_WARNING,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY,
- "%s: failed to set fd ctx",
- local->file_loc.path);
- }
-
- /* if weight == 0, we disable caching on it */
- if (!weight) {
- /* we allow a pattern-matched cache disable this way */
- ret = fd_ctx_set (fd, this, 1);
- if (ret)
- gf_msg (this->name, GF_LOG_WARNING,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY,
- "%s: failed to set fd ctx",
- local->file_loc.path);
- }
-
- }
+ ioc_local_t *local = NULL;
+ ioc_table_t *table = NULL;
+ ioc_inode_t *ioc_inode = NULL;
+ uint32_t weight = 0xffffffff;
+ const char *path = NULL;
+ int ret = -1;
+
+ local = frame->local;
+ if (!this || !this->private) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ goto out;
+ }
+
+ table = this->private;
+ path = local->file_loc.path;
+
+ if (op_ret != -1) {
+ /* assign weight */
+ weight = ioc_get_priority(table, path);
+
+ ioc_inode = ioc_inode_create(table, inode, weight);
+
+ ioc_inode_lock(ioc_inode);
+ {
+ ioc_inode->cache.mtime = buf->ia_mtime;
+ ioc_inode->cache.mtime_nsec = buf->ia_mtime_nsec;
+ ioc_inode->ia_size = buf->ia_size;
+
+ if ((table->min_file_size > ioc_inode->ia_size) ||
+ ((table->max_file_size > 0) &&
+ (table->max_file_size < ioc_inode->ia_size))) {
+ ret = fd_ctx_set(fd, this, 1);
+ if (ret)
+ gf_msg(this->name, GF_LOG_WARNING, ENOMEM,
+ IO_CACHE_MSG_NO_MEMORY, "%s: failed to set fd ctx",
+ local->file_loc.path);
+ }
+ }
+ ioc_inode_unlock(ioc_inode);
+
+ inode_ctx_put(fd->inode, this, (uint64_t)(long)ioc_inode);
+
+ /* If O_DIRECT open, we disable caching on it */
+ if (local->flags & O_DIRECT) {
+ /*
+ * O_DIRECT is only for one fd, not the inode
+ * as a whole */
+ ret = fd_ctx_set(fd, this, 1);
+ if (ret)
+ gf_msg(this->name, GF_LOG_WARNING, ENOMEM,
+ IO_CACHE_MSG_NO_MEMORY, "%s: failed to set fd ctx",
+ local->file_loc.path);
+ }
+
+ /* if weight == 0, we disable caching on it */
+ if (!weight) {
+ /* we allow a pattern-matched cache disable this way */
+ ret = fd_ctx_set(fd, this, 1);
+ if (ret)
+ gf_msg(this->name, GF_LOG_WARNING, ENOMEM,
+ IO_CACHE_MSG_NO_MEMORY, "%s: failed to set fd ctx",
+ local->file_loc.path);
+ }
+ }
out:
- frame->local = NULL;
- mem_put (local);
+ frame->local = NULL;
+ mem_put(local);
- STACK_UNWIND_STRICT (create, frame, op_ret, op_errno, fd, inode, buf,
- preparent, postparent, xdata);
+ STACK_UNWIND_STRICT(create, frame, op_ret, op_errno, fd, inode, buf,
+ preparent, postparent, xdata);
- return 0;
+ return 0;
}
-
int32_t
-ioc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+ioc_mknod_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- ioc_local_t *local = NULL;
- ioc_table_t *table = NULL;
- ioc_inode_t *ioc_inode = NULL;
- uint32_t weight = 0xffffffff;
- const char *path = NULL;
+ ioc_local_t *local = NULL;
+ ioc_table_t *table = NULL;
+ ioc_inode_t *ioc_inode = NULL;
+ uint32_t weight = 0xffffffff;
+ const char *path = NULL;
- local = frame->local;
- if (!this || !this->private) {
- op_ret = -1;
- op_errno = EINVAL;
- goto out;
- }
-
- table = this->private;
- path = local->file_loc.path;
+ local = frame->local;
+ if (!this || !this->private) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ goto out;
+ }
- if (op_ret != -1) {
- /* assign weight */
- weight = ioc_get_priority (table, path);
+ table = this->private;
+ path = local->file_loc.path;
- ioc_inode = ioc_inode_create (table, inode, weight);
+ if (op_ret != -1) {
+ /* assign weight */
+ weight = ioc_get_priority(table, path);
- ioc_inode_lock (ioc_inode);
- {
- ioc_inode->cache.mtime = buf->ia_mtime;
- ioc_inode->cache.mtime_nsec = buf->ia_mtime_nsec;
- ioc_inode->ia_size = buf->ia_size;
- }
- ioc_inode_unlock (ioc_inode);
+ ioc_inode = ioc_inode_create(table, inode, weight);
- inode_ctx_put (inode, this,
- (uint64_t)(long)ioc_inode);
+ ioc_inode_lock(ioc_inode);
+ {
+ ioc_inode->cache.mtime = buf->ia_mtime;
+ ioc_inode->cache.mtime_nsec = buf->ia_mtime_nsec;
+ ioc_inode->ia_size = buf->ia_size;
}
+ ioc_inode_unlock(ioc_inode);
+
+ inode_ctx_put(inode, this, (uint64_t)(long)ioc_inode);
+ }
out:
- frame->local = NULL;
+ frame->local = NULL;
- loc_wipe (&local->file_loc);
- mem_put (local);
+ loc_wipe(&local->file_loc);
+ mem_put(local);
- STACK_UNWIND_STRICT (mknod, frame, op_ret, op_errno, inode, buf,
- preparent, postparent, xdata);
- return 0;
+ STACK_UNWIND_STRICT(mknod, frame, op_ret, op_errno, inode, buf, preparent,
+ postparent, xdata);
+ return 0;
}
-
int
-ioc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
- dev_t rdev, mode_t umask, dict_t *xdata)
+ioc_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
+ dev_t rdev, mode_t umask, dict_t *xdata)
{
- ioc_local_t *local = NULL;
- int32_t op_errno = -1, ret = -1;
-
- local = mem_get0 (this->local_pool);
- if (local == NULL) {
- op_errno = ENOMEM;
- gf_msg (this->name, GF_LOG_ERROR,
- 0, IO_CACHE_MSG_NO_MEMORY, "out of memory");
- goto unwind;
- }
-
- ret = loc_copy (&local->file_loc, loc);
- if (ret != 0) {
- op_errno = ENOMEM;
- gf_msg (this->name, GF_LOG_ERROR,
- 0, IO_CACHE_MSG_NO_MEMORY, "out of memory");
- goto unwind;
- }
-
- frame->local = local;
-
- STACK_WIND (frame, ioc_mknod_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->mknod,
- loc, mode, rdev, umask, xdata);
- return 0;
+ ioc_local_t *local = NULL;
+ int32_t op_errno = -1, ret = -1;
+
+ local = mem_get0(this->local_pool);
+ if (local == NULL) {
+ op_errno = ENOMEM;
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ goto unwind;
+ }
+
+ ret = loc_copy(&local->file_loc, loc);
+ if (ret != 0) {
+ op_errno = ENOMEM;
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ goto unwind;
+ }
+
+ frame->local = local;
+
+ STACK_WIND(frame, ioc_mknod_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mknod, loc, mode, rdev, umask, xdata);
+ return 0;
unwind:
- if (local != NULL) {
- loc_wipe (&local->file_loc);
- mem_put (local);
- }
+ if (local != NULL) {
+ loc_wipe(&local->file_loc);
+ mem_put(local);
+ }
- STACK_UNWIND_STRICT (mknod, frame, -1, op_errno, NULL, NULL,
- NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(mknod, frame, -1, op_errno, NULL, NULL, NULL, NULL,
+ NULL);
- return 0;
+ return 0;
}
-
/*
* ioc_open - open fop for io cache
* @frame:
@@ -822,31 +799,29 @@ unwind:
*
*/
int32_t
-ioc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- fd_t *fd, dict_t *xdata)
+ioc_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ fd_t *fd, dict_t *xdata)
{
+ ioc_local_t *local = NULL;
- ioc_local_t *local = NULL;
-
- local = mem_get0 (this->local_pool);
- if (local == NULL) {
- gf_msg (this->name, GF_LOG_ERROR,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory");
- STACK_UNWIND_STRICT (open, frame, -1, ENOMEM, NULL, NULL);
- return 0;
- }
+ local = mem_get0(this->local_pool);
+ if (local == NULL) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ STACK_UNWIND_STRICT(open, frame, -1, ENOMEM, NULL, NULL);
+ return 0;
+ }
- local->flags = flags;
- local->file_loc.path = loc->path;
- local->file_loc.inode = loc->inode;
+ local->flags = flags;
+ local->file_loc.path = loc->path;
+ local->file_loc.inode = loc->inode;
- frame->local = local;
+ frame->local = local;
- STACK_WIND (frame, ioc_open_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->open, loc, flags, fd,
- xdata);
+ STACK_WIND(frame, ioc_open_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata);
- return 0;
+ return 0;
}
/*
@@ -860,33 +835,30 @@ ioc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
*
*/
int32_t
-ioc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
+ioc_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
{
- ioc_local_t *local = NULL;
-
- local = mem_get0 (this->local_pool);
- if (local == NULL) {
- gf_msg (this->name, GF_LOG_ERROR,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory");
- STACK_UNWIND_STRICT (create, frame, -1, ENOMEM, NULL, NULL,
- NULL, NULL, NULL, NULL);
- return 0;
- }
-
- local->flags = flags;
- local->file_loc.path = loc->path;
- frame->local = local;
-
- STACK_WIND (frame, ioc_create_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->create, loc, flags, mode,
- umask, fd, xdata);
-
+ ioc_local_t *local = NULL;
+
+ local = mem_get0(this->local_pool);
+ if (local == NULL) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ STACK_UNWIND_STRICT(create, frame, -1, ENOMEM, NULL, NULL, NULL, NULL,
+ NULL, NULL);
return 0;
-}
+ }
+ local->flags = flags;
+ local->file_loc.path = loc->path;
+ frame->local = local;
+ STACK_WIND(frame, ioc_create_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->create, loc, flags, mode, umask, fd,
+ xdata);
+ return 0;
+}
/*
* ioc_release - release fop for io cache
@@ -897,26 +869,26 @@ ioc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
*
*/
int32_t
-ioc_release (xlator_t *this, fd_t *fd)
+ioc_release(xlator_t *this, fd_t *fd)
{
- return 0;
+ return 0;
}
int32_t
-ioc_need_prune (ioc_table_t *table)
+ioc_need_prune(ioc_table_t *table)
{
- int64_t cache_difference = 0;
+ int64_t cache_difference = 0;
- ioc_table_lock (table);
- {
- cache_difference = table->cache_used - table->cache_size;
- }
- ioc_table_unlock (table);
+ ioc_table_lock(table);
+ {
+ cache_difference = table->cache_used - table->cache_size;
+ }
+ ioc_table_unlock(table);
- if (cache_difference > 0)
- return 1;
- else
- return 0;
+ if (cache_difference > 0)
+ return 1;
+ else
+ return 0;
}
/*
@@ -928,163 +900,151 @@ ioc_need_prune (ioc_table_t *table)
*
*/
void
-ioc_dispatch_requests (call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
- off_t offset, size_t size)
+ioc_dispatch_requests(call_frame_t *frame, ioc_inode_t *ioc_inode, fd_t *fd,
+ off_t offset, size_t size)
{
- ioc_local_t *local = NULL;
- ioc_table_t *table = NULL;
- ioc_page_t *trav = NULL;
- ioc_waitq_t *waitq = NULL;
- off_t rounded_offset = 0;
- off_t rounded_end = 0;
- off_t trav_offset = 0;
- int32_t fault = 0;
- size_t trav_size = 0;
- off_t local_offset = 0;
- int32_t ret = -1;
- int8_t need_validate = 0;
- int8_t might_need_validate = 0; /*
- * if a page exists, do we need
- * to validate it?
- */
- local = frame->local;
- table = ioc_inode->table;
-
- rounded_offset = floor (offset, table->page_size);
- rounded_end = roof (offset + size, table->page_size);
- trav_offset = rounded_offset;
-
- /* once a frame does read, it should be waiting on something */
- local->wait_count++;
-
- /* Requested region can fall in three different pages,
- * 1. Ready - region is already in cache, we just have to serve it.
- * 2. In-transit - page fault has been generated on this page, we need
- * to wait till the page is ready
- * 3. Fault - page is not in cache, we have to generate a page fault
- */
+ ioc_local_t *local = NULL;
+ ioc_table_t *table = NULL;
+ ioc_page_t *trav = NULL;
+ ioc_waitq_t *waitq = NULL;
+ off_t rounded_offset = 0;
+ off_t rounded_end = 0;
+ off_t trav_offset = 0;
+ int32_t fault = 0;
+ size_t trav_size = 0;
+ off_t local_offset = 0;
+ int32_t ret = -1;
+ int8_t need_validate = 0;
+ int8_t might_need_validate = 0; /*
+ * if a page exists, do we need
+ * to validate it?
+ */
+ local = frame->local;
+ table = ioc_inode->table;
+
+ rounded_offset = floor(offset, table->page_size);
+ rounded_end = roof(offset + size, table->page_size);
+ trav_offset = rounded_offset;
+
+ /* once a frame does read, it should be waiting on something */
+ local->wait_count++;
+
+ /* Requested region can fall in three different pages,
+ * 1. Ready - region is already in cache, we just have to serve it.
+ * 2. In-transit - page fault has been generated on this page, we need
+ * to wait till the page is ready
+ * 3. Fault - page is not in cache, we have to generate a page fault
+ */
+
+ might_need_validate = ioc_inode_need_revalidate(ioc_inode);
+
+ while (trav_offset < rounded_end) {
+ ioc_inode_lock(ioc_inode);
+ {
+ /* look for requested region in the cache */
+ trav = __ioc_page_get(ioc_inode, trav_offset);
- might_need_validate = ioc_inode_need_revalidate (ioc_inode);
+ local_offset = max(trav_offset, offset);
+ trav_size = min(((offset + size) - local_offset), table->page_size);
- while (trav_offset < rounded_end) {
- ioc_inode_lock (ioc_inode);
- {
- /* look for requested region in the cache */
- trav = __ioc_page_get (ioc_inode, trav_offset);
-
- local_offset = max (trav_offset, offset);
- trav_size = min (((offset+size) - local_offset),
- table->page_size);
-
- if (!trav) {
- /* page not in cache, we need to generate page
- * fault
- */
- trav = __ioc_page_create (ioc_inode,
- trav_offset);
- fault = 1;
- if (!trav) {
- gf_msg (frame->this->name,
- GF_LOG_CRITICAL,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY,
- "out of memory");
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- ioc_inode_unlock (ioc_inode);
- goto out;
- }
- }
+ if (!trav) {
+ /* page not in cache, we need to generate page
+ * fault
+ */
+ trav = __ioc_page_create(ioc_inode, trav_offset);
+ fault = 1;
+ if (!trav) {
+ gf_msg(frame->this->name, GF_LOG_CRITICAL, ENOMEM,
+ IO_CACHE_MSG_NO_MEMORY, "out of memory");
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ ioc_inode_unlock(ioc_inode);
+ goto out;
+ }
+ }
+
+ __ioc_wait_on_page(trav, frame, local_offset, trav_size);
+
+ if (trav->ready) {
+ /* page found in cache */
+ if (!might_need_validate && !ioc_inode->waitq) {
+ /* fresh enough */
+ gf_msg_trace(frame->this->name, 0,
+ "cache hit for "
+ "trav_offset=%" PRId64
+ "/local_"
+ "offset=%" PRId64 "",
+ trav_offset, local_offset);
+ waitq = __ioc_page_wakeup(trav, trav->op_errno);
+ } else {
+ /* if waitq already exists, fstat
+ * revalidate is
+ * already on the way
+ */
+ if (!ioc_inode->waitq) {
+ need_validate = 1;
+ }
+
+ ret = ioc_wait_on_inode(ioc_inode, trav);
+ if (ret < 0) {
+ local->op_ret = -1;
+ local->op_errno = -ret;
+ need_validate = 0;
- __ioc_wait_on_page (trav, frame, local_offset,
- trav_size);
-
- if (trav->ready) {
- /* page found in cache */
- if (!might_need_validate && !ioc_inode->waitq) {
- /* fresh enough */
- gf_msg_trace (frame->this->name, 0,
- "cache hit for "
- "trav_offset=%"
- PRId64"/local_"
- "offset=%"PRId64"",
- trav_offset,
- local_offset);
- waitq = __ioc_page_wakeup (trav,
- trav->op_errno);
- } else {
- /* if waitq already exists, fstat
- * revalidate is
- * already on the way
- */
- if (!ioc_inode->waitq) {
- need_validate = 1;
- }
-
- ret = ioc_wait_on_inode (ioc_inode,
- trav);
- if (ret < 0) {
- local->op_ret = -1;
- local->op_errno = -ret;
- need_validate = 0;
-
- waitq = __ioc_page_wakeup (trav,
- trav->op_errno);
- ioc_inode_unlock (ioc_inode);
-
- ioc_waitq_return (waitq);
- waitq = NULL;
- goto out;
- }
- }
- }
+ waitq = __ioc_page_wakeup(trav, trav->op_errno);
+ ioc_inode_unlock(ioc_inode);
+ ioc_waitq_return(waitq);
+ waitq = NULL;
+ goto out;
+ }
}
- ioc_inode_unlock (ioc_inode);
+ }
+ }
+ ioc_inode_unlock(ioc_inode);
- ioc_waitq_return (waitq);
- waitq = NULL;
+ ioc_waitq_return(waitq);
+ waitq = NULL;
- if (fault) {
- fault = 0;
- /* new page created, increase the table->cache_used */
- ioc_page_fault (ioc_inode, frame, fd, trav_offset);
- }
+ if (fault) {
+ fault = 0;
+ /* new page created, increase the table->cache_used */
+ ioc_page_fault(ioc_inode, frame, fd, trav_offset);
+ }
- if (need_validate) {
- need_validate = 0;
- gf_msg_trace (frame->this->name, 0,
- "sending validate request for "
- "inode(%s) at offset=%"PRId64"",
- uuid_utoa (fd->inode->gfid), trav_offset);
- ret = ioc_cache_validate (frame, ioc_inode, fd, trav);
- if (ret == -1) {
- ioc_inode_lock (ioc_inode);
- {
- waitq = __ioc_page_wakeup (trav,
- trav->op_errno);
- }
- ioc_inode_unlock (ioc_inode);
-
- ioc_waitq_return (waitq);
- waitq = NULL;
- goto out;
- }
+ if (need_validate) {
+ need_validate = 0;
+ gf_msg_trace(frame->this->name, 0,
+ "sending validate request for "
+ "inode(%s) at offset=%" PRId64 "",
+ uuid_utoa(fd->inode->gfid), trav_offset);
+ ret = ioc_cache_validate(frame, ioc_inode, fd, trav);
+ if (ret == -1) {
+ ioc_inode_lock(ioc_inode);
+ {
+ waitq = __ioc_page_wakeup(trav, trav->op_errno);
}
+ ioc_inode_unlock(ioc_inode);
- trav_offset += table->page_size;
+ ioc_waitq_return(waitq);
+ waitq = NULL;
+ goto out;
+ }
}
+ trav_offset += table->page_size;
+ }
+
out:
- ioc_frame_return (frame);
+ ioc_frame_return(frame);
- if (ioc_need_prune (ioc_inode->table)) {
- ioc_prune (ioc_inode->table);
- }
+ if (ioc_need_prune(ioc_inode->table)) {
+ ioc_prune(ioc_inode->table);
+ }
- return;
+ return;
}
-
/*
* ioc_readv -
*
@@ -1096,112 +1056,108 @@ out:
*
*/
int32_t
-ioc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd,
- size_t size, off_t offset, uint32_t flags, dict_t *xdata)
+ioc_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, uint32_t flags, dict_t *xdata)
{
- uint64_t tmp_ioc_inode = 0;
- ioc_inode_t *ioc_inode = NULL;
- ioc_local_t *local = NULL;
- uint32_t weight = 0;
- ioc_table_t *table = NULL;
- int32_t op_errno = EINVAL;
-
- if (!this) {
- goto out;
- }
-
- inode_ctx_get (fd->inode, this, &tmp_ioc_inode);
- ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
- if (!ioc_inode) {
- /* caching disabled, go ahead with normal readv */
- STACK_WIND_TAIL (frame, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->readv, fd,
- size, offset, flags, xdata);
- return 0;
- }
-
- if (flags & O_DIRECT) {
- /* disable caching for this fd, if O_DIRECT is used */
- STACK_WIND_TAIL (frame, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->readv, fd,
- size, offset, flags, xdata);
- return 0;
- }
+ uint64_t tmp_ioc_inode = 0;
+ ioc_inode_t *ioc_inode = NULL;
+ ioc_local_t *local = NULL;
+ uint32_t weight = 0;
+ ioc_table_t *table = NULL;
+ int32_t op_errno = EINVAL;
+
+ if (!this) {
+ goto out;
+ }
+
+ inode_ctx_get(fd->inode, this, &tmp_ioc_inode);
+ ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
+ if (!ioc_inode) {
+ /* caching disabled, go ahead with normal readv */
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv, fd, size, offset, flags,
+ xdata);
+ return 0;
+ }
+ if (flags & O_DIRECT) {
+ /* disable caching for this fd, if O_DIRECT is used */
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv, fd, size, offset, flags,
+ xdata);
+ return 0;
+ }
- table = this->private;
+ table = this->private;
- if (!table) {
- gf_msg (this->name, GF_LOG_ERROR, EINVAL,
- IO_CACHE_MSG_ENFORCEMENT_FAILED, "table is null");
- op_errno = EINVAL;
- goto out;
- }
+ if (!table) {
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL,
+ IO_CACHE_MSG_ENFORCEMENT_FAILED, "table is null");
+ op_errno = EINVAL;
+ goto out;
+ }
- ioc_inode_lock (ioc_inode);
- {
- if (!ioc_inode->cache.page_table) {
- ioc_inode->cache.page_table
- = rbthash_table_init
- (this->ctx, IOC_PAGE_TABLE_BUCKET_COUNT,
- ioc_hashfn, NULL, 0,
- table->mem_pool);
-
- if (ioc_inode->cache.page_table == NULL) {
- op_errno = ENOMEM;
- ioc_inode_unlock (ioc_inode);
- goto out;
- }
- }
- }
- ioc_inode_unlock (ioc_inode);
-
- if (!fd_ctx_get (fd, this, NULL)) {
- /* disable caching for this fd, go ahead with normal readv */
- STACK_WIND_TAIL (frame, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->readv, fd,
- size, offset, flags, xdata);
- return 0;
- }
+ ioc_inode_lock(ioc_inode);
+ {
+ if (!ioc_inode->cache.page_table) {
+ ioc_inode->cache.page_table = rbthash_table_init(
+ this->ctx, IOC_PAGE_TABLE_BUCKET_COUNT, ioc_hashfn, NULL, 0,
+ table->mem_pool);
- local = mem_get0 (this->local_pool);
- if (local == NULL) {
- gf_msg (this->name, GF_LOG_ERROR,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory");
+ if (ioc_inode->cache.page_table == NULL) {
op_errno = ENOMEM;
+ ioc_inode_unlock(ioc_inode);
goto out;
+ }
}
+ }
+ ioc_inode_unlock(ioc_inode);
- INIT_LIST_HEAD (&local->fill_list);
-
- frame->local = local;
- local->pending_offset = offset;
- local->pending_size = size;
- local->offset = offset;
- local->size = size;
- local->inode = ioc_inode;
-
- gf_msg_trace (this->name, 0,
- "NEW REQ (%p) offset "
- "= %"PRId64" && size = %"GF_PRI_SIZET"",
- frame, offset, size);
-
- weight = ioc_inode->weight;
-
- ioc_table_lock (ioc_inode->table);
- {
- list_move_tail (&ioc_inode->inode_lru,
- &ioc_inode->table->inode_lru[weight]);
- }
- ioc_table_unlock (ioc_inode->table);
-
- ioc_dispatch_requests (frame, ioc_inode, fd, offset, size);
+ if (!fd_ctx_get(fd, this, NULL)) {
+ /* disable caching for this fd, go ahead with normal readv */
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv, fd, size, offset, flags,
+ xdata);
return 0;
+ }
+
+ local = mem_get0(this->local_pool);
+ if (local == NULL) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ op_errno = ENOMEM;
+ goto out;
+ }
+
+ INIT_LIST_HEAD(&local->fill_list);
+
+ frame->local = local;
+ local->pending_offset = offset;
+ local->pending_size = size;
+ local->offset = offset;
+ local->size = size;
+ local->inode = ioc_inode;
+
+ gf_msg_trace(this->name, 0,
+ "NEW REQ (%p) offset "
+ "= %" PRId64 " && size = %" GF_PRI_SIZET "",
+ frame, offset, size);
+
+ weight = ioc_inode->weight;
+
+ ioc_table_lock(ioc_inode->table);
+ {
+ list_move_tail(&ioc_inode->inode_lru,
+ &ioc_inode->table->inode_lru[weight]);
+ }
+ ioc_table_unlock(ioc_inode->table);
+
+ ioc_dispatch_requests(frame, ioc_inode, fd, offset, size);
+ return 0;
out:
- STACK_UNWIND_STRICT (readv, frame, -1, op_errno, NULL, 0, NULL, NULL,
- NULL);
- return 0;
+ STACK_UNWIND_STRICT(readv, frame, -1, op_errno, NULL, 0, NULL, NULL, NULL);
+ return 0;
}
/*
@@ -1215,22 +1171,22 @@ out:
*
*/
int32_t
-ioc_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, dict_t *xdata)
+ioc_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, dict_t *xdata)
{
- ioc_local_t *local = NULL;
- uint64_t ioc_inode = 0;
+ ioc_local_t *local = NULL;
+ uint64_t ioc_inode = 0;
- local = frame->local;
- inode_ctx_get (local->fd->inode, this, &ioc_inode);
+ local = frame->local;
+ inode_ctx_get(local->fd->inode, this, &ioc_inode);
- if (ioc_inode)
- ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
+ if (ioc_inode)
+ ioc_inode_flush((ioc_inode_t *)(long)ioc_inode);
- STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
- return 0;
+ STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
/*
@@ -1245,35 +1201,35 @@ ioc_writev_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
*
*/
int32_t
-ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iovec *vector, int32_t count, off_t offset,
- uint32_t flags, struct iobref *iobref, dict_t *xdata)
+ioc_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
+ int32_t count, off_t offset, uint32_t flags, struct iobref *iobref,
+ dict_t *xdata)
{
- ioc_local_t *local = NULL;
- uint64_t ioc_inode = 0;
+ ioc_local_t *local = NULL;
+ uint64_t ioc_inode = 0;
- local = mem_get0 (this->local_pool);
- if (local == NULL) {
- gf_msg (this->name, GF_LOG_ERROR,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY, "out of memory");
+ local = mem_get0(this->local_pool);
+ if (local == NULL) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_CACHE_MSG_NO_MEMORY,
+ "out of memory");
- STACK_UNWIND_STRICT (writev, frame, -1, ENOMEM, NULL, NULL, NULL);
- return 0;
- }
+ STACK_UNWIND_STRICT(writev, frame, -1, ENOMEM, NULL, NULL, NULL);
+ return 0;
+ }
- /* TODO: why is it not fd_ref'ed */
- local->fd = fd;
- frame->local = local;
+ /* TODO: why is it not fd_ref'ed */
+ local->fd = fd;
+ frame->local = local;
- inode_ctx_get (fd->inode, this, &ioc_inode);
- if (ioc_inode)
- ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
+ inode_ctx_get(fd->inode, this, &ioc_inode);
+ if (ioc_inode)
+ ioc_inode_flush((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND (frame, ioc_writev_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->writev, fd, vector, count, offset,
- flags, iobref, xdata);
+ STACK_WIND(frame, ioc_writev_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->writev, fd, vector, count, offset,
+ flags, iobref, xdata);
- return 0;
+ return 0;
}
/*
@@ -1288,17 +1244,15 @@ ioc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
*
*/
int32_t
-ioc_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+ioc_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
-
- STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, prebuf,
- postbuf, xdata);
- return 0;
+ STACK_UNWIND_STRICT(truncate, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
-
/*
* ioc_ftruncate_cbk -
*
@@ -1311,17 +1265,15 @@ ioc_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
*
*/
int32_t
-ioc_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+ioc_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
-
- STACK_UNWIND_STRICT (ftruncate, frame, op_ret, op_errno, prebuf,
- postbuf, xdata);
- return 0;
+ STACK_UNWIND_STRICT(ftruncate, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
-
/*
* ioc_truncate -
*
@@ -1332,19 +1284,19 @@ ioc_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
*
*/
int32_t
-ioc_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
- dict_t *xdata)
+ioc_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
+ dict_t *xdata)
{
- uint64_t ioc_inode = 0;
+ uint64_t ioc_inode = 0;
- inode_ctx_get (loc->inode, this, &ioc_inode);
+ inode_ctx_get(loc->inode, this, &ioc_inode);
- if (ioc_inode)
- ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
+ if (ioc_inode)
+ ioc_inode_flush((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND (frame, ioc_truncate_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
- return 0;
+ STACK_WIND(frame, ioc_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
+ return 0;
}
/*
@@ -1357,731 +1309,732 @@ ioc_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
*
*/
int32_t
-ioc_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- dict_t *xdata)
+ioc_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ dict_t *xdata)
{
- uint64_t ioc_inode = 0;
+ uint64_t ioc_inode = 0;
- inode_ctx_get (fd->inode, this, &ioc_inode);
+ inode_ctx_get(fd->inode, this, &ioc_inode);
- if (ioc_inode)
- ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
+ if (ioc_inode)
+ ioc_inode_flush((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND (frame, ioc_ftruncate_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata);
- return 0;
+ STACK_WIND(frame, ioc_ftruncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata);
+ return 0;
}
int32_t
-ioc_lk_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
- int32_t op_errno, struct gf_flock *lock, dict_t *xdata)
+ioc_lk_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct gf_flock *lock, dict_t *xdata)
{
- STACK_UNWIND_STRICT (lk, frame, op_ret, op_errno, lock, xdata);
- return 0;
+ STACK_UNWIND_STRICT(lk, frame, op_ret, op_errno, lock, xdata);
+ return 0;
}
int32_t
-ioc_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
- struct gf_flock *lock, dict_t *xdata)
+ioc_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
+ struct gf_flock *lock, dict_t *xdata)
{
- ioc_inode_t *ioc_inode = NULL;
- uint64_t tmp_inode = 0;
-
- inode_ctx_get (fd->inode, this, &tmp_inode);
- ioc_inode = (ioc_inode_t *)(long)tmp_inode;
- if (!ioc_inode) {
- gf_msg_debug (this->name, EBADFD,
- "inode context is NULL: returning EBADFD");
- STACK_UNWIND_STRICT (lk, frame, -1, EBADFD, NULL, NULL);
- return 0;
- }
+ ioc_inode_t *ioc_inode = NULL;
+ uint64_t tmp_inode = 0;
+
+ inode_ctx_get(fd->inode, this, &tmp_inode);
+ ioc_inode = (ioc_inode_t *)(long)tmp_inode;
+ if (!ioc_inode) {
+ gf_msg_debug(this->name, EBADFD,
+ "inode context is NULL: returning EBADFD");
+ STACK_UNWIND_STRICT(lk, frame, -1, EBADFD, NULL, NULL);
+ return 0;
+ }
- ioc_inode_lock (ioc_inode);
- {
- gettimeofday (&ioc_inode->cache.tv, NULL);
- }
- ioc_inode_unlock (ioc_inode);
+ ioc_inode_lock(ioc_inode);
+ {
+ gettimeofday(&ioc_inode->cache.tv, NULL);
+ }
+ ioc_inode_unlock(ioc_inode);
- STACK_WIND (frame, ioc_lk_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->lk, fd, cmd, lock, xdata);
+ STACK_WIND(frame, ioc_lk_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lk, fd, cmd, lock, xdata);
- return 0;
+ return 0;
}
int
-ioc_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, gf_dirent_t *entries, dict_t *xdata)
+ioc_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
+ int op_errno, gf_dirent_t *entries, dict_t *xdata)
{
- gf_dirent_t *entry = NULL;
- char *path = NULL;
- fd_t *fd = NULL;
+ gf_dirent_t *entry = NULL;
+ char *path = NULL;
+ fd_t *fd = NULL;
- fd = frame->local;
- frame->local = NULL;
+ fd = frame->local;
+ frame->local = NULL;
- if (op_ret <= 0)
- goto unwind;
+ if (op_ret <= 0)
+ goto unwind;
- list_for_each_entry (entry, &entries->list, list) {
- inode_path (fd->inode, entry->d_name, &path);
- ioc_inode_update (this, entry->inode, path, &entry->d_stat);
- GF_FREE (path);
- path = NULL;
- }
+ list_for_each_entry(entry, &entries->list, list)
+ {
+ inode_path(fd->inode, entry->d_name, &path);
+ ioc_inode_update(this, entry->inode, path, &entry->d_stat);
+ GF_FREE(path);
+ path = NULL;
+ }
unwind:
- STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries, xdata);
+ STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, entries, xdata);
- return 0;
+ return 0;
}
int
-ioc_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, dict_t *dict)
+ioc_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, dict_t *dict)
{
- frame->local = fd;
+ frame->local = fd;
- STACK_WIND (frame, ioc_readdirp_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->readdirp,
- fd, size, offset, dict);
+ STACK_WIND(frame, ioc_readdirp_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp, fd, size, offset, dict);
- return 0;
+ return 0;
}
static int32_t
ioc_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *pre,
- struct iatt *post, dict_t *xdata)
+ int32_t op_ret, int32_t op_errno, struct iatt *pre,
+ struct iatt *post, dict_t *xdata)
{
- STACK_UNWIND_STRICT(discard, frame, op_ret, op_errno, pre, post, xdata);
- return 0;
+ STACK_UNWIND_STRICT(discard, frame, op_ret, op_errno, pre, post, xdata);
+ return 0;
}
static int32_t
ioc_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- size_t len, dict_t *xdata)
+ size_t len, dict_t *xdata)
{
- uint64_t ioc_inode = 0;
+ uint64_t ioc_inode = 0;
- inode_ctx_get (fd->inode, this, &ioc_inode);
+ inode_ctx_get(fd->inode, this, &ioc_inode);
- if (ioc_inode)
- ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
+ if (ioc_inode)
+ ioc_inode_flush((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND(frame, ioc_discard_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->discard, fd, offset, len, xdata);
- return 0;
+ STACK_WIND(frame, ioc_discard_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->discard, fd, offset, len, xdata);
+ return 0;
}
static int32_t
ioc_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *pre,
- struct iatt *post, dict_t *xdata)
+ int32_t op_ret, int32_t op_errno, struct iatt *pre,
+ struct iatt *post, dict_t *xdata)
{
- STACK_UNWIND_STRICT(zerofill, frame, op_ret,
- op_errno, pre, post, xdata);
- return 0;
+ STACK_UNWIND_STRICT(zerofill, frame, op_ret, op_errno, pre, post, xdata);
+ return 0;
}
static int32_t
ioc_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- off_t len, dict_t *xdata)
+ off_t len, dict_t *xdata)
{
- uint64_t ioc_inode = 0;
+ uint64_t ioc_inode = 0;
- inode_ctx_get (fd->inode, this, &ioc_inode);
+ inode_ctx_get(fd->inode, this, &ioc_inode);
- if (ioc_inode)
- ioc_inode_flush ((ioc_inode_t *)(long)ioc_inode);
+ if (ioc_inode)
+ ioc_inode_flush((ioc_inode_t *)(long)ioc_inode);
- STACK_WIND(frame, ioc_zerofill_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->zerofill, fd, offset, len, xdata);
- return 0;
+ STACK_WIND(frame, ioc_zerofill_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->zerofill, fd, offset, len, xdata);
+ return 0;
}
-
int32_t
-ioc_get_priority_list (const char *opt_str, struct list_head *first)
+ioc_get_priority_list(const char *opt_str, struct list_head *first)
{
- int32_t max_pri = 1;
- char *tmp_str = NULL;
- char *tmp_str1 = NULL;
- char *tmp_str2 = NULL;
- char *dup_str = NULL;
- char *stripe_str = NULL;
- char *pattern = NULL;
- char *priority = NULL;
- char *string = NULL;
- struct ioc_priority *curr = NULL, *tmp = NULL;
-
- string = gf_strdup (opt_str);
- if (string == NULL) {
- max_pri = -1;
- goto out;
- }
-
- /* Get the pattern for cache priority.
- * "option priority *.jpg:1,abc*:2" etc
- */
- /* TODO: inode_lru in table is statically hard-coded to 5,
- * should be changed to run-time configuration
- */
- stripe_str = strtok_r (string, ",", &tmp_str);
- while (stripe_str) {
- curr = GF_CALLOC (1, sizeof (struct ioc_priority),
- gf_ioc_mt_ioc_priority);
- if (curr == NULL) {
- max_pri = -1;
- goto out;
- }
-
- list_add_tail (&curr->list, first);
-
- dup_str = gf_strdup (stripe_str);
- if (dup_str == NULL) {
- max_pri = -1;
- goto out;
- }
-
- pattern = strtok_r (dup_str, ":", &tmp_str1);
- if (!pattern) {
- max_pri = -1;
- goto out;
- }
-
- priority = strtok_r (NULL, ":", &tmp_str1);
- if (!priority) {
- max_pri = -1;
- goto out;
- }
-
- gf_msg_trace ("io-cache", 0,
- "ioc priority : pattern %s : priority %s",
- pattern, priority);
-
- curr->pattern = gf_strdup (pattern);
- if (curr->pattern == NULL) {
- max_pri = -1;
- goto out;
- }
-
- curr->priority = strtol (priority, &tmp_str2, 0);
- if (tmp_str2 && (*tmp_str2)) {
- max_pri = -1;
- goto out;
- } else {
- max_pri = max (max_pri, curr->priority);
- }
-
- GF_FREE (dup_str);
- dup_str = NULL;
-
- stripe_str = strtok_r (NULL, ",", &tmp_str);
- }
+ int32_t max_pri = 1;
+ char *tmp_str = NULL;
+ char *tmp_str1 = NULL;
+ char *tmp_str2 = NULL;
+ char *dup_str = NULL;
+ char *stripe_str = NULL;
+ char *pattern = NULL;
+ char *priority = NULL;
+ char *string = NULL;
+ struct ioc_priority *curr = NULL, *tmp = NULL;
+
+ string = gf_strdup(opt_str);
+ if (string == NULL) {
+ max_pri = -1;
+ goto out;
+ }
+
+ /* Get the pattern for cache priority.
+ * "option priority *.jpg:1,abc*:2" etc
+ */
+ /* TODO: inode_lru in table is statically hard-coded to 5,
+ * should be changed to run-time configuration
+ */
+ stripe_str = strtok_r(string, ",", &tmp_str);
+ while (stripe_str) {
+ curr = GF_CALLOC(1, sizeof(struct ioc_priority),
+ gf_ioc_mt_ioc_priority);
+ if (curr == NULL) {
+ max_pri = -1;
+ goto out;
+ }
+
+ list_add_tail(&curr->list, first);
+
+ dup_str = gf_strdup(stripe_str);
+ if (dup_str == NULL) {
+ max_pri = -1;
+ goto out;
+ }
+
+ pattern = strtok_r(dup_str, ":", &tmp_str1);
+ if (!pattern) {
+ max_pri = -1;
+ goto out;
+ }
+
+ priority = strtok_r(NULL, ":", &tmp_str1);
+ if (!priority) {
+ max_pri = -1;
+ goto out;
+ }
+
+ gf_msg_trace("io-cache", 0, "ioc priority : pattern %s : priority %s",
+ pattern, priority);
+
+ curr->pattern = gf_strdup(pattern);
+ if (curr->pattern == NULL) {
+ max_pri = -1;
+ goto out;
+ }
+
+ curr->priority = strtol(priority, &tmp_str2, 0);
+ if (tmp_str2 && (*tmp_str2)) {
+ max_pri = -1;
+ goto out;
+ } else {
+ max_pri = max(max_pri, curr->priority);
+ }
+
+ GF_FREE(dup_str);
+ dup_str = NULL;
+
+ stripe_str = strtok_r(NULL, ",", &tmp_str);
+ }
out:
- GF_FREE (string);
+ GF_FREE(string);
- GF_FREE (dup_str);
+ GF_FREE(dup_str);
- if (max_pri == -1) {
- list_for_each_entry_safe (curr, tmp, first, list) {
- list_del_init (&curr->list);
- GF_FREE (curr->pattern);
- GF_FREE (curr);
- }
+ if (max_pri == -1) {
+ list_for_each_entry_safe(curr, tmp, first, list)
+ {
+ list_del_init(&curr->list);
+ GF_FREE(curr->pattern);
+ GF_FREE(curr);
}
+ }
- return max_pri;
+ return max_pri;
}
int32_t
-mem_acct_init (xlator_t *this)
+mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- if (!this)
- return ret;
+ if (!this)
+ return ret;
- ret = xlator_mem_acct_init (this, gf_ioc_mt_end + 1);
-
- if (ret != 0) {
- gf_msg (this->name, GF_LOG_ERROR,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY,
- "Memory accounting init failed");
- return ret;
- }
+ ret = xlator_mem_acct_init(this, gf_ioc_mt_end + 1);
+ if (ret != 0) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_CACHE_MSG_NO_MEMORY,
+ "Memory accounting init failed");
return ret;
-}
+ }
+ return ret;
+}
static gf_boolean_t
-check_cache_size_ok (xlator_t *this, uint64_t cache_size)
+check_cache_size_ok(xlator_t *this, uint64_t cache_size)
{
- gf_boolean_t ret = _gf_true;
- uint64_t total_mem = 0;
- uint64_t max_cache_size = 0;
- volume_option_t *opt = NULL;
-
- GF_ASSERT (this);
- opt = xlator_volume_option_get (this, "cache-size");
- if (!opt) {
- ret = _gf_false;
- gf_msg (this->name, GF_LOG_ERROR,
- EINVAL, IO_CACHE_MSG_ENFORCEMENT_FAILED,
- "could not get cache-size option");
- goto out;
- }
-
- total_mem = get_mem_size ();
- if (-1 == total_mem)
- max_cache_size = opt->max;
- else
- max_cache_size = total_mem;
-
- gf_msg_debug (this->name, 0, "Max cache size is %"PRIu64,
- max_cache_size);
-
- if (cache_size > max_cache_size) {
- ret = _gf_false;
- gf_msg (this->name, GF_LOG_ERROR,
- 0, IO_CACHE_MSG_INVALID_ARGUMENT,
- "Cache size %"PRIu64
- " is greater than the max size of %"PRIu64,
- cache_size, max_cache_size);
- goto out;
- }
+ gf_boolean_t ret = _gf_true;
+ uint64_t total_mem = 0;
+ uint64_t max_cache_size = 0;
+ volume_option_t *opt = NULL;
+
+ GF_ASSERT(this);
+ opt = xlator_volume_option_get(this, "cache-size");
+ if (!opt) {
+ ret = _gf_false;
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL,
+ IO_CACHE_MSG_ENFORCEMENT_FAILED,
+ "could not get cache-size option");
+ goto out;
+ }
+
+ total_mem = get_mem_size();
+ if (-1 == total_mem)
+ max_cache_size = opt->max;
+ else
+ max_cache_size = total_mem;
+
+ gf_msg_debug(this->name, 0, "Max cache size is %" PRIu64, max_cache_size);
+
+ if (cache_size > max_cache_size) {
+ ret = _gf_false;
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_CACHE_MSG_INVALID_ARGUMENT,
+ "Cache size %" PRIu64
+ " is greater than the max size of %" PRIu64,
+ cache_size, max_cache_size);
+ goto out;
+ }
out:
- return ret;
+ return ret;
}
int
-reconfigure (xlator_t *this, dict_t *options)
+reconfigure(xlator_t *this, dict_t *options)
{
- data_t *data = NULL;
- ioc_table_t *table = NULL;
- int ret = -1;
- uint64_t cache_size_new = 0;
- if (!this || !this->private)
- goto out;
+ data_t *data = NULL;
+ ioc_table_t *table = NULL;
+ int ret = -1;
+ uint64_t cache_size_new = 0;
+ if (!this || !this->private)
+ goto out;
- table = this->private;
+ table = this->private;
- ioc_table_lock (table);
- {
- GF_OPTION_RECONF ("pass-through", this->pass_through, options,
- bool, unlock);
+ ioc_table_lock(table);
+ {
+ GF_OPTION_RECONF("pass-through", this->pass_through, options, bool,
+ unlock);
- GF_OPTION_RECONF ("cache-timeout", table->cache_timeout,
- options, int32, unlock);
+ GF_OPTION_RECONF("cache-timeout", table->cache_timeout, options, int32,
+ unlock);
- data = dict_get (options, "priority");
- if (data) {
- char *option_list = data_to_str (data);
+ data = dict_get(options, "priority");
+ if (data) {
+ char *option_list = data_to_str(data);
- gf_msg_trace (this->name, 0,
- "option path %s", option_list);
- /* parse the list of pattern:priority */
- table->max_pri = ioc_get_priority_list (option_list,
- &table->priority_list);
+ gf_msg_trace(this->name, 0, "option path %s", option_list);
+ /* parse the list of pattern:priority */
+ table->max_pri = ioc_get_priority_list(option_list,
+ &table->priority_list);
- if (table->max_pri == -1) {
- goto unlock;
- }
- table->max_pri ++;
- }
+ if (table->max_pri == -1) {
+ goto unlock;
+ }
+ table->max_pri++;
+ }
- GF_OPTION_RECONF ("max-file-size", table->max_file_size,
- options, size_uint64, unlock);
-
- GF_OPTION_RECONF ("min-file-size", table->min_file_size,
- options, size_uint64, unlock);
-
- if ((table->max_file_size <= UINT64_MAX) &&
- (table->min_file_size > table->max_file_size)) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- IO_CACHE_MSG_INVALID_ARGUMENT, "minimum size (%"
- PRIu64") of a file that can be cached is "
- "greater than maximum size (%"PRIu64"). "
- "Hence Defaulting to old value",
- table->min_file_size, table->max_file_size);
- goto unlock;
- }
+ GF_OPTION_RECONF("max-file-size", table->max_file_size, options,
+ size_uint64, unlock);
- GF_OPTION_RECONF ("cache-size", cache_size_new,
- options, size_uint64, unlock);
- if (!check_cache_size_ok (this, cache_size_new)) {
- ret = -1;
- gf_msg (this->name, GF_LOG_ERROR,
- 0, IO_CACHE_MSG_INVALID_ARGUMENT,
- "Not reconfiguring cache-size");
- goto unlock;
- }
- table->cache_size = cache_size_new;
+ GF_OPTION_RECONF("min-file-size", table->min_file_size, options,
+ size_uint64, unlock);
+
+ if ((table->max_file_size <= UINT64_MAX) &&
+ (table->min_file_size > table->max_file_size)) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_CACHE_MSG_INVALID_ARGUMENT,
+ "minimum size (%" PRIu64
+ ") of a file that can be cached is "
+ "greater than maximum size (%" PRIu64
+ "). "
+ "Hence Defaulting to old value",
+ table->min_file_size, table->max_file_size);
+ goto unlock;
+ }
- ret = 0;
+ GF_OPTION_RECONF("cache-size", cache_size_new, options, size_uint64,
+ unlock);
+ if (!check_cache_size_ok(this, cache_size_new)) {
+ ret = -1;
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_CACHE_MSG_INVALID_ARGUMENT,
+ "Not reconfiguring cache-size");
+ goto unlock;
}
+ table->cache_size = cache_size_new;
+
+ ret = 0;
+ }
unlock:
- ioc_table_unlock (table);
+ ioc_table_unlock(table);
out:
- return ret;
+ return ret;
}
-
/*
* init -
* @this:
*
*/
int32_t
-init (xlator_t *this)
+init(xlator_t *this)
{
- ioc_table_t *table = NULL;
- dict_t *xl_options = NULL;
- uint32_t index = 0;
- int32_t ret = -1;
- glusterfs_ctx_t *ctx = NULL;
- data_t *data = 0;
- uint32_t num_pages = 0;
-
- xl_options = this->options;
-
- if (!this->children || this->children->next) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- IO_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED,
- "FATAL: io-cache not configured with exactly "
- "one child");
- goto out;
- }
-
- if (!this->parents) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- IO_CACHE_MSG_VOL_MISCONFIGURED,
- "dangling volume. check volfile ");
- }
-
- table = (void *) GF_CALLOC (1, sizeof (*table), gf_ioc_mt_ioc_table_t);
- if (table == NULL) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- IO_CACHE_MSG_NO_MEMORY, "out of memory");
- goto out;
- }
-
- table->xl = this;
- table->page_size = this->ctx->page_size;
-
- GF_OPTION_INIT ("pass-through", this->pass_through, bool, out);
-
- GF_OPTION_INIT ("cache-size", table->cache_size, size_uint64, out);
-
- GF_OPTION_INIT ("cache-timeout", table->cache_timeout, int32, out);
-
- GF_OPTION_INIT ("min-file-size", table->min_file_size, size_uint64, out);
-
- GF_OPTION_INIT ("max-file-size", table->max_file_size, size_uint64, out);
-
- if (!check_cache_size_ok (this, table->cache_size)) {
- ret = -1;
- goto out;
- }
-
- INIT_LIST_HEAD (&table->priority_list);
- table->max_pri = 1;
- data = dict_get (xl_options, "priority");
- if (data) {
- char *option_list = data_to_str (data);
- gf_msg_trace (this->name, 0,
- "option path %s", option_list);
- /* parse the list of pattern:priority */
- table->max_pri = ioc_get_priority_list (option_list,
- &table->priority_list);
-
- if (table->max_pri == -1) {
- goto out;
- }
- }
- table->max_pri ++;
-
- INIT_LIST_HEAD (&table->inodes);
-
- if ((table->max_file_size <= UINT64_MAX)
- && (table->min_file_size > table->max_file_size)) {
- gf_msg ("io-cache", GF_LOG_ERROR, 0,
- IO_CACHE_MSG_INVALID_ARGUMENT, "minimum size (%"
- PRIu64") of a file that can be cached is "
- "greater than maximum size (%"PRIu64")",
- table->min_file_size, table->max_file_size);
- goto out;
- }
-
- table->inode_lru = GF_CALLOC (table->max_pri,
- sizeof (struct list_head),
- gf_ioc_mt_list_head);
- if (table->inode_lru == NULL) {
- goto out;
- }
-
- for (index = 0; index < (table->max_pri); index++)
- INIT_LIST_HEAD (&table->inode_lru[index]);
-
- this->local_pool = mem_pool_new (ioc_local_t, 64);
- if (!this->local_pool) {
- ret = -1;
- gf_msg (this->name, GF_LOG_ERROR,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY,
- "failed to create local_t's memory pool");
- goto out;
- }
-
- pthread_mutex_init (&table->table_lock, NULL);
- this->private = table;
-
- num_pages = (table->cache_size / table->page_size)
- + ((table->cache_size % table->page_size)
- ? 1 : 0);
-
- table->mem_pool = mem_pool_new (rbthash_entry_t, num_pages);
- if (!table->mem_pool) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- IO_CACHE_MSG_NO_MEMORY, "Unable to allocate mem_pool");
- goto out;
- }
-
- ret = 0;
-
- ctx = this->ctx;
- ioc_log2_page_size = log_base2 (ctx->page_size);
+ ioc_table_t *table = NULL;
+ dict_t *xl_options = NULL;
+ uint32_t index = 0;
+ int32_t ret = -1;
+ glusterfs_ctx_t *ctx = NULL;
+ data_t *data = 0;
+ uint32_t num_pages = 0;
+
+ xl_options = this->options;
+
+ if (!this->children || this->children->next) {
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ IO_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED,
+ "FATAL: io-cache not configured with exactly "
+ "one child");
+ goto out;
+ }
+
+ if (!this->parents) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, IO_CACHE_MSG_VOL_MISCONFIGURED,
+ "dangling volume. check volfile ");
+ }
+
+ table = (void *)GF_CALLOC(1, sizeof(*table), gf_ioc_mt_ioc_table_t);
+ if (table == NULL) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ goto out;
+ }
+
+ table->xl = this;
+ table->page_size = this->ctx->page_size;
+
+ GF_OPTION_INIT("pass-through", this->pass_through, bool, out);
+
+ GF_OPTION_INIT("cache-size", table->cache_size, size_uint64, out);
+
+ GF_OPTION_INIT("cache-timeout", table->cache_timeout, int32, out);
+
+ GF_OPTION_INIT("min-file-size", table->min_file_size, size_uint64, out);
+
+ GF_OPTION_INIT("max-file-size", table->max_file_size, size_uint64, out);
+
+ if (!check_cache_size_ok(this, table->cache_size)) {
+ ret = -1;
+ goto out;
+ }
+
+ INIT_LIST_HEAD(&table->priority_list);
+ table->max_pri = 1;
+ data = dict_get(xl_options, "priority");
+ if (data) {
+ char *option_list = data_to_str(data);
+ gf_msg_trace(this->name, 0, "option path %s", option_list);
+ /* parse the list of pattern:priority */
+ table->max_pri = ioc_get_priority_list(option_list,
+ &table->priority_list);
+
+ if (table->max_pri == -1) {
+ goto out;
+ }
+ }
+ table->max_pri++;
+
+ INIT_LIST_HEAD(&table->inodes);
+
+ if ((table->max_file_size <= UINT64_MAX) &&
+ (table->min_file_size > table->max_file_size)) {
+ gf_msg("io-cache", GF_LOG_ERROR, 0, IO_CACHE_MSG_INVALID_ARGUMENT,
+ "minimum size (%" PRIu64
+ ") of a file that can be cached is "
+ "greater than maximum size (%" PRIu64 ")",
+ table->min_file_size, table->max_file_size);
+ goto out;
+ }
+
+ table->inode_lru = GF_CALLOC(table->max_pri, sizeof(struct list_head),
+ gf_ioc_mt_list_head);
+ if (table->inode_lru == NULL) {
+ goto out;
+ }
+
+ for (index = 0; index < (table->max_pri); index++)
+ INIT_LIST_HEAD(&table->inode_lru[index]);
+
+ this->local_pool = mem_pool_new(ioc_local_t, 64);
+ if (!this->local_pool) {
+ ret = -1;
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_CACHE_MSG_NO_MEMORY,
+ "failed to create local_t's memory pool");
+ goto out;
+ }
+
+ pthread_mutex_init(&table->table_lock, NULL);
+ this->private = table;
+
+ num_pages = (table->cache_size / table->page_size) +
+ ((table->cache_size % table->page_size) ? 1 : 0);
+
+ table->mem_pool = mem_pool_new(rbthash_entry_t, num_pages);
+ if (!table->mem_pool) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_CACHE_MSG_NO_MEMORY,
+ "Unable to allocate mem_pool");
+ goto out;
+ }
+
+ ret = 0;
+
+ ctx = this->ctx;
+ ioc_log2_page_size = log_base2(ctx->page_size);
out:
- if (ret == -1) {
- if (table != NULL) {
- GF_FREE (table->inode_lru);
- GF_FREE (table);
- }
+ if (ret == -1) {
+ if (table != NULL) {
+ GF_FREE(table->inode_lru);
+ GF_FREE(table);
}
+ }
- return ret;
+ return ret;
}
void
-ioc_page_waitq_dump (ioc_page_t *page, char *prefix)
+ioc_page_waitq_dump(ioc_page_t *page, char *prefix)
{
- ioc_waitq_t *trav = NULL;
- call_frame_t *frame = NULL;
- int32_t i = 0;
- char key[GF_DUMP_MAX_BUF_LEN] = {0, };
-
- trav = page->waitq;
-
- while (trav) {
- frame = trav->data;
- sprintf (key, "waitq.frame[%d]", i++);
- gf_proc_dump_write (key, "%"PRId64, frame->root->unique);
-
- trav = trav->next;
- }
+ ioc_waitq_t *trav = NULL;
+ call_frame_t *frame = NULL;
+ int32_t i = 0;
+ char key[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+
+ trav = page->waitq;
+
+ while (trav) {
+ frame = trav->data;
+ sprintf(key, "waitq.frame[%d]", i++);
+ gf_proc_dump_write(key, "%" PRId64, frame->root->unique);
+
+ trav = trav->next;
+ }
}
void
-__ioc_inode_waitq_dump (ioc_inode_t *ioc_inode, char *prefix)
+__ioc_inode_waitq_dump(ioc_inode_t *ioc_inode, char *prefix)
{
- ioc_waitq_t *trav = NULL;
- ioc_page_t *page = NULL;
- int32_t i = 0;
- char key[GF_DUMP_MAX_BUF_LEN] = {0, };
+ ioc_waitq_t *trav = NULL;
+ ioc_page_t *page = NULL;
+ int32_t i = 0;
+ char key[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
- trav = ioc_inode->waitq;
+ trav = ioc_inode->waitq;
- while (trav) {
- page = trav->data;
+ while (trav) {
+ page = trav->data;
- sprintf (key, "cache-validation-waitq.page[%d].offset", i++);
- gf_proc_dump_write (key, "%"PRId64, page->offset);
+ sprintf(key, "cache-validation-waitq.page[%d].offset", i++);
+ gf_proc_dump_write(key, "%" PRId64, page->offset);
- trav = trav->next;
- }
+ trav = trav->next;
+ }
}
void
-__ioc_page_dump (ioc_page_t *page, char *prefix)
+__ioc_page_dump(ioc_page_t *page, char *prefix)
{
+ int ret = -1;
- int ret = -1;
-
- if (!page)
- return;
- /* ioc_page_lock can be used to hold the mutex. But in statedump
- * its better to use trylock to avoid deadlocks.
- */
- ret = pthread_mutex_trylock (&page->page_lock);
- if (ret)
- goto out;
- {
- gf_proc_dump_write ("offset", "%"PRId64, page->offset);
- gf_proc_dump_write ("size", "%"PRId64, page->size);
- gf_proc_dump_write ("dirty", "%s", page->dirty ? "yes" : "no");
- gf_proc_dump_write ("ready", "%s", page->ready ? "yes" : "no");
- ioc_page_waitq_dump (page, prefix);
- }
- pthread_mutex_unlock (&page->page_lock);
+ if (!page)
+ return;
+ /* ioc_page_lock can be used to hold the mutex. But in statedump
+ * its better to use trylock to avoid deadlocks.
+ */
+ ret = pthread_mutex_trylock(&page->page_lock);
+ if (ret)
+ goto out;
+ {
+ gf_proc_dump_write("offset", "%" PRId64, page->offset);
+ gf_proc_dump_write("size", "%" PRId64, page->size);
+ gf_proc_dump_write("dirty", "%s", page->dirty ? "yes" : "no");
+ gf_proc_dump_write("ready", "%s", page->ready ? "yes" : "no");
+ ioc_page_waitq_dump(page, prefix);
+ }
+ pthread_mutex_unlock(&page->page_lock);
out:
- if (ret && page)
- gf_proc_dump_write ("Unable to dump the page information",
- "(Lock acquisition failed) %p", page);
+ if (ret && page)
+ gf_proc_dump_write("Unable to dump the page information",
+ "(Lock acquisition failed) %p", page);
- return;
+ return;
}
void
-__ioc_cache_dump (ioc_inode_t *ioc_inode, char *prefix)
+__ioc_cache_dump(ioc_inode_t *ioc_inode, char *prefix)
{
- off_t offset = 0;
- ioc_table_t *table = NULL;
- ioc_page_t *page = NULL;
- int i = 0;
- char key[GF_DUMP_MAX_BUF_LEN] = {0, };
- char timestr[256] = {0, };
-
- if ((ioc_inode == NULL) || (prefix == NULL)) {
- goto out;
- }
-
- table = ioc_inode->table;
-
- if (ioc_inode->cache.tv.tv_sec) {
- gf_time_fmt (timestr, sizeof timestr,
- ioc_inode->cache.tv.tv_sec, gf_timefmt_FT);
- snprintf (timestr + strlen (timestr), sizeof timestr - strlen (timestr),
- ".%"GF_PRI_SUSECONDS, ioc_inode->cache.tv.tv_usec);
-
- gf_proc_dump_write ("last-cache-validation-time", "%s",
- timestr);
- }
-
- for (offset = 0; offset < ioc_inode->ia_size;
- offset += table->page_size) {
- page = __ioc_page_get (ioc_inode, offset);
- if (page == NULL) {
- continue;
- }
-
- sprintf (key, "inode.cache.page[%d]", i++);
- __ioc_page_dump (page, key);
- }
+ off_t offset = 0;
+ ioc_table_t *table = NULL;
+ ioc_page_t *page = NULL;
+ int i = 0;
+ char key[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ char timestr[256] = {
+ 0,
+ };
+
+ if ((ioc_inode == NULL) || (prefix == NULL)) {
+ goto out;
+ }
+
+ table = ioc_inode->table;
+
+ if (ioc_inode->cache.tv.tv_sec) {
+ gf_time_fmt(timestr, sizeof timestr, ioc_inode->cache.tv.tv_sec,
+ gf_timefmt_FT);
+ snprintf(timestr + strlen(timestr), sizeof timestr - strlen(timestr),
+ ".%" GF_PRI_SUSECONDS, ioc_inode->cache.tv.tv_usec);
+
+ gf_proc_dump_write("last-cache-validation-time", "%s", timestr);
+ }
+
+ for (offset = 0; offset < ioc_inode->ia_size; offset += table->page_size) {
+ page = __ioc_page_get(ioc_inode, offset);
+ if (page == NULL) {
+ continue;
+ }
+
+ sprintf(key, "inode.cache.page[%d]", i++);
+ __ioc_page_dump(page, key);
+ }
out:
- return;
+ return;
}
-
int
-ioc_inode_dump (xlator_t *this, inode_t *inode)
+ioc_inode_dump(xlator_t *this, inode_t *inode)
{
-
- char *path = NULL;
- int ret = -1;
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
- uint64_t tmp_ioc_inode = 0;
- ioc_inode_t *ioc_inode = NULL;
- gf_boolean_t section_added = _gf_false;
- char uuid_str[64] = {0,};
-
- if (this == NULL || inode == NULL)
- goto out;
-
- gf_proc_dump_build_key (key_prefix, "io-cache", "inode");
-
- inode_ctx_get (inode, this, &tmp_ioc_inode);
- ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
- if (ioc_inode == NULL)
- goto out;
-
- /* Similar to ioc_page_dump function its better to use
- * pthread_mutex_trylock and not to use gf_log in statedump
- * to avoid deadlocks.
- */
- ret = pthread_mutex_trylock (&ioc_inode->inode_lock);
- if (ret)
- goto out;
-
- {
- if (gf_uuid_is_null (ioc_inode->inode->gfid))
- goto unlock;
-
- gf_proc_dump_add_section (key_prefix);
- section_added = _gf_true;
-
- __inode_path (ioc_inode->inode, NULL, &path);
-
- gf_proc_dump_write ("inode.weight", "%d", ioc_inode->weight);
-
- if (path) {
- gf_proc_dump_write ("path", "%s", path);
- GF_FREE (path);
- }
-
- gf_proc_dump_write ("uuid", "%s", uuid_utoa_r
- (ioc_inode->inode->gfid, uuid_str));
- __ioc_cache_dump (ioc_inode, key_prefix);
- __ioc_inode_waitq_dump (ioc_inode, key_prefix);
- }
+ char *path = NULL;
+ int ret = -1;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ uint64_t tmp_ioc_inode = 0;
+ ioc_inode_t *ioc_inode = NULL;
+ gf_boolean_t section_added = _gf_false;
+ char uuid_str[64] = {
+ 0,
+ };
+
+ if (this == NULL || inode == NULL)
+ goto out;
+
+ gf_proc_dump_build_key(key_prefix, "io-cache", "inode");
+
+ inode_ctx_get(inode, this, &tmp_ioc_inode);
+ ioc_inode = (ioc_inode_t *)(long)tmp_ioc_inode;
+ if (ioc_inode == NULL)
+ goto out;
+
+ /* Similar to ioc_page_dump function its better to use
+ * pthread_mutex_trylock and not to use gf_log in statedump
+ * to avoid deadlocks.
+ */
+ ret = pthread_mutex_trylock(&ioc_inode->inode_lock);
+ if (ret)
+ goto out;
+
+ {
+ if (gf_uuid_is_null(ioc_inode->inode->gfid))
+ goto unlock;
+
+ gf_proc_dump_add_section(key_prefix);
+ section_added = _gf_true;
+
+ __inode_path(ioc_inode->inode, NULL, &path);
+
+ gf_proc_dump_write("inode.weight", "%d", ioc_inode->weight);
+
+ if (path) {
+ gf_proc_dump_write("path", "%s", path);
+ GF_FREE(path);
+ }
+
+ gf_proc_dump_write("uuid", "%s",
+ uuid_utoa_r(ioc_inode->inode->gfid, uuid_str));
+ __ioc_cache_dump(ioc_inode, key_prefix);
+ __ioc_inode_waitq_dump(ioc_inode, key_prefix);
+ }
unlock:
- pthread_mutex_unlock (&ioc_inode->inode_lock);
+ pthread_mutex_unlock(&ioc_inode->inode_lock);
out:
- if (ret && ioc_inode) {
- if (section_added == _gf_false)
- gf_proc_dump_add_section (key_prefix);
- gf_proc_dump_write ("Unable to print the status of ioc_inode",
- "(Lock acquisition failed) %s",
- uuid_utoa (inode->gfid));
- }
- return ret;
+ if (ret && ioc_inode) {
+ if (section_added == _gf_false)
+ gf_proc_dump_add_section(key_prefix);
+ gf_proc_dump_write("Unable to print the status of ioc_inode",
+ "(Lock acquisition failed) %s",
+ uuid_utoa(inode->gfid));
+ }
+ return ret;
}
int
-ioc_priv_dump (xlator_t *this)
+ioc_priv_dump(xlator_t *this)
{
- ioc_table_t *priv = NULL;
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
- int ret = -1;
- gf_boolean_t add_section = _gf_false;
-
- if (!this || !this->private)
- goto out;
-
- priv = this->private;
-
- gf_proc_dump_build_key (key_prefix, "io-cache", "priv");
- gf_proc_dump_add_section (key_prefix);
- add_section = _gf_true;
-
- ret = pthread_mutex_trylock (&priv->table_lock);
- if (ret)
- goto out;
- {
- gf_proc_dump_write ("page_size", "%ld", priv->page_size);
- gf_proc_dump_write ("cache_size", "%ld", priv->cache_size);
- gf_proc_dump_write ("cache_used", "%ld", priv->cache_used);
- gf_proc_dump_write ("inode_count", "%u", priv->inode_count);
- gf_proc_dump_write ("cache_timeout", "%u", priv->cache_timeout);
- gf_proc_dump_write ("min-file-size", "%u", priv->min_file_size);
- gf_proc_dump_write ("max-file-size", "%u", priv->max_file_size);
- }
- pthread_mutex_unlock (&priv->table_lock);
+ ioc_table_t *priv = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ int ret = -1;
+ gf_boolean_t add_section = _gf_false;
+
+ if (!this || !this->private)
+ goto out;
+
+ priv = this->private;
+
+ gf_proc_dump_build_key(key_prefix, "io-cache", "priv");
+ gf_proc_dump_add_section(key_prefix);
+ add_section = _gf_true;
+
+ ret = pthread_mutex_trylock(&priv->table_lock);
+ if (ret)
+ goto out;
+ {
+ gf_proc_dump_write("page_size", "%ld", priv->page_size);
+ gf_proc_dump_write("cache_size", "%ld", priv->cache_size);
+ gf_proc_dump_write("cache_used", "%ld", priv->cache_used);
+ gf_proc_dump_write("inode_count", "%u", priv->inode_count);
+ gf_proc_dump_write("cache_timeout", "%u", priv->cache_timeout);
+ gf_proc_dump_write("min-file-size", "%u", priv->min_file_size);
+ gf_proc_dump_write("max-file-size", "%u", priv->max_file_size);
+ }
+ pthread_mutex_unlock(&priv->table_lock);
out:
- if (ret && priv) {
- if (!add_section) {
- gf_proc_dump_build_key (key_prefix, "xlator."
- "performance.io-cache", "priv");
- gf_proc_dump_add_section (key_prefix);
- }
- gf_proc_dump_write ("Unable to dump the state of private "
- "structure of io-cache xlator", "(Lock "
- "acquisition failed) %s", this->name);
- }
-
- return 0;
+ if (ret && priv) {
+ if (!add_section) {
+ gf_proc_dump_build_key(key_prefix,
+ "xlator."
+ "performance.io-cache",
+ "priv");
+ gf_proc_dump_add_section(key_prefix);
+ }
+ gf_proc_dump_write(
+ "Unable to dump the state of private "
+ "structure of io-cache xlator",
+ "(Lock "
+ "acquisition failed) %s",
+ this->name);
+ }
+
+ return 0;
}
/*
@@ -2091,128 +2044,122 @@ out:
*
*/
void
-fini (xlator_t *this)
+fini(xlator_t *this)
{
- ioc_table_t *table = NULL;
- struct ioc_priority *curr = NULL, *tmp = NULL;
+ ioc_table_t *table = NULL;
+ struct ioc_priority *curr = NULL, *tmp = NULL;
- table = this->private;
+ table = this->private;
- if (table == NULL)
- return;
-
- this->private = NULL;
-
- if (table->mem_pool != NULL) {
- mem_pool_destroy (table->mem_pool);
- table->mem_pool = NULL;
- }
-
- list_for_each_entry_safe (curr, tmp, &table->priority_list, list) {
- list_del_init (&curr->list);
- GF_FREE (curr->pattern);
- GF_FREE (curr);
- }
-
- /* inode_lru and inodes list can be empty in case fini() is
- * called soon after init()? Hence commenting the below asserts.
- */
- /*for (i = 0; i < table->max_pri; i++) {
- GF_ASSERT (list_empty (&table->inode_lru[i]));
- }
-
- GF_ASSERT (list_empty (&table->inodes));
- */
- pthread_mutex_destroy (&table->table_lock);
- GF_FREE (table);
-
- this->private = NULL;
+ if (table == NULL)
return;
+
+ this->private = NULL;
+
+ if (table->mem_pool != NULL) {
+ mem_pool_destroy(table->mem_pool);
+ table->mem_pool = NULL;
+ }
+
+ list_for_each_entry_safe(curr, tmp, &table->priority_list, list)
+ {
+ list_del_init(&curr->list);
+ GF_FREE(curr->pattern);
+ GF_FREE(curr);
+ }
+
+ /* inode_lru and inodes list can be empty in case fini() is
+ * called soon after init()? Hence commenting the below asserts.
+ */
+ /*for (i = 0; i < table->max_pri; i++) {
+ GF_ASSERT (list_empty (&table->inode_lru[i]));
+ }
+
+ GF_ASSERT (list_empty (&table->inodes));
+ */
+ pthread_mutex_destroy(&table->table_lock);
+ GF_FREE(table);
+
+ this->private = NULL;
+ return;
}
struct xlator_fops fops = {
- .open = ioc_open,
- .create = ioc_create,
- .readv = ioc_readv,
- .writev = ioc_writev,
- .truncate = ioc_truncate,
- .ftruncate = ioc_ftruncate,
- .lookup = ioc_lookup,
- .lk = ioc_lk,
- .setattr = ioc_setattr,
- .mknod = ioc_mknod,
-
- .readdirp = ioc_readdirp,
- .discard = ioc_discard,
- .zerofill = ioc_zerofill,
+ .open = ioc_open,
+ .create = ioc_create,
+ .readv = ioc_readv,
+ .writev = ioc_writev,
+ .truncate = ioc_truncate,
+ .ftruncate = ioc_ftruncate,
+ .lookup = ioc_lookup,
+ .lk = ioc_lk,
+ .setattr = ioc_setattr,
+ .mknod = ioc_mknod,
+
+ .readdirp = ioc_readdirp,
+ .discard = ioc_discard,
+ .zerofill = ioc_zerofill,
};
-
struct xlator_dumpops dumpops = {
- .priv = ioc_priv_dump,
- .inodectx = ioc_inode_dump,
+ .priv = ioc_priv_dump,
+ .inodectx = ioc_inode_dump,
};
struct xlator_cbks cbks = {
- .forget = ioc_forget,
- .release = ioc_release,
- .invalidate = ioc_invalidate,
+ .forget = ioc_forget,
+ .release = ioc_release,
+ .invalidate = ioc_invalidate,
};
struct volume_options options[] = {
- { .key = {"priority"},
- .type = GF_OPTION_TYPE_PRIORITY_LIST,
- .default_value = "",
- .description = "Assigns priority to filenames with specific "
- "patterns so that when a page needs to be ejected "
- "out of the cache, the page of a file whose "
- "priority is the lowest will be ejected earlier",
- .op_version = {1},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC
- },
- { .key = {"cache-timeout", "force-revalidate-timeout"},
- .type = GF_OPTION_TYPE_INT,
- .min = 0,
- .max = 60,
- .default_value = "1",
- .description = "The cached data for a file will be retained for "
- "'cache-refresh-timeout' seconds, after which data "
- "re-validation is performed.",
- .op_version = {1},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC
- },
- { .key = {"cache-size"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 4 * GF_UNIT_MB,
- .max = INFINITY,
- .default_value = "32MB",
- .description = "Size of the read cache.",
- .op_version = {1},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC
- },
- { .key = {"min-file-size"},
- .type = GF_OPTION_TYPE_SIZET,
- .default_value = "0",
- .description = "Minimum file size which would be cached by the "
- "io-cache translator.",
- .op_version = {1},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC
- },
- { .key = {"max-file-size"},
- .type = GF_OPTION_TYPE_SIZET,
- .default_value = "0",
- .description = "Maximum file size which would be cached by the "
- "io-cache translator.",
- .op_version = {1},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC
- },
- { .key = {"pass-through"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"io-cache"},
- .description = "Enable/Disable io cache translator"
- },
- { .key = {NULL} },
+ {.key = {"priority"},
+ .type = GF_OPTION_TYPE_PRIORITY_LIST,
+ .default_value = "",
+ .description = "Assigns priority to filenames with specific "
+ "patterns so that when a page needs to be ejected "
+ "out of the cache, the page of a file whose "
+ "priority is the lowest will be ejected earlier",
+ .op_version = {1},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC},
+ {.key = {"cache-timeout", "force-revalidate-timeout"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = 0,
+ .max = 60,
+ .default_value = "1",
+ .description = "The cached data for a file will be retained for "
+ "'cache-refresh-timeout' seconds, after which data "
+ "re-validation is performed.",
+ .op_version = {1},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC},
+ {.key = {"cache-size"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 4 * GF_UNIT_MB,
+ .max = INFINITY,
+ .default_value = "32MB",
+ .description = "Size of the read cache.",
+ .op_version = {1},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC},
+ {.key = {"min-file-size"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .default_value = "0",
+ .description = "Minimum file size which would be cached by the "
+ "io-cache translator.",
+ .op_version = {1},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC},
+ {.key = {"max-file-size"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .default_value = "0",
+ .description = "Maximum file size which would be cached by the "
+ "io-cache translator.",
+ .op_version = {1},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC},
+ {.key = {"pass-through"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"io-cache"},
+ .description = "Enable/Disable io cache translator"},
+ {.key = {NULL}},
};
diff --git a/xlators/performance/io-cache/src/ioc-inode.c b/xlators/performance/io-cache/src/ioc-inode.c
index f8653fae6aa..a26e6d35adb 100644
--- a/xlators/performance/io-cache/src/ioc-inode.c
+++ b/xlators/performance/io-cache/src/ioc-inode.c
@@ -19,151 +19,140 @@ extern int ioc_log2_page_size;
*
*/
void *
-str_to_ptr (char *string)
+str_to_ptr(char *string)
{
- void *ptr = NULL;
+ void *ptr = NULL;
- GF_VALIDATE_OR_GOTO ("io-cache", string, out);
+ GF_VALIDATE_OR_GOTO("io-cache", string, out);
- ptr = (void *)strtoul (string, NULL, 16);
+ ptr = (void *)strtoul(string, NULL, 16);
out:
- return ptr;
+ return ptr;
}
-
/*
* ptr_to_str - convert a pointer to string
* @ptr: pointer
*
*/
char *
-ptr_to_str (void *ptr)
+ptr_to_str(void *ptr)
{
- int ret = 0;
- char *str = NULL;
-
- GF_VALIDATE_OR_GOTO ("io-cache", ptr, out);
-
- ret = gf_asprintf (&str, "%p", ptr);
- if (-1 == ret) {
- gf_msg ("io-cache", GF_LOG_WARNING, 0,
- IO_CACHE_MSG_STR_COVERSION_FAILED,
- "asprintf failed while converting ptr to str");
- str = NULL;
- goto out;
- }
+ int ret = 0;
+ char *str = NULL;
+
+ GF_VALIDATE_OR_GOTO("io-cache", ptr, out);
+
+ ret = gf_asprintf(&str, "%p", ptr);
+ if (-1 == ret) {
+ gf_msg("io-cache", GF_LOG_WARNING, 0, IO_CACHE_MSG_STR_COVERSION_FAILED,
+ "asprintf failed while converting ptr to str");
+ str = NULL;
+ goto out;
+ }
out:
- return str;
+ return str;
}
-
void
-ioc_inode_wakeup (call_frame_t *frame, ioc_inode_t *ioc_inode,
- struct iatt *stbuf)
+ioc_inode_wakeup(call_frame_t *frame, ioc_inode_t *ioc_inode,
+ struct iatt *stbuf)
{
- ioc_waitq_t *waiter = NULL, *waited = NULL;
- ioc_waitq_t *page_waitq = NULL;
- int8_t cache_still_valid = 1;
- ioc_local_t *local = NULL;
- int8_t need_fault = 0;
- ioc_page_t *waiter_page = NULL;
-
- GF_VALIDATE_OR_GOTO ("io-cache", frame, out);
-
- local = frame->local;
- GF_VALIDATE_OR_GOTO (frame->this->name, local, out);
-
- if (ioc_inode == NULL) {
- local->op_ret = -1;
- local->op_errno = EINVAL;
- gf_msg (frame->this->name, GF_LOG_WARNING, 0,
- IO_CACHE_MSG_INODE_NULL, "ioc_inode is NULL");
- goto out;
+ ioc_waitq_t *waiter = NULL, *waited = NULL;
+ ioc_waitq_t *page_waitq = NULL;
+ int8_t cache_still_valid = 1;
+ ioc_local_t *local = NULL;
+ int8_t need_fault = 0;
+ ioc_page_t *waiter_page = NULL;
+
+ GF_VALIDATE_OR_GOTO("io-cache", frame, out);
+
+ local = frame->local;
+ GF_VALIDATE_OR_GOTO(frame->this->name, local, out);
+
+ if (ioc_inode == NULL) {
+ local->op_ret = -1;
+ local->op_errno = EINVAL;
+ gf_msg(frame->this->name, GF_LOG_WARNING, 0, IO_CACHE_MSG_INODE_NULL,
+ "ioc_inode is NULL");
+ goto out;
+ }
+
+ if (stbuf)
+ cache_still_valid = ioc_cache_still_valid(ioc_inode, stbuf);
+ else
+ cache_still_valid = 0;
+
+ ioc_inode_lock(ioc_inode);
+ {
+ waiter = ioc_inode->waitq;
+ if (!waiter) {
+ gf_msg(frame->this->name, GF_LOG_WARNING, 0,
+ IO_CACHE_MSG_PAGE_WAIT_VALIDATE,
+ "cache validate called without any "
+ "page waiting to be validated");
+
+ ioc_inode_unlock(ioc_inode);
+ goto out;
}
- if (stbuf)
- cache_still_valid = ioc_cache_still_valid (ioc_inode, stbuf);
- else
- cache_still_valid = 0;
-
- ioc_inode_lock (ioc_inode);
- {
-
- waiter = ioc_inode->waitq;
- if (!waiter) {
- gf_msg (frame->this->name, GF_LOG_WARNING, 0,
- IO_CACHE_MSG_PAGE_WAIT_VALIDATE,
- "cache validate called without any "
- "page waiting to be validated");
-
- ioc_inode_unlock (ioc_inode);
- goto out;
+ while (waiter) {
+ waiter_page = waiter->data;
+ ioc_inode->waitq = waiter->next;
+ page_waitq = NULL;
+
+ if (waiter_page) {
+ if (cache_still_valid) {
+ /* cache valid, wake up page */
+ page_waitq = __ioc_page_wakeup(waiter_page,
+ waiter_page->op_errno);
+ if (page_waitq) {
+ ioc_inode_unlock(ioc_inode);
+ ioc_waitq_return(page_waitq);
+ ioc_inode_lock(ioc_inode);
+ }
+ } else {
+ /* cache invalid, generate page fault and set
+ * page->ready = 0, to avoid double faults
+ */
+ if (waiter_page->ready) {
+ waiter_page->ready = 0;
+ need_fault = 1;
+ } else {
+ gf_msg_trace(frame->this->name, 0,
+ "validate "
+ "frame(%p) is "
+ "waiting for "
+ "in-transit"
+ " page = %p",
+ frame, waiter_page);
+ }
+
+ if (need_fault) {
+ need_fault = 0;
+ ioc_inode_unlock(ioc_inode);
+ ioc_page_fault(ioc_inode, frame, local->fd,
+ waiter_page->offset);
+ ioc_inode_lock(ioc_inode);
+ }
}
+ }
- while (waiter) {
- waiter_page = waiter->data;
- ioc_inode->waitq = waiter->next;
- page_waitq = NULL;
-
- if (waiter_page) {
- if (cache_still_valid) {
- /* cache valid, wake up page */
- page_waitq =
- __ioc_page_wakeup (waiter_page,
- waiter_page->op_errno);
- if (page_waitq) {
- ioc_inode_unlock (ioc_inode);
- ioc_waitq_return (page_waitq);
- ioc_inode_lock (ioc_inode);
- }
- } else {
- /* cache invalid, generate page fault and set
- * page->ready = 0, to avoid double faults
- */
- if (waiter_page->ready) {
- waiter_page->ready = 0;
- need_fault = 1;
- } else {
- gf_msg_trace (frame->this->name,
- 0,
- "validate "
- "frame(%p) is "
- "waiting for "
- "in-transit"
- " page = %p",
- frame,
- waiter_page);
- }
-
-
- if (need_fault) {
- need_fault = 0;
- ioc_inode_unlock (ioc_inode);
- ioc_page_fault (ioc_inode,
- frame,
- local->fd,
- waiter_page->offset);
- ioc_inode_lock (ioc_inode);
- }
- }
- }
-
- waited = waiter;
- waiter = ioc_inode->waitq;
-
- waited->data = NULL;
- GF_FREE (waited);
- }
+ waited = waiter;
+ waiter = ioc_inode->waitq;
+
+ waited->data = NULL;
+ GF_FREE(waited);
}
- ioc_inode_unlock (ioc_inode);
+ }
+ ioc_inode_unlock(ioc_inode);
out:
- return;
+ return;
}
-
/*
* ioc_inode_create - create a new ioc_inode_t structure and add it to
* the table table. fill in the fields which are derived
@@ -175,40 +164,37 @@ out:
* not for external reference
*/
ioc_inode_t *
-ioc_inode_create (ioc_table_t *table, inode_t *inode, uint32_t weight)
+ioc_inode_create(ioc_table_t *table, inode_t *inode, uint32_t weight)
{
- ioc_inode_t *ioc_inode = NULL;
+ ioc_inode_t *ioc_inode = NULL;
- GF_VALIDATE_OR_GOTO ("io-cache", table, out);
+ GF_VALIDATE_OR_GOTO("io-cache", table, out);
- ioc_inode = GF_CALLOC (1, sizeof (ioc_inode_t), gf_ioc_mt_ioc_inode_t);
- if (ioc_inode == NULL) {
- goto out;
- }
+ ioc_inode = GF_CALLOC(1, sizeof(ioc_inode_t), gf_ioc_mt_ioc_inode_t);
+ if (ioc_inode == NULL) {
+ goto out;
+ }
- ioc_inode->inode = inode;
- ioc_inode->table = table;
- INIT_LIST_HEAD (&ioc_inode->cache.page_lru);
- pthread_mutex_init (&ioc_inode->inode_lock, NULL);
- ioc_inode->weight = weight;
-
- ioc_table_lock (table);
- {
- table->inode_count++;
- list_add (&ioc_inode->inode_list, &table->inodes);
- list_add_tail (&ioc_inode->inode_lru,
- &table->inode_lru[weight]);
- }
- ioc_table_unlock (table);
+ ioc_inode->inode = inode;
+ ioc_inode->table = table;
+ INIT_LIST_HEAD(&ioc_inode->cache.page_lru);
+ pthread_mutex_init(&ioc_inode->inode_lock, NULL);
+ ioc_inode->weight = weight;
+
+ ioc_table_lock(table);
+ {
+ table->inode_count++;
+ list_add(&ioc_inode->inode_list, &table->inodes);
+ list_add_tail(&ioc_inode->inode_lru, &table->inode_lru[weight]);
+ }
+ ioc_table_unlock(table);
- gf_msg_trace (table->xl->name, 0,
- "adding to inode_lru[%d]", weight);
+ gf_msg_trace(table->xl->name, 0, "adding to inode_lru[%d]", weight);
out:
- return ioc_inode;
+ return ioc_inode;
}
-
/*
* ioc_inode_destroy - destroy an ioc_inode_t object.
*
@@ -217,27 +203,27 @@ out:
* to be called only from ioc_forget.
*/
void
-ioc_inode_destroy (ioc_inode_t *ioc_inode)
+ioc_inode_destroy(ioc_inode_t *ioc_inode)
{
- ioc_table_t *table = NULL;
+ ioc_table_t *table = NULL;
- GF_VALIDATE_OR_GOTO ("io-cache", ioc_inode, out);
+ GF_VALIDATE_OR_GOTO("io-cache", ioc_inode, out);
- table = ioc_inode->table;
+ table = ioc_inode->table;
- ioc_table_lock (table);
- {
- table->inode_count--;
- list_del (&ioc_inode->inode_list);
- list_del (&ioc_inode->inode_lru);
- }
- ioc_table_unlock (table);
+ ioc_table_lock(table);
+ {
+ table->inode_count--;
+ list_del(&ioc_inode->inode_list);
+ list_del(&ioc_inode->inode_lru);
+ }
+ ioc_table_unlock(table);
- ioc_inode_flush (ioc_inode);
- rbthash_table_destroy (ioc_inode->cache.page_table);
+ ioc_inode_flush(ioc_inode);
+ rbthash_table_destroy(ioc_inode->cache.page_table);
- pthread_mutex_destroy (&ioc_inode->inode_lock);
- GF_FREE (ioc_inode);
+ pthread_mutex_destroy(&ioc_inode->inode_lock);
+ GF_FREE(ioc_inode);
out:
- return;
+ return;
}
diff --git a/xlators/performance/io-cache/src/page.c b/xlators/performance/io-cache/src/page.c
index a6148e04746..dada4ebc55b 100644
--- a/xlators/performance/io-cache/src/page.c
+++ b/xlators/performance/io-cache/src/page.c
@@ -18,66 +18,63 @@
#include <sys/time.h>
#include "io-cache-messages.h"
char
-ioc_empty (struct ioc_cache *cache)
+ioc_empty(struct ioc_cache *cache)
{
- char is_empty = -1;
+ char is_empty = -1;
- GF_VALIDATE_OR_GOTO ("io-cache", cache, out);
+ GF_VALIDATE_OR_GOTO("io-cache", cache, out);
- is_empty = list_empty (&cache->page_lru);
+ is_empty = list_empty(&cache->page_lru);
out:
- return is_empty;
+ return is_empty;
}
-
ioc_page_t *
-__ioc_page_get (ioc_inode_t *ioc_inode, off_t offset)
+__ioc_page_get(ioc_inode_t *ioc_inode, off_t offset)
{
- ioc_page_t *page = NULL;
- ioc_table_t *table = NULL;
- off_t rounded_offset = 0;
+ ioc_page_t *page = NULL;
+ ioc_table_t *table = NULL;
+ off_t rounded_offset = 0;
- GF_VALIDATE_OR_GOTO ("io-cache", ioc_inode, out);
+ GF_VALIDATE_OR_GOTO("io-cache", ioc_inode, out);
- table = ioc_inode->table;
- GF_VALIDATE_OR_GOTO ("io-cache", ioc_inode, out);
+ table = ioc_inode->table;
+ GF_VALIDATE_OR_GOTO("io-cache", ioc_inode, out);
- rounded_offset = floor (offset, table->page_size);
+ rounded_offset = floor(offset, table->page_size);
- page = rbthash_get (ioc_inode->cache.page_table, &rounded_offset,
- sizeof (rounded_offset));
+ page = rbthash_get(ioc_inode->cache.page_table, &rounded_offset,
+ sizeof(rounded_offset));
- if (page != NULL) {
- /* push the page to the end of the lru list */
- list_move_tail (&page->page_lru, &ioc_inode->cache.page_lru);
- }
+ if (page != NULL) {
+ /* push the page to the end of the lru list */
+ list_move_tail(&page->page_lru, &ioc_inode->cache.page_lru);
+ }
out:
- return page;
+ return page;
}
-
ioc_page_t *
-ioc_page_get (ioc_inode_t *ioc_inode, off_t offset)
+ioc_page_get(ioc_inode_t *ioc_inode, off_t offset)
{
- ioc_page_t *page = NULL;
+ ioc_page_t *page = NULL;
- if (ioc_inode == NULL) {
- goto out;
- }
+ if (ioc_inode == NULL) {
+ goto out;
+ }
- ioc_inode_lock (ioc_inode);
- {
- page = __ioc_page_get (ioc_inode, offset);
- }
- ioc_inode_unlock (ioc_inode);
+ ioc_inode_lock(ioc_inode);
+ {
+ page = __ioc_page_get(ioc_inode, offset);
+ }
+ ioc_inode_unlock(ioc_inode);
out:
- return page;
+ return page;
}
-
/*
* __ioc_page_destroy -
*
@@ -85,106 +82,108 @@ out:
*
*/
int64_t
-__ioc_page_destroy (ioc_page_t *page)
+__ioc_page_destroy(ioc_page_t *page)
{
- int64_t page_size = 0;
-
- GF_VALIDATE_OR_GOTO ("io-cache", page, out);
-
- if (page->iobref)
- page_size = iobref_size (page->iobref);
-
- if (page->waitq) {
- /* frames waiting on this page, do not destroy this page */
- page_size = -1;
- page->stale = 1;
- } else {
- rbthash_remove (page->inode->cache.page_table, &page->offset,
- sizeof (page->offset));
- list_del (&page->page_lru);
-
- gf_msg_trace (page->inode->table->xl->name, 0,
- "destroying page = %p, offset = %"PRId64" "
- "&& inode = %p",
- page, page->offset, page->inode);
-
- if (page->vector){
- iobref_unref (page->iobref);
- GF_FREE (page->vector);
- page->vector = NULL;
- }
-
- page->inode = NULL;
+ int64_t page_size = 0;
+
+ GF_VALIDATE_OR_GOTO("io-cache", page, out);
+
+ if (page->iobref)
+ page_size = iobref_size(page->iobref);
+
+ if (page->waitq) {
+ /* frames waiting on this page, do not destroy this page */
+ page_size = -1;
+ page->stale = 1;
+ } else {
+ rbthash_remove(page->inode->cache.page_table, &page->offset,
+ sizeof(page->offset));
+ list_del(&page->page_lru);
+
+ gf_msg_trace(page->inode->table->xl->name, 0,
+ "destroying page = %p, offset = %" PRId64
+ " "
+ "&& inode = %p",
+ page, page->offset, page->inode);
+
+ if (page->vector) {
+ iobref_unref(page->iobref);
+ GF_FREE(page->vector);
+ page->vector = NULL;
}
- if (page_size != -1) {
- pthread_mutex_destroy (&page->page_lock);
- GF_FREE (page);
- }
+ page->inode = NULL;
+ }
+
+ if (page_size != -1) {
+ pthread_mutex_destroy(&page->page_lock);
+ GF_FREE(page);
+ }
out:
- return page_size;
+ return page_size;
}
-
int64_t
-ioc_page_destroy (ioc_page_t *page)
+ioc_page_destroy(ioc_page_t *page)
{
- int64_t ret = 0;
- struct ioc_inode *inode = NULL;
+ int64_t ret = 0;
+ struct ioc_inode *inode = NULL;
- if (page == NULL) {
- goto out;
- }
+ if (page == NULL) {
+ goto out;
+ }
- ioc_inode_lock (page->inode);
- {
- inode = page->inode;
- ret = __ioc_page_destroy (page);
- }
- ioc_inode_unlock (inode);
+ ioc_inode_lock(page->inode);
+ {
+ inode = page->inode;
+ ret = __ioc_page_destroy(page);
+ }
+ ioc_inode_unlock(inode);
out:
- return ret;
+ return ret;
}
int32_t
-__ioc_inode_prune (ioc_inode_t *curr, uint64_t *size_pruned,
- uint64_t size_to_prune, uint32_t index)
+__ioc_inode_prune(ioc_inode_t *curr, uint64_t *size_pruned,
+ uint64_t size_to_prune, uint32_t index)
{
- ioc_page_t *page = NULL, *next = NULL;
- int32_t ret = 0;
- ioc_table_t *table = NULL;
+ ioc_page_t *page = NULL, *next = NULL;
+ int32_t ret = 0;
+ ioc_table_t *table = NULL;
- if (curr == NULL) {
- goto out;
- }
+ if (curr == NULL) {
+ goto out;
+ }
- table = curr->table;
+ table = curr->table;
- list_for_each_entry_safe (page, next, &curr->cache.page_lru, page_lru) {
- *size_pruned += page->size;
- ret = __ioc_page_destroy (page);
+ list_for_each_entry_safe(page, next, &curr->cache.page_lru, page_lru)
+ {
+ *size_pruned += page->size;
+ ret = __ioc_page_destroy(page);
- if (ret != -1)
- table->cache_used -= ret;
+ if (ret != -1)
+ table->cache_used -= ret;
- gf_msg_trace (table->xl->name, 0,
- "index = %d && "
- "table->cache_used = %"PRIu64" && table->"
- "cache_size = %"PRIu64, index, table->cache_used,
- table->cache_size);
+ gf_msg_trace(table->xl->name, 0,
+ "index = %d && "
+ "table->cache_used = %" PRIu64
+ " && table->"
+ "cache_size = %" PRIu64,
+ index, table->cache_used, table->cache_size);
- if ((*size_pruned) >= size_to_prune)
- break;
- }
+ if ((*size_pruned) >= size_to_prune)
+ break;
+ }
- if (ioc_empty (&curr->cache)) {
- list_del_init (&curr->inode_lru);
- }
+ if (ioc_empty(&curr->cache)) {
+ list_del_init(&curr->inode_lru);
+ }
out:
- return 0;
+ return 0;
}
/*
* ioc_prune - prune the cache. we have a limit to the number of pages we
@@ -194,46 +193,44 @@ out:
*
*/
int32_t
-ioc_prune (ioc_table_t *table)
+ioc_prune(ioc_table_t *table)
{
- ioc_inode_t *curr = NULL, *next_ioc_inode = NULL;
- int32_t index = 0;
- uint64_t size_to_prune = 0;
- uint64_t size_pruned = 0;
+ ioc_inode_t *curr = NULL, *next_ioc_inode = NULL;
+ int32_t index = 0;
+ uint64_t size_to_prune = 0;
+ uint64_t size_pruned = 0;
+
+ GF_VALIDATE_OR_GOTO("io-cache", table, out);
+
+ ioc_table_lock(table);
+ {
+ size_to_prune = table->cache_used - table->cache_size;
+ /* take out the least recently used inode */
+ for (index = 0; index < table->max_pri; index++) {
+ list_for_each_entry_safe(curr, next_ioc_inode,
+ &table->inode_lru[index], inode_lru)
+ {
+ /* prune page-by-page for this inode, till
+ * we reach the equilibrium */
+ ioc_inode_lock(curr);
+ {
+ __ioc_inode_prune(curr, &size_pruned, size_to_prune, index);
+ }
+ ioc_inode_unlock(curr);
- GF_VALIDATE_OR_GOTO ("io-cache", table, out);
+ if (size_pruned >= size_to_prune)
+ break;
+ } /* list_for_each_entry_safe (curr...) */
- ioc_table_lock (table);
- {
- size_to_prune = table->cache_used - table->cache_size;
- /* take out the least recently used inode */
- for (index=0; index < table->max_pri; index++) {
- list_for_each_entry_safe (curr, next_ioc_inode,
- &table->inode_lru[index],
- inode_lru) {
- /* prune page-by-page for this inode, till
- * we reach the equilibrium */
- ioc_inode_lock (curr);
- {
- __ioc_inode_prune (curr, &size_pruned,
- size_to_prune,
- index);
- }
- ioc_inode_unlock (curr);
-
- if (size_pruned >= size_to_prune)
- break;
- } /* list_for_each_entry_safe (curr...) */
-
- if (size_pruned >= size_to_prune)
- break;
- } /* for(index=0;...) */
-
- } /* ioc_inode_table locked region end */
- ioc_table_unlock (table);
+ if (size_pruned >= size_to_prune)
+ break;
+ } /* for(index=0;...) */
+
+ } /* ioc_inode_table locked region end */
+ ioc_table_unlock(table);
out:
- return 0;
+ return 0;
}
/*
@@ -244,47 +241,46 @@ out:
*
*/
ioc_page_t *
-__ioc_page_create (ioc_inode_t *ioc_inode, off_t offset)
+__ioc_page_create(ioc_inode_t *ioc_inode, off_t offset)
{
- ioc_table_t *table = NULL;
- ioc_page_t *page = NULL;
- off_t rounded_offset = 0;
- ioc_page_t *newpage = NULL;
+ ioc_table_t *table = NULL;
+ ioc_page_t *page = NULL;
+ off_t rounded_offset = 0;
+ ioc_page_t *newpage = NULL;
- GF_VALIDATE_OR_GOTO ("io-cache", ioc_inode, out);
+ GF_VALIDATE_OR_GOTO("io-cache", ioc_inode, out);
- table = ioc_inode->table;
- GF_VALIDATE_OR_GOTO ("io-cache", table, out);
+ table = ioc_inode->table;
+ GF_VALIDATE_OR_GOTO("io-cache", table, out);
- rounded_offset = floor (offset, table->page_size);
+ rounded_offset = floor(offset, table->page_size);
- newpage = GF_CALLOC (1, sizeof (*newpage), gf_ioc_mt_ioc_newpage_t);
- if (newpage == NULL) {
- goto out;
- }
+ newpage = GF_CALLOC(1, sizeof(*newpage), gf_ioc_mt_ioc_newpage_t);
+ if (newpage == NULL) {
+ goto out;
+ }
- if (!ioc_inode) {
- GF_FREE (newpage);
- newpage = NULL;
- goto out;
- }
+ if (!ioc_inode) {
+ GF_FREE(newpage);
+ newpage = NULL;
+ goto out;
+ }
- newpage->offset = rounded_offset;
- newpage->inode = ioc_inode;
- pthread_mutex_init (&newpage->page_lock, NULL);
+ newpage->offset = rounded_offset;
+ newpage->inode = ioc_inode;
+ pthread_mutex_init(&newpage->page_lock, NULL);
- rbthash_insert (ioc_inode->cache.page_table, newpage, &rounded_offset,
- sizeof (rounded_offset));
+ rbthash_insert(ioc_inode->cache.page_table, newpage, &rounded_offset,
+ sizeof(rounded_offset));
- list_add_tail (&newpage->page_lru, &ioc_inode->cache.page_lru);
+ list_add_tail(&newpage->page_lru, &ioc_inode->cache.page_lru);
- page = newpage;
+ page = newpage;
- gf_msg_trace ("io-cache", 0,
- "returning new page %p", page);
+ gf_msg_trace("io-cache", 0, "returning new page %p", page);
out:
- return page;
+ return page;
}
/*
@@ -297,56 +293,55 @@ out:
*
*/
void
-__ioc_wait_on_page (ioc_page_t *page, call_frame_t *frame, off_t offset,
- size_t size)
+__ioc_wait_on_page(ioc_page_t *page, call_frame_t *frame, off_t offset,
+ size_t size)
{
- ioc_waitq_t *waitq = NULL;
- ioc_local_t *local = NULL;
-
- GF_VALIDATE_OR_GOTO ("io-cache", frame, out);
- local = frame->local;
-
- GF_VALIDATE_OR_GOTO (frame->this->name, local, out);
-
- if (page == NULL) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- gf_msg (frame->this->name, GF_LOG_WARNING,
- 0, IO_CACHE_MSG_NO_MEMORY,
- "asked to wait on a NULL page");
- goto out;
- }
-
- waitq = GF_CALLOC (1, sizeof (*waitq), gf_ioc_mt_ioc_waitq_t);
- if (waitq == NULL) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- goto out;
- }
-
- gf_msg_trace (frame->this->name, 0,
- "frame(%p) waiting on page = %p, offset=%"PRId64", "
- "size=%"GF_PRI_SIZET"",
- frame, page, offset, size);
-
- waitq->data = frame;
- waitq->next = page->waitq;
- waitq->pending_offset = offset;
- waitq->pending_size = size;
- page->waitq = waitq;
- /* one frame can wait only once on a given page,
- * local->wait_count is number of pages a frame is waiting on */
- ioc_local_lock (local);
- {
- local->wait_count++;
- }
- ioc_local_unlock (local);
+ ioc_waitq_t *waitq = NULL;
+ ioc_local_t *local = NULL;
+
+ GF_VALIDATE_OR_GOTO("io-cache", frame, out);
+ local = frame->local;
+
+ GF_VALIDATE_OR_GOTO(frame->this->name, local, out);
+
+ if (page == NULL) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ gf_msg(frame->this->name, GF_LOG_WARNING, 0, IO_CACHE_MSG_NO_MEMORY,
+ "asked to wait on a NULL page");
+ goto out;
+ }
+
+ waitq = GF_CALLOC(1, sizeof(*waitq), gf_ioc_mt_ioc_waitq_t);
+ if (waitq == NULL) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ goto out;
+ }
+
+ gf_msg_trace(frame->this->name, 0,
+ "frame(%p) waiting on page = %p, offset=%" PRId64
+ ", "
+ "size=%" GF_PRI_SIZET "",
+ frame, page, offset, size);
+
+ waitq->data = frame;
+ waitq->next = page->waitq;
+ waitq->pending_offset = offset;
+ waitq->pending_size = size;
+ page->waitq = waitq;
+ /* one frame can wait only once on a given page,
+ * local->wait_count is number of pages a frame is waiting on */
+ ioc_local_lock(local);
+ {
+ local->wait_count++;
+ }
+ ioc_local_unlock(local);
out:
- return;
+ return;
}
-
/*
* ioc_cache_still_valid - see if cached pages ioc_inode are still valid
* against given stbuf
@@ -357,11 +352,11 @@ out:
* assumes ioc_inode is locked
*/
int8_t
-ioc_cache_still_valid (ioc_inode_t *ioc_inode, struct iatt *stbuf)
+ioc_cache_still_valid(ioc_inode_t *ioc_inode, struct iatt *stbuf)
{
- int8_t cache_still_valid = 1;
+ int8_t cache_still_valid = 1;
- GF_VALIDATE_OR_GOTO ("io-cache", ioc_inode, out);
+ GF_VALIDATE_OR_GOTO("io-cache", ioc_inode, out);
#if 0
if (!stbuf || (stbuf->ia_mtime != ioc_inode->cache.mtime) ||
@@ -369,9 +364,9 @@ ioc_cache_still_valid (ioc_inode_t *ioc_inode, struct iatt *stbuf)
cache_still_valid = 0;
#else
- if (!stbuf || (stbuf->ia_mtime != ioc_inode->cache.mtime)
- || (stbuf->ia_mtime_nsec != ioc_inode->cache.mtime_nsec))
- cache_still_valid = 0;
+ if (!stbuf || (stbuf->ia_mtime != ioc_inode->cache.mtime) ||
+ (stbuf->ia_mtime_nsec != ioc_inode->cache.mtime_nsec))
+ cache_still_valid = 0;
#endif
@@ -384,185 +379,174 @@ ioc_cache_still_valid (ioc_inode_t *ioc_inode, struct iatt *stbuf)
#endif
out:
- return cache_still_valid;
+ return cache_still_valid;
}
-
void
-ioc_waitq_return (ioc_waitq_t *waitq)
+ioc_waitq_return(ioc_waitq_t *waitq)
{
- ioc_waitq_t *trav = NULL;
- ioc_waitq_t *next = NULL;
- call_frame_t *frame = NULL;
+ ioc_waitq_t *trav = NULL;
+ ioc_waitq_t *next = NULL;
+ call_frame_t *frame = NULL;
- for (trav = waitq; trav; trav = next) {
- next = trav->next;
+ for (trav = waitq; trav; trav = next) {
+ next = trav->next;
- frame = trav->data;
- ioc_frame_return (frame);
- GF_FREE (trav);
- }
+ frame = trav->data;
+ ioc_frame_return(frame);
+ GF_FREE(trav);
+ }
}
-
int
-ioc_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iovec *vector,
- int32_t count, struct iatt *stbuf, struct iobref *iobref,
- dict_t *xdata)
+ioc_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iovec *vector, int32_t count,
+ struct iatt *stbuf, struct iobref *iobref, dict_t *xdata)
{
- ioc_local_t *local = NULL;
- off_t offset = 0;
- ioc_inode_t *ioc_inode = NULL;
- ioc_table_t *table = NULL;
- ioc_page_t *page = NULL;
- int32_t destroy_size = 0;
- size_t page_size = 0;
- ioc_waitq_t *waitq = NULL;
- size_t iobref_page_size = 0;
- char zero_filled = 0;
-
- GF_ASSERT (frame);
-
- local = frame->local;
- GF_ASSERT (local);
-
- offset = local->pending_offset;
- ioc_inode = local->inode;
- GF_ASSERT (ioc_inode);
+ ioc_local_t *local = NULL;
+ off_t offset = 0;
+ ioc_inode_t *ioc_inode = NULL;
+ ioc_table_t *table = NULL;
+ ioc_page_t *page = NULL;
+ int32_t destroy_size = 0;
+ size_t page_size = 0;
+ ioc_waitq_t *waitq = NULL;
+ size_t iobref_page_size = 0;
+ char zero_filled = 0;
+
+ GF_ASSERT(frame);
+
+ local = frame->local;
+ GF_ASSERT(local);
+
+ offset = local->pending_offset;
+ ioc_inode = local->inode;
+ GF_ASSERT(ioc_inode);
+
+ table = ioc_inode->table;
+ GF_ASSERT(table);
+
+ zero_filled = ((op_ret >= 0) && (stbuf->ia_mtime == 0));
+
+ ioc_inode_lock(ioc_inode);
+ {
+ if (op_ret == -1 ||
+ !(zero_filled || ioc_cache_still_valid(ioc_inode, stbuf))) {
+ gf_msg_trace(ioc_inode->table->xl->name, 0,
+ "cache for inode(%p) is invalid. flushing "
+ "all pages",
+ ioc_inode);
+ destroy_size = __ioc_inode_flush(ioc_inode);
+ }
- table = ioc_inode->table;
- GF_ASSERT (table);
+ if ((op_ret >= 0) && !zero_filled) {
+ ioc_inode->cache.mtime = stbuf->ia_mtime;
+ ioc_inode->cache.mtime_nsec = stbuf->ia_mtime_nsec;
+ }
- zero_filled = ((op_ret >=0) && (stbuf->ia_mtime == 0));
+ gettimeofday(&ioc_inode->cache.tv, NULL);
- ioc_inode_lock (ioc_inode);
- {
- if (op_ret == -1 || !(zero_filled ||
- ioc_cache_still_valid(ioc_inode,
- stbuf))) {
- gf_msg_trace (ioc_inode->table->xl->name, 0,
- "cache for inode(%p) is invalid. flushing "
- "all pages", ioc_inode);
- destroy_size = __ioc_inode_flush (ioc_inode);
+ if (op_ret < 0) {
+ /* error, readv returned -1 */
+ page = __ioc_page_get(ioc_inode, offset);
+ if (page)
+ waitq = __ioc_page_error(page, op_ret, op_errno);
+ } else {
+ gf_msg_trace(ioc_inode->table->xl->name, 0, "op_ret = %d", op_ret);
+ page = __ioc_page_get(ioc_inode, offset);
+ if (!page) {
+ /* page was flushed */
+ /* some serious bug ? */
+ gf_msg(frame->this->name, GF_LOG_WARNING, 0,
+ IO_CACHE_MSG_WASTED_COPY,
+ "wasted copy: %" PRId64 "[+%" PRId64
+ "] "
+ "ioc_inode=%p",
+ offset, table->page_size, ioc_inode);
+ } else {
+ if (page->vector) {
+ iobref_unref(page->iobref);
+ GF_FREE(page->vector);
+ page->vector = NULL;
+ page->iobref = NULL;
}
- if ((op_ret >= 0) && !zero_filled) {
- ioc_inode->cache.mtime = stbuf->ia_mtime;
- ioc_inode->cache.mtime_nsec = stbuf->ia_mtime_nsec;
+ /* keep a copy of the page for our cache */
+ page->vector = iov_dup(vector, count);
+ if (page->vector == NULL) {
+ page = __ioc_page_get(ioc_inode, offset);
+ if (page != NULL)
+ waitq = __ioc_page_error(page, -1, ENOMEM);
+ goto unlock;
}
- gettimeofday (&ioc_inode->cache.tv, NULL);
-
- if (op_ret < 0) {
- /* error, readv returned -1 */
- page = __ioc_page_get (ioc_inode, offset);
- if (page)
- waitq = __ioc_page_error (page, op_ret,
- op_errno);
+ page->count = count;
+ if (iobref) {
+ page->iobref = iobref_ref(iobref);
} else {
- gf_msg_trace (ioc_inode->table->xl->name, 0,
- "op_ret = %d", op_ret);
- page = __ioc_page_get (ioc_inode, offset);
- if (!page) {
- /* page was flushed */
- /* some serious bug ? */
- gf_msg (frame->this->name, GF_LOG_WARNING, 0,
- IO_CACHE_MSG_WASTED_COPY,
- "wasted copy: %"PRId64"[+%"PRId64"] "
- "ioc_inode=%p", offset,
- table->page_size, ioc_inode);
- } else {
- if (page->vector) {
- iobref_unref (page->iobref);
- GF_FREE (page->vector);
- page->vector = NULL;
- page->iobref = NULL;
- }
-
- /* keep a copy of the page for our cache */
- page->vector = iov_dup (vector, count);
- if (page->vector == NULL) {
- page = __ioc_page_get (ioc_inode,
- offset);
- if (page != NULL)
- waitq = __ioc_page_error (page,
- -1,
- ENOMEM);
- goto unlock;
- }
-
- page->count = count;
- if (iobref) {
- page->iobref = iobref_ref (iobref);
- } else {
- /* TODO: we have got a response to
- * our request and no data */
- gf_msg (frame->this->name,
- GF_LOG_CRITICAL,
- ENOMEM, IO_CACHE_MSG_NO_MEMORY,
- "frame>root>rsp_refs is null");
- } /* if(frame->root->rsp_refs) */
-
- /* page->size should indicate exactly how
- * much the readv call to the child
- * translator returned. earlier op_ret
- * from child translator was used, which
- * gave rise to a bug where reads from
- * io-cached volume were resulting in 0
- * byte replies */
- page_size = iov_length(vector, count);
- page->size = page_size;
- page->op_errno = op_errno;
-
- iobref_page_size = iobref_size (page->iobref);
-
- if (page->waitq) {
- /* wake up all the frames waiting on
- * this page, including
- * the frame which triggered fault */
- waitq = __ioc_page_wakeup (page,
- op_errno);
- } /* if(page->waitq) */
- } /* if(!page)...else */
- } /* if(op_ret < 0)...else */
- } /* ioc_inode locked region end */
+ /* TODO: we have got a response to
+ * our request and no data */
+ gf_msg(frame->this->name, GF_LOG_CRITICAL, ENOMEM,
+ IO_CACHE_MSG_NO_MEMORY,
+ "frame>root>rsp_refs is null");
+ } /* if(frame->root->rsp_refs) */
+
+ /* page->size should indicate exactly how
+ * much the readv call to the child
+ * translator returned. earlier op_ret
+ * from child translator was used, which
+ * gave rise to a bug where reads from
+ * io-cached volume were resulting in 0
+ * byte replies */
+ page_size = iov_length(vector, count);
+ page->size = page_size;
+ page->op_errno = op_errno;
+
+ iobref_page_size = iobref_size(page->iobref);
+
+ if (page->waitq) {
+ /* wake up all the frames waiting on
+ * this page, including
+ * the frame which triggered fault */
+ waitq = __ioc_page_wakeup(page, op_errno);
+ } /* if(page->waitq) */
+ } /* if(!page)...else */
+ } /* if(op_ret < 0)...else */
+ } /* ioc_inode locked region end */
unlock:
- ioc_inode_unlock (ioc_inode);
+ ioc_inode_unlock(ioc_inode);
- ioc_waitq_return (waitq);
+ ioc_waitq_return(waitq);
- if (iobref_page_size) {
- ioc_table_lock (table);
- {
- table->cache_used += iobref_page_size;
- }
- ioc_table_unlock (table);
+ if (iobref_page_size) {
+ ioc_table_lock(table);
+ {
+ table->cache_used += iobref_page_size;
}
+ ioc_table_unlock(table);
+ }
- if (destroy_size) {
- ioc_table_lock (table);
- {
- table->cache_used -= destroy_size;
- }
- ioc_table_unlock (table);
+ if (destroy_size) {
+ ioc_table_lock(table);
+ {
+ table->cache_used -= destroy_size;
}
+ ioc_table_unlock(table);
+ }
- if (ioc_need_prune (ioc_inode->table)) {
- ioc_prune (ioc_inode->table);
- }
+ if (ioc_need_prune(ioc_inode->table)) {
+ ioc_prune(ioc_inode->table);
+ }
- gf_msg_trace (frame->this->name, 0, "fault frame %p returned",
- frame);
- pthread_mutex_destroy (&local->local_lock);
+ gf_msg_trace(frame->this->name, 0, "fault frame %p returned", frame);
+ pthread_mutex_destroy(&local->local_lock);
- fd_unref (local->fd);
+ fd_unref(local->fd);
- STACK_DESTROY (frame->root);
- return 0;
+ STACK_DESTROY(frame->root);
+ return 0;
}
-
/*
* ioc_page_fault -
*
@@ -573,221 +557,214 @@ unlock:
*
*/
void
-ioc_page_fault (ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
- off_t offset)
+ioc_page_fault(ioc_inode_t *ioc_inode, call_frame_t *frame, fd_t *fd,
+ off_t offset)
{
- ioc_table_t *table = NULL;
- call_frame_t *fault_frame = NULL;
- ioc_local_t *fault_local = NULL;
- int32_t op_ret = -1, op_errno = -1;
- ioc_waitq_t *waitq = NULL;
- ioc_page_t *page = NULL;
-
- GF_ASSERT (ioc_inode);
- if (frame == NULL) {
- op_ret = -1;
- op_errno = EINVAL;
- gf_msg ("io-cache", GF_LOG_WARNING,
- EINVAL, IO_CACHE_MSG_ENFORCEMENT_FAILED,
- "page fault on a NULL frame");
- goto err;
- }
-
- table = ioc_inode->table;
- fault_frame = copy_frame (frame);
- if (fault_frame == NULL) {
- op_ret = -1;
- op_errno = ENOMEM;
- goto err;
- }
-
- fault_local = mem_get0 (THIS->local_pool);
- if (fault_local == NULL) {
- op_ret = -1;
- op_errno = ENOMEM;
- STACK_DESTROY (fault_frame->root);
- goto err;
- }
-
- /* NOTE: copy_frame() means, the frame the fop whose fd_ref we
- * are using till now won't be valid till we get reply from server.
- * we unref this fd, in fault_cbk */
- fault_local->fd = fd_ref (fd);
-
- fault_frame->local = fault_local;
- pthread_mutex_init (&fault_local->local_lock, NULL);
-
- INIT_LIST_HEAD (&fault_local->fill_list);
- fault_local->pending_offset = offset;
- fault_local->pending_size = table->page_size;
- fault_local->inode = ioc_inode;
-
- gf_msg_trace (frame->this->name, 0,
- "stack winding page fault for offset = %"PRId64" with "
- "frame %p", offset, fault_frame);
-
- STACK_WIND (fault_frame, ioc_fault_cbk, FIRST_CHILD(fault_frame->this),
- FIRST_CHILD(fault_frame->this)->fops->readv, fd,
- table->page_size, offset, 0, NULL);
- return;
+ ioc_table_t *table = NULL;
+ call_frame_t *fault_frame = NULL;
+ ioc_local_t *fault_local = NULL;
+ int32_t op_ret = -1, op_errno = -1;
+ ioc_waitq_t *waitq = NULL;
+ ioc_page_t *page = NULL;
+
+ GF_ASSERT(ioc_inode);
+ if (frame == NULL) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ gf_msg("io-cache", GF_LOG_WARNING, EINVAL,
+ IO_CACHE_MSG_ENFORCEMENT_FAILED, "page fault on a NULL frame");
+ goto err;
+ }
+
+ table = ioc_inode->table;
+ fault_frame = copy_frame(frame);
+ if (fault_frame == NULL) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ fault_local = mem_get0(THIS->local_pool);
+ if (fault_local == NULL) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ STACK_DESTROY(fault_frame->root);
+ goto err;
+ }
+
+ /* NOTE: copy_frame() means, the frame the fop whose fd_ref we
+ * are using till now won't be valid till we get reply from server.
+ * we unref this fd, in fault_cbk */
+ fault_local->fd = fd_ref(fd);
+
+ fault_frame->local = fault_local;
+ pthread_mutex_init(&fault_local->local_lock, NULL);
+
+ INIT_LIST_HEAD(&fault_local->fill_list);
+ fault_local->pending_offset = offset;
+ fault_local->pending_size = table->page_size;
+ fault_local->inode = ioc_inode;
+
+ gf_msg_trace(frame->this->name, 0,
+ "stack winding page fault for offset = %" PRId64
+ " with "
+ "frame %p",
+ offset, fault_frame);
+
+ STACK_WIND(fault_frame, ioc_fault_cbk, FIRST_CHILD(fault_frame->this),
+ FIRST_CHILD(fault_frame->this)->fops->readv, fd,
+ table->page_size, offset, 0, NULL);
+ return;
err:
- ioc_inode_lock (ioc_inode);
- {
- page = __ioc_page_get (ioc_inode, offset);
- if (page != NULL) {
- waitq = __ioc_page_error (page, op_ret, op_errno);
- }
+ ioc_inode_lock(ioc_inode);
+ {
+ page = __ioc_page_get(ioc_inode, offset);
+ if (page != NULL) {
+ waitq = __ioc_page_error(page, op_ret, op_errno);
}
- ioc_inode_unlock (ioc_inode);
+ }
+ ioc_inode_unlock(ioc_inode);
- if (waitq != NULL) {
- ioc_waitq_return (waitq);
- }
+ if (waitq != NULL) {
+ ioc_waitq_return(waitq);
+ }
}
-
int32_t
-__ioc_frame_fill (ioc_page_t *page, call_frame_t *frame, off_t offset,
- size_t size, int32_t op_errno)
+__ioc_frame_fill(ioc_page_t *page, call_frame_t *frame, off_t offset,
+ size_t size, int32_t op_errno)
{
- ioc_local_t *local = NULL;
- ioc_fill_t *fill = NULL;
- off_t src_offset = 0;
- off_t dst_offset = 0;
- ssize_t copy_size = 0;
- ioc_inode_t *ioc_inode = NULL;
- ioc_fill_t *new = NULL;
- int8_t found = 0;
- int32_t ret = -1;
-
- GF_VALIDATE_OR_GOTO ("io-cache", frame, out);
-
- local = frame->local;
- GF_VALIDATE_OR_GOTO (frame->this->name, local, out);
-
- if (page == NULL) {
- gf_msg (frame->this->name, GF_LOG_WARNING, 0,
- IO_CACHE_MSG_ENFORCEMENT_FAILED,
- "NULL page has been provided to serve read request");
- local->op_ret = -1;
- local->op_errno = EINVAL;
- goto out;
+ ioc_local_t *local = NULL;
+ ioc_fill_t *fill = NULL;
+ off_t src_offset = 0;
+ off_t dst_offset = 0;
+ ssize_t copy_size = 0;
+ ioc_inode_t *ioc_inode = NULL;
+ ioc_fill_t *new = NULL;
+ int8_t found = 0;
+ int32_t ret = -1;
+
+ GF_VALIDATE_OR_GOTO("io-cache", frame, out);
+
+ local = frame->local;
+ GF_VALIDATE_OR_GOTO(frame->this->name, local, out);
+
+ if (page == NULL) {
+ gf_msg(frame->this->name, GF_LOG_WARNING, 0,
+ IO_CACHE_MSG_ENFORCEMENT_FAILED,
+ "NULL page has been provided to serve read request");
+ local->op_ret = -1;
+ local->op_errno = EINVAL;
+ goto out;
+ }
+
+ ioc_inode = page->inode;
+
+ gf_msg_trace(frame->this->name, 0,
+ "frame (%p) offset = %" PRId64 " && size = %" GF_PRI_SIZET
+ " "
+ "&& page->size = %" GF_PRI_SIZET " && wait_count = %d",
+ frame, offset, size, page->size, local->wait_count);
+
+ /* immediately move this page to the end of the page_lru list */
+ list_move_tail(&page->page_lru, &ioc_inode->cache.page_lru);
+ /* fill local->pending_size bytes from local->pending_offset */
+ if (local->op_ret != -1) {
+ local->op_errno = op_errno;
+
+ if (page->size == 0) {
+ goto done;
}
- ioc_inode = page->inode;
-
- gf_msg_trace (frame->this->name, 0,
- "frame (%p) offset = %"PRId64" && size = %"GF_PRI_SIZET" "
- "&& page->size = %"GF_PRI_SIZET" && wait_count = %d",
- frame, offset, size, page->size, local->wait_count);
+ if (offset > page->offset)
+ /* offset is offset in file, convert it to offset in
+ * page */
+ src_offset = offset - page->offset;
+ /*FIXME: since offset is the offset within page is the
+ * else case valid? */
+ else
+ /* local->pending_offset is in previous page. do not
+ * fill until we have filled all previous pages */
+ dst_offset = page->offset - offset;
+
+ /* we have to copy from offset to either end of this page
+ * or till the requested size */
+ copy_size = min(page->size - src_offset, size - dst_offset);
+
+ if (copy_size < 0) {
+ /* if page contains fewer bytes and the required offset
+ is beyond the page size in the page */
+ copy_size = src_offset = 0;
+ }
- /* immediately move this page to the end of the page_lru list */
- list_move_tail (&page->page_lru, &ioc_inode->cache.page_lru);
- /* fill local->pending_size bytes from local->pending_offset */
- if (local->op_ret != -1) {
- local->op_errno = op_errno;
+ gf_msg_trace(page->inode->table->xl->name, 0,
+ "copy_size = %" GF_PRI_SIZET
+ " && src_offset = "
+ "%" PRId64 " && dst_offset = %" PRId64 "",
+ copy_size, src_offset, dst_offset);
- if (page->size == 0) {
- goto done;
- }
+ {
+ new = GF_CALLOC(1, sizeof(*new), gf_ioc_mt_ioc_fill_t);
+ if (new == NULL) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ goto out;
+ }
- if (offset > page->offset)
- /* offset is offset in file, convert it to offset in
- * page */
- src_offset = offset - page->offset;
- /*FIXME: since offset is the offset within page is the
- * else case valid? */
- else
- /* local->pending_offset is in previous page. do not
- * fill until we have filled all previous pages */
- dst_offset = page->offset - offset;
-
- /* we have to copy from offset to either end of this page
- * or till the requested size */
- copy_size = min (page->size - src_offset,
- size - dst_offset);
-
- if (copy_size < 0) {
- /* if page contains fewer bytes and the required offset
- is beyond the page size in the page */
- copy_size = src_offset = 0;
- }
+ new->offset = page->offset;
+ new->size = copy_size;
+ new->iobref = iobref_ref(page->iobref);
+ new->count = iov_subset(page->vector, page->count, src_offset,
+ src_offset + copy_size, NULL);
- gf_msg_trace (page->inode->table->xl->name, 0,
- "copy_size = %"GF_PRI_SIZET" && src_offset = "
- "%"PRId64" && dst_offset = %"PRId64"",
- copy_size, src_offset, dst_offset);
+ new->vector = GF_CALLOC(new->count, sizeof(struct iovec),
+ gf_ioc_mt_iovec);
+ if (new->vector == NULL) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ iobref_unref(new->iobref);
+ GF_FREE(new);
+ goto out;
+ }
+
+ new->count = iov_subset(page->vector, page->count, src_offset,
+ src_offset + copy_size, new->vector);
+
+ /* add the ioc_fill to fill_list for this frame */
+ if (list_empty(&local->fill_list)) {
+ /* if list is empty, then this is the first
+ * time we are filling frame, add the
+ * ioc_fill_t to the end of list */
+ list_add_tail(&new->list, &local->fill_list);
+ } else {
+ found = 0;
+ /* list is not empty, we need to look for
+ * where this offset fits in list */
+ list_for_each_entry(fill, &local->fill_list, list)
{
- new = GF_CALLOC (1, sizeof (*new),
- gf_ioc_mt_ioc_fill_t);
- if (new == NULL) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- goto out;
- }
-
- new->offset = page->offset;
- new->size = copy_size;
- new->iobref = iobref_ref (page->iobref);
- new->count = iov_subset (page->vector, page->count,
- src_offset,
- src_offset + copy_size,
- NULL);
-
- new->vector = GF_CALLOC (new->count,
- sizeof (struct iovec),
- gf_ioc_mt_iovec);
- if (new->vector == NULL) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
-
- iobref_unref (new->iobref);
- GF_FREE (new);
- goto out;
- }
-
- new->count = iov_subset (page->vector, page->count,
- src_offset,
- src_offset + copy_size,
- new->vector);
-
- /* add the ioc_fill to fill_list for this frame */
- if (list_empty (&local->fill_list)) {
- /* if list is empty, then this is the first
- * time we are filling frame, add the
- * ioc_fill_t to the end of list */
- list_add_tail (&new->list, &local->fill_list);
- } else {
- found = 0;
- /* list is not empty, we need to look for
- * where this offset fits in list */
- list_for_each_entry (fill, &local->fill_list,
- list) {
- if (fill->offset > new->offset) {
- found = 1;
- break;
- }
- }
-
- if (found) {
- list_add_tail (&new->list,
- &fill->list);
- } else {
- list_add_tail (&new->list,
- &local->fill_list);
- }
- }
+ if (fill->offset > new->offset) {
+ found = 1;
+ break;
+ }
}
- local->op_ret += copy_size;
+ if (found) {
+ list_add_tail(&new->list, &fill->list);
+ } else {
+ list_add_tail(&new->list, &local->fill_list);
+ }
+ }
}
+ local->op_ret += copy_size;
+ }
+
done:
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
/*
@@ -800,107 +777,107 @@ out:
*
*/
static void
-ioc_frame_unwind (call_frame_t *frame)
+ioc_frame_unwind(call_frame_t *frame)
{
- ioc_local_t *local = NULL;
- ioc_fill_t *fill = NULL, *next = NULL;
- int32_t count = 0;
- struct iovec *vector = NULL;
- int32_t copied = 0;
- struct iobref *iobref = NULL;
- struct iatt stbuf = {0,};
- int32_t op_ret = 0, op_errno = 0;
-
- GF_ASSERT (frame);
-
- local = frame->local;
- if (local == NULL) {
- gf_msg (frame->this->name, GF_LOG_WARNING, ENOMEM,
- IO_CACHE_MSG_NO_MEMORY, "local is NULL");
+ ioc_local_t *local = NULL;
+ ioc_fill_t *fill = NULL, *next = NULL;
+ int32_t count = 0;
+ struct iovec *vector = NULL;
+ int32_t copied = 0;
+ struct iobref *iobref = NULL;
+ struct iatt stbuf = {
+ 0,
+ };
+ int32_t op_ret = 0, op_errno = 0;
+
+ GF_ASSERT(frame);
+
+ local = frame->local;
+ if (local == NULL) {
+ gf_msg(frame->this->name, GF_LOG_WARNING, ENOMEM,
+ IO_CACHE_MSG_NO_MEMORY, "local is NULL");
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto unwind;
+ }
+
+ if (local->op_ret < 0) {
+ op_ret = local->op_ret;
+ op_errno = local->op_errno;
+ goto unwind;
+ }
+
+ // ioc_local_lock (local);
+ iobref = iobref_new();
+ if (iobref == NULL) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ }
+
+ if (list_empty(&local->fill_list)) {
+ gf_msg_trace(frame->this->name, 0,
+ "frame(%p) has 0 entries in local->fill_list "
+ "(offset = %" PRId64 " && size = %" GF_PRI_SIZET ")",
+ frame, local->offset, local->size);
+ }
+
+ list_for_each_entry(fill, &local->fill_list, list) { count += fill->count; }
+
+ vector = GF_CALLOC(count, sizeof(*vector), gf_ioc_mt_iovec);
+ if (vector == NULL) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ }
+
+ list_for_each_entry_safe(fill, next, &local->fill_list, list)
+ {
+ /* # TODO: check why this if clause is needed at all. */
+ if ((vector != NULL) && (iobref != NULL)) {
+ memcpy(((char *)vector) + copied, fill->vector,
+ fill->count * sizeof(*vector));
+
+ copied += (fill->count * sizeof(*vector));
+
+ if (iobref_merge(iobref, fill->iobref)) {
op_ret = -1;
op_errno = ENOMEM;
- goto unwind;
+ }
}
- if (local->op_ret < 0) {
- op_ret = local->op_ret;
- op_errno = local->op_errno;
- goto unwind;
- }
+ list_del(&fill->list);
+ iobref_unref(fill->iobref);
+ GF_FREE(fill->vector);
+ GF_FREE(fill);
+ }
- // ioc_local_lock (local);
- iobref = iobref_new ();
- if (iobref == NULL) {
- op_ret = -1;
- op_errno = ENOMEM;
- }
-
- if (list_empty (&local->fill_list)) {
- gf_msg_trace (frame->this->name, 0,
- "frame(%p) has 0 entries in local->fill_list "
- "(offset = %"PRId64" && size = %"GF_PRI_SIZET")",
- frame, local->offset, local->size);
- }
-
- list_for_each_entry (fill, &local->fill_list, list) {
- count += fill->count;
- }
-
- vector = GF_CALLOC (count, sizeof (*vector), gf_ioc_mt_iovec);
- if (vector == NULL) {
- op_ret = -1;
- op_errno = ENOMEM;
- }
-
- list_for_each_entry_safe (fill, next, &local->fill_list, list) {
- /* # TODO: check why this if clause is needed at all. */
- if ((vector != NULL) && (iobref != NULL)) {
- memcpy (((char *)vector) + copied,
- fill->vector,
- fill->count * sizeof (*vector));
-
- copied += (fill->count * sizeof (*vector));
-
- if (iobref_merge (iobref, fill->iobref)) {
- op_ret = -1;
- op_errno = ENOMEM;
- }
- }
-
- list_del (&fill->list);
- iobref_unref (fill->iobref);
- GF_FREE (fill->vector);
- GF_FREE (fill);
- }
-
- if (op_ret != -1) {
- op_ret = iov_length (vector, count);
- }
+ if (op_ret != -1) {
+ op_ret = iov_length(vector, count);
+ }
unwind:
- gf_msg_trace (frame->this->name, 0,
- "frame(%p) unwinding with op_ret=%d", frame, op_ret);
+ gf_msg_trace(frame->this->name, 0, "frame(%p) unwinding with op_ret=%d",
+ frame, op_ret);
- // ioc_local_unlock (local);
+ // ioc_local_unlock (local);
- frame->local = NULL;
- STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno, vector,
- count, &stbuf, iobref, NULL);
+ frame->local = NULL;
+ STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, vector, count, &stbuf,
+ iobref, NULL);
- if (iobref != NULL) {
- iobref_unref (iobref);
- }
+ if (iobref != NULL) {
+ iobref_unref(iobref);
+ }
- if (vector != NULL) {
- GF_FREE (vector);
- vector = NULL;
- }
+ if (vector != NULL) {
+ GF_FREE(vector);
+ vector = NULL;
+ }
- if (local) {
- pthread_mutex_destroy (&local->local_lock);
- mem_put (local);
- }
- return;
+ if (local) {
+ pthread_mutex_destroy(&local->local_lock);
+ mem_put(local);
+ }
+ return;
}
/*
@@ -910,27 +887,27 @@ unwind:
* to be called only when a frame is waiting on an in-transit page
*/
void
-ioc_frame_return (call_frame_t *frame)
+ioc_frame_return(call_frame_t *frame)
{
- ioc_local_t *local = NULL;
- int32_t wait_count = 0;
+ ioc_local_t *local = NULL;
+ int32_t wait_count = 0;
- GF_ASSERT (frame);
+ GF_ASSERT(frame);
- local = frame->local;
- GF_ASSERT (local->wait_count > 0);
+ local = frame->local;
+ GF_ASSERT(local->wait_count > 0);
- ioc_local_lock (local);
- {
- wait_count = --local->wait_count;
- }
- ioc_local_unlock (local);
+ ioc_local_lock(local);
+ {
+ wait_count = --local->wait_count;
+ }
+ ioc_local_unlock(local);
- if (!wait_count) {
- ioc_frame_unwind (frame);
- }
+ if (!wait_count) {
+ ioc_frame_unwind(frame);
+ }
- return;
+ return;
}
/*
@@ -940,41 +917,39 @@ ioc_frame_return (call_frame_t *frame)
* to be called only when a frame is waiting on an in-transit page
*/
ioc_waitq_t *
-__ioc_page_wakeup (ioc_page_t *page, int32_t op_errno)
+__ioc_page_wakeup(ioc_page_t *page, int32_t op_errno)
{
- ioc_waitq_t *waitq = NULL, *trav = NULL;
- call_frame_t *frame = NULL;
- int32_t ret = -1;
+ ioc_waitq_t *waitq = NULL, *trav = NULL;
+ call_frame_t *frame = NULL;
+ int32_t ret = -1;
- GF_VALIDATE_OR_GOTO ("io-cache", page, out);
+ GF_VALIDATE_OR_GOTO("io-cache", page, out);
- waitq = page->waitq;
- page->waitq = NULL;
+ waitq = page->waitq;
+ page->waitq = NULL;
- page->ready = 1;
+ page->ready = 1;
- gf_msg_trace (page->inode->table->xl->name, 0,
- "page is %p && waitq = %p", page, waitq);
+ gf_msg_trace(page->inode->table->xl->name, 0, "page is %p && waitq = %p",
+ page, waitq);
- for (trav = waitq; trav; trav = trav->next) {
- frame = trav->data;
- ret = __ioc_frame_fill (page, frame, trav->pending_offset,
- trav->pending_size, op_errno);
- if (ret == -1) {
- break;
- }
+ for (trav = waitq; trav; trav = trav->next) {
+ frame = trav->data;
+ ret = __ioc_frame_fill(page, frame, trav->pending_offset,
+ trav->pending_size, op_errno);
+ if (ret == -1) {
+ break;
}
+ }
- if (page->stale) {
- __ioc_page_destroy (page);
- }
+ if (page->stale) {
+ __ioc_page_destroy(page);
+ }
out:
- return waitq;
+ return waitq;
}
-
-
/*
* ioc_page_error -
* @page:
@@ -983,46 +958,45 @@ out:
*
*/
ioc_waitq_t *
-__ioc_page_error (ioc_page_t *page, int32_t op_ret, int32_t op_errno)
+__ioc_page_error(ioc_page_t *page, int32_t op_ret, int32_t op_errno)
{
- ioc_waitq_t *waitq = NULL, *trav = NULL;
- call_frame_t *frame = NULL;
- int64_t ret = 0;
- ioc_table_t *table = NULL;
- ioc_local_t *local = NULL;
+ ioc_waitq_t *waitq = NULL, *trav = NULL;
+ call_frame_t *frame = NULL;
+ int64_t ret = 0;
+ ioc_table_t *table = NULL;
+ ioc_local_t *local = NULL;
- GF_VALIDATE_OR_GOTO ("io-cache", page, out);
+ GF_VALIDATE_OR_GOTO("io-cache", page, out);
- waitq = page->waitq;
- page->waitq = NULL;
+ waitq = page->waitq;
+ page->waitq = NULL;
- gf_msg_debug (page->inode->table->xl->name, 0,
- "page error for page = %p & waitq = %p", page, waitq);
+ gf_msg_debug(page->inode->table->xl->name, 0,
+ "page error for page = %p & waitq = %p", page, waitq);
- for (trav = waitq; trav; trav = trav->next) {
+ for (trav = waitq; trav; trav = trav->next) {
+ frame = trav->data;
- frame = trav->data;
-
- local = frame->local;
- ioc_local_lock (local);
- {
- if (local->op_ret != -1) {
- local->op_ret = op_ret;
- local->op_errno = op_errno;
- }
- }
- ioc_local_unlock (local);
+ local = frame->local;
+ ioc_local_lock(local);
+ {
+ if (local->op_ret != -1) {
+ local->op_ret = op_ret;
+ local->op_errno = op_errno;
+ }
}
+ ioc_local_unlock(local);
+ }
- table = page->inode->table;
- ret = __ioc_page_destroy (page);
+ table = page->inode->table;
+ ret = __ioc_page_destroy(page);
- if (ret != -1) {
- table->cache_used -= ret;
- }
+ if (ret != -1) {
+ table->cache_used -= ret;
+ }
out:
- return waitq;
+ return waitq;
}
/*
@@ -1033,22 +1007,22 @@ out:
*
*/
ioc_waitq_t *
-ioc_page_error (ioc_page_t *page, int32_t op_ret, int32_t op_errno)
+ioc_page_error(ioc_page_t *page, int32_t op_ret, int32_t op_errno)
{
- ioc_waitq_t *waitq = NULL;
- struct ioc_inode *inode = NULL;
+ ioc_waitq_t *waitq = NULL;
+ struct ioc_inode *inode = NULL;
- if (page == NULL) {
- goto out;
- }
+ if (page == NULL) {
+ goto out;
+ }
- ioc_inode_lock (page->inode);
- {
- inode = page->inode;
- waitq = __ioc_page_error (page, op_ret, op_errno);
- }
- ioc_inode_unlock (inode);
+ ioc_inode_lock(page->inode);
+ {
+ inode = page->inode;
+ waitq = __ioc_page_error(page, op_ret, op_errno);
+ }
+ ioc_inode_unlock(inode);
out:
- return waitq;
+ return waitq;
}
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
index 832291d3a6d..78678adb859 100644
--- a/xlators/performance/io-threads/src/io-threads.c
+++ b/xlators/performance/io-threads/src/io-threads.c
@@ -23,281 +23,281 @@
#include "io-threads-messages.h"
#include "timespec.h"
-void *iot_worker (void *arg);
-int iot_workers_scale (iot_conf_t *conf);
-int __iot_workers_scale (iot_conf_t *conf);
+void *
+iot_worker(void *arg);
+int
+iot_workers_scale(iot_conf_t *conf);
+int
+__iot_workers_scale(iot_conf_t *conf);
struct volume_options options[];
-#define IOT_FOP(name, frame, this, args ...) \
- do { \
- call_stub_t *__stub = NULL; \
- int __ret = -1; \
+#define IOT_FOP(name, frame, this, args...) \
+ do { \
+ call_stub_t *__stub = NULL; \
+ int __ret = -1; \
\
- __stub = fop_##name##_stub(frame, default_##name##_resume, args); \
- if (!__stub) { \
- __ret = -ENOMEM; \
- goto out; \
- } \
+ __stub = fop_##name##_stub(frame, default_##name##_resume, args); \
+ if (!__stub) { \
+ __ret = -ENOMEM; \
+ goto out; \
+ } \
\
- __ret = iot_schedule (frame, this, __stub); \
+ __ret = iot_schedule(frame, this, __stub); \
\
- out: \
- if (__ret < 0) { \
- default_##name##_failure_cbk (frame, -__ret); \
- if (__stub != NULL) { \
- call_stub_destroy (__stub); \
- } \
- } \
- } while (0)
+ out: \
+ if (__ret < 0) { \
+ default_##name##_failure_cbk(frame, -__ret); \
+ if (__stub != NULL) { \
+ call_stub_destroy(__stub); \
+ } \
+ } \
+ } while (0)
iot_client_ctx_t *
-iot_get_ctx (xlator_t *this, client_t *client)
-{
- iot_client_ctx_t *ctx = NULL;
- iot_client_ctx_t *setted_ctx = NULL;
- int i;
-
- if (client_ctx_get (client, this, (void **)&ctx) != 0) {
- ctx = GF_CALLOC (GF_FOP_PRI_MAX, sizeof(*ctx),
- gf_iot_mt_client_ctx_t);
- if (ctx) {
- for (i = 0; i < GF_FOP_PRI_MAX; ++i) {
- INIT_LIST_HEAD (&ctx[i].clients);
- INIT_LIST_HEAD (&ctx[i].reqs);
- }
- setted_ctx = client_ctx_set (client, this, ctx);
- if (ctx != setted_ctx) {
- GF_FREE (ctx);
- ctx = setted_ctx;
- }
- }
+iot_get_ctx(xlator_t *this, client_t *client)
+{
+ iot_client_ctx_t *ctx = NULL;
+ iot_client_ctx_t *setted_ctx = NULL;
+ int i;
+
+ if (client_ctx_get(client, this, (void **)&ctx) != 0) {
+ ctx = GF_CALLOC(GF_FOP_PRI_MAX, sizeof(*ctx), gf_iot_mt_client_ctx_t);
+ if (ctx) {
+ for (i = 0; i < GF_FOP_PRI_MAX; ++i) {
+ INIT_LIST_HEAD(&ctx[i].clients);
+ INIT_LIST_HEAD(&ctx[i].reqs);
+ }
+ setted_ctx = client_ctx_set(client, this, ctx);
+ if (ctx != setted_ctx) {
+ GF_FREE(ctx);
+ ctx = setted_ctx;
+ }
}
+ }
- return ctx;
+ return ctx;
}
call_stub_t *
-__iot_dequeue (iot_conf_t *conf, int *pri)
+__iot_dequeue(iot_conf_t *conf, int *pri)
{
- call_stub_t *stub = NULL;
- int i = 0;
- iot_client_ctx_t *ctx;
-
- *pri = -1;
- for (i = 0; i < GF_FOP_PRI_MAX; i++) {
+ call_stub_t *stub = NULL;
+ int i = 0;
+ iot_client_ctx_t *ctx;
- if (conf->ac_iot_count[i] >= conf->ac_iot_limit[i]) {
- continue;
- }
-
- if (list_empty (&conf->clients[i])) {
- continue;
- }
+ *pri = -1;
+ for (i = 0; i < GF_FOP_PRI_MAX; i++) {
+ if (conf->ac_iot_count[i] >= conf->ac_iot_limit[i]) {
+ continue;
+ }
- /* Get the first per-client queue for this priority. */
- ctx = list_first_entry (&conf->clients[i],
- iot_client_ctx_t, clients);
- if (!ctx) {
- continue;
- }
+ if (list_empty(&conf->clients[i])) {
+ continue;
+ }
- if (list_empty (&ctx->reqs)) {
- continue;
- }
+ /* Get the first per-client queue for this priority. */
+ ctx = list_first_entry(&conf->clients[i], iot_client_ctx_t, clients);
+ if (!ctx) {
+ continue;
+ }
- /* Get the first request on that queue. */
- stub = list_first_entry (&ctx->reqs, call_stub_t, list);
- list_del_init (&stub->list);
- if (list_empty (&ctx->reqs)) {
- list_del_init (&ctx->clients);
- } else {
- list_rotate_left (&conf->clients[i]);
- }
+ if (list_empty(&ctx->reqs)) {
+ continue;
+ }
- conf->ac_iot_count[i]++;
- conf->queue_marked[i] = _gf_false;
- *pri = i;
- break;
+ /* Get the first request on that queue. */
+ stub = list_first_entry(&ctx->reqs, call_stub_t, list);
+ list_del_init(&stub->list);
+ if (list_empty(&ctx->reqs)) {
+ list_del_init(&ctx->clients);
+ } else {
+ list_rotate_left(&conf->clients[i]);
}
- if (!stub)
- return NULL;
+ conf->ac_iot_count[i]++;
+ conf->queue_marked[i] = _gf_false;
+ *pri = i;
+ break;
+ }
+
+ if (!stub)
+ return NULL;
- conf->queue_size--;
- conf->queue_sizes[*pri]--;
+ conf->queue_size--;
+ conf->queue_sizes[*pri]--;
- return stub;
+ return stub;
}
void
-__iot_enqueue (iot_conf_t *conf, call_stub_t *stub, int pri)
+__iot_enqueue(iot_conf_t *conf, call_stub_t *stub, int pri)
{
- client_t *client = stub->frame->root->client;
- iot_client_ctx_t *ctx;
+ client_t *client = stub->frame->root->client;
+ iot_client_ctx_t *ctx;
- if (pri < 0 || pri >= GF_FOP_PRI_MAX)
- pri = GF_FOP_PRI_MAX-1;
+ if (pri < 0 || pri >= GF_FOP_PRI_MAX)
+ pri = GF_FOP_PRI_MAX - 1;
- if (client) {
- ctx = iot_get_ctx (THIS, client);
- if (ctx) {
- ctx = &ctx[pri];
- }
- } else {
- ctx = NULL;
- }
- if (!ctx) {
- ctx = &conf->no_client[pri];
+ if (client) {
+ ctx = iot_get_ctx(THIS, client);
+ if (ctx) {
+ ctx = &ctx[pri];
}
+ } else {
+ ctx = NULL;
+ }
+ if (!ctx) {
+ ctx = &conf->no_client[pri];
+ }
- if (list_empty (&ctx->reqs)) {
- list_add_tail (&ctx->clients, &conf->clients[pri]);
- }
- list_add_tail (&stub->list, &ctx->reqs);
+ if (list_empty(&ctx->reqs)) {
+ list_add_tail(&ctx->clients, &conf->clients[pri]);
+ }
+ list_add_tail(&stub->list, &ctx->reqs);
- conf->queue_size++;
- conf->queue_sizes[pri]++;
+ conf->queue_size++;
+ conf->queue_sizes[pri]++;
}
void *
-iot_worker (void *data)
-{
- iot_conf_t *conf = NULL;
- xlator_t *this = NULL;
- call_stub_t *stub = NULL;
- struct timespec sleep_till = {0, };
- int ret = 0;
- int pri = -1;
- gf_boolean_t bye = _gf_false;
-
- conf = data;
- this = conf->this;
- THIS = this;
-
- for (;;) {
- pthread_mutex_lock (&conf->mutex);
- {
- if (pri != -1) {
- conf->ac_iot_count[pri]--;
- pri = -1;
- }
- while (conf->queue_size == 0) {
- if (conf->down) {
- bye = _gf_true;/*Avoid sleep*/
- break;
- }
-
- clock_gettime (CLOCK_REALTIME_COARSE,
- &sleep_till);
- sleep_till.tv_sec += conf->idle_time;
-
- conf->sleep_count++;
- ret = pthread_cond_timedwait (&conf->cond,
- &conf->mutex,
- &sleep_till);
- conf->sleep_count--;
-
- if (conf->down || ret == ETIMEDOUT) {
- bye = _gf_true;
- break;
- }
- }
-
- if (bye) {
- if (conf->down || conf->curr_count > IOT_MIN_THREADS) {
- conf->curr_count--;
- if (conf->curr_count == 0)
- pthread_cond_broadcast (&conf->cond);
- gf_msg_debug (conf->this->name, 0,
- "terminated. "
- "conf->curr_count=%d",
- conf->curr_count);
- } else {
- bye = _gf_false;
- }
- }
-
- if (!bye)
- stub = __iot_dequeue (conf, &pri);
+iot_worker(void *data)
+{
+ iot_conf_t *conf = NULL;
+ xlator_t *this = NULL;
+ call_stub_t *stub = NULL;
+ struct timespec sleep_till = {
+ 0,
+ };
+ int ret = 0;
+ int pri = -1;
+ gf_boolean_t bye = _gf_false;
+
+ conf = data;
+ this = conf->this;
+ THIS = this;
+
+ for (;;) {
+ pthread_mutex_lock(&conf->mutex);
+ {
+ if (pri != -1) {
+ conf->ac_iot_count[pri]--;
+ pri = -1;
+ }
+ while (conf->queue_size == 0) {
+ if (conf->down) {
+ bye = _gf_true; /*Avoid sleep*/
+ break;
+ }
+
+ clock_gettime(CLOCK_REALTIME_COARSE, &sleep_till);
+ sleep_till.tv_sec += conf->idle_time;
+
+ conf->sleep_count++;
+ ret = pthread_cond_timedwait(&conf->cond, &conf->mutex,
+ &sleep_till);
+ conf->sleep_count--;
+
+ if (conf->down || ret == ETIMEDOUT) {
+ bye = _gf_true;
+ break;
}
- pthread_mutex_unlock (&conf->mutex);
-
- if (stub) { /* guard against spurious wakeups */
- if (stub->poison) {
- gf_log (this->name, GF_LOG_INFO,
- "Dropping poisoned request %p.", stub);
- call_stub_destroy (stub);
- } else {
- call_resume (stub);
- }
+ }
+
+ if (bye) {
+ if (conf->down || conf->curr_count > IOT_MIN_THREADS) {
+ conf->curr_count--;
+ if (conf->curr_count == 0)
+ pthread_cond_broadcast(&conf->cond);
+ gf_msg_debug(conf->this->name, 0,
+ "terminated. "
+ "conf->curr_count=%d",
+ conf->curr_count);
+ } else {
+ bye = _gf_false;
}
- stub = NULL;
+ }
- if (bye)
- break;
+ if (!bye)
+ stub = __iot_dequeue(conf, &pri);
+ }
+ pthread_mutex_unlock(&conf->mutex);
+
+ if (stub) { /* guard against spurious wakeups */
+ if (stub->poison) {
+ gf_log(this->name, GF_LOG_INFO, "Dropping poisoned request %p.",
+ stub);
+ call_stub_destroy(stub);
+ } else {
+ call_resume(stub);
+ }
}
+ stub = NULL;
- return NULL;
+ if (bye)
+ break;
+ }
+
+ return NULL;
}
int
-do_iot_schedule (iot_conf_t *conf, call_stub_t *stub, int pri)
+do_iot_schedule(iot_conf_t *conf, call_stub_t *stub, int pri)
{
- int ret = 0;
+ int ret = 0;
- pthread_mutex_lock (&conf->mutex);
- {
- __iot_enqueue (conf, stub, pri);
+ pthread_mutex_lock(&conf->mutex);
+ {
+ __iot_enqueue(conf, stub, pri);
- pthread_cond_signal (&conf->cond);
+ pthread_cond_signal(&conf->cond);
- ret = __iot_workers_scale (conf);
- }
- pthread_mutex_unlock (&conf->mutex);
+ ret = __iot_workers_scale(conf);
+ }
+ pthread_mutex_unlock(&conf->mutex);
- return ret;
+ return ret;
}
-char*
-iot_get_pri_meaning (gf_fop_pri_t pri)
+char *
+iot_get_pri_meaning(gf_fop_pri_t pri)
{
- char *name = NULL;
- switch (pri) {
+ char *name = NULL;
+ switch (pri) {
case GF_FOP_PRI_HI:
- name = "fast";
- break;
+ name = "fast";
+ break;
case GF_FOP_PRI_NORMAL:
- name = "normal";
- break;
+ name = "normal";
+ break;
case GF_FOP_PRI_LO:
- name = "slow";
- break;
+ name = "slow";
+ break;
case GF_FOP_PRI_LEAST:
- name = "least priority";
- break;
+ name = "least priority";
+ break;
case GF_FOP_PRI_MAX:
- name = "invalid";
- break;
+ name = "invalid";
+ break;
case GF_FOP_PRI_UNSPEC:
- name = "unspecified";
- break;
- }
- return name;
+ name = "unspecified";
+ break;
+ }
+ return name;
}
int
-iot_schedule (call_frame_t *frame, xlator_t *this, call_stub_t *stub)
+iot_schedule(call_frame_t *frame, xlator_t *this, call_stub_t *stub)
{
- int ret = -1;
- gf_fop_pri_t pri = GF_FOP_PRI_MAX - 1;
- iot_conf_t *conf = this->private;
+ int ret = -1;
+ gf_fop_pri_t pri = GF_FOP_PRI_MAX - 1;
+ iot_conf_t *conf = this->private;
- if ((frame->root->pid < GF_CLIENT_PID_MAX) && conf->least_priority) {
- pri = GF_FOP_PRI_LEAST;
- goto out;
- }
+ if ((frame->root->pid < GF_CLIENT_PID_MAX) && conf->least_priority) {
+ pri = GF_FOP_PRI_LEAST;
+ goto out;
+ }
- switch (stub->fop) {
+ switch (stub->fop) {
case GF_FOP_OPEN:
case GF_FOP_STAT:
case GF_FOP_FSTAT:
@@ -312,8 +312,8 @@ iot_schedule (call_frame_t *frame, xlator_t *this, call_stub_t *stub)
case GF_FOP_SETACTIVELK:
case GF_FOP_ICREATE:
case GF_FOP_NAMELINK:
- pri = GF_FOP_PRI_HI;
- break;
+ pri = GF_FOP_PRI_HI;
+ break;
case GF_FOP_CREATE:
case GF_FOP_FLUSH:
@@ -339,8 +339,8 @@ iot_schedule (call_frame_t *frame, xlator_t *this, call_stub_t *stub)
case GF_FOP_REMOVEXATTR:
case GF_FOP_FREMOVEXATTR:
case GF_FOP_PUT:
- pri = GF_FOP_PRI_NORMAL;
- break;
+ pri = GF_FOP_PRI_NORMAL;
+ break;
case GF_FOP_READ:
case GF_FOP_WRITE:
@@ -355,613 +355,603 @@ iot_schedule (call_frame_t *frame, xlator_t *this, call_stub_t *stub)
case GF_FOP_DISCARD:
case GF_FOP_ZEROFILL:
case GF_FOP_SEEK:
- pri = GF_FOP_PRI_LO;
- break;
+ pri = GF_FOP_PRI_LO;
+ break;
case GF_FOP_FORGET:
case GF_FOP_RELEASE:
case GF_FOP_RELEASEDIR:
case GF_FOP_GETSPEC:
- break;
+ break;
case GF_FOP_IPC:
default:
- return -EINVAL;
- }
+ return -EINVAL;
+ }
out:
- gf_msg_debug (this->name, 0, "%s scheduled as %s fop",
- gf_fop_list[stub->fop], iot_get_pri_meaning (pri));
- if (this->private)
- ret = do_iot_schedule (this->private, stub, pri);
- return ret;
+ gf_msg_debug(this->name, 0, "%s scheduled as %s fop",
+ gf_fop_list[stub->fop], iot_get_pri_meaning(pri));
+ if (this->private)
+ ret = do_iot_schedule(this->private, stub, pri);
+ return ret;
}
int
-iot_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+iot_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- IOT_FOP (lookup, frame, this, loc, xdata);
- return 0;
+ IOT_FOP(lookup, frame, this, loc, xdata);
+ return 0;
}
int
-iot_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- struct iatt *stbuf, int32_t valid, dict_t *xdata)
+iot_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf,
+ int32_t valid, dict_t *xdata)
{
- IOT_FOP (setattr, frame, this, loc, stbuf, valid, xdata);
- return 0;
+ IOT_FOP(setattr, frame, this, loc, stbuf, valid, xdata);
+ return 0;
}
int
-iot_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iatt *stbuf, int32_t valid, dict_t *xdata)
+iot_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,
+ int32_t valid, dict_t *xdata)
{
- IOT_FOP (fsetattr, frame, this, fd, stbuf, valid, xdata);
- return 0;
+ IOT_FOP(fsetattr, frame, this, fd, stbuf, valid, xdata);
+ return 0;
}
int
-iot_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask,
- dict_t *xdata)
+iot_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask,
+ dict_t *xdata)
{
- IOT_FOP (access, frame, this, loc, mask, xdata);
- return 0;
+ IOT_FOP(access, frame, this, loc, mask, xdata);
+ return 0;
}
int
-iot_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size, dict_t *xdata)
+iot_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size,
+ dict_t *xdata)
{
- IOT_FOP (readlink, frame, this, loc, size, xdata);
- return 0;
+ IOT_FOP(readlink, frame, this, loc, size, xdata);
+ return 0;
}
int
-iot_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
- dev_t rdev, mode_t umask, dict_t *xdata)
+iot_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
+ dev_t rdev, mode_t umask, dict_t *xdata)
{
- IOT_FOP (mknod, frame, this, loc, mode, rdev, umask, xdata);
- return 0;
+ IOT_FOP(mknod, frame, this, loc, mode, rdev, umask, xdata);
+ return 0;
}
int
-iot_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
- mode_t umask, dict_t *xdata)
+iot_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
+ mode_t umask, dict_t *xdata)
{
- IOT_FOP (mkdir, frame, this, loc, mode, umask, xdata);
- return 0;
+ IOT_FOP(mkdir, frame, this, loc, mode, umask, xdata);
+ return 0;
}
int
-iot_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, dict_t *xdata)
+iot_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
+ dict_t *xdata)
{
- IOT_FOP (rmdir, frame, this, loc, flags, xdata);
- return 0;
+ IOT_FOP(rmdir, frame, this, loc, flags, xdata);
+ return 0;
}
int
-iot_symlink (call_frame_t *frame, xlator_t *this, const char *linkname,
- loc_t *loc, mode_t umask, dict_t *xdata)
+iot_symlink(call_frame_t *frame, xlator_t *this, const char *linkname,
+ loc_t *loc, mode_t umask, dict_t *xdata)
{
- IOT_FOP (symlink, frame, this, linkname, loc, umask, xdata);
- return 0;
+ IOT_FOP(symlink, frame, this, linkname, loc, umask, xdata);
+ return 0;
}
int
-iot_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
- dict_t *xdata)
+iot_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
{
- IOT_FOP (rename, frame, this, oldloc, newloc, xdata);
- return 0;
+ IOT_FOP(rename, frame, this, oldloc, newloc, xdata);
+ return 0;
}
int
-iot_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- fd_t *fd, dict_t *xdata)
+iot_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ fd_t *fd, dict_t *xdata)
{
- IOT_FOP (open, frame, this, loc, flags, fd, xdata);
- return 0;
+ IOT_FOP(open, frame, this, loc, flags, fd, xdata);
+ return 0;
}
int
-iot_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
+iot_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
{
- IOT_FOP (create, frame, this, loc, flags, mode, umask, fd, xdata);
- return 0;
+ IOT_FOP(create, frame, this, loc, flags, mode, umask, fd, xdata);
+ return 0;
}
+int
+iot_put(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
+ mode_t umask, uint32_t flags, struct iovec *vector, int32_t count,
+ off_t offset, struct iobref *iobref, dict_t *xattr, dict_t *xdata)
+{
+ IOT_FOP(put, frame, this, loc, mode, umask, flags, vector, count, offset,
+ iobref, xattr, xdata);
+ return 0;
+}
int
-iot_put (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
- mode_t umask, uint32_t flags, struct iovec *vector, int32_t count,
- off_t offset, struct iobref *iobref, dict_t *xattr, dict_t *xdata)
+iot_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, uint32_t flags, dict_t *xdata)
{
- IOT_FOP (put, frame, this, loc, mode, umask, flags, vector, count,
- offset, iobref, xattr, xdata);
- return 0;
+ IOT_FOP(readv, frame, this, fd, size, offset, flags, xdata);
+ return 0;
}
int
-iot_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, uint32_t flags, dict_t *xdata)
+iot_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- IOT_FOP (readv, frame, this, fd, size, offset, flags, xdata);
- return 0;
+ IOT_FOP(flush, frame, this, fd, xdata);
+ return 0;
}
int
-iot_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+iot_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync,
+ dict_t *xdata)
{
- IOT_FOP (flush, frame, this, fd, xdata);
- return 0;
+ IOT_FOP(fsync, frame, this, fd, datasync, xdata);
+ return 0;
}
int
-iot_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync,
+iot_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
+ int32_t count, off_t offset, uint32_t flags, struct iobref *iobref,
dict_t *xdata)
{
- IOT_FOP (fsync, frame, this, fd, datasync, xdata);
- return 0;
+ IOT_FOP(writev, frame, this, fd, vector, count, offset, flags, iobref,
+ xdata);
+ return 0;
}
int
-iot_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iovec *vector, int32_t count, off_t offset,
- uint32_t flags, struct iobref *iobref, dict_t *xdata)
+iot_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
+ struct gf_flock *flock, dict_t *xdata)
{
- IOT_FOP (writev, frame, this, fd, vector, count, offset,
- flags, iobref, xdata);
- return 0;
+ IOT_FOP(lk, frame, this, fd, cmd, flock, xdata);
+ return 0;
}
int
-iot_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t cmd,
- struct gf_flock *flock, dict_t *xdata)
+iot_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- IOT_FOP (lk, frame, this, fd, cmd, flock, xdata);
- return 0;
+ IOT_FOP(stat, frame, this, loc, xdata);
+ return 0;
}
int
-iot_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+iot_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- IOT_FOP (stat, frame, this, loc, xdata);
- return 0;
+ IOT_FOP(fstat, frame, this, fd, xdata);
+ return 0;
}
int
-iot_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+iot_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
+ dict_t *xdata)
{
- IOT_FOP (fstat, frame, this, fd, xdata);
- return 0;
+ IOT_FOP(truncate, frame, this, loc, offset, xdata);
+ return 0;
}
int
-iot_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
+iot_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
dict_t *xdata)
{
- IOT_FOP (truncate, frame, this, loc, offset, xdata);
- return 0;
+ IOT_FOP(ftruncate, frame, this, fd, offset, xdata);
+ return 0;
}
int
-iot_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- dict_t *xdata)
+iot_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t xflag,
+ dict_t *xdata)
{
- IOT_FOP (ftruncate, frame, this, fd, offset, xdata);
- return 0;
+ IOT_FOP(unlink, frame, this, loc, xflag, xdata);
+ return 0;
}
int
-iot_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t xflag,
- dict_t *xdata)
+iot_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
{
- IOT_FOP (unlink, frame, this, loc, xflag, xdata);
- return 0;
+ IOT_FOP(link, frame, this, oldloc, newloc, xdata);
+ return 0;
}
int
-iot_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
- dict_t *xdata)
+iot_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
+ dict_t *xdata)
{
- IOT_FOP (link, frame, this, oldloc, newloc, xdata);
- return 0;
+ IOT_FOP(opendir, frame, this, loc, fd, xdata);
+ return 0;
}
int
-iot_opendir (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
+iot_fsyncdir(call_frame_t *frame, xlator_t *this, fd_t *fd, int datasync,
dict_t *xdata)
{
- IOT_FOP (opendir, frame, this, loc, fd, xdata);
- return 0;
+ IOT_FOP(fsyncdir, frame, this, fd, datasync, xdata);
+ return 0;
}
int
-iot_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int datasync,
- dict_t *xdata)
+iot_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- IOT_FOP (fsyncdir, frame, this, fd, datasync, xdata);
- return 0;
+ IOT_FOP(statfs, frame, this, loc, xdata);
+ return 0;
}
int
-iot_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+iot_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
+ int32_t flags, dict_t *xdata)
{
- IOT_FOP (statfs, frame, this, loc, xdata);
- return 0;
+ IOT_FOP(setxattr, frame, this, loc, dict, flags, xdata);
+ return 0;
}
int
-iot_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
- int32_t flags, dict_t *xdata)
+iot_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *name,
+ dict_t *xdata)
{
- IOT_FOP (setxattr, frame, this, loc, dict, flags, xdata);
- return 0;
-}
-
-int
-iot_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- const char *name, dict_t *xdata)
-{
- iot_conf_t *conf = NULL;
- dict_t *depths = NULL;
- int i = 0;
- int32_t op_ret = 0;
- int32_t op_errno = 0;
-
- conf = this->private;
-
- if (conf && name && strcmp (name, IO_THREADS_QUEUE_SIZE_KEY) == 0) {
- /*
- * We explicitly do not want a reference count
- * for this dict in this translator
- */
- depths = dict_new ();
- if (!depths) {
- op_ret = -1;
- op_errno = ENOMEM;
- goto unwind_special_getxattr;
- }
-
- for (i = 0; i < GF_FOP_PRI_MAX; i++) {
- if (dict_set_int32 (depths,
- (char *)fop_pri_to_string (i),
- conf->queue_sizes[i]) != 0) {
- dict_unref (depths);
- depths = NULL;
- goto unwind_special_getxattr;
- }
- }
+ iot_conf_t *conf = NULL;
+ dict_t *depths = NULL;
+ int i = 0;
+ int32_t op_ret = 0;
+ int32_t op_errno = 0;
+
+ conf = this->private;
+
+ if (conf && name && strcmp(name, IO_THREADS_QUEUE_SIZE_KEY) == 0) {
+ /*
+ * We explicitly do not want a reference count
+ * for this dict in this translator
+ */
+ depths = dict_new();
+ if (!depths) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto unwind_special_getxattr;
+ }
-unwind_special_getxattr:
- STACK_UNWIND_STRICT (getxattr, frame, op_ret, op_errno,
- depths, xdata);
- if (depths)
- dict_unref(depths);
- return 0;
+ for (i = 0; i < GF_FOP_PRI_MAX; i++) {
+ if (dict_set_int32(depths, (char *)fop_pri_to_string(i),
+ conf->queue_sizes[i]) != 0) {
+ dict_unref(depths);
+ depths = NULL;
+ goto unwind_special_getxattr;
+ }
}
- IOT_FOP (getxattr, frame, this, loc, name, xdata);
+ unwind_special_getxattr:
+ STACK_UNWIND_STRICT(getxattr, frame, op_ret, op_errno, depths, xdata);
+ if (depths)
+ dict_unref(depths);
return 0;
+ }
+
+ IOT_FOP(getxattr, frame, this, loc, name, xdata);
+ return 0;
}
int
-iot_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
- const char *name, dict_t *xdata)
+iot_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name,
+ dict_t *xdata)
{
- IOT_FOP (fgetxattr, frame, this, fd, name, xdata);
- return 0;
+ IOT_FOP(fgetxattr, frame, this, fd, name, xdata);
+ return 0;
}
-
int
-iot_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
- int32_t flags, dict_t *xdata)
+iot_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
+ int32_t flags, dict_t *xdata)
{
- IOT_FOP (fsetxattr, frame, this, fd, dict, flags, xdata);
- return 0;
+ IOT_FOP(fsetxattr, frame, this, fd, dict, flags, xdata);
+ return 0;
}
int
-iot_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- const char *name, dict_t *xdata)
+iot_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
+ const char *name, dict_t *xdata)
{
- IOT_FOP (removexattr, frame, this, loc, name, xdata);
- return 0;
+ IOT_FOP(removexattr, frame, this, loc, name, xdata);
+ return 0;
}
int
-iot_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
+iot_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
const char *name, dict_t *xdata)
{
- IOT_FOP (fremovexattr, frame, this, fd, name, xdata);
- return 0;
+ IOT_FOP(fremovexattr, frame, this, fd, name, xdata);
+ return 0;
}
int
-iot_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, dict_t *xdata)
+iot_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, dict_t *xdata)
{
- IOT_FOP (readdirp, frame, this, fd, size, offset, xdata);
- return 0;
+ IOT_FOP(readdirp, frame, this, fd, size, offset, xdata);
+ return 0;
}
int
-iot_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, dict_t *xdata)
+iot_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, dict_t *xdata)
{
- IOT_FOP (readdir, frame, this, fd, size, offset, xdata);
- return 0;
+ IOT_FOP(readdir, frame, this, fd, size, offset, xdata);
+ return 0;
}
int
-iot_inodelk (call_frame_t *frame, xlator_t *this,
- const char *volume, loc_t *loc, int32_t cmd, struct gf_flock *lock,
- dict_t *xdata)
+iot_inodelk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc,
+ int32_t cmd, struct gf_flock *lock, dict_t *xdata)
{
- IOT_FOP (inodelk, frame, this, volume, loc, cmd, lock, xdata);
- return 0;
+ IOT_FOP(inodelk, frame, this, volume, loc, cmd, lock, xdata);
+ return 0;
}
int
-iot_finodelk (call_frame_t *frame, xlator_t *this,
- const char *volume, fd_t *fd, int32_t cmd, struct gf_flock *lock,
- dict_t *xdata)
+iot_finodelk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
+ int32_t cmd, struct gf_flock *lock, dict_t *xdata)
{
- IOT_FOP (finodelk, frame, this, volume, fd, cmd, lock, xdata);
- return 0;
+ IOT_FOP(finodelk, frame, this, volume, fd, cmd, lock, xdata);
+ return 0;
}
int
-iot_entrylk (call_frame_t *frame, xlator_t *this,
- const char *volume, loc_t *loc, const char *basename,
- entrylk_cmd cmd, entrylk_type type, dict_t *xdata)
+iot_entrylk(call_frame_t *frame, xlator_t *this, const char *volume, loc_t *loc,
+ const char *basename, entrylk_cmd cmd, entrylk_type type,
+ dict_t *xdata)
{
- IOT_FOP (entrylk, frame, this, volume, loc, basename, cmd, type, xdata);
- return 0;
+ IOT_FOP(entrylk, frame, this, volume, loc, basename, cmd, type, xdata);
+ return 0;
}
int
-iot_fentrylk (call_frame_t *frame, xlator_t *this,
- const char *volume, fd_t *fd, const char *basename,
- entrylk_cmd cmd, entrylk_type type, dict_t *xdata)
+iot_fentrylk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
+ const char *basename, entrylk_cmd cmd, entrylk_type type,
+ dict_t *xdata)
{
- IOT_FOP (fentrylk, frame, this, volume, fd, basename, cmd, type, xdata);
- return 0;
+ IOT_FOP(fentrylk, frame, this, volume, fd, basename, cmd, type, xdata);
+ return 0;
}
int
-iot_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc,
- gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
+iot_xattrop(call_frame_t *frame, xlator_t *this, loc_t *loc,
+ gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
{
- IOT_FOP (xattrop, frame, this, loc, optype, xattr, xdata);
- return 0;
+ IOT_FOP(xattrop, frame, this, loc, optype, xattr, xdata);
+ return 0;
}
int
-iot_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd,
- gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
+iot_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd,
+ gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
{
- IOT_FOP (fxattrop, frame, this, fd, optype, xattr, xdata);
- return 0;
+ IOT_FOP(fxattrop, frame, this, fd, optype, xattr, xdata);
+ return 0;
}
int32_t
-iot_rchecksum (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- int32_t len, dict_t *xdata)
+iot_rchecksum(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ int32_t len, dict_t *xdata)
{
- IOT_FOP (rchecksum, frame, this, fd, offset, len, xdata);
- return 0;
+ IOT_FOP(rchecksum, frame, this, fd, offset, len, xdata);
+ return 0;
}
int
-iot_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,
- off_t offset, size_t len, dict_t *xdata)
+iot_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,
+ off_t offset, size_t len, dict_t *xdata)
{
- IOT_FOP (fallocate, frame, this, fd, mode, offset, len, xdata);
- return 0;
+ IOT_FOP(fallocate, frame, this, fd, mode, offset, len, xdata);
+ return 0;
}
int
-iot_discard (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- size_t len, dict_t *xdata)
+iot_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ size_t len, dict_t *xdata)
{
- IOT_FOP (discard, frame, this, fd, offset, len, xdata);
- return 0;
+ IOT_FOP(discard, frame, this, fd, offset, len, xdata);
+ return 0;
}
int
-iot_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- off_t len, dict_t *xdata)
+iot_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ off_t len, dict_t *xdata)
{
- IOT_FOP (zerofill, frame, this, fd, offset, len, xdata);
- return 0;
+ IOT_FOP(zerofill, frame, this, fd, offset, len, xdata);
+ return 0;
}
int
-iot_seek (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- gf_seek_what_t what, dict_t *xdata)
+iot_seek(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ gf_seek_what_t what, dict_t *xdata)
{
- IOT_FOP (seek, frame, this, fd, offset, what, xdata);
- return 0;
+ IOT_FOP(seek, frame, this, fd, offset, what, xdata);
+ return 0;
}
int
-iot_lease (call_frame_t *frame, xlator_t *this, loc_t *loc,
- struct gf_lease *lease, dict_t *xdata)
+iot_lease(call_frame_t *frame, xlator_t *this, loc_t *loc,
+ struct gf_lease *lease, dict_t *xdata)
{
- IOT_FOP (lease, frame, this, loc, lease, xdata);
- return 0;
+ IOT_FOP(lease, frame, this, loc, lease, xdata);
+ return 0;
}
int
-iot_getactivelk (call_frame_t *frame, xlator_t *this,
- loc_t *loc, dict_t *xdata)
+iot_getactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- IOT_FOP (getactivelk, frame, this, loc, xdata);
- return 0;
+ IOT_FOP(getactivelk, frame, this, loc, xdata);
+ return 0;
}
int
-iot_setactivelk (call_frame_t *frame, xlator_t *this, loc_t *loc,
- lock_migration_info_t *locklist, dict_t *xdata)
+iot_setactivelk(call_frame_t *frame, xlator_t *this, loc_t *loc,
+ lock_migration_info_t *locklist, dict_t *xdata)
{
- IOT_FOP (setactivelk, frame, this, loc, locklist, xdata);
- return 0;
+ IOT_FOP(setactivelk, frame, this, loc, locklist, xdata);
+ return 0;
}
int
-__iot_workers_scale (iot_conf_t *conf)
+__iot_workers_scale(iot_conf_t *conf)
{
- int scale = 0;
- int diff = 0;
- pthread_t thread;
- int ret = 0;
- int i = 0;
- char thread_name[GF_THREAD_NAMEMAX] = {0,};
+ int scale = 0;
+ int diff = 0;
+ pthread_t thread;
+ int ret = 0;
+ int i = 0;
+ char thread_name[GF_THREAD_NAMEMAX] = {
+ 0,
+ };
- for (i = 0; i < GF_FOP_PRI_MAX; i++)
- scale += min (conf->queue_sizes[i], conf->ac_iot_limit[i]);
+ for (i = 0; i < GF_FOP_PRI_MAX; i++)
+ scale += min(conf->queue_sizes[i], conf->ac_iot_limit[i]);
- if (scale < IOT_MIN_THREADS)
- scale = IOT_MIN_THREADS;
+ if (scale < IOT_MIN_THREADS)
+ scale = IOT_MIN_THREADS;
- if (scale > conf->max_count)
- scale = conf->max_count;
+ if (scale > conf->max_count)
+ scale = conf->max_count;
- if (conf->curr_count < scale) {
- diff = scale - conf->curr_count;
- }
+ if (conf->curr_count < scale) {
+ diff = scale - conf->curr_count;
+ }
- while (diff) {
- diff --;
-
- snprintf (thread_name, sizeof(thread_name),
- "iotwr%03hx", (conf->curr_count & 0x3ff));
- ret = gf_thread_create (&thread, &conf->w_attr, iot_worker,
- conf, thread_name);
- if (ret == 0) {
- conf->curr_count++;
- gf_msg_debug (conf->this->name, 0,
- "scaled threads to %d (queue_size=%d/%d)",
- conf->curr_count,
- conf->queue_size, scale);
- } else {
- break;
- }
+ while (diff) {
+ diff--;
+
+ snprintf(thread_name, sizeof(thread_name), "iotwr%03hx",
+ (conf->curr_count & 0x3ff));
+ ret = gf_thread_create(&thread, &conf->w_attr, iot_worker, conf,
+ thread_name);
+ if (ret == 0) {
+ conf->curr_count++;
+ gf_msg_debug(conf->this->name, 0,
+ "scaled threads to %d (queue_size=%d/%d)",
+ conf->curr_count, conf->queue_size, scale);
+ } else {
+ break;
}
+ }
- return diff;
+ return diff;
}
int
-iot_workers_scale (iot_conf_t *conf)
+iot_workers_scale(iot_conf_t *conf)
{
- int ret = -1;
+ int ret = -1;
- if (conf == NULL) {
- ret = -EINVAL;
- goto out;
- }
+ if (conf == NULL) {
+ ret = -EINVAL;
+ goto out;
+ }
- pthread_mutex_lock (&conf->mutex);
- {
- ret = __iot_workers_scale (conf);
- }
- pthread_mutex_unlock (&conf->mutex);
+ pthread_mutex_lock(&conf->mutex);
+ {
+ ret = __iot_workers_scale(conf);
+ }
+ pthread_mutex_unlock(&conf->mutex);
out:
- return ret;
+ return ret;
}
int
-set_stack_size (iot_conf_t *conf)
+set_stack_size(iot_conf_t *conf)
{
- int err = 0;
- size_t stacksize = IOT_THREAD_STACK_SIZE;
- xlator_t *this = NULL;
-
- this = THIS;
+ int err = 0;
+ size_t stacksize = IOT_THREAD_STACK_SIZE;
+ xlator_t *this = NULL;
- err = pthread_attr_init (&conf->w_attr);
- if (err != 0) {
- gf_msg (this->name, GF_LOG_ERROR, err,
- IO_THREADS_MSG_INIT_FAILED,
- "Thread attribute initialization failed");
- return err;
- }
+ this = THIS;
- err = pthread_attr_setstacksize (&conf->w_attr, stacksize);
- if (err == EINVAL) {
- err = pthread_attr_getstacksize (&conf->w_attr, &stacksize);
- if (!err) {
- gf_msg (this->name, GF_LOG_WARNING,
- 0, IO_THREADS_MSG_SIZE_NOT_SET,
- "Using default thread stack size %zd",
- stacksize);
- } else {
- gf_msg (this->name, GF_LOG_WARNING,
- 0, IO_THREADS_MSG_SIZE_NOT_SET,
- "Using default thread stack size");
- err = 0;
- }
+ err = pthread_attr_init(&conf->w_attr);
+ if (err != 0) {
+ gf_msg(this->name, GF_LOG_ERROR, err, IO_THREADS_MSG_INIT_FAILED,
+ "Thread attribute initialization failed");
+ return err;
+ }
+
+ err = pthread_attr_setstacksize(&conf->w_attr, stacksize);
+ if (err == EINVAL) {
+ err = pthread_attr_getstacksize(&conf->w_attr, &stacksize);
+ if (!err) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, IO_THREADS_MSG_SIZE_NOT_SET,
+ "Using default thread stack size %zd", stacksize);
+ } else {
+ gf_msg(this->name, GF_LOG_WARNING, 0, IO_THREADS_MSG_SIZE_NOT_SET,
+ "Using default thread stack size");
+ err = 0;
}
+ }
- conf->stack_size = stacksize;
- return err;
+ conf->stack_size = stacksize;
+ return err;
}
int32_t
-mem_acct_init (xlator_t *this)
+mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- if (!this)
- return ret;
-
- ret = xlator_mem_acct_init (this, gf_iot_mt_end + 1);
+ if (!this)
+ return ret;
- if (ret != 0) {
- gf_msg (this->name, GF_LOG_ERROR,
- ENOMEM, IO_THREADS_MSG_NO_MEMORY,
- "Memory accounting init failed");
- return ret;
- }
+ ret = xlator_mem_acct_init(this, gf_iot_mt_end + 1);
+ if (ret != 0) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_THREADS_MSG_NO_MEMORY,
+ "Memory accounting init failed");
return ret;
+ }
+
+ return ret;
}
int
-iot_priv_dump (xlator_t *this)
+iot_priv_dump(xlator_t *this)
{
- iot_conf_t *conf = NULL;
- char key_prefix[GF_DUMP_MAX_BUF_LEN];
+ iot_conf_t *conf = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
- if (!this)
- return 0;
+ if (!this)
+ return 0;
- conf = this->private;
- if (!conf)
- return 0;
+ conf = this->private;
+ if (!conf)
+ return 0;
- snprintf (key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type,
- this->name);
+ snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type, this->name);
- gf_proc_dump_add_section(key_prefix);
+ gf_proc_dump_add_section(key_prefix);
- gf_proc_dump_write("maximum_threads_count", "%d", conf->max_count);
- gf_proc_dump_write("current_threads_count", "%d", conf->curr_count);
- gf_proc_dump_write("sleep_count", "%d", conf->sleep_count);
- gf_proc_dump_write("idle_time", "%d", conf->idle_time);
- gf_proc_dump_write("stack_size", "%zd", conf->stack_size);
- gf_proc_dump_write("high_priority_threads", "%d",
- conf->ac_iot_limit[GF_FOP_PRI_HI]);
- gf_proc_dump_write("normal_priority_threads", "%d",
- conf->ac_iot_limit[GF_FOP_PRI_NORMAL]);
- gf_proc_dump_write("low_priority_threads", "%d",
- conf->ac_iot_limit[GF_FOP_PRI_LO]);
- gf_proc_dump_write("least_priority_threads", "%d",
- conf->ac_iot_limit[GF_FOP_PRI_LEAST]);
+ gf_proc_dump_write("maximum_threads_count", "%d", conf->max_count);
+ gf_proc_dump_write("current_threads_count", "%d", conf->curr_count);
+ gf_proc_dump_write("sleep_count", "%d", conf->sleep_count);
+ gf_proc_dump_write("idle_time", "%d", conf->idle_time);
+ gf_proc_dump_write("stack_size", "%zd", conf->stack_size);
+ gf_proc_dump_write("high_priority_threads", "%d",
+ conf->ac_iot_limit[GF_FOP_PRI_HI]);
+ gf_proc_dump_write("normal_priority_threads", "%d",
+ conf->ac_iot_limit[GF_FOP_PRI_NORMAL]);
+ gf_proc_dump_write("low_priority_threads", "%d",
+ conf->ac_iot_limit[GF_FOP_PRI_LO]);
+ gf_proc_dump_write("least_priority_threads", "%d",
+ conf->ac_iot_limit[GF_FOP_PRI_LEAST]);
- return 0;
+ return 0;
}
/*
@@ -995,551 +985,539 @@ iot_priv_dump (xlator_t *this)
*/
typedef struct {
- uint32_t value;
- time_t update_time;
+ uint32_t value;
+ time_t update_time;
} threshold_t;
/*
* Variables so that I can hack these for testing.
* TBD: make these tunable?
*/
-static uint32_t THRESH_SECONDS = 604800;
-static uint32_t THRESH_EVENTS = 3;
-static uint32_t THRESH_LIMIT = 1209600; /* SECONDS * (EVENTS-1) */
+static uint32_t THRESH_SECONDS = 604800;
+static uint32_t THRESH_EVENTS = 3;
+static uint32_t THRESH_LIMIT = 1209600; /* SECONDS * (EVENTS-1) */
static void
-iot_apply_event (xlator_t *this, threshold_t *thresh)
+iot_apply_event(xlator_t *this, threshold_t *thresh)
{
- struct timespec now;
- time_t delta;
+ struct timespec now;
+ time_t delta;
- /* Refresh for manual testing/debugging. It's cheap. */
- THRESH_LIMIT = THRESH_SECONDS * (THRESH_EVENTS - 1);
+ /* Refresh for manual testing/debugging. It's cheap. */
+ THRESH_LIMIT = THRESH_SECONDS * (THRESH_EVENTS - 1);
- timespec_now (&now);
+ timespec_now(&now);
- if (thresh->value && thresh->update_time) {
- delta = now.tv_sec - thresh->update_time;
- /* Be careful about underflow. */
- if (thresh->value <= delta) {
- thresh->value = 0;
- } else {
- thresh->value -= delta;
- }
+ if (thresh->value && thresh->update_time) {
+ delta = now.tv_sec - thresh->update_time;
+ /* Be careful about underflow. */
+ if (thresh->value <= delta) {
+ thresh->value = 0;
+ } else {
+ thresh->value -= delta;
}
+ }
- thresh->value += THRESH_SECONDS;
- if (thresh->value >= THRESH_LIMIT) {
- gf_log (this->name, GF_LOG_EMERG, "watchdog firing too often");
- /*
- * The default action for SIGTRAP is to dump core, but the fact
- * that it's distinct from other signals we use means that
- * there are other possibilities as well (e.g. drop into gdb or
- * invoke a special handler).
- */
- kill (getpid (), SIGTRAP);
- }
+ thresh->value += THRESH_SECONDS;
+ if (thresh->value >= THRESH_LIMIT) {
+ gf_log(this->name, GF_LOG_EMERG, "watchdog firing too often");
+ /*
+ * The default action for SIGTRAP is to dump core, but the fact
+ * that it's distinct from other signals we use means that
+ * there are other possibilities as well (e.g. drop into gdb or
+ * invoke a special handler).
+ */
+ kill(getpid(), SIGTRAP);
+ }
- thresh->update_time = now.tv_sec;
+ thresh->update_time = now.tv_sec;
}
static void *
-iot_watchdog (void *arg)
-{
- xlator_t *this = arg;
- iot_conf_t *priv = this->private;
- int i;
- int bad_times[GF_FOP_PRI_MAX] = { 0, };
- threshold_t thresholds[GF_FOP_PRI_MAX] = { { 0, } };
-
- for (;;) {
- sleep (max (priv->watchdog_secs/5, 1));
- pthread_setcancelstate (PTHREAD_CANCEL_DISABLE, NULL);
- pthread_mutex_lock (&priv->mutex);
- for (i = 0; i < GF_FOP_PRI_MAX; ++i) {
- if (priv->queue_marked[i]) {
- if (++bad_times[i] >= 5) {
- gf_log (this->name, GF_LOG_WARNING,
- "queue %d stalled", i);
- iot_apply_event (this, &thresholds[i]);
- /*
- * We might not get here if the event
- * put us over our threshold.
- */
- ++(priv->ac_iot_limit[i]);
- bad_times[i] = 0;
- }
- } else {
- bad_times[i] = 0;
- }
- priv->queue_marked[i] = (priv->queue_sizes[i] > 0);
+iot_watchdog(void *arg)
+{
+ xlator_t *this = arg;
+ iot_conf_t *priv = this->private;
+ int i;
+ int bad_times[GF_FOP_PRI_MAX] = {
+ 0,
+ };
+ threshold_t thresholds[GF_FOP_PRI_MAX] = {{
+ 0,
+ }};
+
+ for (;;) {
+ sleep(max(priv->watchdog_secs / 5, 1));
+ pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
+ pthread_mutex_lock(&priv->mutex);
+ for (i = 0; i < GF_FOP_PRI_MAX; ++i) {
+ if (priv->queue_marked[i]) {
+ if (++bad_times[i] >= 5) {
+ gf_log(this->name, GF_LOG_WARNING, "queue %d stalled", i);
+ iot_apply_event(this, &thresholds[i]);
+ /*
+ * We might not get here if the event
+ * put us over our threshold.
+ */
+ ++(priv->ac_iot_limit[i]);
+ bad_times[i] = 0;
}
- pthread_mutex_unlock (&priv->mutex);
- pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, NULL);
+ } else {
+ bad_times[i] = 0;
+ }
+ priv->queue_marked[i] = (priv->queue_sizes[i] > 0);
}
+ pthread_mutex_unlock(&priv->mutex);
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
+ }
- /* NOTREACHED */
- return NULL;
+ /* NOTREACHED */
+ return NULL;
}
static void
-start_iot_watchdog (xlator_t *this)
+start_iot_watchdog(xlator_t *this)
{
- iot_conf_t *priv = this->private;
- int ret;
+ iot_conf_t *priv = this->private;
+ int ret;
- if (priv->watchdog_running) {
- return;
- }
+ if (priv->watchdog_running) {
+ return;
+ }
- ret = pthread_create (&priv->watchdog_thread, NULL, iot_watchdog, this);
- if (ret == 0) {
- priv->watchdog_running = _gf_true;
- } else {
- gf_log (this->name, GF_LOG_WARNING,
- "pthread_create(iot_watchdog) failed");
- }
+ ret = pthread_create(&priv->watchdog_thread, NULL, iot_watchdog, this);
+ if (ret == 0) {
+ priv->watchdog_running = _gf_true;
+ } else {
+ gf_log(this->name, GF_LOG_WARNING,
+ "pthread_create(iot_watchdog) failed");
+ }
}
static void
-stop_iot_watchdog (xlator_t *this)
+stop_iot_watchdog(xlator_t *this)
{
- iot_conf_t *priv = this->private;
+ iot_conf_t *priv = this->private;
- if (!priv->watchdog_running) {
- return;
- }
+ if (!priv->watchdog_running) {
+ return;
+ }
- if (pthread_cancel (priv->watchdog_thread) != 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "pthread_cancel(iot_watchdog) failed");
- }
+ if (pthread_cancel(priv->watchdog_thread) != 0) {
+ gf_log(this->name, GF_LOG_WARNING,
+ "pthread_cancel(iot_watchdog) failed");
+ }
- if (pthread_join (priv->watchdog_thread, NULL) != 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "pthread_join(iot_watchdog) failed");
- }
+ if (pthread_join(priv->watchdog_thread, NULL) != 0) {
+ gf_log(this->name, GF_LOG_WARNING, "pthread_join(iot_watchdog) failed");
+ }
- /* Failure probably means it's already dead. */
- priv->watchdog_running = _gf_false;
+ /* Failure probably means it's already dead. */
+ priv->watchdog_running = _gf_false;
}
int
-reconfigure (xlator_t *this, dict_t *options)
+reconfigure(xlator_t *this, dict_t *options)
{
- iot_conf_t *conf = NULL;
- int ret = -1;
+ iot_conf_t *conf = NULL;
+ int ret = -1;
- conf = this->private;
- if (!conf)
- goto out;
+ conf = this->private;
+ if (!conf)
+ goto out;
- GF_OPTION_RECONF ("thread-count", conf->max_count, options, int32, out);
+ GF_OPTION_RECONF("thread-count", conf->max_count, options, int32, out);
- GF_OPTION_RECONF ("high-prio-threads",
- conf->ac_iot_limit[GF_FOP_PRI_HI], options, int32,
- out);
+ GF_OPTION_RECONF("high-prio-threads", conf->ac_iot_limit[GF_FOP_PRI_HI],
+ options, int32, out);
- GF_OPTION_RECONF ("normal-prio-threads",
- conf->ac_iot_limit[GF_FOP_PRI_NORMAL], options, int32,
- out);
+ GF_OPTION_RECONF("normal-prio-threads",
+ conf->ac_iot_limit[GF_FOP_PRI_NORMAL], options, int32,
+ out);
- GF_OPTION_RECONF ("low-prio-threads",
- conf->ac_iot_limit[GF_FOP_PRI_LO], options, int32,
- out);
+ GF_OPTION_RECONF("low-prio-threads", conf->ac_iot_limit[GF_FOP_PRI_LO],
+ options, int32, out);
- GF_OPTION_RECONF ("least-prio-threads",
- conf->ac_iot_limit[GF_FOP_PRI_LEAST], options, int32,
- out);
+ GF_OPTION_RECONF("least-prio-threads", conf->ac_iot_limit[GF_FOP_PRI_LEAST],
+ options, int32, out);
- GF_OPTION_RECONF ("enable-least-priority", conf->least_priority,
- options, bool, out);
+ GF_OPTION_RECONF("enable-least-priority", conf->least_priority, options,
+ bool, out);
- GF_OPTION_RECONF ("cleanup-disconnected-reqs",
- conf->cleanup_disconnected_reqs, options, bool, out);
+ GF_OPTION_RECONF("cleanup-disconnected-reqs",
+ conf->cleanup_disconnected_reqs, options, bool, out);
- GF_OPTION_RECONF ("watchdog-secs", conf->watchdog_secs, options,
- int32, out);
+ GF_OPTION_RECONF("watchdog-secs", conf->watchdog_secs, options, int32, out);
- GF_OPTION_RECONF ("pass-through", this->pass_through, options, bool,
- out);
+ GF_OPTION_RECONF("pass-through", this->pass_through, options, bool, out);
- if (conf->watchdog_secs > 0) {
- start_iot_watchdog (this);
- } else {
- stop_iot_watchdog (this);
- }
+ if (conf->watchdog_secs > 0) {
+ start_iot_watchdog(this);
+ } else {
+ stop_iot_watchdog(this);
+ }
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
int
-init (xlator_t *this)
-{
- iot_conf_t *conf = NULL;
- int ret = -1;
- int i = 0;
-
- if (!this->children || this->children->next) {
- gf_msg ("io-threads", GF_LOG_ERROR, 0,
- IO_THREADS_MSG_XLATOR_CHILD_MISCONFIGURED,
- "FATAL: iot not configured "
- "with exactly one child");
- goto out;
- }
-
- if (!this->parents) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- IO_THREADS_MSG_VOL_MISCONFIGURED,
- "dangling volume. check volfile ");
- }
-
- conf = (void *) GF_CALLOC (1, sizeof (*conf),
- gf_iot_mt_iot_conf_t);
- if (conf == NULL) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- IO_THREADS_MSG_NO_MEMORY, "out of memory");
- goto out;
- }
+init(xlator_t *this)
+{
+ iot_conf_t *conf = NULL;
+ int ret = -1;
+ int i = 0;
- if ((ret = pthread_cond_init(&conf->cond, NULL)) != 0) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- IO_THREADS_MSG_INIT_FAILED,
- "pthread_cond_init failed (%d)", ret);
- goto out;
- }
- conf->cond_inited = _gf_true;
+ if (!this->children || this->children->next) {
+ gf_msg("io-threads", GF_LOG_ERROR, 0,
+ IO_THREADS_MSG_XLATOR_CHILD_MISCONFIGURED,
+ "FATAL: iot not configured "
+ "with exactly one child");
+ goto out;
+ }
- if ((ret = pthread_mutex_init(&conf->mutex, NULL)) != 0) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- IO_THREADS_MSG_INIT_FAILED,
- "pthread_mutex_init failed (%d)", ret);
- goto out;
- }
- conf->mutex_inited = _gf_true;
+ if (!this->parents) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, IO_THREADS_MSG_VOL_MISCONFIGURED,
+ "dangling volume. check volfile ");
+ }
- ret = set_stack_size (conf);
+ conf = (void *)GF_CALLOC(1, sizeof(*conf), gf_iot_mt_iot_conf_t);
+ if (conf == NULL) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, IO_THREADS_MSG_NO_MEMORY,
+ "out of memory");
+ goto out;
+ }
- if (ret != 0)
- goto out;
+ if ((ret = pthread_cond_init(&conf->cond, NULL)) != 0) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_THREADS_MSG_INIT_FAILED,
+ "pthread_cond_init failed (%d)", ret);
+ goto out;
+ }
+ conf->cond_inited = _gf_true;
- GF_OPTION_INIT ("thread-count", conf->max_count, int32, out);
+ if ((ret = pthread_mutex_init(&conf->mutex, NULL)) != 0) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_THREADS_MSG_INIT_FAILED,
+ "pthread_mutex_init failed (%d)", ret);
+ goto out;
+ }
+ conf->mutex_inited = _gf_true;
- GF_OPTION_INIT ("high-prio-threads",
- conf->ac_iot_limit[GF_FOP_PRI_HI], int32, out);
+ ret = set_stack_size(conf);
- GF_OPTION_INIT ("normal-prio-threads",
- conf->ac_iot_limit[GF_FOP_PRI_NORMAL], int32, out);
+ if (ret != 0)
+ goto out;
- GF_OPTION_INIT ("low-prio-threads",
- conf->ac_iot_limit[GF_FOP_PRI_LO], int32, out);
+ GF_OPTION_INIT("thread-count", conf->max_count, int32, out);
- GF_OPTION_INIT ("least-prio-threads",
- conf->ac_iot_limit[GF_FOP_PRI_LEAST], int32, out);
+ GF_OPTION_INIT("high-prio-threads", conf->ac_iot_limit[GF_FOP_PRI_HI],
+ int32, out);
- GF_OPTION_INIT ("idle-time", conf->idle_time, int32, out);
+ GF_OPTION_INIT("normal-prio-threads", conf->ac_iot_limit[GF_FOP_PRI_NORMAL],
+ int32, out);
- GF_OPTION_INIT ("enable-least-priority", conf->least_priority,
- bool, out);
+ GF_OPTION_INIT("low-prio-threads", conf->ac_iot_limit[GF_FOP_PRI_LO], int32,
+ out);
- GF_OPTION_INIT ("cleanup-disconnected-reqs",
- conf->cleanup_disconnected_reqs, bool, out);
+ GF_OPTION_INIT("least-prio-threads", conf->ac_iot_limit[GF_FOP_PRI_LEAST],
+ int32, out);
- GF_OPTION_INIT ("pass-through", this->pass_through, bool, out);
+ GF_OPTION_INIT("idle-time", conf->idle_time, int32, out);
- conf->this = this;
+ GF_OPTION_INIT("enable-least-priority", conf->least_priority, bool, out);
- for (i = 0; i < GF_FOP_PRI_MAX; i++) {
- INIT_LIST_HEAD (&conf->clients[i]);
- INIT_LIST_HEAD (&conf->no_client[i].clients);
- INIT_LIST_HEAD (&conf->no_client[i].reqs);
- }
+ GF_OPTION_INIT("cleanup-disconnected-reqs", conf->cleanup_disconnected_reqs,
+ bool, out);
- ret = iot_workers_scale (conf);
+ GF_OPTION_INIT("pass-through", this->pass_through, bool, out);
- if (ret == -1) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- IO_THREADS_MSG_INIT_FAILED,
- "cannot initialize worker threads, exiting init");
- goto out;
- }
+ conf->this = this;
- this->private = conf;
+ for (i = 0; i < GF_FOP_PRI_MAX; i++) {
+ INIT_LIST_HEAD(&conf->clients[i]);
+ INIT_LIST_HEAD(&conf->no_client[i].clients);
+ INIT_LIST_HEAD(&conf->no_client[i].reqs);
+ }
- conf->watchdog_secs = 0;
- GF_OPTION_INIT ("watchdog-secs", conf->watchdog_secs, int32, out);
- if (conf->watchdog_secs > 0) {
- start_iot_watchdog (this);
- }
+ ret = iot_workers_scale(conf);
+
+ if (ret == -1) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, IO_THREADS_MSG_INIT_FAILED,
+ "cannot initialize worker threads, exiting init");
+ goto out;
+ }
- ret = 0;
+ this->private = conf;
+
+ conf->watchdog_secs = 0;
+ GF_OPTION_INIT("watchdog-secs", conf->watchdog_secs, int32, out);
+ if (conf->watchdog_secs > 0) {
+ start_iot_watchdog(this);
+ }
+
+ ret = 0;
out:
- if (ret)
- GF_FREE (conf);
+ if (ret)
+ GF_FREE(conf);
- return ret;
+ return ret;
}
static void
-iot_exit_threads (iot_conf_t *conf)
+iot_exit_threads(iot_conf_t *conf)
{
- pthread_mutex_lock (&conf->mutex);
- {
- conf->down = _gf_true;
- /*Let all the threads know that xl is going down*/
- pthread_cond_broadcast (&conf->cond);
- while (conf->curr_count)/*Wait for threads to exit*/
- pthread_cond_wait (&conf->cond, &conf->mutex);
- }
- pthread_mutex_unlock (&conf->mutex);
+ pthread_mutex_lock(&conf->mutex);
+ {
+ conf->down = _gf_true;
+ /*Let all the threads know that xl is going down*/
+ pthread_cond_broadcast(&conf->cond);
+ while (conf->curr_count) /*Wait for threads to exit*/
+ pthread_cond_wait(&conf->cond, &conf->mutex);
+ }
+ pthread_mutex_unlock(&conf->mutex);
}
int
-notify (xlator_t *this, int32_t event, void *data, ...)
+notify(xlator_t *this, int32_t event, void *data, ...)
{
- iot_conf_t *conf = this->private;
+ iot_conf_t *conf = this->private;
- if (GF_EVENT_PARENT_DOWN == event)
- iot_exit_threads (conf);
+ if (GF_EVENT_PARENT_DOWN == event)
+ iot_exit_threads(conf);
- default_notify (this, event, data);
+ default_notify(this, event, data);
- return 0;
+ return 0;
}
void
-fini (xlator_t *this)
+fini(xlator_t *this)
{
- iot_conf_t *conf = this->private;
+ iot_conf_t *conf = this->private;
- if (!conf)
- return;
+ if (!conf)
+ return;
- if (conf->mutex_inited && conf->cond_inited)
- iot_exit_threads (conf);
+ if (conf->mutex_inited && conf->cond_inited)
+ iot_exit_threads(conf);
- if (conf->cond_inited)
- pthread_cond_destroy (&conf->cond);
+ if (conf->cond_inited)
+ pthread_cond_destroy(&conf->cond);
- if (conf->mutex_inited)
- pthread_mutex_destroy (&conf->mutex);
+ if (conf->mutex_inited)
+ pthread_mutex_destroy(&conf->mutex);
- stop_iot_watchdog (this);
+ stop_iot_watchdog(this);
- GF_FREE (conf);
+ GF_FREE(conf);
- this->private = NULL;
- return;
+ this->private = NULL;
+ return;
}
int
-iot_client_destroy (xlator_t *this, client_t *client)
+iot_client_destroy(xlator_t *this, client_t *client)
{
- void *tmp = NULL;
+ void *tmp = NULL;
- if (client_ctx_del (client, this, &tmp) == 0) {
- GF_FREE (tmp);
- }
+ if (client_ctx_del(client, this, &tmp) == 0) {
+ GF_FREE(tmp);
+ }
- return 0;
+ return 0;
}
static int
-iot_disconnect_cbk (xlator_t *this, client_t *client)
-{
- int i;
- call_stub_t *curr;
- call_stub_t *next;
- iot_conf_t *conf = this->private;
- iot_client_ctx_t *ctx;
-
- if (!conf || !conf->cleanup_disconnected_reqs) {
- goto out;
- }
-
- pthread_mutex_lock (&conf->mutex);
- for (i = 0; i < GF_FOP_PRI_MAX; i++) {
- ctx = &conf->no_client[i];
- list_for_each_entry_safe (curr, next, &ctx->reqs, list) {
- if (curr->frame->root->client != client) {
- continue;
- }
- gf_log (this->name, GF_LOG_INFO,
- "poisoning %s fop at %p for client %s",
- gf_fop_list[curr->fop], curr,
- client->client_uid);
- curr->poison = _gf_true;
- }
+iot_disconnect_cbk(xlator_t *this, client_t *client)
+{
+ int i;
+ call_stub_t *curr;
+ call_stub_t *next;
+ iot_conf_t *conf = this->private;
+ iot_client_ctx_t *ctx;
+
+ if (!conf || !conf->cleanup_disconnected_reqs) {
+ goto out;
+ }
+
+ pthread_mutex_lock(&conf->mutex);
+ for (i = 0; i < GF_FOP_PRI_MAX; i++) {
+ ctx = &conf->no_client[i];
+ list_for_each_entry_safe(curr, next, &ctx->reqs, list)
+ {
+ if (curr->frame->root->client != client) {
+ continue;
+ }
+ gf_log(this->name, GF_LOG_INFO,
+ "poisoning %s fop at %p for client %s",
+ gf_fop_list[curr->fop], curr, client->client_uid);
+ curr->poison = _gf_true;
}
- pthread_mutex_unlock (&conf->mutex);
+ }
+ pthread_mutex_unlock(&conf->mutex);
out:
- return 0;
+ return 0;
}
struct xlator_dumpops dumpops = {
- .priv = iot_priv_dump,
+ .priv = iot_priv_dump,
};
struct xlator_fops fops = {
- .open = iot_open,
- .create = iot_create,
- .readv = iot_readv,
- .writev = iot_writev,
- .flush = iot_flush,
- .fsync = iot_fsync,
- .lk = iot_lk,
- .stat = iot_stat,
- .fstat = iot_fstat,
- .truncate = iot_truncate,
- .ftruncate = iot_ftruncate,
- .unlink = iot_unlink,
- .lookup = iot_lookup,
- .setattr = iot_setattr,
- .fsetattr = iot_fsetattr,
- .access = iot_access,
- .readlink = iot_readlink,
- .mknod = iot_mknod,
- .mkdir = iot_mkdir,
- .rmdir = iot_rmdir,
- .symlink = iot_symlink,
- .rename = iot_rename,
- .link = iot_link,
- .opendir = iot_opendir,
- .fsyncdir = iot_fsyncdir,
- .statfs = iot_statfs,
- .setxattr = iot_setxattr,
- .getxattr = iot_getxattr,
- .fgetxattr = iot_fgetxattr,
- .fsetxattr = iot_fsetxattr,
- .removexattr = iot_removexattr,
- .fremovexattr = iot_fremovexattr,
- .readdir = iot_readdir,
- .readdirp = iot_readdirp,
- .inodelk = iot_inodelk,
- .finodelk = iot_finodelk,
- .entrylk = iot_entrylk,
- .fentrylk = iot_fentrylk,
- .xattrop = iot_xattrop,
- .fxattrop = iot_fxattrop,
- .rchecksum = iot_rchecksum,
- .fallocate = iot_fallocate,
- .discard = iot_discard,
- .zerofill = iot_zerofill,
- .seek = iot_seek,
- .lease = iot_lease,
- .getactivelk = iot_getactivelk,
- .setactivelk = iot_setactivelk,
- .put = iot_put,
+ .open = iot_open,
+ .create = iot_create,
+ .readv = iot_readv,
+ .writev = iot_writev,
+ .flush = iot_flush,
+ .fsync = iot_fsync,
+ .lk = iot_lk,
+ .stat = iot_stat,
+ .fstat = iot_fstat,
+ .truncate = iot_truncate,
+ .ftruncate = iot_ftruncate,
+ .unlink = iot_unlink,
+ .lookup = iot_lookup,
+ .setattr = iot_setattr,
+ .fsetattr = iot_fsetattr,
+ .access = iot_access,
+ .readlink = iot_readlink,
+ .mknod = iot_mknod,
+ .mkdir = iot_mkdir,
+ .rmdir = iot_rmdir,
+ .symlink = iot_symlink,
+ .rename = iot_rename,
+ .link = iot_link,
+ .opendir = iot_opendir,
+ .fsyncdir = iot_fsyncdir,
+ .statfs = iot_statfs,
+ .setxattr = iot_setxattr,
+ .getxattr = iot_getxattr,
+ .fgetxattr = iot_fgetxattr,
+ .fsetxattr = iot_fsetxattr,
+ .removexattr = iot_removexattr,
+ .fremovexattr = iot_fremovexattr,
+ .readdir = iot_readdir,
+ .readdirp = iot_readdirp,
+ .inodelk = iot_inodelk,
+ .finodelk = iot_finodelk,
+ .entrylk = iot_entrylk,
+ .fentrylk = iot_fentrylk,
+ .xattrop = iot_xattrop,
+ .fxattrop = iot_fxattrop,
+ .rchecksum = iot_rchecksum,
+ .fallocate = iot_fallocate,
+ .discard = iot_discard,
+ .zerofill = iot_zerofill,
+ .seek = iot_seek,
+ .lease = iot_lease,
+ .getactivelk = iot_getactivelk,
+ .setactivelk = iot_setactivelk,
+ .put = iot_put,
};
struct xlator_cbks cbks = {
- .client_destroy = iot_client_destroy,
- .client_disconnect = iot_disconnect_cbk,
+ .client_destroy = iot_client_destroy,
+ .client_disconnect = iot_disconnect_cbk,
};
struct volume_options options[] = {
- { .key = {"thread-count"},
- .type = GF_OPTION_TYPE_INT,
- .min = IOT_MIN_THREADS,
- .max = IOT_MAX_THREADS,
- .default_value = "16",
- .op_version = {1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .tags = {"io-threads"},
- /*.option = "thread-count"*/
- .description = "Number of threads in IO threads translator which "
- "perform concurrent IO operations"
-
- },
- { .key = {"high-prio-threads"},
- .type = GF_OPTION_TYPE_INT,
- .min = IOT_MIN_THREADS,
- .max = IOT_MAX_THREADS,
- .default_value = "16",
- .op_version = {1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .tags = {"io-threads"},
- .description = "Max number of threads in IO threads translator which "
- "perform high priority IO operations at a given time"
-
- },
- { .key = {"normal-prio-threads"},
- .type = GF_OPTION_TYPE_INT,
- .min = IOT_MIN_THREADS,
- .max = IOT_MAX_THREADS,
- .default_value = "16",
- .op_version = {1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .tags = {"io-threads"},
- .description = "Max number of threads in IO threads translator which "
- "perform normal priority IO operations at a given time"
-
- },
- { .key = {"low-prio-threads"},
- .type = GF_OPTION_TYPE_INT,
- .min = IOT_MIN_THREADS,
- .max = IOT_MAX_THREADS,
- .default_value = "16",
- .op_version = {1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .tags = {"io-threads"},
- .description = "Max number of threads in IO threads translator which "
- "perform low priority IO operations at a given time"
-
- },
- { .key = {"least-prio-threads"},
- .type = GF_OPTION_TYPE_INT,
- .min = IOT_MIN_THREADS,
- .max = IOT_MAX_THREADS,
- .default_value = "1",
- .op_version = {1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .tags = {"io-threads"},
- .description = "Max number of threads in IO threads translator which "
- "perform least priority IO operations at a given time"
- },
- { .key = {"enable-least-priority"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = SITE_H_ENABLE_LEAST_PRIORITY,
- .op_version = {1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .tags = {"io-threads"},
- .description = "Enable/Disable least priority"
- },
- { .key = {"idle-time"},
- .type = GF_OPTION_TYPE_INT,
- .min = 1,
- .max = 0x7fffffff,
- .default_value = "120",
- },
- { .key = {"watchdog-secs"},
- .type = GF_OPTION_TYPE_INT,
- .min = 0,
- .default_value = 0,
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .tags = {"io-threads"},
- .description = "Number of seconds a queue must be stalled before "
- "starting an 'emergency' thread."
- },
- { .key = {"cleanup-disconnected-reqs"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "off",
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"io-threads"},
- .description = "'Poison' queued requests when a client disconnects"
- },
- { .key = {"pass-through"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"io-threads"},
- .description = "Enable/Disable io threads translator"
- },
- { .key = {NULL},
- },
+ {.key = {"thread-count"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = IOT_MIN_THREADS,
+ .max = IOT_MAX_THREADS,
+ .default_value = "16",
+ .op_version = {1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .tags = {"io-threads"},
+ /*.option = "thread-count"*/
+ .description = "Number of threads in IO threads translator which "
+ "perform concurrent IO operations"
+
+ },
+ {.key = {"high-prio-threads"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = IOT_MIN_THREADS,
+ .max = IOT_MAX_THREADS,
+ .default_value = "16",
+ .op_version = {1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .tags = {"io-threads"},
+ .description = "Max number of threads in IO threads translator which "
+ "perform high priority IO operations at a given time"
+
+ },
+ {.key = {"normal-prio-threads"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = IOT_MIN_THREADS,
+ .max = IOT_MAX_THREADS,
+ .default_value = "16",
+ .op_version = {1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .tags = {"io-threads"},
+ .description = "Max number of threads in IO threads translator which "
+ "perform normal priority IO operations at a given time"
+
+ },
+ {.key = {"low-prio-threads"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = IOT_MIN_THREADS,
+ .max = IOT_MAX_THREADS,
+ .default_value = "16",
+ .op_version = {1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .tags = {"io-threads"},
+ .description = "Max number of threads in IO threads translator which "
+ "perform low priority IO operations at a given time"
+
+ },
+ {.key = {"least-prio-threads"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = IOT_MIN_THREADS,
+ .max = IOT_MAX_THREADS,
+ .default_value = "1",
+ .op_version = {1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .tags = {"io-threads"},
+ .description = "Max number of threads in IO threads translator which "
+ "perform least priority IO operations at a given time"},
+ {.key = {"enable-least-priority"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = SITE_H_ENABLE_LEAST_PRIORITY,
+ .op_version = {1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .tags = {"io-threads"},
+ .description = "Enable/Disable least priority"},
+ {
+ .key = {"idle-time"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = 1,
+ .max = 0x7fffffff,
+ .default_value = "120",
+ },
+ {.key = {"watchdog-secs"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = 0,
+ .default_value = 0,
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .tags = {"io-threads"},
+ .description = "Number of seconds a queue must be stalled before "
+ "starting an 'emergency' thread."},
+ {.key = {"cleanup-disconnected-reqs"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"io-threads"},
+ .description = "'Poison' queued requests when a client disconnects"},
+ {.key = {"pass-through"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"io-threads"},
+ .description = "Enable/Disable io threads translator"},
+ {
+ .key = {NULL},
+ },
};
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c
index 1e208b3638f..21cc9de081e 100644
--- a/xlators/performance/md-cache/src/md-cache.c
+++ b/xlators/performance/md-cache/src/md-cache.c
@@ -32,3835 +32,3708 @@
*/
struct mdc_statfs_cache {
- pthread_mutex_t lock;
- gf_boolean_t initialized;
- struct timespec last_refreshed;
- struct statvfs buf;
+ pthread_mutex_t lock;
+ gf_boolean_t initialized;
+ struct timespec last_refreshed;
+ struct statvfs buf;
};
struct mdc_statistics {
- gf_atomic_t stat_hit; /* No. of times lookup/stat was served from
- mdc */
+ gf_atomic_t stat_hit; /* No. of times lookup/stat was served from
+ mdc */
- gf_atomic_t stat_miss; /* No. of times valid stat wasn't present in
- mdc */
+ gf_atomic_t stat_miss; /* No. of times valid stat wasn't present in
+ mdc */
- gf_atomic_t xattr_hit; /* No. of times getxattr was served from mdc,
- Note: this doesn't count the xattr served
- from lookup */
+ gf_atomic_t xattr_hit; /* No. of times getxattr was served from mdc,
+ Note: this doesn't count the xattr served
+ from lookup */
- gf_atomic_t xattr_miss; /* No. of times xattr req was WIND from mdc */
- gf_atomic_t negative_lookup; /* No. of negative lookups */
- gf_atomic_t nameless_lookup; /* No. of negative lookups that were sent
- to bricks */
+ gf_atomic_t xattr_miss; /* No. of times xattr req was WIND from mdc */
+ gf_atomic_t negative_lookup; /* No. of negative lookups */
+ gf_atomic_t nameless_lookup; /* No. of negative lookups that were sent
+ to bricks */
- gf_atomic_t stat_invals; /* No. of invalidates received from upcall */
- gf_atomic_t xattr_invals; /* No. of invalidates received from upcall */
- gf_atomic_t need_lookup; /* No. of lookups issued, because other
- xlators requested for explicit lookup */
+ gf_atomic_t stat_invals; /* No. of invalidates received from upcall */
+ gf_atomic_t xattr_invals; /* No. of invalidates received from upcall */
+ gf_atomic_t need_lookup; /* No. of lookups issued, because other
+ xlators requested for explicit lookup */
};
-
struct mdc_conf {
- int timeout;
- gf_boolean_t cache_posix_acl;
- gf_boolean_t cache_selinux;
- gf_boolean_t cache_capability;
- gf_boolean_t cache_ima;
- gf_boolean_t force_readdirp;
- gf_boolean_t cache_swift_metadata;
- gf_boolean_t cache_samba_metadata;
- gf_boolean_t mdc_invalidation;
- time_t last_child_down;
- gf_lock_t lock;
- struct mdc_statistics mdc_counter;
- gf_boolean_t cache_statfs;
- struct mdc_statfs_cache statfs_cache;
- char *mdc_xattr_str;
- gf_atomic_int32_t generation;
+ int timeout;
+ gf_boolean_t cache_posix_acl;
+ gf_boolean_t cache_selinux;
+ gf_boolean_t cache_capability;
+ gf_boolean_t cache_ima;
+ gf_boolean_t force_readdirp;
+ gf_boolean_t cache_swift_metadata;
+ gf_boolean_t cache_samba_metadata;
+ gf_boolean_t mdc_invalidation;
+ time_t last_child_down;
+ gf_lock_t lock;
+ struct mdc_statistics mdc_counter;
+ gf_boolean_t cache_statfs;
+ struct mdc_statfs_cache statfs_cache;
+ char *mdc_xattr_str;
+ gf_atomic_int32_t generation;
};
-
struct mdc_local;
typedef struct mdc_local mdc_local_t;
-#define MDC_STACK_UNWIND(fop, frame, params ...) do { \
- mdc_local_t *__local = NULL; \
- xlator_t *__xl = NULL; \
- if (frame) { \
- __xl = frame->this; \
- __local = frame->local; \
- frame->local = NULL; \
- } \
- STACK_UNWIND_STRICT (fop, frame, params); \
- mdc_local_wipe (__xl, __local); \
- } while (0)
-
+#define MDC_STACK_UNWIND(fop, frame, params...) \
+ do { \
+ mdc_local_t *__local = NULL; \
+ xlator_t *__xl = NULL; \
+ if (frame) { \
+ __xl = frame->this; \
+ __local = frame->local; \
+ frame->local = NULL; \
+ } \
+ STACK_UNWIND_STRICT(fop, frame, params); \
+ mdc_local_wipe(__xl, __local); \
+ } while (0)
struct md_cache {
- ia_prot_t md_prot;
- uint32_t md_nlink;
- uint32_t md_uid;
- uint32_t md_gid;
- uint32_t md_atime;
- uint32_t md_atime_nsec;
- uint32_t md_mtime;
- uint32_t md_mtime_nsec;
- uint32_t md_ctime;
- uint32_t md_ctime_nsec;
- uint64_t md_rdev;
- uint64_t md_size;
- uint64_t md_blocks;
- uint64_t invalidation_time;
- uint64_t generation;
- dict_t *xattr;
- char *linkname;
- time_t ia_time;
- time_t xa_time;
- gf_boolean_t need_lookup;
- gf_boolean_t valid;
- gf_boolean_t gen_rollover;
- gf_boolean_t invalidation_rollover;
- gf_lock_t lock;
+ ia_prot_t md_prot;
+ uint32_t md_nlink;
+ uint32_t md_uid;
+ uint32_t md_gid;
+ uint32_t md_atime;
+ uint32_t md_atime_nsec;
+ uint32_t md_mtime;
+ uint32_t md_mtime_nsec;
+ uint32_t md_ctime;
+ uint32_t md_ctime_nsec;
+ uint64_t md_rdev;
+ uint64_t md_size;
+ uint64_t md_blocks;
+ uint64_t invalidation_time;
+ uint64_t generation;
+ dict_t *xattr;
+ char *linkname;
+ time_t ia_time;
+ time_t xa_time;
+ gf_boolean_t need_lookup;
+ gf_boolean_t valid;
+ gf_boolean_t gen_rollover;
+ gf_boolean_t invalidation_rollover;
+ gf_lock_t lock;
};
-
struct mdc_local {
- loc_t loc;
- loc_t loc2;
- fd_t *fd;
- char *linkname;
- char *key;
- dict_t *xattr;
- uint64_t incident_time;
+ loc_t loc;
+ loc_t loc2;
+ fd_t *fd;
+ char *linkname;
+ char *key;
+ dict_t *xattr;
+ uint64_t incident_time;
};
-
int
-__mdc_inode_ctx_get (xlator_t *this, inode_t *inode, struct md_cache **mdc_p)
+__mdc_inode_ctx_get(xlator_t *this, inode_t *inode, struct md_cache **mdc_p)
{
- int ret = 0;
- struct md_cache *mdc = NULL;
- uint64_t mdc_int = 0;
+ int ret = 0;
+ struct md_cache *mdc = NULL;
+ uint64_t mdc_int = 0;
- ret = __inode_ctx_get (inode, this, &mdc_int);
- mdc = (void *) (long) (mdc_int);
- if (ret == 0 && mdc_p)
- *mdc_p = mdc;
+ ret = __inode_ctx_get(inode, this, &mdc_int);
+ mdc = (void *)(long)(mdc_int);
+ if (ret == 0 && mdc_p)
+ *mdc_p = mdc;
- return ret;
+ return ret;
}
-
int
-mdc_inode_ctx_get (xlator_t *this, inode_t *inode, struct md_cache **mdc_p)
+mdc_inode_ctx_get(xlator_t *this, inode_t *inode, struct md_cache **mdc_p)
{
- int ret = -1;
+ int ret = -1;
- if (!inode)
- goto out;
+ if (!inode)
+ goto out;
- LOCK(&inode->lock);
- {
- ret = __mdc_inode_ctx_get (this, inode, mdc_p);
- }
- UNLOCK(&inode->lock);
+ LOCK(&inode->lock);
+ {
+ ret = __mdc_inode_ctx_get(this, inode, mdc_p);
+ }
+ UNLOCK(&inode->lock);
out:
- return ret;
+ return ret;
}
uint64_t
-__mdc_get_generation (xlator_t *this, struct md_cache *mdc)
+__mdc_get_generation(xlator_t *this, struct md_cache *mdc)
{
- uint64_t gen = 0, rollover;
- struct mdc_conf *conf = NULL;
+ uint64_t gen = 0, rollover;
+ struct mdc_conf *conf = NULL;
- conf = this->private;
+ conf = this->private;
- gen = GF_ATOMIC_INC (conf->generation);
- if (gen == 0) {
- mdc->gen_rollover = !mdc->gen_rollover;
- gen = GF_ATOMIC_INC (conf->generation);
- mdc->ia_time = 0;
- mdc->generation = 0;
- mdc->invalidation_time = gen - 1;
- }
+ gen = GF_ATOMIC_INC(conf->generation);
+ if (gen == 0) {
+ mdc->gen_rollover = !mdc->gen_rollover;
+ gen = GF_ATOMIC_INC(conf->generation);
+ mdc->ia_time = 0;
+ mdc->generation = 0;
+ mdc->invalidation_time = gen - 1;
+ }
- rollover = mdc->gen_rollover;
- gen |= (rollover << 32);
- return gen;
+ rollover = mdc->gen_rollover;
+ gen |= (rollover << 32);
+ return gen;
}
uint64_t
-mdc_get_generation (xlator_t *this, inode_t *inode)
+mdc_get_generation(xlator_t *this, inode_t *inode)
{
- struct mdc_conf *conf = NULL;
- uint64_t gen = 0;
- struct md_cache *mdc = NULL;
+ struct mdc_conf *conf = NULL;
+ uint64_t gen = 0;
+ struct md_cache *mdc = NULL;
- conf = this->private;
+ conf = this->private;
- mdc_inode_ctx_get (this, inode, &mdc);
+ mdc_inode_ctx_get(this, inode, &mdc);
- if (mdc) {
- LOCK (&mdc->lock);
- {
- gen = __mdc_get_generation (this, mdc);
- }
- UNLOCK (&mdc->lock);
- } else {
- gen = GF_ATOMIC_INC (conf->generation);
- if (gen == 0) {
- gen = GF_ATOMIC_INC (conf->generation);
- }
+ if (mdc) {
+ LOCK(&mdc->lock);
+ {
+ gen = __mdc_get_generation(this, mdc);
+ }
+ UNLOCK(&mdc->lock);
+ } else {
+ gen = GF_ATOMIC_INC(conf->generation);
+ if (gen == 0) {
+ gen = GF_ATOMIC_INC(conf->generation);
}
+ }
- return gen;
+ return gen;
}
int
-__mdc_inode_ctx_set (xlator_t *this, inode_t *inode, struct md_cache *mdc)
+__mdc_inode_ctx_set(xlator_t *this, inode_t *inode, struct md_cache *mdc)
{
- int ret = 0;
- uint64_t mdc_int = 0;
+ int ret = 0;
+ uint64_t mdc_int = 0;
- mdc_int = (long) mdc;
- ret = __inode_ctx_set (inode, this, &mdc_int);
+ mdc_int = (long)mdc;
+ ret = __inode_ctx_set(inode, this, &mdc_int);
- return ret;
+ return ret;
}
-
int
-mdc_inode_ctx_set (xlator_t *this, inode_t *inode, struct md_cache *mdc)
+mdc_inode_ctx_set(xlator_t *this, inode_t *inode, struct md_cache *mdc)
{
- int ret;
+ int ret;
- LOCK(&inode->lock);
- {
- ret = __mdc_inode_ctx_set (this, inode, mdc);
- }
- UNLOCK(&inode->lock);
+ LOCK(&inode->lock);
+ {
+ ret = __mdc_inode_ctx_set(this, inode, mdc);
+ }
+ UNLOCK(&inode->lock);
- return ret;
+ return ret;
}
-
mdc_local_t *
-mdc_local_get (call_frame_t *frame, inode_t *inode)
+mdc_local_get(call_frame_t *frame, inode_t *inode)
{
- mdc_local_t *local = NULL;
-
- local = frame->local;
- if (local)
- goto out;
+ mdc_local_t *local = NULL;
+ local = frame->local;
+ if (local)
+ goto out;
- local = GF_CALLOC (sizeof (*local), 1, gf_mdc_mt_mdc_local_t);
- if (!local)
- goto out;
+ local = GF_CALLOC(sizeof(*local), 1, gf_mdc_mt_mdc_local_t);
+ if (!local)
+ goto out;
- local->incident_time = mdc_get_generation (frame->this, inode);
- frame->local = local;
+ local->incident_time = mdc_get_generation(frame->this, inode);
+ frame->local = local;
out:
- return local;
+ return local;
}
-
void
-mdc_local_wipe (xlator_t *this, mdc_local_t *local)
+mdc_local_wipe(xlator_t *this, mdc_local_t *local)
{
- if (!local)
- return;
+ if (!local)
+ return;
- loc_wipe (&local->loc);
+ loc_wipe(&local->loc);
- loc_wipe (&local->loc2);
+ loc_wipe(&local->loc2);
- if (local->fd)
- fd_unref (local->fd);
+ if (local->fd)
+ fd_unref(local->fd);
- GF_FREE (local->linkname);
+ GF_FREE(local->linkname);
- GF_FREE (local->key);
+ GF_FREE(local->key);
- if (local->xattr)
- dict_unref (local->xattr);
+ if (local->xattr)
+ dict_unref(local->xattr);
- GF_FREE (local);
- return;
+ GF_FREE(local);
+ return;
}
-
int
-mdc_inode_wipe (xlator_t *this, inode_t *inode)
+mdc_inode_wipe(xlator_t *this, inode_t *inode)
{
- int ret = 0;
- uint64_t mdc_int = 0;
- struct md_cache *mdc = NULL;
+ int ret = 0;
+ uint64_t mdc_int = 0;
+ struct md_cache *mdc = NULL;
- ret = inode_ctx_del (inode, this, &mdc_int);
- if (ret != 0)
- goto out;
+ ret = inode_ctx_del(inode, this, &mdc_int);
+ if (ret != 0)
+ goto out;
- mdc = (void *) (long) mdc_int;
+ mdc = (void *)(long)mdc_int;
- if (mdc->xattr)
- dict_unref (mdc->xattr);
+ if (mdc->xattr)
+ dict_unref(mdc->xattr);
- GF_FREE (mdc->linkname);
+ GF_FREE(mdc->linkname);
- GF_FREE (mdc);
+ GF_FREE(mdc);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
struct md_cache *
-mdc_inode_prep (xlator_t *this, inode_t *inode)
+mdc_inode_prep(xlator_t *this, inode_t *inode)
{
- int ret = 0;
- struct md_cache *mdc = NULL;
+ int ret = 0;
+ struct md_cache *mdc = NULL;
- LOCK (&inode->lock);
- {
- ret = __mdc_inode_ctx_get (this, inode, &mdc);
- if (ret == 0)
- goto unlock;
-
- mdc = GF_CALLOC (sizeof (*mdc), 1, gf_mdc_mt_md_cache_t);
- if (!mdc) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- MD_CACHE_MSG_NO_MEMORY, "out of memory");
- goto unlock;
- }
-
- LOCK_INIT (&mdc->lock);
-
- ret = __mdc_inode_ctx_set (this, inode, mdc);
- if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- MD_CACHE_MSG_NO_MEMORY, "out of memory");
- GF_FREE (mdc);
- mdc = NULL;
- }
+ LOCK(&inode->lock);
+ {
+ ret = __mdc_inode_ctx_get(this, inode, &mdc);
+ if (ret == 0)
+ goto unlock;
+
+ mdc = GF_CALLOC(sizeof(*mdc), 1, gf_mdc_mt_md_cache_t);
+ if (!mdc) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, MD_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ goto unlock;
+ }
+
+ LOCK_INIT(&mdc->lock);
+
+ ret = __mdc_inode_ctx_set(this, inode, mdc);
+ if (ret) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, MD_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ GF_FREE(mdc);
+ mdc = NULL;
}
+ }
unlock:
- UNLOCK (&inode->lock);
+ UNLOCK(&inode->lock);
- return mdc;
+ return mdc;
}
-
/* Cache is valid if:
* - It is not cached before any brick was down. Brick down case is handled by
* invalidating all the cache when any brick went down.
* - The cache time is not expired
*/
static gf_boolean_t
-__is_cache_valid (xlator_t *this, time_t mdc_time)
+__is_cache_valid(xlator_t *this, time_t mdc_time)
{
- time_t now = 0;
- gf_boolean_t ret = _gf_true;
- struct mdc_conf *conf = NULL;
- int timeout = 0;
- time_t last_child_down = 0;
+ time_t now = 0;
+ gf_boolean_t ret = _gf_true;
+ struct mdc_conf *conf = NULL;
+ int timeout = 0;
+ time_t last_child_down = 0;
- conf = this->private;
+ conf = this->private;
- /* conf->lock here is not taken deliberately, so that the multi
- * threaded IO doesn't contend on a global lock. While updating
- * the variable, the lock is taken, so that at least the writes are
- * intact. The read of last_child_down may return junk, but that
- * is for a very short period of time.
- */
- last_child_down = conf->last_child_down;
- timeout = conf->timeout;
+ /* conf->lock here is not taken deliberately, so that the multi
+ * threaded IO doesn't contend on a global lock. While updating
+ * the variable, the lock is taken, so that at least the writes are
+ * intact. The read of last_child_down may return junk, but that
+ * is for a very short period of time.
+ */
+ last_child_down = conf->last_child_down;
+ timeout = conf->timeout;
- time (&now);
+ time(&now);
- if ((mdc_time == 0) ||
- ((last_child_down != 0) && (mdc_time < last_child_down))) {
- ret = _gf_false;
- goto out;
- }
+ if ((mdc_time == 0) ||
+ ((last_child_down != 0) && (mdc_time < last_child_down))) {
+ ret = _gf_false;
+ goto out;
+ }
- if (now >= (mdc_time + timeout)) {
- ret = _gf_false;
- }
+ if (now >= (mdc_time + timeout)) {
+ ret = _gf_false;
+ }
out:
- return ret;
+ return ret;
}
-
static gf_boolean_t
-is_md_cache_iatt_valid (xlator_t *this, struct md_cache *mdc)
+is_md_cache_iatt_valid(xlator_t *this, struct md_cache *mdc)
{
- gf_boolean_t ret = _gf_true;
+ gf_boolean_t ret = _gf_true;
- LOCK (&mdc->lock);
- {
- if (mdc->valid == _gf_false) {
- ret = mdc->valid;
- } else {
- ret = __is_cache_valid (this, mdc->ia_time);
- if (ret == _gf_false) {
- mdc->ia_time = 0;
- mdc->invalidation_time
- = __mdc_get_generation (this, mdc)
- & 0xffffffff;
- }
- }
+ LOCK(&mdc->lock);
+ {
+ if (mdc->valid == _gf_false) {
+ ret = mdc->valid;
+ } else {
+ ret = __is_cache_valid(this, mdc->ia_time);
+ if (ret == _gf_false) {
+ mdc->ia_time = 0;
+ mdc->invalidation_time = __mdc_get_generation(this, mdc) &
+ 0xffffffff;
+ }
}
- UNLOCK (&mdc->lock);
+ }
+ UNLOCK(&mdc->lock);
- return ret;
+ return ret;
}
-
static gf_boolean_t
-is_md_cache_xatt_valid (xlator_t *this, struct md_cache *mdc)
+is_md_cache_xatt_valid(xlator_t *this, struct md_cache *mdc)
{
- gf_boolean_t ret = _gf_true;
+ gf_boolean_t ret = _gf_true;
- LOCK (&mdc->lock);
- {
- ret = __is_cache_valid (this, mdc->xa_time);
- if (ret == _gf_false)
- mdc->xa_time = 0;
- }
- UNLOCK (&mdc->lock);
+ LOCK(&mdc->lock);
+ {
+ ret = __is_cache_valid(this, mdc->xa_time);
+ if (ret == _gf_false)
+ mdc->xa_time = 0;
+ }
+ UNLOCK(&mdc->lock);
- return ret;
+ return ret;
}
-
void
-mdc_from_iatt (struct md_cache *mdc, struct iatt *iatt)
-{
- mdc->md_prot = iatt->ia_prot;
- mdc->md_nlink = iatt->ia_nlink;
- mdc->md_uid = iatt->ia_uid;
- mdc->md_gid = iatt->ia_gid;
- mdc->md_atime = iatt->ia_atime;
- mdc->md_atime_nsec = iatt->ia_atime_nsec;
- mdc->md_mtime = iatt->ia_mtime;
- mdc->md_mtime_nsec = iatt->ia_mtime_nsec;
- mdc->md_ctime = iatt->ia_ctime;
- mdc->md_ctime_nsec = iatt->ia_ctime_nsec;
- mdc->md_rdev = iatt->ia_rdev;
- mdc->md_size = iatt->ia_size;
- mdc->md_blocks = iatt->ia_blocks;
+mdc_from_iatt(struct md_cache *mdc, struct iatt *iatt)
+{
+ mdc->md_prot = iatt->ia_prot;
+ mdc->md_nlink = iatt->ia_nlink;
+ mdc->md_uid = iatt->ia_uid;
+ mdc->md_gid = iatt->ia_gid;
+ mdc->md_atime = iatt->ia_atime;
+ mdc->md_atime_nsec = iatt->ia_atime_nsec;
+ mdc->md_mtime = iatt->ia_mtime;
+ mdc->md_mtime_nsec = iatt->ia_mtime_nsec;
+ mdc->md_ctime = iatt->ia_ctime;
+ mdc->md_ctime_nsec = iatt->ia_ctime_nsec;
+ mdc->md_rdev = iatt->ia_rdev;
+ mdc->md_size = iatt->ia_size;
+ mdc->md_blocks = iatt->ia_blocks;
}
-
void
-mdc_to_iatt (struct md_cache *mdc, struct iatt *iatt)
+mdc_to_iatt(struct md_cache *mdc, struct iatt *iatt)
{
- iatt->ia_prot = mdc->md_prot;
- iatt->ia_nlink = mdc->md_nlink;
- iatt->ia_uid = mdc->md_uid;
- iatt->ia_gid = mdc->md_gid;
- iatt->ia_atime = mdc->md_atime;
- iatt->ia_atime_nsec = mdc->md_atime_nsec;
- iatt->ia_mtime = mdc->md_mtime;
- iatt->ia_mtime_nsec = mdc->md_mtime_nsec;
- iatt->ia_ctime = mdc->md_ctime;
- iatt->ia_ctime_nsec = mdc->md_ctime_nsec;
- iatt->ia_rdev = mdc->md_rdev;
- iatt->ia_size = mdc->md_size;
- iatt->ia_blocks = mdc->md_blocks;
+ iatt->ia_prot = mdc->md_prot;
+ iatt->ia_nlink = mdc->md_nlink;
+ iatt->ia_uid = mdc->md_uid;
+ iatt->ia_gid = mdc->md_gid;
+ iatt->ia_atime = mdc->md_atime;
+ iatt->ia_atime_nsec = mdc->md_atime_nsec;
+ iatt->ia_mtime = mdc->md_mtime;
+ iatt->ia_mtime_nsec = mdc->md_mtime_nsec;
+ iatt->ia_ctime = mdc->md_ctime;
+ iatt->ia_ctime_nsec = mdc->md_ctime_nsec;
+ iatt->ia_rdev = mdc->md_rdev;
+ iatt->ia_size = mdc->md_size;
+ iatt->ia_blocks = mdc->md_blocks;
}
-
int
mdc_inode_iatt_set_validate(xlator_t *this, inode_t *inode, struct iatt *prebuf,
- struct iatt *iatt, gf_boolean_t update_time,
+ struct iatt *iatt, gf_boolean_t update_time,
uint64_t incident_time)
{
- int ret = 0;
- struct md_cache *mdc = NULL;
- uint32_t rollover = 0;
- uint64_t gen = 0;
-
- mdc = mdc_inode_prep (this, inode);
- if (!mdc) {
- ret = -1;
- goto out;
- }
-
- rollover = incident_time >> 32;
- incident_time = (incident_time & 0xffffffff);
-
- LOCK (&mdc->lock);
- {
- if (!iatt || !iatt->ia_ctime) {
- gf_msg_callingfn ("md-cache", GF_LOG_TRACE, 0, 0,
- "invalidating iatt(NULL)"
- "(%s)", uuid_utoa (inode->gfid));
- mdc->ia_time = 0;
- mdc->valid = 0;
-
- gen = __mdc_get_generation (this, mdc);
- mdc->invalidation_time = (gen & 0xffffffff);
- goto unlock;
- }
-
- /* There could be a race in invalidation, where the
- * invalidations in order A, B reaches md-cache in the order
- * B, A. Hence, make sure the invalidation A is discarded if
- * it comes after B. ctime of a file is always in ascending
- * order unlike atime and mtime(which can be changed by user
- * to any date), also ctime gets updates when atime/mtime
- * changes, hence check for ctime only.
- */
- if (mdc->md_ctime > iatt->ia_ctime) {
- gf_msg_callingfn (this->name, GF_LOG_DEBUG, EINVAL,
- MD_CACHE_MSG_DISCARD_UPDATE,
- "discarding the iatt validate "
- "request (%s)",
- uuid_utoa (inode->gfid));
- ret = -1;
- goto unlock;
-
- }
- if ((mdc->md_ctime == iatt->ia_ctime) &&
- (mdc->md_ctime_nsec > iatt->ia_ctime_nsec)) {
- gf_msg_callingfn (this->name, GF_LOG_DEBUG, EINVAL,
- MD_CACHE_MSG_DISCARD_UPDATE,
- "discarding the iatt validate "
- "request(ctime_nsec) (%s)",
- uuid_utoa (inode->gfid));
- ret = -1;
- goto unlock;
- }
-
- /*
- * Invalidate the inode if the mtime or ctime has changed
- * and the prebuf doesn't match the value we have cached.
- * TODO: writev returns with a NULL iatt due to
- * performance/write-behind, causing invalidation on writes.
- */
- if (IA_ISREG(inode->ia_type) &&
- ((iatt->ia_mtime != mdc->md_mtime) ||
- (iatt->ia_mtime_nsec != mdc->md_mtime_nsec) ||
- (iatt->ia_ctime != mdc->md_ctime) ||
- (iatt->ia_ctime_nsec != mdc->md_ctime_nsec)))
- if (!prebuf || (prebuf->ia_ctime != mdc->md_ctime) ||
- (prebuf->ia_ctime_nsec != mdc->md_ctime_nsec) ||
- (prebuf->ia_mtime != mdc->md_mtime) ||
- (prebuf->ia_mtime_nsec != mdc->md_mtime_nsec)) {
- gf_msg_trace ("md-cache", 0, "prebuf doesn't "
- "match the value we have cached,"
- " invalidate the inode(%s)",
- uuid_utoa (inode->gfid));
-
- inode_invalidate(inode);
- }
-
- if ((mdc->gen_rollover == rollover) &&
- ((incident_time > mdc->generation) &&
- (mdc->valid ||
- (incident_time > mdc->invalidation_time)))) {
- mdc_from_iatt (mdc, iatt);
- mdc->generation = incident_time;
- mdc->valid = _gf_true;
- if (update_time)
- time (&mdc->ia_time);
-
- gf_msg_callingfn ("md-cache", GF_LOG_TRACE, 0,
- MD_CACHE_MSG_CACHE_UPDATE,
- "Updated iatt(%s)"
- " time:%lld generation=%lld",
- uuid_utoa (iatt->ia_gfid),
- (unsigned long long)mdc->ia_time,
- (unsigned long long) mdc->generation);
- } else {
- gf_msg_callingfn ("md-cache", GF_LOG_TRACE, 0, 0,
- "not updating cache (%s)"
- "mdc-rollover=%u rollover=%u "
- "mdc-generation=%llu "
- "mdc-ia_time=%llu incident_time=%llu "
- "mdc-invalidation-time=%llu",
- uuid_utoa (iatt->ia_gfid),
- mdc->gen_rollover, rollover,
- (unsigned long long) mdc->generation,
- (unsigned long long) mdc->ia_time,
- (unsigned long long) incident_time,
- (unsigned long long) mdc->invalidation_time);
- }
- }
+ int ret = 0;
+ struct md_cache *mdc = NULL;
+ uint32_t rollover = 0;
+ uint64_t gen = 0;
+
+ mdc = mdc_inode_prep(this, inode);
+ if (!mdc) {
+ ret = -1;
+ goto out;
+ }
+
+ rollover = incident_time >> 32;
+ incident_time = (incident_time & 0xffffffff);
+
+ LOCK(&mdc->lock);
+ {
+ if (!iatt || !iatt->ia_ctime) {
+ gf_msg_callingfn("md-cache", GF_LOG_TRACE, 0, 0,
+ "invalidating iatt(NULL)"
+ "(%s)",
+ uuid_utoa(inode->gfid));
+ mdc->ia_time = 0;
+ mdc->valid = 0;
+
+ gen = __mdc_get_generation(this, mdc);
+ mdc->invalidation_time = (gen & 0xffffffff);
+ goto unlock;
+ }
+
+ /* There could be a race in invalidation, where the
+ * invalidations in order A, B reaches md-cache in the order
+ * B, A. Hence, make sure the invalidation A is discarded if
+ * it comes after B. ctime of a file is always in ascending
+ * order unlike atime and mtime(which can be changed by user
+ * to any date), also ctime gets updates when atime/mtime
+ * changes, hence check for ctime only.
+ */
+ if (mdc->md_ctime > iatt->ia_ctime) {
+ gf_msg_callingfn(this->name, GF_LOG_DEBUG, EINVAL,
+ MD_CACHE_MSG_DISCARD_UPDATE,
+ "discarding the iatt validate "
+ "request (%s)",
+ uuid_utoa(inode->gfid));
+ ret = -1;
+ goto unlock;
+ }
+ if ((mdc->md_ctime == iatt->ia_ctime) &&
+ (mdc->md_ctime_nsec > iatt->ia_ctime_nsec)) {
+ gf_msg_callingfn(this->name, GF_LOG_DEBUG, EINVAL,
+ MD_CACHE_MSG_DISCARD_UPDATE,
+ "discarding the iatt validate "
+ "request(ctime_nsec) (%s)",
+ uuid_utoa(inode->gfid));
+ ret = -1;
+ goto unlock;
+ }
+
+ /*
+ * Invalidate the inode if the mtime or ctime has changed
+ * and the prebuf doesn't match the value we have cached.
+ * TODO: writev returns with a NULL iatt due to
+ * performance/write-behind, causing invalidation on writes.
+ */
+ if (IA_ISREG(inode->ia_type) &&
+ ((iatt->ia_mtime != mdc->md_mtime) ||
+ (iatt->ia_mtime_nsec != mdc->md_mtime_nsec) ||
+ (iatt->ia_ctime != mdc->md_ctime) ||
+ (iatt->ia_ctime_nsec != mdc->md_ctime_nsec)))
+ if (!prebuf || (prebuf->ia_ctime != mdc->md_ctime) ||
+ (prebuf->ia_ctime_nsec != mdc->md_ctime_nsec) ||
+ (prebuf->ia_mtime != mdc->md_mtime) ||
+ (prebuf->ia_mtime_nsec != mdc->md_mtime_nsec)) {
+ gf_msg_trace("md-cache", 0,
+ "prebuf doesn't "
+ "match the value we have cached,"
+ " invalidate the inode(%s)",
+ uuid_utoa(inode->gfid));
+
+ inode_invalidate(inode);
+ }
+
+ if ((mdc->gen_rollover == rollover) &&
+ ((incident_time > mdc->generation) &&
+ (mdc->valid || (incident_time > mdc->invalidation_time)))) {
+ mdc_from_iatt(mdc, iatt);
+ mdc->generation = incident_time;
+ mdc->valid = _gf_true;
+ if (update_time)
+ time(&mdc->ia_time);
+
+ gf_msg_callingfn(
+ "md-cache", GF_LOG_TRACE, 0, MD_CACHE_MSG_CACHE_UPDATE,
+ "Updated iatt(%s)"
+ " time:%lld generation=%lld",
+ uuid_utoa(iatt->ia_gfid), (unsigned long long)mdc->ia_time,
+ (unsigned long long)mdc->generation);
+ } else {
+ gf_msg_callingfn("md-cache", GF_LOG_TRACE, 0, 0,
+ "not updating cache (%s)"
+ "mdc-rollover=%u rollover=%u "
+ "mdc-generation=%llu "
+ "mdc-ia_time=%llu incident_time=%llu "
+ "mdc-invalidation-time=%llu",
+ uuid_utoa(iatt->ia_gfid), mdc->gen_rollover,
+ rollover, (unsigned long long)mdc->generation,
+ (unsigned long long)mdc->ia_time,
+ (unsigned long long)incident_time,
+ (unsigned long long)mdc->invalidation_time);
+ }
+ }
unlock:
- UNLOCK (&mdc->lock);
+ UNLOCK(&mdc->lock);
out:
- return ret;
+ return ret;
}
-int mdc_inode_iatt_set(xlator_t *this, inode_t *inode, struct iatt *iatt,
- uint64_t incident_time)
+int
+mdc_inode_iatt_set(xlator_t *this, inode_t *inode, struct iatt *iatt,
+ uint64_t incident_time)
{
- return mdc_inode_iatt_set_validate(this, inode, NULL, iatt, _gf_true,
- incident_time);
+ return mdc_inode_iatt_set_validate(this, inode, NULL, iatt, _gf_true,
+ incident_time);
}
int
-mdc_inode_iatt_get (xlator_t *this, inode_t *inode, struct iatt *iatt)
+mdc_inode_iatt_get(xlator_t *this, inode_t *inode, struct iatt *iatt)
{
- int ret = -1;
- struct md_cache *mdc = NULL;
+ int ret = -1;
+ struct md_cache *mdc = NULL;
- if (mdc_inode_ctx_get (this, inode, &mdc) != 0) {
- gf_msg_trace ("md-cache", 0, "mdc_inode_ctx_get failed (%s)",
- uuid_utoa (inode->gfid));
- goto out;
- }
+ if (mdc_inode_ctx_get(this, inode, &mdc) != 0) {
+ gf_msg_trace("md-cache", 0, "mdc_inode_ctx_get failed (%s)",
+ uuid_utoa(inode->gfid));
+ goto out;
+ }
- if (!is_md_cache_iatt_valid (this, mdc)) {
- gf_msg_trace ("md-cache", 0, "iatt cache not valid for (%s)",
- uuid_utoa (inode->gfid));
- goto out;
- }
+ if (!is_md_cache_iatt_valid(this, mdc)) {
+ gf_msg_trace("md-cache", 0, "iatt cache not valid for (%s)",
+ uuid_utoa(inode->gfid));
+ goto out;
+ }
- LOCK (&mdc->lock);
- {
- mdc_to_iatt (mdc, iatt);
- }
- UNLOCK (&mdc->lock);
+ LOCK(&mdc->lock);
+ {
+ mdc_to_iatt(mdc, iatt);
+ }
+ UNLOCK(&mdc->lock);
- gf_uuid_copy (iatt->ia_gfid, inode->gfid);
- iatt->ia_ino = gfid_to_ino (inode->gfid);
- iatt->ia_dev = 42;
- iatt->ia_type = inode->ia_type;
+ gf_uuid_copy(iatt->ia_gfid, inode->gfid);
+ iatt->ia_ino = gfid_to_ino(inode->gfid);
+ iatt->ia_dev = 42;
+ iatt->ia_type = inode->ia_type;
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
struct updatedict {
- dict_t *dict;
- int ret;
+ dict_t *dict;
+ int ret;
};
static int
-is_mdc_key_satisfied (xlator_t *this, const char *key)
-{
- int ret = 0;
- char *pattern = NULL;
- struct mdc_conf *conf = this->private;
- char *mdc_xattr_str = NULL;
- char *tmp = NULL;
- char *tmp1 = NULL;
-
- if (!key)
- goto out;
-
- /* conf->mdc_xattr_str, is never freed and is hence safely used outside
- * of lock*/
- tmp1 = conf->mdc_xattr_str;
- if (!tmp1)
- goto out;
-
- mdc_xattr_str = gf_strdup (tmp1);
- if (!mdc_xattr_str)
- goto out;
-
- pattern = strtok_r (mdc_xattr_str, ",", &tmp);
- while (pattern) {
- gf_strTrim (&pattern);
- if (fnmatch (pattern, key, 0) == 0) {
- ret = 1;
- break;
- } else {
- gf_msg_trace ("md-cache", 0, "xattr key %s doesn't satisfy "
- "caching requirements", key);
- }
- pattern = strtok_r (NULL, ",", &tmp);
- }
- GF_FREE (mdc_xattr_str);
+is_mdc_key_satisfied(xlator_t *this, const char *key)
+{
+ int ret = 0;
+ char *pattern = NULL;
+ struct mdc_conf *conf = this->private;
+ char *mdc_xattr_str = NULL;
+ char *tmp = NULL;
+ char *tmp1 = NULL;
+
+ if (!key)
+ goto out;
+
+ /* conf->mdc_xattr_str, is never freed and is hence safely used outside
+ * of lock*/
+ tmp1 = conf->mdc_xattr_str;
+ if (!tmp1)
+ goto out;
+
+ mdc_xattr_str = gf_strdup(tmp1);
+ if (!mdc_xattr_str)
+ goto out;
+
+ pattern = strtok_r(mdc_xattr_str, ",", &tmp);
+ while (pattern) {
+ gf_strTrim(&pattern);
+ if (fnmatch(pattern, key, 0) == 0) {
+ ret = 1;
+ break;
+ } else {
+ gf_msg_trace("md-cache", 0,
+ "xattr key %s doesn't satisfy "
+ "caching requirements",
+ key);
+ }
+ pattern = strtok_r(NULL, ",", &tmp);
+ }
+ GF_FREE(mdc_xattr_str);
out:
- return ret;
+ return ret;
}
static int
updatefn(dict_t *dict, char *key, data_t *value, void *data)
{
- struct updatedict *u = data;
-
- if (is_mdc_key_satisfied (THIS, key)) {
- if (!u->dict) {
- u->dict = dict_new();
- if (!u->dict) {
- u->ret = -1;
- return -1;
- }
- }
-
- /* posix xlator as part of listxattr will send both names
- * and values of the xattrs in the dict. But as per man page
- * listxattr is mainly supposed to send names of the all the
- * xattrs. gfapi, as of now will put all the keys it obtained
- * in the dict (sent by posix) into a buffer provided by the
- * caller (thus the values of those xattrs are lost). If some
- * xlator makes gfapi based calls (ex: snapview-server), then
- * it has to unwind the calls by putting those names it got
- * in the buffer again into the dict. But now it would not be
- * having the values for those xattrs. So it might just put
- * a 0 byte value ("") into the dict for each xattr and unwind
- * the call. So the xlators which cache the xattrs (as of now
- * md-cache caches the acl and selinux related xattrs), should
- * not update their cache if the value of a xattr is a 0 byte
- * data (i.e. "").
- */
- if (value->len == 1 && value->data[0] == '\0')
- return 0;
-
- if (dict_set(u->dict, key, value) < 0) {
- u->ret = -1;
- return -1;
- }
- }
- return 0;
+ struct updatedict *u = data;
+
+ if (is_mdc_key_satisfied(THIS, key)) {
+ if (!u->dict) {
+ u->dict = dict_new();
+ if (!u->dict) {
+ u->ret = -1;
+ return -1;
+ }
+ }
+
+ /* posix xlator as part of listxattr will send both names
+ * and values of the xattrs in the dict. But as per man page
+ * listxattr is mainly supposed to send names of the all the
+ * xattrs. gfapi, as of now will put all the keys it obtained
+ * in the dict (sent by posix) into a buffer provided by the
+ * caller (thus the values of those xattrs are lost). If some
+ * xlator makes gfapi based calls (ex: snapview-server), then
+ * it has to unwind the calls by putting those names it got
+ * in the buffer again into the dict. But now it would not be
+ * having the values for those xattrs. So it might just put
+ * a 0 byte value ("") into the dict for each xattr and unwind
+ * the call. So the xlators which cache the xattrs (as of now
+ * md-cache caches the acl and selinux related xattrs), should
+ * not update their cache if the value of a xattr is a 0 byte
+ * data (i.e. "").
+ */
+ if (value->len == 1 && value->data[0] == '\0')
+ return 0;
+
+ if (dict_set(u->dict, key, value) < 0) {
+ u->ret = -1;
+ return -1;
+ }
+ }
+ return 0;
}
static int
mdc_dict_update(dict_t **tgt, dict_t *src)
{
- struct updatedict u = {
- .dict = *tgt,
- .ret = 0,
- };
+ struct updatedict u = {
+ .dict = *tgt,
+ .ret = 0,
+ };
- dict_foreach(src, updatefn, &u);
+ dict_foreach(src, updatefn, &u);
- if (*tgt)
- return u.ret;
+ if (*tgt)
+ return u.ret;
- if ((u.ret < 0) && u.dict) {
- dict_unref(u.dict);
- return u.ret;
- }
+ if ((u.ret < 0) && u.dict) {
+ dict_unref(u.dict);
+ return u.ret;
+ }
- *tgt = u.dict;
+ *tgt = u.dict;
- return u.ret;
+ return u.ret;
}
int
-mdc_inode_xatt_set (xlator_t *this, inode_t *inode, dict_t *dict)
+mdc_inode_xatt_set(xlator_t *this, inode_t *inode, dict_t *dict)
{
- int ret = -1;
- struct md_cache *mdc = NULL;
- dict_t *newdict = NULL;
+ int ret = -1;
+ struct md_cache *mdc = NULL;
+ dict_t *newdict = NULL;
- mdc = mdc_inode_prep (this, inode);
- if (!mdc)
- goto out;
+ mdc = mdc_inode_prep(this, inode);
+ if (!mdc)
+ goto out;
- if (!dict) {
- gf_msg_trace ("md-cache", 0, "mdc_inode_xatt_set failed (%s) "
- "dict NULL", uuid_utoa (inode->gfid));
- goto out;
- }
+ if (!dict) {
+ gf_msg_trace("md-cache", 0,
+ "mdc_inode_xatt_set failed (%s) "
+ "dict NULL",
+ uuid_utoa(inode->gfid));
+ goto out;
+ }
- LOCK (&mdc->lock);
- {
- if (mdc->xattr) {
- gf_msg_trace ("md-cache", 0, "deleting the old xattr "
- "cache (%s)", uuid_utoa (inode->gfid));
- dict_unref (mdc->xattr);
- mdc->xattr = NULL;
- }
-
- ret = mdc_dict_update(&newdict, dict);
- if (ret < 0) {
- UNLOCK(&mdc->lock);
- goto out;
- }
-
- if (newdict)
- mdc->xattr = newdict;
-
- time (&mdc->xa_time);
- gf_msg_trace ("md-cache", 0, "xatt cache set for (%s) time:%lld",
- uuid_utoa (inode->gfid), (long long)mdc->xa_time);
+ LOCK(&mdc->lock);
+ {
+ if (mdc->xattr) {
+ gf_msg_trace("md-cache", 0,
+ "deleting the old xattr "
+ "cache (%s)",
+ uuid_utoa(inode->gfid));
+ dict_unref(mdc->xattr);
+ mdc->xattr = NULL;
+ }
+ ret = mdc_dict_update(&newdict, dict);
+ if (ret < 0) {
+ UNLOCK(&mdc->lock);
+ goto out;
}
- UNLOCK (&mdc->lock);
- ret = 0;
+
+ if (newdict)
+ mdc->xattr = newdict;
+
+ time(&mdc->xa_time);
+ gf_msg_trace("md-cache", 0, "xatt cache set for (%s) time:%lld",
+ uuid_utoa(inode->gfid), (long long)mdc->xa_time);
+ }
+ UNLOCK(&mdc->lock);
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
int
-mdc_inode_xatt_update (xlator_t *this, inode_t *inode, dict_t *dict)
+mdc_inode_xatt_update(xlator_t *this, inode_t *inode, dict_t *dict)
{
- int ret = -1;
- struct md_cache *mdc = NULL;
+ int ret = -1;
+ struct md_cache *mdc = NULL;
- mdc = mdc_inode_prep (this, inode);
- if (!mdc)
- goto out;
+ mdc = mdc_inode_prep(this, inode);
+ if (!mdc)
+ goto out;
- if (!dict)
- goto out;
+ if (!dict)
+ goto out;
- LOCK (&mdc->lock);
- {
- ret = mdc_dict_update(&mdc->xattr, dict);
- if (ret < 0) {
- UNLOCK(&mdc->lock);
- goto out;
- }
+ LOCK(&mdc->lock);
+ {
+ ret = mdc_dict_update(&mdc->xattr, dict);
+ if (ret < 0) {
+ UNLOCK(&mdc->lock);
+ goto out;
}
- UNLOCK (&mdc->lock);
+ }
+ UNLOCK(&mdc->lock);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
int
-mdc_inode_xatt_unset (xlator_t *this, inode_t *inode, char *name)
+mdc_inode_xatt_unset(xlator_t *this, inode_t *inode, char *name)
{
- int ret = -1;
- struct md_cache *mdc = NULL;
+ int ret = -1;
+ struct md_cache *mdc = NULL;
- mdc = mdc_inode_prep (this, inode);
- if (!mdc)
- goto out;
+ mdc = mdc_inode_prep(this, inode);
+ if (!mdc)
+ goto out;
- if (!name || !mdc->xattr)
- goto out;
+ if (!name || !mdc->xattr)
+ goto out;
- LOCK (&mdc->lock);
- {
- dict_del (mdc->xattr, name);
- }
- UNLOCK (&mdc->lock);
+ LOCK(&mdc->lock);
+ {
+ dict_del(mdc->xattr, name);
+ }
+ UNLOCK(&mdc->lock);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
int
-mdc_inode_xatt_get (xlator_t *this, inode_t *inode, dict_t **dict)
+mdc_inode_xatt_get(xlator_t *this, inode_t *inode, dict_t **dict)
{
- int ret = -1;
- struct md_cache *mdc = NULL;
+ int ret = -1;
+ struct md_cache *mdc = NULL;
- if (mdc_inode_ctx_get (this, inode, &mdc) != 0) {
- gf_msg_trace ("md-cache", 0, "mdc_inode_ctx_get failed (%s)",
- uuid_utoa (inode->gfid));
- goto out;
- }
+ if (mdc_inode_ctx_get(this, inode, &mdc) != 0) {
+ gf_msg_trace("md-cache", 0, "mdc_inode_ctx_get failed (%s)",
+ uuid_utoa(inode->gfid));
+ goto out;
+ }
- if (!is_md_cache_xatt_valid (this, mdc)) {
- gf_msg_trace ("md-cache", 0, "xattr cache not valid for (%s)",
- uuid_utoa (inode->gfid));
- goto out;
- }
+ if (!is_md_cache_xatt_valid(this, mdc)) {
+ gf_msg_trace("md-cache", 0, "xattr cache not valid for (%s)",
+ uuid_utoa(inode->gfid));
+ goto out;
+ }
- LOCK (&mdc->lock);
- {
- ret = 0;
- /* Missing xattr only means no keys were there, i.e
- a negative cache for the "loaded" keys
- */
- if (!mdc->xattr) {
- gf_msg_trace ("md-cache", 0, "xattr not present (%s)",
- uuid_utoa (inode->gfid));
- goto unlock;
- }
-
- if (dict)
- *dict = dict_ref (mdc->xattr);
- }
+ LOCK(&mdc->lock);
+ {
+ ret = 0;
+ /* Missing xattr only means no keys were there, i.e
+ a negative cache for the "loaded" keys
+ */
+ if (!mdc->xattr) {
+ gf_msg_trace("md-cache", 0, "xattr not present (%s)",
+ uuid_utoa(inode->gfid));
+ goto unlock;
+ }
+
+ if (dict)
+ *dict = dict_ref(mdc->xattr);
+ }
unlock:
- UNLOCK (&mdc->lock);
+ UNLOCK(&mdc->lock);
out:
- return ret;
+ return ret;
}
gf_boolean_t
-mdc_inode_reset_need_lookup (xlator_t *this, inode_t *inode)
+mdc_inode_reset_need_lookup(xlator_t *this, inode_t *inode)
{
- struct md_cache *mdc = NULL;
- gf_boolean_t need = _gf_false;
+ struct md_cache *mdc = NULL;
+ gf_boolean_t need = _gf_false;
- if (mdc_inode_ctx_get (this, inode, &mdc) != 0)
- goto out;
+ if (mdc_inode_ctx_get(this, inode, &mdc) != 0)
+ goto out;
- LOCK (&mdc->lock);
- {
- need = mdc->need_lookup;
- mdc->need_lookup = _gf_false;
- }
- UNLOCK (&mdc->lock);
+ LOCK(&mdc->lock);
+ {
+ need = mdc->need_lookup;
+ mdc->need_lookup = _gf_false;
+ }
+ UNLOCK(&mdc->lock);
out:
- return need;
+ return need;
}
void
-mdc_inode_set_need_lookup (xlator_t *this, inode_t *inode, gf_boolean_t need)
+mdc_inode_set_need_lookup(xlator_t *this, inode_t *inode, gf_boolean_t need)
{
- struct md_cache *mdc = NULL;
+ struct md_cache *mdc = NULL;
- if (mdc_inode_ctx_get (this, inode, &mdc) != 0)
- goto out;
+ if (mdc_inode_ctx_get(this, inode, &mdc) != 0)
+ goto out;
- LOCK (&mdc->lock);
- {
- mdc->need_lookup = need;
- }
- UNLOCK (&mdc->lock);
+ LOCK(&mdc->lock);
+ {
+ mdc->need_lookup = need;
+ }
+ UNLOCK(&mdc->lock);
out:
- return;
+ return;
}
void
-mdc_inode_iatt_invalidate (xlator_t *this, inode_t *inode)
+mdc_inode_iatt_invalidate(xlator_t *this, inode_t *inode)
{
- struct md_cache *mdc = NULL;
- uint32_t gen = 0;
+ struct md_cache *mdc = NULL;
+ uint32_t gen = 0;
- if (mdc_inode_ctx_get (this, inode, &mdc) != 0)
- goto out;
+ if (mdc_inode_ctx_get(this, inode, &mdc) != 0)
+ goto out;
- gen = mdc_get_generation (this, inode) & 0xffffffff;
+ gen = mdc_get_generation(this, inode) & 0xffffffff;
- LOCK (&mdc->lock);
- {
- mdc->ia_time = 0;
- mdc->valid = _gf_false;
- mdc->invalidation_time = gen;
- }
- UNLOCK (&mdc->lock);
+ LOCK(&mdc->lock);
+ {
+ mdc->ia_time = 0;
+ mdc->valid = _gf_false;
+ mdc->invalidation_time = gen;
+ }
+ UNLOCK(&mdc->lock);
out:
- return;
+ return;
}
-
int
-mdc_inode_xatt_invalidate (xlator_t *this, inode_t *inode)
+mdc_inode_xatt_invalidate(xlator_t *this, inode_t *inode)
{
- int ret = -1;
- struct md_cache *mdc = NULL;
+ int ret = -1;
+ struct md_cache *mdc = NULL;
- if (mdc_inode_ctx_get (this, inode, &mdc) != 0)
- goto out;
+ if (mdc_inode_ctx_get(this, inode, &mdc) != 0)
+ goto out;
- LOCK (&mdc->lock);
- {
- mdc->xa_time = 0;
- }
- UNLOCK (&mdc->lock);
+ LOCK(&mdc->lock);
+ {
+ mdc->xa_time = 0;
+ }
+ UNLOCK(&mdc->lock);
out:
- return ret;
+ return ret;
}
-
static int
-mdc_update_gfid_stat (xlator_t *this, struct iatt *iatt)
-{
- int ret = 0;
- inode_table_t *itable = NULL;
- inode_t *inode = NULL;
-
- itable = ((xlator_t *)this->graph->top)->itable;
- inode = inode_find (itable, iatt->ia_gfid);
- if (!inode) {
- ret = -1;
- goto out;
- }
- ret = mdc_inode_iatt_set_validate (this, inode, NULL,
- iatt, _gf_true,
- mdc_get_generation (this, inode));
+mdc_update_gfid_stat(xlator_t *this, struct iatt *iatt)
+{
+ int ret = 0;
+ inode_table_t *itable = NULL;
+ inode_t *inode = NULL;
+
+ itable = ((xlator_t *)this->graph->top)->itable;
+ inode = inode_find(itable, iatt->ia_gfid);
+ if (!inode) {
+ ret = -1;
+ goto out;
+ }
+ ret = mdc_inode_iatt_set_validate(this, inode, NULL, iatt, _gf_true,
+ mdc_get_generation(this, inode));
out:
- return ret;
+ return ret;
}
-
void
-mdc_load_reqs (xlator_t *this, dict_t *dict)
-{
- struct mdc_conf *conf = this->private;
- char *pattern = NULL;
- char *mdc_xattr_str = NULL;
- char *tmp = NULL;
- char *tmp1 = NULL;
- int ret = 0;
-
- tmp1 = conf->mdc_xattr_str;
- if (!tmp1)
- goto out;
-
- mdc_xattr_str = gf_strdup (tmp1);
- if (!mdc_xattr_str)
- goto out;
-
- pattern = strtok_r (mdc_xattr_str, ",", &tmp);
- while (pattern) {
- gf_strTrim (&pattern);
- ret = dict_set_int8 (dict, pattern, 0);
- if (ret) {
- conf->mdc_xattr_str = NULL;
- gf_msg ("md-cache", GF_LOG_ERROR, 0,
- MD_CACHE_MSG_NO_XATTR_CACHE,
- "Disabled cache for xattrs, dict_set failed");
- }
- pattern = strtok_r (NULL, ",", &tmp);
- }
-
- GF_FREE (mdc_xattr_str);
+mdc_load_reqs(xlator_t *this, dict_t *dict)
+{
+ struct mdc_conf *conf = this->private;
+ char *pattern = NULL;
+ char *mdc_xattr_str = NULL;
+ char *tmp = NULL;
+ char *tmp1 = NULL;
+ int ret = 0;
+
+ tmp1 = conf->mdc_xattr_str;
+ if (!tmp1)
+ goto out;
+
+ mdc_xattr_str = gf_strdup(tmp1);
+ if (!mdc_xattr_str)
+ goto out;
+
+ pattern = strtok_r(mdc_xattr_str, ",", &tmp);
+ while (pattern) {
+ gf_strTrim(&pattern);
+ ret = dict_set_int8(dict, pattern, 0);
+ if (ret) {
+ conf->mdc_xattr_str = NULL;
+ gf_msg("md-cache", GF_LOG_ERROR, 0, MD_CACHE_MSG_NO_XATTR_CACHE,
+ "Disabled cache for xattrs, dict_set failed");
+ }
+ pattern = strtok_r(NULL, ",", &tmp);
+ }
+
+ GF_FREE(mdc_xattr_str);
out:
- return;
+ return;
}
struct checkpair {
- int ret;
- dict_t *rsp;
+ int ret;
+ dict_t *rsp;
};
-
-
static int
-checkfn (dict_t *this, char *key, data_t *value, void *data)
+checkfn(dict_t *this, char *key, data_t *value, void *data)
{
- struct checkpair *pair = data;
+ struct checkpair *pair = data;
- if (!is_mdc_key_satisfied (THIS, key))
- pair->ret = 0;
+ if (!is_mdc_key_satisfied(THIS, key))
+ pair->ret = 0;
- return 0;
+ return 0;
}
-
int
-mdc_xattr_satisfied (xlator_t *this, dict_t *req, dict_t *rsp)
+mdc_xattr_satisfied(xlator_t *this, dict_t *req, dict_t *rsp)
{
- struct checkpair pair = {
- .ret = 1,
- .rsp = rsp,
- };
+ struct checkpair pair = {
+ .ret = 1,
+ .rsp = rsp,
+ };
- dict_foreach (req, checkfn, &pair);
+ dict_foreach(req, checkfn, &pair);
- return pair.ret;
+ return pair.ret;
}
static void
-mdc_cache_statfs (xlator_t *this, struct statvfs *buf)
+mdc_cache_statfs(xlator_t *this, struct statvfs *buf)
{
- struct mdc_conf *conf = this->private;
+ struct mdc_conf *conf = this->private;
- pthread_mutex_lock (&conf->statfs_cache.lock);
- {
- memcpy (&conf->statfs_cache.buf, buf, sizeof (struct statvfs));
- clock_gettime (CLOCK_MONOTONIC,
- &conf->statfs_cache.last_refreshed);
- conf->statfs_cache.initialized = _gf_true;
- }
- pthread_mutex_unlock (&conf->statfs_cache.lock);
+ pthread_mutex_lock(&conf->statfs_cache.lock);
+ {
+ memcpy(&conf->statfs_cache.buf, buf, sizeof(struct statvfs));
+ clock_gettime(CLOCK_MONOTONIC, &conf->statfs_cache.last_refreshed);
+ conf->statfs_cache.initialized = _gf_true;
+ }
+ pthread_mutex_unlock(&conf->statfs_cache.lock);
}
int
-mdc_load_statfs_info_from_cache (xlator_t *this, struct statvfs **buf)
+mdc_load_statfs_info_from_cache(xlator_t *this, struct statvfs **buf)
{
- struct mdc_conf *conf = this->private;
- struct timespec now;
- double cache_age = 0.0;
- int ret = 0;
+ struct mdc_conf *conf = this->private;
+ struct timespec now;
+ double cache_age = 0.0;
+ int ret = 0;
+
+ if (!buf || !conf) {
+ ret = -1;
+ goto err;
+ }
- if (!buf || !conf) {
- ret = -1;
- goto err;
+ pthread_mutex_lock(&conf->statfs_cache.lock);
+ {
+ *buf = NULL;
+
+ /* Skip if the cache is not initialized */
+ if (!conf->statfs_cache.initialized) {
+ ret = -1;
+ goto unlock;
}
- pthread_mutex_lock (&conf->statfs_cache.lock);
- {
- *buf = NULL;
-
- /* Skip if the cache is not initialized */
- if (!conf->statfs_cache.initialized) {
- ret = -1;
- goto unlock;
- }
-
- timespec_now (&now);
-
- cache_age = (
- now.tv_sec - conf->statfs_cache.last_refreshed.tv_sec);
-
- gf_log (this->name, GF_LOG_DEBUG,
- "STATFS cache age = %lf", cache_age);
- if (cache_age > conf->timeout) {
- /* Expire the cache */
- gf_log (this->name, GF_LOG_DEBUG,
- "Cache age %lf exceeded timeout %d",
- cache_age, conf->timeout);
- ret = -1;
- goto unlock;
- }
-
- *buf = &conf->statfs_cache.buf;
+ timespec_now(&now);
+
+ cache_age = (now.tv_sec - conf->statfs_cache.last_refreshed.tv_sec);
+
+ gf_log(this->name, GF_LOG_DEBUG, "STATFS cache age = %lf", cache_age);
+ if (cache_age > conf->timeout) {
+ /* Expire the cache */
+ gf_log(this->name, GF_LOG_DEBUG,
+ "Cache age %lf exceeded timeout %d", cache_age,
+ conf->timeout);
+ ret = -1;
+ goto unlock;
}
+
+ *buf = &conf->statfs_cache.buf;
+ }
unlock:
- pthread_mutex_unlock (&conf->statfs_cache.lock);
+ pthread_mutex_unlock(&conf->statfs_cache.lock);
err:
- return ret;
+ return ret;
}
int
-mdc_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct statvfs *buf, dict_t *xdata)
+mdc_statfs_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct statvfs *buf,
+ dict_t *xdata)
{
- struct mdc_conf *conf = this->private;
- mdc_local_t *local = NULL;
+ struct mdc_conf *conf = this->private;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE)) {
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- }
-
- goto out;
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE)) {
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
}
- if (conf && conf->cache_statfs) {
- mdc_cache_statfs (this, buf);
- }
+ goto out;
+ }
+
+ if (conf && conf->cache_statfs) {
+ mdc_cache_statfs(this, buf);
+ }
out:
- MDC_STACK_UNWIND (statfs, frame, op_ret, op_errno, buf, xdata);
+ MDC_STACK_UNWIND(statfs, frame, op_ret, op_errno, buf, xdata);
- return 0;
+ return 0;
}
int
-mdc_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+mdc_statfs(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- int ret = 0, op_ret = 0, op_errno = 0;
- struct statvfs *buf = NULL;
- mdc_local_t *local = NULL;
- struct mdc_conf *conf = this->private;
+ int ret = 0, op_ret = 0, op_errno = 0;
+ struct statvfs *buf = NULL;
+ mdc_local_t *local = NULL;
+ struct mdc_conf *conf = this->private;
- local = mdc_local_get (frame, loc->inode);
- if (!local) {
- op_ret = -1;
- op_errno = ENOMEM;
- goto out;
- }
+ local = mdc_local_get(frame, loc->inode);
+ if (!local) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto out;
+ }
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- if (!conf) {
- goto uncached;
- }
+ if (!conf) {
+ goto uncached;
+ }
- if (!conf->cache_statfs) {
- goto uncached;
- }
+ if (!conf->cache_statfs) {
+ goto uncached;
+ }
- ret = mdc_load_statfs_info_from_cache (this, &buf);
- if (ret == 0 && buf) {
- op_ret = 0;
- op_errno = 0;
- goto out;
- }
+ ret = mdc_load_statfs_info_from_cache(this, &buf);
+ if (ret == 0 && buf) {
+ op_ret = 0;
+ op_errno = 0;
+ goto out;
+ }
uncached:
- STACK_WIND (frame, mdc_statfs_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->statfs, loc, xdata);
- return 0;
+ STACK_WIND(frame, mdc_statfs_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->statfs, loc, xdata);
+ return 0;
out:
- STACK_UNWIND_STRICT (statfs, frame, op_ret, op_errno, buf, xdata);
- return 0;
+ STACK_UNWIND_STRICT(statfs, frame, op_ret, op_errno, buf, xdata);
+ return 0;
}
int
-mdc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *stbuf, dict_t *dict, struct iatt *postparent)
+mdc_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *stbuf, dict_t *dict, struct iatt *postparent)
{
- mdc_local_t *local = NULL;
- struct mdc_conf *conf = this->private;
+ mdc_local_t *local = NULL;
+ struct mdc_conf *conf = this->private;
- local = frame->local;
+ local = frame->local;
- if (op_ret != 0) {
- if (op_errno == ENOENT)
- GF_ATOMIC_INC (conf->mdc_counter.negative_lookup);
+ if (op_ret != 0) {
+ if (op_errno == ENOENT)
+ GF_ATOMIC_INC(conf->mdc_counter.negative_lookup);
- if (op_errno == ESTALE) {
- /* if op_errno is ENOENT, fuse-bridge will unlink the
- * dentry
- */
- if (local->loc.parent)
- mdc_inode_iatt_invalidate (this,
- local->loc.parent);
- else
- mdc_inode_iatt_invalidate (this,
- local->loc.inode);
- }
-
- goto out;
+ if (op_errno == ESTALE) {
+ /* if op_errno is ENOENT, fuse-bridge will unlink the
+ * dentry
+ */
+ if (local->loc.parent)
+ mdc_inode_iatt_invalidate(this, local->loc.parent);
+ else
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
}
- if (!local)
- goto out;
-
- if (local->loc.parent) {
- mdc_inode_iatt_set (this, local->loc.parent, postparent,
- local->incident_time);
- }
+ goto out;
+ }
- if (local->loc.inode) {
- mdc_inode_iatt_set (this, local->loc.inode, stbuf,
- local->incident_time);
- mdc_inode_xatt_set (this, local->loc.inode, dict);
- }
-out:
- MDC_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode, stbuf,
- dict, postparent);
- return 0;
-}
+ if (!local)
+ goto out;
+ if (local->loc.parent) {
+ mdc_inode_iatt_set(this, local->loc.parent, postparent,
+ local->incident_time);
+ }
-int
-mdc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
- dict_t *xdata)
-{
- int ret = 0;
- struct iatt stbuf = {0, };
- struct iatt postparent = {0, };
- dict_t *xattr_rsp = NULL;
- dict_t *xattr_alloc = NULL;
- mdc_local_t *local = NULL;
- struct mdc_conf *conf = this->private;
-
- local = mdc_local_get (frame, loc->inode);
- if (!local) {
- GF_ATOMIC_INC (conf->mdc_counter.stat_miss);
- goto uncached;
- }
-
- loc_copy (&local->loc, loc);
-
- if (!inode_is_linked(loc->inode)) {
- GF_ATOMIC_INC (conf->mdc_counter.stat_miss);
- goto uncached;
- }
-
- if (mdc_inode_reset_need_lookup (this, loc->inode)) {
- GF_ATOMIC_INC (conf->mdc_counter.need_lookup);
- goto uncached;
- }
-
- ret = mdc_inode_iatt_get (this, loc->inode, &stbuf);
+ if (local->loc.inode) {
+ mdc_inode_iatt_set(this, local->loc.inode, stbuf, local->incident_time);
+ mdc_inode_xatt_set(this, local->loc.inode, dict);
+ }
+out:
+ MDC_STACK_UNWIND(lookup, frame, op_ret, op_errno, inode, stbuf, dict,
+ postparent);
+ return 0;
+}
+
+int
+mdc_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+{
+ int ret = 0;
+ struct iatt stbuf = {
+ 0,
+ };
+ struct iatt postparent = {
+ 0,
+ };
+ dict_t *xattr_rsp = NULL;
+ dict_t *xattr_alloc = NULL;
+ mdc_local_t *local = NULL;
+ struct mdc_conf *conf = this->private;
+
+ local = mdc_local_get(frame, loc->inode);
+ if (!local) {
+ GF_ATOMIC_INC(conf->mdc_counter.stat_miss);
+ goto uncached;
+ }
+
+ loc_copy(&local->loc, loc);
+
+ if (!inode_is_linked(loc->inode)) {
+ GF_ATOMIC_INC(conf->mdc_counter.stat_miss);
+ goto uncached;
+ }
+
+ if (mdc_inode_reset_need_lookup(this, loc->inode)) {
+ GF_ATOMIC_INC(conf->mdc_counter.need_lookup);
+ goto uncached;
+ }
+
+ ret = mdc_inode_iatt_get(this, loc->inode, &stbuf);
+ if (ret != 0) {
+ GF_ATOMIC_INC(conf->mdc_counter.stat_miss);
+ goto uncached;
+ }
+
+ if (xdata) {
+ ret = mdc_inode_xatt_get(this, loc->inode, &xattr_rsp);
if (ret != 0) {
- GF_ATOMIC_INC (conf->mdc_counter.stat_miss);
- goto uncached;
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_miss);
+ goto uncached;
}
- if (xdata) {
- ret = mdc_inode_xatt_get (this, loc->inode, &xattr_rsp);
- if (ret != 0) {
- GF_ATOMIC_INC (conf->mdc_counter.xattr_miss);
- goto uncached;
- }
-
- if (!mdc_xattr_satisfied (this, xdata, xattr_rsp)) {
- GF_ATOMIC_INC (conf->mdc_counter.xattr_miss);
- goto uncached;
- }
+ if (!mdc_xattr_satisfied(this, xdata, xattr_rsp)) {
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_miss);
+ goto uncached;
}
+ }
- GF_ATOMIC_INC (conf->mdc_counter.stat_hit);
- MDC_STACK_UNWIND (lookup, frame, 0, 0, loc->inode, &stbuf,
- xattr_rsp, &postparent);
+ GF_ATOMIC_INC(conf->mdc_counter.stat_hit);
+ MDC_STACK_UNWIND(lookup, frame, 0, 0, loc->inode, &stbuf, xattr_rsp,
+ &postparent);
- if (xattr_rsp)
- dict_unref (xattr_rsp);
+ if (xattr_rsp)
+ dict_unref(xattr_rsp);
- return 0;
+ return 0;
uncached:
- if (!xdata)
- xdata = xattr_alloc = dict_new ();
- if (xdata)
- mdc_load_reqs (this, xdata);
-
- STACK_WIND (frame, mdc_lookup_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->lookup, loc, xdata);
-
- if (xattr_rsp)
- dict_unref (xattr_rsp);
- if (xattr_alloc)
- dict_unref (xattr_alloc);
- return 0;
-}
+ if (!xdata)
+ xdata = xattr_alloc = dict_new();
+ if (xdata)
+ mdc_load_reqs(this, xdata);
+ STACK_WIND(frame, mdc_lookup_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, loc, xdata);
+
+ if (xattr_rsp)
+ dict_unref(xattr_rsp);
+ if (xattr_alloc)
+ dict_unref(xattr_alloc);
+ return 0;
+}
int
-mdc_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf, dict_t *xdata)
+mdc_stat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *buf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
-
- local = frame->local;
- if (!local)
- goto out;
+ mdc_local_t *local = NULL;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- }
+ local = frame->local;
+ if (!local)
+ goto out;
- goto out;
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
}
- mdc_inode_iatt_set (this, local->loc.inode, buf,
- local->incident_time);
+ goto out;
+ }
+
+ mdc_inode_iatt_set(this, local->loc.inode, buf, local->incident_time);
out:
- MDC_STACK_UNWIND (stat, frame, op_ret, op_errno, buf, xdata);
+ MDC_STACK_UNWIND(stat, frame, op_ret, op_errno, buf, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+mdc_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- int ret;
- struct iatt stbuf;
- mdc_local_t *local = NULL;
- struct mdc_conf *conf = this->private;
+ int ret;
+ struct iatt stbuf;
+ mdc_local_t *local = NULL;
+ struct mdc_conf *conf = this->private;
- local = mdc_local_get (frame, loc->inode);
- if (!local)
- goto uncached;
+ local = mdc_local_get(frame, loc->inode);
+ if (!local)
+ goto uncached;
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- if (!inode_is_linked(loc->inode)) {
- GF_ATOMIC_INC (conf->mdc_counter.stat_miss);
- goto uncached;
- }
+ if (!inode_is_linked(loc->inode)) {
+ GF_ATOMIC_INC(conf->mdc_counter.stat_miss);
+ goto uncached;
+ }
- ret = mdc_inode_iatt_get (this, loc->inode, &stbuf);
- if (ret != 0)
- goto uncached;
+ ret = mdc_inode_iatt_get(this, loc->inode, &stbuf);
+ if (ret != 0)
+ goto uncached;
- GF_ATOMIC_INC (conf->mdc_counter.stat_hit);
- MDC_STACK_UNWIND (stat, frame, 0, 0, &stbuf, xdata);
+ GF_ATOMIC_INC(conf->mdc_counter.stat_hit);
+ MDC_STACK_UNWIND(stat, frame, 0, 0, &stbuf, xdata);
- return 0;
+ return 0;
uncached:
- GF_ATOMIC_INC (conf->mdc_counter.stat_miss);
- STACK_WIND (frame, mdc_stat_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->stat,
- loc, xdata);
- return 0;
+ GF_ATOMIC_INC(conf->mdc_counter.stat_miss);
+ STACK_WIND(frame, mdc_stat_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->stat, loc, xdata);
+ return 0;
}
-
int
-mdc_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf,
- dict_t *xdata)
+mdc_fstat_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *buf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE)) {
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- }
-
- goto out;
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE)) {
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
}
- mdc_inode_iatt_set (this, local->fd->inode, buf, local->incident_time);
+ goto out;
+ }
+
+ mdc_inode_iatt_set(this, local->fd->inode, buf, local->incident_time);
out:
- MDC_STACK_UNWIND (fstat, frame, op_ret, op_errno, buf, xdata);
+ MDC_STACK_UNWIND(fstat, frame, op_ret, op_errno, buf, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+mdc_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- int ret;
- struct iatt stbuf;
- mdc_local_t *local = NULL;
- struct mdc_conf *conf = this->private;
+ int ret;
+ struct iatt stbuf;
+ mdc_local_t *local = NULL;
+ struct mdc_conf *conf = this->private;
- local = mdc_local_get (frame, fd->inode);
- if (!local)
- goto uncached;
+ local = mdc_local_get(frame, fd->inode);
+ if (!local)
+ goto uncached;
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- ret = mdc_inode_iatt_get (this, fd->inode, &stbuf);
- if (ret != 0)
- goto uncached;
+ ret = mdc_inode_iatt_get(this, fd->inode, &stbuf);
+ if (ret != 0)
+ goto uncached;
- GF_ATOMIC_INC (conf->mdc_counter.stat_hit);
- MDC_STACK_UNWIND (fstat, frame, 0, 0, &stbuf, xdata);
+ GF_ATOMIC_INC(conf->mdc_counter.stat_hit);
+ MDC_STACK_UNWIND(fstat, frame, 0, 0, &stbuf, xdata);
- return 0;
+ return 0;
uncached:
- GF_ATOMIC_INC (conf->mdc_counter.stat_miss);
- STACK_WIND (frame, mdc_fstat_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fstat,
- fd, xdata);
- return 0;
+ GF_ATOMIC_INC(conf->mdc_counter.stat_miss);
+ STACK_WIND(frame, mdc_fstat_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fstat, fd, xdata);
+ return 0;
}
-
int
-mdc_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+mdc_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
+ local = frame->local;
- if (!local)
- goto out;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT))
- mdc_inode_iatt_invalidate (this, local->loc.inode);
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT))
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
- goto out;
- }
+ goto out;
+ }
- mdc_inode_iatt_set_validate(this, local->loc.inode, prebuf, postbuf,
- _gf_true, local->incident_time);
+ mdc_inode_iatt_set_validate(this, local->loc.inode, prebuf, postbuf,
+ _gf_true, local->incident_time);
out:
- MDC_STACK_UNWIND (truncate, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
+ MDC_STACK_UNWIND(truncate, frame, op_ret, op_errno, prebuf, postbuf, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc,
- off_t offset, dict_t *xdata)
+mdc_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- local->loc.inode = inode_ref (loc->inode);
+ local->loc.inode = inode_ref(loc->inode);
- STACK_WIND (frame, mdc_truncate_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->truncate,
- loc, offset, xdata);
- return 0;
+ STACK_WIND(frame, mdc_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
+ return 0;
}
-
int
-mdc_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+mdc_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
+ local = frame->local;
- if (!local)
- goto out;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
- goto out;
- }
+ goto out;
+ }
- mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
- _gf_true, local->incident_time);
+ mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
+ _gf_true, local->incident_time);
out:
- MDC_STACK_UNWIND (ftruncate, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
+ MDC_STACK_UNWIND(ftruncate, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
- return 0;
+ return 0;
}
-
int
-mdc_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd,
- off_t offset, dict_t *xdata)
+mdc_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, fd->inode);
+ local = mdc_local_get(frame, fd->inode);
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- STACK_WIND (frame, mdc_ftruncate_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->ftruncate,
- fd, offset, xdata);
- return 0;
+ STACK_WIND(frame, mdc_ftruncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata);
+ return 0;
}
-
int
-mdc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+mdc_mknod_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- mdc_local_t *local = NULL;
-
- local = frame->local;
+ mdc_local_t *local = NULL;
- if (!local)
- goto out;
+ local = frame->local;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
- mdc_inode_iatt_invalidate (this, local->loc.parent);
- }
+ if (!local)
+ goto out;
- goto out;
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
+ mdc_inode_iatt_invalidate(this, local->loc.parent);
}
- if (local->loc.parent) {
- mdc_inode_iatt_set (this, local->loc.parent, postparent,
- local->incident_time);
- }
+ goto out;
+ }
- if (local->loc.inode) {
- mdc_inode_iatt_set (this, local->loc.inode, buf,
- local->incident_time);
- mdc_inode_xatt_set (this, local->loc.inode, local->xattr);
- }
+ if (local->loc.parent) {
+ mdc_inode_iatt_set(this, local->loc.parent, postparent,
+ local->incident_time);
+ }
+
+ if (local->loc.inode) {
+ mdc_inode_iatt_set(this, local->loc.inode, buf, local->incident_time);
+ mdc_inode_xatt_set(this, local->loc.inode, local->xattr);
+ }
out:
- MDC_STACK_UNWIND (mknod, frame, op_ret, op_errno, inode, buf,
- preparent, postparent, xdata);
- return 0;
+ MDC_STACK_UNWIND(mknod, frame, op_ret, op_errno, inode, buf, preparent,
+ postparent, xdata);
+ return 0;
}
-
int
-mdc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc,
- mode_t mode, dev_t rdev, mode_t umask, dict_t *xdata)
+mdc_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
+ dev_t rdev, mode_t umask, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
- local->xattr = dict_ref (xdata);
+ loc_copy(&local->loc, loc);
+ local->xattr = dict_ref(xdata);
- STACK_WIND (frame, mdc_mknod_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->mknod,
- loc, mode, rdev, umask, xdata);
- return 0;
+ STACK_WIND(frame, mdc_mknod_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mknod, loc, mode, rdev, umask, xdata);
+ return 0;
}
-
int
-mdc_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+mdc_mkdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- mdc_local_t *local = NULL;
-
- local = frame->local;
+ mdc_local_t *local = NULL;
- if (!local)
- goto out;
+ local = frame->local;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
- mdc_inode_iatt_invalidate (this, local->loc.parent);
- }
+ if (!local)
+ goto out;
- goto out;
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
+ mdc_inode_iatt_invalidate(this, local->loc.parent);
}
- if (local->loc.parent) {
- mdc_inode_iatt_set (this, local->loc.parent, postparent,
- local->incident_time);
- }
+ goto out;
+ }
- if (local->loc.inode) {
- mdc_inode_iatt_set (this, local->loc.inode, buf,
- local->incident_time);
- mdc_inode_xatt_set (this, local->loc.inode, local->xattr);
- }
+ if (local->loc.parent) {
+ mdc_inode_iatt_set(this, local->loc.parent, postparent,
+ local->incident_time);
+ }
+
+ if (local->loc.inode) {
+ mdc_inode_iatt_set(this, local->loc.inode, buf, local->incident_time);
+ mdc_inode_xatt_set(this, local->loc.inode, local->xattr);
+ }
out:
- MDC_STACK_UNWIND (mkdir, frame, op_ret, op_errno, inode, buf,
- preparent, postparent, xdata);
- return 0;
+ MDC_STACK_UNWIND(mkdir, frame, op_ret, op_errno, inode, buf, preparent,
+ postparent, xdata);
+ return 0;
}
-
int
-mdc_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc,
- mode_t mode, mode_t umask, dict_t *xdata)
+mdc_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
+ mode_t umask, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
- local->xattr = dict_ref (xdata);
+ loc_copy(&local->loc, loc);
+ local->xattr = dict_ref(xdata);
- STACK_WIND (frame, mdc_mkdir_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->mkdir,
- loc, mode, umask, xdata);
- return 0;
+ STACK_WIND(frame, mdc_mkdir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->mkdir, loc, mode, umask, xdata);
+ return 0;
}
-
int
-mdc_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
+mdc_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
+ local = frame->local;
- if (!local)
- goto out;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- /* if errno is ESTALE, parent is not present, which implies even
- * child is not present. Also, man 2 unlink states unlink can
- * return ENOENT if a component in pathname does not
- * exist or is a dangling symbolic link. So, invalidate both
- * parent and child for both errno
- */
-
- if ((op_errno == ENOENT) || (op_errno == ESTALE)) {
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- mdc_inode_iatt_invalidate (this, local->loc.parent);
- }
+ if (op_ret != 0) {
+ /* if errno is ESTALE, parent is not present, which implies even
+ * child is not present. Also, man 2 unlink states unlink can
+ * return ENOENT if a component in pathname does not
+ * exist or is a dangling symbolic link. So, invalidate both
+ * parent and child for both errno
+ */
- goto out;
+ if ((op_errno == ENOENT) || (op_errno == ESTALE)) {
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
+ mdc_inode_iatt_invalidate(this, local->loc.parent);
}
- if (local->loc.parent) {
- mdc_inode_iatt_set (this, local->loc.parent, postparent,
- local->incident_time);
- }
+ goto out;
+ }
- if (local->loc.inode) {
- mdc_inode_iatt_set (this, local->loc.inode, NULL,
- local->incident_time);
- }
+ if (local->loc.parent) {
+ mdc_inode_iatt_set(this, local->loc.parent, postparent,
+ local->incident_time);
+ }
+
+ if (local->loc.inode) {
+ mdc_inode_iatt_set(this, local->loc.inode, NULL, local->incident_time);
+ }
out:
- MDC_STACK_UNWIND (unlink, frame, op_ret, op_errno,
- preparent, postparent, xdata);
- return 0;
+ MDC_STACK_UNWIND(unlink, frame, op_ret, op_errno, preparent, postparent,
+ xdata);
+ return 0;
}
-
int
-mdc_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t xflag,
- dict_t *xdata)
+mdc_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t xflag,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- STACK_WIND (frame, mdc_unlink_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->unlink,
- loc, xflag, xdata);
- return 0;
+ STACK_WIND(frame, mdc_unlink_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->unlink, loc, xflag, xdata);
+ return 0;
}
-
int
-mdc_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
+mdc_rmdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *preparent, struct iatt *postparent,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
-
- local = frame->local;
+ mdc_local_t *local = NULL;
- if (!local)
- goto out;
+ local = frame->local;
- if (op_ret != 0) {
- /* if errno is ESTALE, parent is not present, which implies even
- * child is not present. Also, man 2 rmdir states rmdir can
- * return ENOENT if a directory component in pathname does not
- * exist or is a dangling symbolic link. So, invalidate both
- * parent and child for both errno
- */
+ if (!local)
+ goto out;
- if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- mdc_inode_iatt_invalidate (this, local->loc.parent);
- }
+ if (op_ret != 0) {
+ /* if errno is ESTALE, parent is not present, which implies even
+ * child is not present. Also, man 2 rmdir states rmdir can
+ * return ENOENT if a directory component in pathname does not
+ * exist or is a dangling symbolic link. So, invalidate both
+ * parent and child for both errno
+ */
- goto out;
+ if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
+ mdc_inode_iatt_invalidate(this, local->loc.parent);
}
- if (local->loc.parent) {
- mdc_inode_iatt_set (this, local->loc.parent, postparent,
- local->incident_time);
- }
+ goto out;
+ }
+
+ if (local->loc.parent) {
+ mdc_inode_iatt_set(this, local->loc.parent, postparent,
+ local->incident_time);
+ }
out:
- MDC_STACK_UNWIND (rmdir, frame, op_ret, op_errno,
- preparent, postparent, xdata);
- return 0;
+ MDC_STACK_UNWIND(rmdir, frame, op_ret, op_errno, preparent, postparent,
+ xdata);
+ return 0;
}
-
int
-mdc_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int flag,
- dict_t *xdata)
+mdc_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int flag,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- STACK_WIND (frame, mdc_rmdir_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->rmdir,
- loc, flag, xdata);
- return 0;
+ STACK_WIND(frame, mdc_rmdir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->rmdir, loc, flag, xdata);
+ return 0;
}
-
int
-mdc_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+mdc_symlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *buf, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
{
- mdc_local_t *local = NULL;
-
- local = frame->local;
+ mdc_local_t *local = NULL;
- if (!local)
- goto out;
+ local = frame->local;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
- mdc_inode_iatt_invalidate (this, local->loc.parent);
- }
+ if (!local)
+ goto out;
- goto out;
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
+ mdc_inode_iatt_invalidate(this, local->loc.parent);
}
- if (local->loc.parent) {
- mdc_inode_iatt_set (this, local->loc.parent, postparent,
- local->incident_time);
- }
+ goto out;
+ }
- if (local->loc.inode) {
- mdc_inode_iatt_set (this, local->loc.inode, buf,
- local->incident_time);
- }
+ if (local->loc.parent) {
+ mdc_inode_iatt_set(this, local->loc.parent, postparent,
+ local->incident_time);
+ }
+
+ if (local->loc.inode) {
+ mdc_inode_iatt_set(this, local->loc.inode, buf, local->incident_time);
+ }
out:
- MDC_STACK_UNWIND (symlink, frame, op_ret, op_errno, inode, buf,
- preparent, postparent, xdata);
- return 0;
+ MDC_STACK_UNWIND(symlink, frame, op_ret, op_errno, inode, buf, preparent,
+ postparent, xdata);
+ return 0;
}
-
int
-mdc_symlink (call_frame_t *frame, xlator_t *this, const char *linkname,
- loc_t *loc, mode_t umask, dict_t *xdata)
+mdc_symlink(call_frame_t *frame, xlator_t *this, const char *linkname,
+ loc_t *loc, mode_t umask, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- local->linkname = gf_strdup (linkname);
+ local->linkname = gf_strdup(linkname);
- STACK_WIND (frame, mdc_symlink_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->symlink,
- linkname, loc, umask, xdata);
- return 0;
+ STACK_WIND(frame, mdc_symlink_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->symlink, linkname, loc, umask, xdata);
+ return 0;
}
-
int
-mdc_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf,
- struct iatt *preoldparent, struct iatt *postoldparent,
- struct iatt *prenewparent, struct iatt *postnewparent,
- dict_t *xdata)
+mdc_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *buf,
+ struct iatt *preoldparent, struct iatt *postoldparent,
+ struct iatt *prenewparent, struct iatt *postnewparent,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
-
- local = frame->local;
- if (!local)
- goto out;
+ mdc_local_t *local = NULL;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- mdc_inode_iatt_invalidate (this, local->loc2.parent);
- }
+ local = frame->local;
+ if (!local)
+ goto out;
- goto out;
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
+ mdc_inode_iatt_invalidate(this, local->loc2.parent);
}
- if (local->loc.parent) {
- mdc_inode_iatt_set (this, local->loc.parent, postoldparent,
- local->incident_time);
- }
+ goto out;
+ }
- if (local->loc.inode) {
- /* TODO: fix dht_rename() not to return linkfile
- attributes before setting attributes here
- */
+ if (local->loc.parent) {
+ mdc_inode_iatt_set(this, local->loc.parent, postoldparent,
+ local->incident_time);
+ }
- mdc_inode_iatt_set (this, local->loc.inode, NULL,
- local->incident_time);
- }
+ if (local->loc.inode) {
+ /* TODO: fix dht_rename() not to return linkfile
+ attributes before setting attributes here
+ */
- if (local->loc2.parent) {
- mdc_inode_iatt_set (this, local->loc2.parent, postnewparent,
- local->incident_time);
- }
+ mdc_inode_iatt_set(this, local->loc.inode, NULL, local->incident_time);
+ }
+
+ if (local->loc2.parent) {
+ mdc_inode_iatt_set(this, local->loc2.parent, postnewparent,
+ local->incident_time);
+ }
out:
- MDC_STACK_UNWIND (rename, frame, op_ret, op_errno, buf,
- preoldparent, postoldparent, prenewparent,
- postnewparent, xdata);
- return 0;
+ MDC_STACK_UNWIND(rename, frame, op_ret, op_errno, buf, preoldparent,
+ postoldparent, prenewparent, postnewparent, xdata);
+ return 0;
}
-
int
-mdc_rename (call_frame_t *frame, xlator_t *this,
- loc_t *oldloc, loc_t *newloc, dict_t *xdata)
+mdc_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, oldloc->inode);
+ local = mdc_local_get(frame, oldloc->inode);
- loc_copy (&local->loc, oldloc);
- loc_copy (&local->loc2, newloc);
+ loc_copy(&local->loc, oldloc);
+ loc_copy(&local->loc2, newloc);
- STACK_WIND (frame, mdc_rename_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->rename,
- oldloc, newloc, xdata);
- return 0;
+ STACK_WIND(frame, mdc_rename_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->rename, oldloc, newloc, xdata);
+ return 0;
}
-
int
-mdc_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
+mdc_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- mdc_local_t *local = NULL;
-
- local = frame->local;
+ mdc_local_t *local = NULL;
- if (!local)
- goto out;
+ local = frame->local;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE)) {
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- mdc_inode_iatt_invalidate (this, local->loc2.parent);
- }
+ if (!local)
+ goto out;
- goto out;
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE)) {
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
+ mdc_inode_iatt_invalidate(this, local->loc2.parent);
}
- if (local->loc.inode) {
- mdc_inode_iatt_set (this, local->loc.inode, buf,
- local->incident_time);
- }
+ goto out;
+ }
- if (local->loc2.parent) {
- mdc_inode_iatt_set (this, local->loc2.parent, postparent,
- local->incident_time);
- }
+ if (local->loc.inode) {
+ mdc_inode_iatt_set(this, local->loc.inode, buf, local->incident_time);
+ }
+
+ if (local->loc2.parent) {
+ mdc_inode_iatt_set(this, local->loc2.parent, postparent,
+ local->incident_time);
+ }
out:
- MDC_STACK_UNWIND (link, frame, op_ret, op_errno, inode, buf,
- preparent, postparent, xdata);
- return 0;
+ MDC_STACK_UNWIND(link, frame, op_ret, op_errno, inode, buf, preparent,
+ postparent, xdata);
+ return 0;
}
-
int
-mdc_link (call_frame_t *frame, xlator_t *this,
- loc_t *oldloc, loc_t *newloc, dict_t *xdata)
+mdc_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, oldloc->inode);
+ local = mdc_local_get(frame, oldloc->inode);
- loc_copy (&local->loc, oldloc);
- loc_copy (&local->loc2, newloc);
+ loc_copy(&local->loc, oldloc);
+ loc_copy(&local->loc2, newloc);
- STACK_WIND (frame, mdc_link_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->link,
- oldloc, newloc, xdata);
- return 0;
+ STACK_WIND(frame, mdc_link_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->link, oldloc, newloc, xdata);
+ return 0;
}
-
int
-mdc_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 iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+mdc_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 iatt *buf, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
{
- mdc_local_t *local = NULL;
-
- local = frame->local;
+ mdc_local_t *local = NULL;
- if (!local)
- goto out;
+ local = frame->local;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
- mdc_inode_iatt_invalidate (this, local->loc.parent);
- }
+ if (!local)
+ goto out;
- goto out;
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT)) {
+ mdc_inode_iatt_invalidate(this, local->loc.parent);
}
- if (local->loc.parent) {
- mdc_inode_iatt_set (this, local->loc.parent, postparent,
- local->incident_time);
- }
+ goto out;
+ }
- if (local->loc.inode) {
- mdc_inode_iatt_set (this, inode, buf, local->incident_time);
- mdc_inode_xatt_set (this, local->loc.inode, local->xattr);
- }
+ if (local->loc.parent) {
+ mdc_inode_iatt_set(this, local->loc.parent, postparent,
+ local->incident_time);
+ }
+
+ if (local->loc.inode) {
+ mdc_inode_iatt_set(this, inode, buf, local->incident_time);
+ mdc_inode_xatt_set(this, local->loc.inode, local->xattr);
+ }
out:
- MDC_STACK_UNWIND (create, frame, op_ret, op_errno, fd, inode, buf,
- preparent, postparent, xdata);
- return 0;
+ MDC_STACK_UNWIND(create, frame, op_ret, op_errno, fd, inode, buf, preparent,
+ postparent, xdata);
+ return 0;
}
-
int
-mdc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
- mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
+mdc_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
+ mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
- local->xattr = dict_ref (xdata);
+ loc_copy(&local->loc, loc);
+ local->xattr = dict_ref(xdata);
- STACK_WIND (frame, mdc_create_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->create,
- loc, flags, mode, umask, fd, xdata);
- return 0;
+ STACK_WIND(frame, mdc_create_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->create, loc, flags, mode, umask, fd,
+ xdata);
+ return 0;
}
-
static int
-mdc_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd,
- dict_t *xdata)
+mdc_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, fd_t *fd, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
+ local = frame->local;
- if (!local)
- goto out;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT))
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- goto out;
- }
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT))
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
+ goto out;
+ }
- if (local->fd->flags & O_TRUNC) {
- /* O_TRUNC modifies file size. Hence invalidate the
- * cache entry to fetch latest attributes. */
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- }
+ if (local->fd->flags & O_TRUNC) {
+ /* O_TRUNC modifies file size. Hence invalidate the
+ * cache entry to fetch latest attributes. */
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ }
out:
- MDC_STACK_UNWIND (open, frame, op_ret, op_errno, fd, xdata);
- return 0;
+ MDC_STACK_UNWIND(open, frame, op_ret, op_errno, fd, xdata);
+ return 0;
}
-
static int
-mdc_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
- fd_t *fd, dict_t *xdata)
+mdc_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, fd_t *fd,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- if (!fd || !IA_ISREG(fd->inode->ia_type) ||
- !(fd->flags & O_TRUNC)) {
- goto out;
- }
+ if (!fd || !IA_ISREG(fd->inode->ia_type) || !(fd->flags & O_TRUNC)) {
+ goto out;
+ }
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
out:
- STACK_WIND (frame, mdc_open_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->open,
- loc, flags, fd, xdata);
- return 0;
+ STACK_WIND(frame, mdc_open_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata);
+ return 0;
}
-
int
-mdc_readv_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iovec *vector, int32_t count,
- struct iatt *stbuf, struct iobref *iobref, dict_t *xdata)
+mdc_readv_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iovec *vector, int32_t count,
+ struct iatt *stbuf, struct iobref *iobref, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret < 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
+ if (op_ret < 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
- mdc_inode_iatt_set (this, local->fd->inode, stbuf, local->incident_time);
+ mdc_inode_iatt_set(this, local->fd->inode, stbuf, local->incident_time);
out:
- MDC_STACK_UNWIND (readv, frame, op_ret, op_errno, vector, count,
- stbuf, iobref, xdata);
+ MDC_STACK_UNWIND(readv, frame, op_ret, op_errno, vector, count, stbuf,
+ iobref, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, uint32_t flags, dict_t *xdata)
+mdc_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, uint32_t flags, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, fd->inode);
+ local = mdc_local_get(frame, fd->inode);
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- STACK_WIND (frame, mdc_readv_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->readv,
- fd, size, offset, flags, xdata);
- return 0;
+ STACK_WIND(frame, mdc_readv_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv, fd, size, offset, flags, xdata);
+ return 0;
}
-
int
-mdc_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, dict_t *xdata)
+mdc_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, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret == -1) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
+ if (op_ret == -1) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
- mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
- _gf_true, local->incident_time);
+ mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
+ _gf_true, local->incident_time);
out:
- MDC_STACK_UNWIND (writev, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
+ MDC_STACK_UNWIND(writev, frame, op_ret, op_errno, prebuf, postbuf, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
- int count, off_t offset, uint32_t flags, struct iobref *iobref,
- dict_t *xdata)
+mdc_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
+ int count, off_t offset, uint32_t flags, struct iobref *iobref,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, fd->inode);
+ local = mdc_local_get(frame, fd->inode);
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- STACK_WIND (frame, mdc_writev_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->writev,
- fd, vector, count, offset, flags, iobref, xdata);
- return 0;
+ STACK_WIND(frame, mdc_writev_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->writev, fd, vector, count, offset,
+ flags, iobref, xdata);
+ return 0;
}
-
int
-mdc_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+mdc_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
+ local = frame->local;
- if (op_ret != 0) {
- mdc_inode_iatt_set (this, local->loc.inode, NULL,
- local->incident_time);
- goto out;
- }
+ if (op_ret != 0) {
+ mdc_inode_iatt_set(this, local->loc.inode, NULL, local->incident_time);
+ goto out;
+ }
- if (!local)
- goto out;
+ if (!local)
+ goto out;
- mdc_inode_iatt_set_validate(this, local->loc.inode, prebuf, postbuf,
- _gf_true, local->incident_time);
+ mdc_inode_iatt_set_validate(this, local->loc.inode, prebuf, postbuf,
+ _gf_true, local->incident_time);
out:
- MDC_STACK_UNWIND (setattr, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
+ MDC_STACK_UNWIND(setattr, frame, op_ret, op_errno, prebuf, postbuf, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- struct iatt *stbuf, int valid, dict_t *xdata)
+mdc_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf,
+ int valid, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- STACK_WIND (frame, mdc_setattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->setattr,
- loc, stbuf, valid, xdata);
- return 0;
+ STACK_WIND(frame, mdc_setattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setattr, loc, stbuf, valid, xdata);
+ return 0;
}
-
int
-mdc_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+mdc_fsetattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
- mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
- _gf_true, local->incident_time);
+ mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
+ _gf_true, local->incident_time);
out:
- MDC_STACK_UNWIND (fsetattr, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
+ MDC_STACK_UNWIND(fsetattr, frame, op_ret, op_errno, prebuf, postbuf, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iatt *stbuf, int valid, dict_t *xdata)
+mdc_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,
+ int valid, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, fd->inode);
+ local = mdc_local_get(frame, fd->inode);
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- STACK_WIND (frame, mdc_fsetattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsetattr,
- fd, stbuf, valid, xdata);
- return 0;
+ STACK_WIND(frame, mdc_fsetattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsetattr, fd, stbuf, valid, xdata);
+ return 0;
}
-
int
-mdc_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+mdc_fsync_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
- mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
- _gf_true, local->incident_time);
+ mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
+ _gf_true, local->incident_time);
out:
- MDC_STACK_UNWIND (fsync, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
+ MDC_STACK_UNWIND(fsync, frame, op_ret, op_errno, prebuf, postbuf, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int datasync,
- dict_t *xdata)
+mdc_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int datasync,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, fd->inode);
+ local = mdc_local_get(frame, fd->inode);
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- STACK_WIND (frame, mdc_fsync_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsync,
- fd, datasync, xdata);
- return 0;
+ STACK_WIND(frame, mdc_fsync_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsync, fd, datasync, xdata);
+ return 0;
}
-
int
-mdc_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+mdc_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- mdc_local_t *local = NULL;
- struct iatt prestat = {0,};
- struct iatt poststat = {0,};
- int ret = 0;
+ mdc_local_t *local = NULL;
+ struct iatt prestat = {
+ 0,
+ };
+ struct iatt poststat = {
+ 0,
+ };
+ int ret = 0;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- goto out;
- }
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
+ goto out;
+ }
- mdc_inode_xatt_update (this, local->loc.inode, local->xattr);
+ mdc_inode_xatt_update(this, local->loc.inode, local->xattr);
- ret = dict_get_iatt (xdata, GF_PRESTAT, &prestat);
- if (ret >= 0) {
- ret = dict_get_iatt (xdata, GF_POSTSTAT, &poststat);
- mdc_inode_iatt_set_validate (this, local->loc.inode, &prestat,
- &poststat, _gf_true,
- local->incident_time);
- }
+ ret = dict_get_iatt(xdata, GF_PRESTAT, &prestat);
+ if (ret >= 0) {
+ ret = dict_get_iatt(xdata, GF_POSTSTAT, &poststat);
+ mdc_inode_iatt_set_validate(this, local->loc.inode, &prestat, &poststat,
+ _gf_true, local->incident_time);
+ }
- if (ret < 0)
- mdc_inode_iatt_invalidate (this, local->loc.inode);
+ if (ret < 0)
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
out:
- MDC_STACK_UNWIND (setxattr, frame, op_ret, op_errno, xdata);
+ MDC_STACK_UNWIND(setxattr, frame, op_ret, op_errno, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- dict_t *xattr, int flags, dict_t *xdata)
+mdc_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xattr,
+ int flags, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
- local->xattr = dict_ref (xattr);
+ loc_copy(&local->loc, loc);
+ local->xattr = dict_ref(xattr);
- STACK_WIND (frame, mdc_setxattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->setxattr,
- loc, xattr, flags, xdata);
+ STACK_WIND(frame, mdc_setxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setxattr, loc, xattr, flags, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+mdc_fsetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- mdc_local_t *local = NULL;
- struct iatt prestat = {0,};
- struct iatt poststat = {0,};
- int ret = 0;
+ mdc_local_t *local = NULL;
+ struct iatt prestat = {
+ 0,
+ };
+ struct iatt poststat = {
+ 0,
+ };
+ int ret = 0;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ESTALE) || (op_errno == ENOENT))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
+ if (op_ret != 0) {
+ if ((op_errno == ESTALE) || (op_errno == ENOENT))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
- mdc_inode_xatt_update (this, local->fd->inode, local->xattr);
+ mdc_inode_xatt_update(this, local->fd->inode, local->xattr);
- ret = dict_get_iatt (xdata, GF_PRESTAT, &prestat);
- if (ret >= 0) {
- ret = dict_get_iatt (xdata, GF_POSTSTAT, &poststat);
- mdc_inode_iatt_set_validate (this, local->fd->inode, &prestat,
- &poststat, _gf_true,
- local->incident_time);
- }
+ ret = dict_get_iatt(xdata, GF_PRESTAT, &prestat);
+ if (ret >= 0) {
+ ret = dict_get_iatt(xdata, GF_POSTSTAT, &poststat);
+ mdc_inode_iatt_set_validate(this, local->fd->inode, &prestat, &poststat,
+ _gf_true, local->incident_time);
+ }
- if (ret < 0)
- mdc_inode_iatt_invalidate (this, local->fd->inode);
+ if (ret < 0)
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
out:
- MDC_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno, xdata);
+ MDC_STACK_UNWIND(fsetxattr, frame, op_ret, op_errno, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
- dict_t *xattr, int flags, dict_t *xdata)
+mdc_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xattr,
+ int flags, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, fd->inode);
+ local = mdc_local_get(frame, fd->inode);
- local->fd = fd_ref (fd);
- local->xattr = dict_ref (xattr);
+ local->fd = fd_ref(fd);
+ local->xattr = dict_ref(xattr);
- STACK_WIND (frame, mdc_fsetxattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fsetxattr,
- fd, xattr, flags, xdata);
+ STACK_WIND(frame, mdc_fsetxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsetxattr, fd, xattr, flags, xdata);
- return 0;
+ return 0;
}
int
-mdc_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xattr,
- dict_t *xdata)
+mdc_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xattr, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret < 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- goto out;
- }
+ if (op_ret < 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
+ goto out;
+ }
- mdc_inode_xatt_update (this, local->loc.inode, xattr);
+ mdc_inode_xatt_update(this, local->loc.inode, xattr);
out:
- MDC_STACK_UNWIND (getxattr, frame, op_ret, op_errno, xattr, xdata);
+ MDC_STACK_UNWIND(getxattr, frame, op_ret, op_errno, xattr, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *key,
- dict_t *xdata)
+mdc_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *key,
+ dict_t *xdata)
{
- int ret;
- int op_errno = ENODATA;
- mdc_local_t *local = NULL;
- dict_t *xattr = NULL;
- struct mdc_conf *conf = this->private;
+ int ret;
+ int op_errno = ENODATA;
+ mdc_local_t *local = NULL;
+ dict_t *xattr = NULL;
+ struct mdc_conf *conf = this->private;
- local = mdc_local_get (frame, loc->inode);
- if (!local)
- goto uncached;
+ local = mdc_local_get(frame, loc->inode);
+ if (!local)
+ goto uncached;
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- if (!is_mdc_key_satisfied (this, key))
- goto uncached;
+ if (!is_mdc_key_satisfied(this, key))
+ goto uncached;
- ret = mdc_inode_xatt_get (this, loc->inode, &xattr);
- if (ret != 0)
- goto uncached;
+ ret = mdc_inode_xatt_get(this, loc->inode, &xattr);
+ if (ret != 0)
+ goto uncached;
- if (!xattr || !dict_get (xattr, (char *)key)) {
- ret = -1;
- op_errno = ENODATA;
- }
+ if (!xattr || !dict_get(xattr, (char *)key)) {
+ ret = -1;
+ op_errno = ENODATA;
+ }
- GF_ATOMIC_INC (conf->mdc_counter.xattr_hit);
- MDC_STACK_UNWIND (getxattr, frame, ret, op_errno, xattr, xdata);
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_hit);
+ MDC_STACK_UNWIND(getxattr, frame, ret, op_errno, xattr, xdata);
- return 0;
+ return 0;
uncached:
- GF_ATOMIC_INC (conf->mdc_counter.xattr_miss);
- STACK_WIND (frame, mdc_getxattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->getxattr,
- loc, key, xdata);
- return 0;
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_miss);
+ STACK_WIND(frame, mdc_getxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->getxattr, loc, key, xdata);
+ return 0;
}
-
int
-mdc_fgetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xattr,
- dict_t *xdata)
+mdc_fgetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xattr,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret < 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
+ if (op_ret < 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
- mdc_inode_xatt_update (this, local->fd->inode, xattr);
+ mdc_inode_xatt_update(this, local->fd->inode, xattr);
out:
- MDC_STACK_UNWIND (fgetxattr, frame, op_ret, op_errno, xattr, xdata);
+ MDC_STACK_UNWIND(fgetxattr, frame, op_ret, op_errno, xattr, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, const char *key,
- dict_t *xdata)
+mdc_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *key,
+ dict_t *xdata)
{
- int ret;
- mdc_local_t *local = NULL;
- dict_t *xattr = NULL;
- int op_errno = ENODATA;
- struct mdc_conf *conf = this->private;
+ int ret;
+ mdc_local_t *local = NULL;
+ dict_t *xattr = NULL;
+ int op_errno = ENODATA;
+ struct mdc_conf *conf = this->private;
- local = mdc_local_get (frame, fd->inode);
- if (!local)
- goto uncached;
+ local = mdc_local_get(frame, fd->inode);
+ if (!local)
+ goto uncached;
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- if (!is_mdc_key_satisfied (this, key))
- goto uncached;
+ if (!is_mdc_key_satisfied(this, key))
+ goto uncached;
- ret = mdc_inode_xatt_get (this, fd->inode, &xattr);
- if (ret != 0)
- goto uncached;
+ ret = mdc_inode_xatt_get(this, fd->inode, &xattr);
+ if (ret != 0)
+ goto uncached;
- if (!xattr || !dict_get (xattr, (char *)key)) {
- ret = -1;
- op_errno = ENODATA;
- }
+ if (!xattr || !dict_get(xattr, (char *)key)) {
+ ret = -1;
+ op_errno = ENODATA;
+ }
- GF_ATOMIC_INC (conf->mdc_counter.xattr_hit);
- MDC_STACK_UNWIND (fgetxattr, frame, ret, op_errno, xattr, xdata);
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_hit);
+ MDC_STACK_UNWIND(fgetxattr, frame, ret, op_errno, xattr, xdata);
- return 0;
+ return 0;
uncached:
- GF_ATOMIC_INC (conf->mdc_counter.xattr_miss);
- STACK_WIND (frame, mdc_fgetxattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fgetxattr,
- fd, key, xdata);
- return 0;
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_miss);
+ STACK_WIND(frame, mdc_fgetxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fgetxattr, fd, key, xdata);
+ return 0;
}
int
-mdc_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+mdc_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- mdc_local_t *local = NULL;
- struct iatt prestat = {0,};
- struct iatt poststat = {0,};
- int ret = 0;
+ mdc_local_t *local = NULL;
+ struct iatt prestat = {
+ 0,
+ };
+ struct iatt poststat = {
+ 0,
+ };
+ int ret = 0;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->loc.inode);
- goto out;
- }
-
- if (local->key)
- mdc_inode_xatt_unset (this, local->loc.inode, local->key);
- else
- mdc_inode_xatt_invalidate (this, local->loc.inode);
-
- ret = dict_get_iatt (xdata, GF_PRESTAT, &prestat);
- if (ret >= 0) {
- ret = dict_get_iatt (xdata, GF_POSTSTAT, &poststat);
- mdc_inode_iatt_set_validate (this, local->loc.inode, &prestat,
- &poststat, _gf_true,
- local->incident_time);
- }
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
+ goto out;
+ }
+
+ if (local->key)
+ mdc_inode_xatt_unset(this, local->loc.inode, local->key);
+ else
+ mdc_inode_xatt_invalidate(this, local->loc.inode);
+
+ ret = dict_get_iatt(xdata, GF_PRESTAT, &prestat);
+ if (ret >= 0) {
+ ret = dict_get_iatt(xdata, GF_POSTSTAT, &poststat);
+ mdc_inode_iatt_set_validate(this, local->loc.inode, &prestat, &poststat,
+ _gf_true, local->incident_time);
+ }
- if (ret < 0)
- mdc_inode_iatt_invalidate (this, local->loc.inode);
+ if (ret < 0)
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
out:
- MDC_STACK_UNWIND (removexattr, frame, op_ret, op_errno, xdata);
+ MDC_STACK_UNWIND(removexattr, frame, op_ret, op_errno, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- const char *name, dict_t *xdata)
+mdc_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
+ const char *name, dict_t *xdata)
{
- mdc_local_t *local = NULL;
- int op_errno = ENODATA;
- int ret = 0;
- dict_t *xattr = NULL;
- struct mdc_conf *conf = this->private;
+ mdc_local_t *local = NULL;
+ int op_errno = ENODATA;
+ int ret = 0;
+ dict_t *xattr = NULL;
+ struct mdc_conf *conf = this->private;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- local->key = gf_strdup (name);
+ local->key = gf_strdup(name);
- if (!is_mdc_key_satisfied (this, name))
- goto uncached;
+ if (!is_mdc_key_satisfied(this, name))
+ goto uncached;
- ret = mdc_inode_xatt_get (this, loc->inode, &xattr);
- if (ret != 0)
- goto uncached;
+ ret = mdc_inode_xatt_get(this, loc->inode, &xattr);
+ if (ret != 0)
+ goto uncached;
- if (!xattr || !dict_get (xattr, (char *)name)) {
- ret = -1;
- op_errno = ENODATA;
- }
+ if (!xattr || !dict_get(xattr, (char *)name)) {
+ ret = -1;
+ op_errno = ENODATA;
+ }
- GF_ATOMIC_INC (conf->mdc_counter.xattr_hit);
- MDC_STACK_UNWIND (removexattr, frame, ret, op_errno, xdata);
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_hit);
+ MDC_STACK_UNWIND(removexattr, frame, ret, op_errno, xdata);
- return 0;
+ return 0;
uncached:
- GF_ATOMIC_INC (conf->mdc_counter.xattr_miss);
- STACK_WIND (frame, mdc_removexattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->removexattr,
- loc, name, xdata);
- return 0;
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_miss);
+ STACK_WIND(frame, mdc_removexattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->removexattr, loc, name, xdata);
+ return 0;
}
-
int
-mdc_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+mdc_fremovexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- mdc_local_t *local = NULL;
- struct iatt prestat = {0,};
- struct iatt poststat = {0,};
- int ret = 0;
+ mdc_local_t *local = NULL;
+ struct iatt prestat = {
+ 0,
+ };
+ struct iatt poststat = {
+ 0,
+ };
+ int ret = 0;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
-
- if (local->key)
- mdc_inode_xatt_unset (this, local->fd->inode, local->key);
- else
- mdc_inode_xatt_invalidate (this, local->fd->inode);
-
- ret = dict_get_iatt (xdata, GF_PRESTAT, &prestat);
- if (ret >= 0) {
- ret = dict_get_iatt (xdata, GF_POSTSTAT, &poststat);
- mdc_inode_iatt_set_validate (this, local->fd->inode, &prestat,
- &poststat, _gf_true,
- local->incident_time);
- }
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
+
+ if (local->key)
+ mdc_inode_xatt_unset(this, local->fd->inode, local->key);
+ else
+ mdc_inode_xatt_invalidate(this, local->fd->inode);
+
+ ret = dict_get_iatt(xdata, GF_PRESTAT, &prestat);
+ if (ret >= 0) {
+ ret = dict_get_iatt(xdata, GF_POSTSTAT, &poststat);
+ mdc_inode_iatt_set_validate(this, local->fd->inode, &prestat, &poststat,
+ _gf_true, local->incident_time);
+ }
- if (ret < 0)
- mdc_inode_iatt_invalidate (this, local->fd->inode);
+ if (ret < 0)
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
out:
- MDC_STACK_UNWIND (fremovexattr, frame, op_ret, op_errno, xdata);
+ MDC_STACK_UNWIND(fremovexattr, frame, op_ret, op_errno, xdata);
- return 0;
+ return 0;
}
-
int
-mdc_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
- const char *name, dict_t *xdata)
+mdc_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
+ const char *name, dict_t *xdata)
{
- mdc_local_t *local = NULL;
- int op_errno = ENODATA;
- int ret = 0;
- dict_t *xattr = NULL;
- struct mdc_conf *conf = this->private;
+ mdc_local_t *local = NULL;
+ int op_errno = ENODATA;
+ int ret = 0;
+ dict_t *xattr = NULL;
+ struct mdc_conf *conf = this->private;
- local = mdc_local_get (frame, fd->inode);
+ local = mdc_local_get(frame, fd->inode);
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- local->key = gf_strdup (name);
+ local->key = gf_strdup(name);
- if (!is_mdc_key_satisfied (this, name))
- goto uncached;
+ if (!is_mdc_key_satisfied(this, name))
+ goto uncached;
- ret = mdc_inode_xatt_get (this, fd->inode, &xattr);
- if (ret != 0)
- goto uncached;
+ ret = mdc_inode_xatt_get(this, fd->inode, &xattr);
+ if (ret != 0)
+ goto uncached;
- if (!xattr || !dict_get (xattr, (char *)name)) {
- ret = -1;
- op_errno = ENODATA;
- }
+ if (!xattr || !dict_get(xattr, (char *)name)) {
+ ret = -1;
+ op_errno = ENODATA;
+ }
- GF_ATOMIC_INC (conf->mdc_counter.xattr_hit);
- MDC_STACK_UNWIND (fremovexattr, frame, ret, op_errno, xdata);
- return 0;
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_hit);
+ MDC_STACK_UNWIND(fremovexattr, frame, ret, op_errno, xdata);
+ return 0;
uncached:
- GF_ATOMIC_INC (conf->mdc_counter.xattr_miss);
- STACK_WIND (frame, mdc_fremovexattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->fremovexattr,
- fd, name, xdata);
- return 0;
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_miss);
+ STACK_WIND(frame, mdc_fremovexattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fremovexattr, fd, name, xdata);
+ return 0;
}
int32_t
-mdc_opendir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd,
- dict_t *xdata)
+mdc_opendir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret == 0)
- goto out;
+ if (op_ret == 0)
+ goto out;
- if ((op_errno == ESTALE) || (op_errno == ENOENT))
- mdc_inode_iatt_invalidate (this, local->loc.inode);
+ if ((op_errno == ESTALE) || (op_errno == ENOENT))
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
out:
- MDC_STACK_UNWIND (opendir, frame, op_ret, op_errno, fd, xdata);
- return 0;
+ MDC_STACK_UNWIND(opendir, frame, op_ret, op_errno, fd, xdata);
+ return 0;
}
-
int
-mdc_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc,
- fd_t *fd, dict_t *xdata)
+mdc_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
+ dict_t *xdata)
{
- dict_t *xattr_alloc = NULL;
- mdc_local_t *local = NULL;
+ dict_t *xattr_alloc = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
+ local = mdc_local_get(frame, loc->inode);
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- if (!xdata)
- xdata = xattr_alloc = dict_new ();
+ if (!xdata)
+ xdata = xattr_alloc = dict_new();
- if (xdata) {
- /* Tell readdir-ahead to include these keys in xdata when it
- * internally issues readdirp() in it's opendir_cbk */
- mdc_load_reqs (this, xdata);
- }
+ if (xdata) {
+ /* Tell readdir-ahead to include these keys in xdata when it
+ * internally issues readdirp() in it's opendir_cbk */
+ mdc_load_reqs(this, xdata);
+ }
- STACK_WIND (frame, mdc_opendir_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->opendir, loc, fd, xdata);
+ STACK_WIND(frame, mdc_opendir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->opendir, loc, fd, xdata);
- if (xattr_alloc)
- dict_unref (xattr_alloc);
+ if (xattr_alloc)
+ dict_unref(xattr_alloc);
- return 0;
+ return 0;
}
-
int
-mdc_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, gf_dirent_t *entries, dict_t *xdata)
+mdc_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
+ int op_errno, gf_dirent_t *entries, dict_t *xdata)
{
- gf_dirent_t *entry = NULL;
- mdc_local_t *local = NULL;
+ gf_dirent_t *entry = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto unwind;
+ local = frame->local;
+ if (!local)
+ goto unwind;
- if (op_ret <= 0) {
- if ((op_ret == -1) && ((op_errno == ENOENT)
- || (op_errno == ESTALE)))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto unwind;
- }
+ if (op_ret <= 0) {
+ if ((op_ret == -1) && ((op_errno == ENOENT) || (op_errno == ESTALE)))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto unwind;
+ }
- list_for_each_entry (entry, &entries->list, list) {
- if (!entry->inode)
- continue;
- mdc_inode_iatt_set (this, entry->inode, &entry->d_stat,
- local->incident_time);
- mdc_inode_xatt_set (this, entry->inode, entry->dict);
- }
+ list_for_each_entry(entry, &entries->list, list)
+ {
+ if (!entry->inode)
+ continue;
+ mdc_inode_iatt_set(this, entry->inode, &entry->d_stat,
+ local->incident_time);
+ mdc_inode_xatt_set(this, entry->inode, entry->dict);
+ }
unwind:
- MDC_STACK_UNWIND (readdirp, frame, op_ret, op_errno, entries, xdata);
- return 0;
+ MDC_STACK_UNWIND(readdirp, frame, op_ret, op_errno, entries, xdata);
+ return 0;
}
-
int
-mdc_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd,
- size_t size, off_t offset, dict_t *xdata)
+mdc_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, dict_t *xdata)
{
- dict_t *xattr_alloc = NULL;
- mdc_local_t *local = NULL;
+ dict_t *xattr_alloc = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, fd->inode);
- if (!local)
- goto out;
+ local = mdc_local_get(frame, fd->inode);
+ if (!local)
+ goto out;
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- if (!xdata)
- xdata = xattr_alloc = dict_new ();
- if (xdata)
- mdc_load_reqs (this, xdata);
+ if (!xdata)
+ xdata = xattr_alloc = dict_new();
+ if (xdata)
+ mdc_load_reqs(this, xdata);
- STACK_WIND (frame, mdc_readdirp_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->readdirp,
- fd, size, offset, xdata);
- if (xattr_alloc)
- dict_unref (xattr_alloc);
- return 0;
+ STACK_WIND(frame, mdc_readdirp_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp, fd, size, offset, xdata);
+ if (xattr_alloc)
+ dict_unref(xattr_alloc);
+ return 0;
out:
- STACK_UNWIND_STRICT (readdirp, frame, -1, ENOMEM, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(readdirp, frame, -1, ENOMEM, NULL, NULL);
+ return 0;
}
int
mdc_readdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
- int op_errno, gf_dirent_t *entries, dict_t *xdata)
+ int op_errno, gf_dirent_t *entries, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret == 0)
- goto out;
+ if (op_ret == 0)
+ goto out;
- if ((op_errno == ESTALE) || (op_errno == ENOENT))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
+ if ((op_errno == ESTALE) || (op_errno == ENOENT))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
out:
- MDC_STACK_UNWIND (readdir, frame, op_ret, op_errno, entries, xdata);
- return 0;
+ MDC_STACK_UNWIND(readdir, frame, op_ret, op_errno, entries, xdata);
+ return 0;
}
int
-mdc_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd,
- size_t size, off_t offset, dict_t *xdata)
+mdc_readdir(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, dict_t *xdata)
{
- int need_unref = 0;
- mdc_local_t *local = NULL;
- struct mdc_conf *conf = this->private;
+ int need_unref = 0;
+ mdc_local_t *local = NULL;
+ struct mdc_conf *conf = this->private;
- local = mdc_local_get (frame, fd->inode);
- if (!local)
- goto unwind;
+ local = mdc_local_get(frame, fd->inode);
+ if (!local)
+ goto unwind;
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- if (!conf->force_readdirp) {
- STACK_WIND(frame, mdc_readdir_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdir, fd, size, offset,
- xdata);
- return 0;
- }
+ if (!conf->force_readdirp) {
+ STACK_WIND(frame, mdc_readdir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdir, fd, size, offset, xdata);
+ return 0;
+ }
- if (!xdata) {
- xdata = dict_new ();
- need_unref = 1;
- }
+ if (!xdata) {
+ xdata = dict_new();
+ need_unref = 1;
+ }
- if (xdata)
- mdc_load_reqs (this, xdata);
+ if (xdata)
+ mdc_load_reqs(this, xdata);
- STACK_WIND(frame, mdc_readdirp_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdirp, fd, size, offset,
- xdata);
+ STACK_WIND(frame, mdc_readdirp_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp, fd, size, offset, xdata);
- if (need_unref && xdata)
- dict_unref (xdata);
+ if (need_unref && xdata)
+ dict_unref(xdata);
- return 0;
+ return 0;
unwind:
- MDC_STACK_UNWIND (readdir, frame, -1, ENOMEM, NULL, NULL);
- return 0;
+ MDC_STACK_UNWIND(readdir, frame, -1, ENOMEM, NULL, NULL);
+ return 0;
}
int
mdc_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
- mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
- _gf_true, local->incident_time);
+ mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
+ _gf_true, local->incident_time);
out:
- MDC_STACK_UNWIND (fallocate, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
+ MDC_STACK_UNWIND(fallocate, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
- return 0;
+ return 0;
}
-int mdc_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,
- off_t offset, size_t len, dict_t *xdata)
+int
+mdc_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,
+ off_t offset, size_t len, dict_t *xdata)
{
- mdc_local_t *local;
+ mdc_local_t *local;
- local = mdc_local_get (frame, fd->inode);
- local->fd = fd_ref(fd);
+ local = mdc_local_get(frame, fd->inode);
+ local->fd = fd_ref(fd);
- STACK_WIND(frame, mdc_fallocate_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fallocate, fd, mode, offset, len,
- xdata);
+ STACK_WIND(frame, mdc_fallocate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fallocate, fd, mode, offset, len,
+ xdata);
- return 0;
+ return 0;
}
int
mdc_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
- mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
- _gf_true, local->incident_time);
+ mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
+ _gf_true, local->incident_time);
out:
- MDC_STACK_UNWIND(discard, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
+ MDC_STACK_UNWIND(discard, frame, op_ret, op_errno, prebuf, postbuf, xdata);
- return 0;
+ return 0;
}
-int mdc_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- size_t len, dict_t *xdata)
+int
+mdc_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ size_t len, dict_t *xdata)
{
- mdc_local_t *local;
+ mdc_local_t *local;
- local = mdc_local_get (frame, fd->inode);
- local->fd = fd_ref(fd);
+ local = mdc_local_get(frame, fd->inode);
+ local->fd = fd_ref(fd);
- STACK_WIND(frame, mdc_discard_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->discard, fd, offset, len,
- xdata);
+ STACK_WIND(frame, mdc_discard_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->discard, fd, offset, len, xdata);
- return 0;
+ return 0;
}
int
mdc_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno,
- struct iatt *prebuf, struct iatt *postbuf, dict_t *xdata)
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret != 0) {
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
- goto out;
- }
+ if (op_ret != 0) {
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
+ goto out;
+ }
- mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
- _gf_true, local->incident_time);
+ mdc_inode_iatt_set_validate(this, local->fd->inode, prebuf, postbuf,
+ _gf_true, local->incident_time);
out:
- MDC_STACK_UNWIND(zerofill, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
+ MDC_STACK_UNWIND(zerofill, frame, op_ret, op_errno, prebuf, postbuf, xdata);
- return 0;
+ return 0;
}
-int mdc_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- off_t len, dict_t *xdata)
+int
+mdc_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ off_t len, dict_t *xdata)
{
- mdc_local_t *local;
+ mdc_local_t *local;
- local = mdc_local_get (frame, fd->inode);
- local->fd = fd_ref(fd);
+ local = mdc_local_get(frame, fd->inode);
+ local->fd = fd_ref(fd);
- STACK_WIND(frame, mdc_zerofill_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->zerofill, fd, offset, len,
- xdata);
+ STACK_WIND(frame, mdc_zerofill_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->zerofill, fd, offset, len, xdata);
- return 0;
+ return 0;
}
int32_t
-mdc_readlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, const char *path,
- struct iatt *buf, dict_t *xdata)
+mdc_readlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, const char *path,
+ struct iatt *buf, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret == 0)
- goto out;
+ if (op_ret == 0)
+ goto out;
- if ((op_errno == ENOENT) || (op_errno == ESTALE))
- mdc_inode_iatt_invalidate (this, local->loc.inode);
+ if ((op_errno == ENOENT) || (op_errno == ESTALE))
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
out:
- MDC_STACK_UNWIND (readlink, frame, op_ret, op_errno,
- path, buf, xdata);
- return 0;
+ MDC_STACK_UNWIND(readlink, frame, op_ret, op_errno, path, buf, xdata);
+ return 0;
}
int32_t
-mdc_readlink (call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size,
- dict_t *xdata)
+mdc_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
- if (!local)
- goto unwind;
+ local = mdc_local_get(frame, loc->inode);
+ if (!local)
+ goto unwind;
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- STACK_WIND (frame, mdc_readlink_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readlink,
- loc, size, xdata);
- return 0;
+ STACK_WIND(frame, mdc_readlink_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readlink, loc, size, xdata);
+ return 0;
unwind:
- MDC_STACK_UNWIND (readlink, frame, -1, ENOMEM, NULL, NULL, NULL);
- return 0;
+ MDC_STACK_UNWIND(readlink, frame, -1, ENOMEM, NULL, NULL, NULL);
+ return 0;
}
int32_t
-mdc_fsyncdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+mdc_fsyncdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret == 0)
- goto out;
+ if (op_ret == 0)
+ goto out;
- if ((op_errno == ESTALE) || (op_errno == ENOENT))
- mdc_inode_iatt_invalidate (this, local->fd->inode);
+ if ((op_errno == ESTALE) || (op_errno == ENOENT))
+ mdc_inode_iatt_invalidate(this, local->fd->inode);
out:
- MDC_STACK_UNWIND (fsyncdir, frame, op_ret, op_errno, xdata);
- return 0;
+ MDC_STACK_UNWIND(fsyncdir, frame, op_ret, op_errno, xdata);
+ return 0;
}
int32_t
-mdc_fsyncdir (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
- dict_t *xdata)
+mdc_fsyncdir(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t flags,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, fd->inode);
- if (!local)
- goto unwind;
+ local = mdc_local_get(frame, fd->inode);
+ if (!local)
+ goto unwind;
- local->fd = fd_ref (fd);
+ local->fd = fd_ref(fd);
- STACK_WIND (frame, mdc_fsyncdir_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsyncdir, fd, flags, xdata);
- return 0;
+ STACK_WIND(frame, mdc_fsyncdir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsyncdir, fd, flags, xdata);
+ return 0;
unwind:
- MDC_STACK_UNWIND (fsyncdir, frame, -1, ENOMEM, NULL);
- return 0;
+ MDC_STACK_UNWIND(fsyncdir, frame, -1, ENOMEM, NULL);
+ return 0;
}
int32_t
-mdc_access_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+mdc_access_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = frame->local;
- if (!local)
- goto out;
+ local = frame->local;
+ if (!local)
+ goto out;
- if (op_ret == 0)
- goto out;
+ if (op_ret == 0)
+ goto out;
- if ((op_errno == ESTALE) || (op_errno == ENOENT))
- mdc_inode_iatt_invalidate (this, local->loc.inode);
+ if ((op_errno == ESTALE) || (op_errno == ENOENT))
+ mdc_inode_iatt_invalidate(this, local->loc.inode);
out:
- MDC_STACK_UNWIND (access, frame, op_ret, op_errno, xdata);
- return 0;
+ MDC_STACK_UNWIND(access, frame, op_ret, op_errno, xdata);
+ return 0;
}
-
-
int32_t
-mdc_access (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask,
- dict_t *xdata)
+mdc_access(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t mask,
+ dict_t *xdata)
{
- mdc_local_t *local = NULL;
+ mdc_local_t *local = NULL;
- local = mdc_local_get (frame, loc->inode);
- if (!local)
- goto unwind;
+ local = mdc_local_get(frame, loc->inode);
+ if (!local)
+ goto unwind;
- loc_copy (&local->loc, loc);
+ loc_copy(&local->loc, loc);
- STACK_WIND (frame, mdc_access_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->access, loc, mask, xdata);
- return 0;
+ STACK_WIND(frame, mdc_access_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->access, loc, mask, xdata);
+ return 0;
unwind:
- MDC_STACK_UNWIND (access, frame, -1, ENOMEM, NULL);
- return 0;
+ MDC_STACK_UNWIND(access, frame, -1, ENOMEM, NULL);
+ return 0;
}
-
int
-mdc_priv_dump (xlator_t *this)
+mdc_priv_dump(xlator_t *this)
{
- struct mdc_conf *conf = NULL;
- char key_prefix[GF_DUMP_MAX_BUF_LEN];
+ struct mdc_conf *conf = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
- conf = this->private;
+ conf = this->private;
- snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type, this->name);
- gf_proc_dump_add_section(key_prefix);
+ snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type, this->name);
+ gf_proc_dump_add_section(key_prefix);
- gf_proc_dump_write("stat_hit_count", "%"PRId64,
- GF_ATOMIC_GET(conf->mdc_counter.stat_hit));
- gf_proc_dump_write("stat_miss_count", "%"PRId64,
- GF_ATOMIC_GET(conf->mdc_counter.stat_miss));
- gf_proc_dump_write("xattr_hit_count", "%"PRId64,
- GF_ATOMIC_GET(conf->mdc_counter.xattr_hit));
- gf_proc_dump_write("xattr_miss_count", "%"PRId64,
- GF_ATOMIC_GET(conf->mdc_counter.xattr_miss));
- gf_proc_dump_write("nameless_lookup_count", "%"PRId64,
- GF_ATOMIC_GET(conf->mdc_counter.nameless_lookup));
- gf_proc_dump_write("negative_lookup_count", "%"PRId64,
- GF_ATOMIC_GET(conf->mdc_counter.negative_lookup));
- gf_proc_dump_write("stat_invalidations_received", "%"PRId64,
- GF_ATOMIC_GET(conf->mdc_counter.stat_invals));
- gf_proc_dump_write("xattr_invalidations_received", "%"PRId64,
- GF_ATOMIC_GET(conf->mdc_counter.xattr_invals));
+ gf_proc_dump_write("stat_hit_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->mdc_counter.stat_hit));
+ gf_proc_dump_write("stat_miss_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->mdc_counter.stat_miss));
+ gf_proc_dump_write("xattr_hit_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->mdc_counter.xattr_hit));
+ gf_proc_dump_write("xattr_miss_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->mdc_counter.xattr_miss));
+ gf_proc_dump_write("nameless_lookup_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->mdc_counter.nameless_lookup));
+ gf_proc_dump_write("negative_lookup_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->mdc_counter.negative_lookup));
+ gf_proc_dump_write("stat_invalidations_received", "%" PRId64,
+ GF_ATOMIC_GET(conf->mdc_counter.stat_invals));
+ gf_proc_dump_write("xattr_invalidations_received", "%" PRId64,
+ GF_ATOMIC_GET(conf->mdc_counter.xattr_invals));
- return 0;
+ return 0;
}
-
static int32_t
-mdc_dump_metrics (xlator_t *this, int fd)
-{
- struct mdc_conf *conf = NULL;
-
- conf = this->private;
- if (!conf)
- goto out;
-
- dprintf (fd, "%s.stat_cache_hit_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->mdc_counter.stat_hit));
- dprintf (fd, "%s.stat_cache_miss_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->mdc_counter.stat_miss));
- dprintf (fd, "%s.xattr_cache_hit_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->mdc_counter.xattr_hit));
- dprintf (fd, "%s.xattr_cache_miss_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->mdc_counter.xattr_miss));
- dprintf (fd, "%s.nameless_lookup_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->mdc_counter.nameless_lookup));
- dprintf (fd, "%s.negative_lookup_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->mdc_counter.negative_lookup));
- dprintf (fd, "%s.stat_cache_invalidations_received %"PRId64"\n",
- this->name,
- GF_ATOMIC_GET(conf->mdc_counter.stat_invals));
- dprintf (fd, "%s.xattr_cache_invalidations_received %"PRId64"\n",
- this->name,
- GF_ATOMIC_GET(conf->mdc_counter.xattr_invals));
+mdc_dump_metrics(xlator_t *this, int fd)
+{
+ struct mdc_conf *conf = NULL;
+
+ conf = this->private;
+ if (!conf)
+ goto out;
+
+ dprintf(fd, "%s.stat_cache_hit_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->mdc_counter.stat_hit));
+ dprintf(fd, "%s.stat_cache_miss_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->mdc_counter.stat_miss));
+ dprintf(fd, "%s.xattr_cache_hit_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->mdc_counter.xattr_hit));
+ dprintf(fd, "%s.xattr_cache_miss_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->mdc_counter.xattr_miss));
+ dprintf(fd, "%s.nameless_lookup_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->mdc_counter.nameless_lookup));
+ dprintf(fd, "%s.negative_lookup_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->mdc_counter.negative_lookup));
+ dprintf(fd, "%s.stat_cache_invalidations_received %" PRId64 "\n",
+ this->name, GF_ATOMIC_GET(conf->mdc_counter.stat_invals));
+ dprintf(fd, "%s.xattr_cache_invalidations_received %" PRId64 "\n",
+ this->name, GF_ATOMIC_GET(conf->mdc_counter.xattr_invals));
out:
- return 0;
+ return 0;
}
-
int
-mdc_forget (xlator_t *this, inode_t *inode)
+mdc_forget(xlator_t *this, inode_t *inode)
{
- mdc_inode_wipe (this, inode);
+ mdc_inode_wipe(this, inode);
- return 0;
+ return 0;
}
-
int
-is_strpfx (const char *str1, const char *str2)
+is_strpfx(const char *str1, const char *str2)
{
- /* is one of the string a prefix of the other? */
- int i;
+ /* is one of the string a prefix of the other? */
+ int i;
- for (i = 0; str1[i] == str2[i]; i++) {
- if (!str1[i] || !str2[i])
- break;
- }
+ for (i = 0; str1[i] == str2[i]; i++) {
+ if (!str1[i] || !str2[i])
+ break;
+ }
- return !(str1[i] && str2[i]);
+ return !(str1[i] && str2[i]);
}
-
static int
-mdc_key_unload_all (struct mdc_conf *conf)
+mdc_key_unload_all(struct mdc_conf *conf)
{
- conf->mdc_xattr_str = NULL;
+ conf->mdc_xattr_str = NULL;
- return 0;
+ return 0;
}
-
int
-mdc_xattr_list_populate (struct mdc_conf *conf, char *tmp_str)
+mdc_xattr_list_populate(struct mdc_conf *conf, char *tmp_str)
{
- char *mdc_xattr_str = NULL;
- size_t max_size = 0;
- int ret = 0;
+ char *mdc_xattr_str = NULL;
+ size_t max_size = 0;
+ int ret = 0;
- max_size = SLEN ("security.capability,security.selinux,security.ima,"
- POSIX_ACL_ACCESS_XATTR","POSIX_ACL_DEFAULT_XATTR","
- GF_POSIX_ACL_ACCESS","GF_POSIX_ACL_DEFAULT","
- "user.swift.metadata,user.DOSATTRIB,user.DosStream.*"
- ",user.org.netatalk.Metadata,security.NTACL,"
- "user.org.netatalk.ResourceFork")
- + strlen (tmp_str) + 5; /*Some buffer bytes*/
+ max_size = SLEN(
+ "security.capability,security.selinux,security."
+ "ima," POSIX_ACL_ACCESS_XATTR "," POSIX_ACL_DEFAULT_XATTR
+ "," GF_POSIX_ACL_ACCESS "," GF_POSIX_ACL_DEFAULT
+ ","
+ "user.swift.metadata,user.DOSATTRIB,user.DosStream.*"
+ ",user.org.netatalk.Metadata,security.NTACL,"
+ "user.org.netatalk.ResourceFork") +
+ strlen(tmp_str) + 5; /*Some buffer bytes*/
- mdc_xattr_str = GF_MALLOC (max_size, gf_common_mt_char);
- GF_CHECK_ALLOC (mdc_xattr_str, ret, out);
+ mdc_xattr_str = GF_MALLOC(max_size, gf_common_mt_char);
+ GF_CHECK_ALLOC(mdc_xattr_str, ret, out);
- if (conf->cache_capability)
- strcat (mdc_xattr_str, "security.capability,");
+ if (conf->cache_capability)
+ strcat(mdc_xattr_str, "security.capability,");
- if (conf->cache_selinux)
- strcat (mdc_xattr_str, "security.selinux,");
+ if (conf->cache_selinux)
+ strcat(mdc_xattr_str, "security.selinux,");
- if (conf->cache_ima)
- strcat (mdc_xattr_str, "security.ima,");
+ if (conf->cache_ima)
+ strcat(mdc_xattr_str, "security.ima,");
- if (conf->cache_posix_acl)
- strcat (mdc_xattr_str, POSIX_ACL_ACCESS_XATTR","
- POSIX_ACL_DEFAULT_XATTR","GF_POSIX_ACL_ACCESS
- ","GF_POSIX_ACL_DEFAULT",");
+ if (conf->cache_posix_acl)
+ strcat(mdc_xattr_str, POSIX_ACL_ACCESS_XATTR
+ "," POSIX_ACL_DEFAULT_XATTR "," GF_POSIX_ACL_ACCESS
+ "," GF_POSIX_ACL_DEFAULT ",");
- if (conf->cache_swift_metadata)
- strcat (mdc_xattr_str, "user.swift.metadata,");
+ if (conf->cache_swift_metadata)
+ strcat(mdc_xattr_str, "user.swift.metadata,");
- if (conf->cache_samba_metadata)
- strcat (mdc_xattr_str, "user.DOSATTRIB,user.DosStream.*,"
- "user.org.netatalk.Metadata,user.org.netatalk."
- "ResourceFork,security.NTACL,");
+ if (conf->cache_samba_metadata)
+ strcat(mdc_xattr_str,
+ "user.DOSATTRIB,user.DosStream.*,"
+ "user.org.netatalk.Metadata,user.org.netatalk."
+ "ResourceFork,security.NTACL,");
- strcat (mdc_xattr_str, tmp_str);
+ strcat(mdc_xattr_str, tmp_str);
- LOCK (&conf->lock);
- {
- /* This is not freed, else is_mdc_key_satisfied, which is
- * called by every fop has to take lock, and will lead to
- * lock contention
- */
- conf->mdc_xattr_str = mdc_xattr_str;
- }
- UNLOCK (&conf->lock);
+ LOCK(&conf->lock);
+ {
+ /* This is not freed, else is_mdc_key_satisfied, which is
+ * called by every fop has to take lock, and will lead to
+ * lock contention
+ */
+ conf->mdc_xattr_str = mdc_xattr_str;
+ }
+ UNLOCK(&conf->lock);
out:
- return ret;
+ return ret;
}
-
struct set {
- inode_t *inode;
- xlator_t *this;
+ inode_t *inode;
+ xlator_t *this;
};
static int
-mdc_inval_xatt (dict_t *d, char *k, data_t *v, void *tmp)
+mdc_inval_xatt(dict_t *d, char *k, data_t *v, void *tmp)
{
- struct set *tmp1 = NULL;
- int ret = 0;
+ struct set *tmp1 = NULL;
+ int ret = 0;
- tmp1 = (struct set *)tmp;
- ret = mdc_inode_xatt_unset (tmp1->this, tmp1->inode, k);
- return ret;
+ tmp1 = (struct set *)tmp;
+ ret = mdc_inode_xatt_unset(tmp1->this, tmp1->inode, k);
+ return ret;
}
static int
-mdc_invalidate (xlator_t *this, void *data)
-{
- struct gf_upcall *up_data = NULL;
- struct gf_upcall_cache_invalidation *up_ci = NULL;
- inode_t *inode = NULL;
- int ret = 0;
- struct set tmp = {0, };
- inode_table_t *itable = NULL;
- struct mdc_conf *conf = this->private;
- uint64_t gen = 0;
-
- up_data = (struct gf_upcall *)data;
-
- if (up_data->event_type != GF_UPCALL_CACHE_INVALIDATION)
- goto out;
-
- up_ci = (struct gf_upcall_cache_invalidation *)up_data->data;
-
- itable = ((xlator_t *)this->graph->top)->itable;
- inode = inode_find (itable, up_data->gfid);
- if (!inode) {
- ret = -1;
- goto out;
- }
-
- if (up_ci->flags & UP_PARENT_DENTRY_FLAGS) {
- mdc_update_gfid_stat (this, &up_ci->p_stat);
- if (up_ci->flags & UP_RENAME_FLAGS)
- mdc_update_gfid_stat (this, &up_ci->oldp_stat);
- }
-
- if (up_ci->flags & UP_EXPLICIT_LOOKUP) {
- mdc_inode_set_need_lookup (this, inode, _gf_true);
- goto out;
- }
-
- if (up_ci->flags &
- (UP_NLINK | UP_RENAME_FLAGS | UP_FORGET | UP_INVAL_ATTR)) {
- mdc_inode_iatt_invalidate (this, inode);
- mdc_inode_xatt_invalidate (this, inode);
- GF_ATOMIC_INC (conf->mdc_counter.stat_invals);
- goto out;
- }
-
- if (up_ci->flags & IATT_UPDATE_FLAGS) {
- gen = mdc_get_generation (this, inode);
- ret = mdc_inode_iatt_set_validate (this, inode, NULL,
- &up_ci->stat, _gf_false,
- gen);
- /* one of the scenarios where ret < 0 is when this invalidate
- * is older than the current stat, in that case do not
- * update the xattrs as well
- */
- if (ret < 0)
- goto out;
- GF_ATOMIC_INC (conf->mdc_counter.stat_invals);
- }
+mdc_invalidate(xlator_t *this, void *data)
+{
+ struct gf_upcall *up_data = NULL;
+ struct gf_upcall_cache_invalidation *up_ci = NULL;
+ inode_t *inode = NULL;
+ int ret = 0;
+ struct set tmp = {
+ 0,
+ };
+ inode_table_t *itable = NULL;
+ struct mdc_conf *conf = this->private;
+ uint64_t gen = 0;
+
+ up_data = (struct gf_upcall *)data;
+
+ if (up_data->event_type != GF_UPCALL_CACHE_INVALIDATION)
+ goto out;
+
+ up_ci = (struct gf_upcall_cache_invalidation *)up_data->data;
+
+ itable = ((xlator_t *)this->graph->top)->itable;
+ inode = inode_find(itable, up_data->gfid);
+ if (!inode) {
+ ret = -1;
+ goto out;
+ }
+
+ if (up_ci->flags & UP_PARENT_DENTRY_FLAGS) {
+ mdc_update_gfid_stat(this, &up_ci->p_stat);
+ if (up_ci->flags & UP_RENAME_FLAGS)
+ mdc_update_gfid_stat(this, &up_ci->oldp_stat);
+ }
+
+ if (up_ci->flags & UP_EXPLICIT_LOOKUP) {
+ mdc_inode_set_need_lookup(this, inode, _gf_true);
+ goto out;
+ }
+
+ if (up_ci->flags &
+ (UP_NLINK | UP_RENAME_FLAGS | UP_FORGET | UP_INVAL_ATTR)) {
+ mdc_inode_iatt_invalidate(this, inode);
+ mdc_inode_xatt_invalidate(this, inode);
+ GF_ATOMIC_INC(conf->mdc_counter.stat_invals);
+ goto out;
+ }
+
+ if (up_ci->flags & IATT_UPDATE_FLAGS) {
+ gen = mdc_get_generation(this, inode);
+ ret = mdc_inode_iatt_set_validate(this, inode, NULL, &up_ci->stat,
+ _gf_false, gen);
+ /* one of the scenarios where ret < 0 is when this invalidate
+ * is older than the current stat, in that case do not
+ * update the xattrs as well
+ */
+ if (ret < 0)
+ goto out;
+ GF_ATOMIC_INC(conf->mdc_counter.stat_invals);
+ }
- if (up_ci->flags & UP_XATTR) {
- if (up_ci->dict)
- ret = mdc_inode_xatt_update (this, inode, up_ci->dict);
- else
- ret = mdc_inode_xatt_invalidate (this, inode);
+ if (up_ci->flags & UP_XATTR) {
+ if (up_ci->dict)
+ ret = mdc_inode_xatt_update(this, inode, up_ci->dict);
+ else
+ ret = mdc_inode_xatt_invalidate(this, inode);
- GF_ATOMIC_INC (conf->mdc_counter.xattr_invals);
- } else if (up_ci->flags & UP_XATTR_RM) {
- tmp.inode = inode;
- tmp.this = this;
- ret = dict_foreach (up_ci->dict, mdc_inval_xatt, &tmp);
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_invals);
+ } else if (up_ci->flags & UP_XATTR_RM) {
+ tmp.inode = inode;
+ tmp.this = this;
+ ret = dict_foreach(up_ci->dict, mdc_inval_xatt, &tmp);
- GF_ATOMIC_INC (conf->mdc_counter.xattr_invals);
- }
+ GF_ATOMIC_INC(conf->mdc_counter.xattr_invals);
+ }
out:
- if (inode)
- inode_unref (inode);
+ if (inode)
+ inode_unref(inode);
- return ret;
+ return ret;
}
struct mdc_ipc {
- xlator_t *this;
- dict_t *xattr;
+ xlator_t *this;
+ dict_t *xattr;
};
static int
-mdc_send_xattrs_cbk (int ret, call_frame_t *frame, void *data)
+mdc_send_xattrs_cbk(int ret, call_frame_t *frame, void *data)
{
- struct mdc_ipc *tmp = data;
+ struct mdc_ipc *tmp = data;
- if (ret < 0) {
- mdc_key_unload_all (THIS->private);
- gf_msg ("md-cache", GF_LOG_INFO, 0, MD_CACHE_MSG_NO_XATTR_CACHE,
- "Disabled cache for all xattrs, as registering for "
- "xattr cache invalidation failed");
- }
- STACK_DESTROY (frame->root);
- dict_unref (tmp->xattr);
- GF_FREE (tmp);
+ if (ret < 0) {
+ mdc_key_unload_all(THIS->private);
+ gf_msg("md-cache", GF_LOG_INFO, 0, MD_CACHE_MSG_NO_XATTR_CACHE,
+ "Disabled cache for all xattrs, as registering for "
+ "xattr cache invalidation failed");
+ }
+ STACK_DESTROY(frame->root);
+ dict_unref(tmp->xattr);
+ GF_FREE(tmp);
- return 0;
+ return 0;
}
static int
-mdc_send_xattrs (void *data)
+mdc_send_xattrs(void *data)
{
- int ret = 0;
- struct mdc_ipc *tmp = data;
+ int ret = 0;
+ struct mdc_ipc *tmp = data;
- ret = syncop_ipc (FIRST_CHILD (tmp->this), GF_IPC_TARGET_UPCALL,
- tmp->xattr, NULL);
- DECODE_SYNCOP_ERR (ret);
- if (ret < 0) {
- gf_msg (tmp->this->name, GF_LOG_WARNING, errno,
- MD_CACHE_MSG_IPC_UPCALL_FAILED, "Registering the list "
- "of xattrs that needs invalidaton, with upcall, failed");
- }
+ ret = syncop_ipc(FIRST_CHILD(tmp->this), GF_IPC_TARGET_UPCALL, tmp->xattr,
+ NULL);
+ DECODE_SYNCOP_ERR(ret);
+ if (ret < 0) {
+ gf_msg(tmp->this->name, GF_LOG_WARNING, errno,
+ MD_CACHE_MSG_IPC_UPCALL_FAILED,
+ "Registering the list "
+ "of xattrs that needs invalidaton, with upcall, failed");
+ }
- return ret;
+ return ret;
}
-
static int
-mdc_register_xattr_inval (xlator_t *this)
-{
- dict_t *xattr = NULL;
- int ret = 0;
- struct mdc_conf *conf = NULL;
- call_frame_t *frame = NULL;
- struct mdc_ipc *data = NULL;
-
- conf = this->private;
-
- LOCK (&conf->lock);
- {
- if (!conf->mdc_invalidation) {
- UNLOCK (&conf->lock);
- goto out;
- }
- }
- UNLOCK (&conf->lock);
-
- xattr = dict_new ();
- if (!xattr) {
- gf_msg (this->name, GF_LOG_WARNING, ENOMEM,
- MD_CACHE_MSG_NO_MEMORY, "dict_new failed");
- ret = -1;
- goto out;
- }
-
- mdc_load_reqs (this, xattr);
-
- frame = create_frame (this, this->ctx->pool);
- if (!frame) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- MD_CACHE_MSG_NO_MEMORY,
- "failed to create the frame");
- ret = -1;
- goto out;
- }
-
- data = GF_CALLOC (1, sizeof (struct mdc_ipc), gf_mdc_mt_mdc_ipc);
- if (!data) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- MD_CACHE_MSG_NO_MEMORY,
- "failed to allocate memory");
- ret = -1;
- goto out;
- }
-
- data->this = this;
- data->xattr = xattr;
- ret = synctask_new (this->ctx->env, mdc_send_xattrs, mdc_send_xattrs_cbk,
- frame, data);
- if (ret < 0) {
- gf_msg (this->name, GF_LOG_WARNING, errno,
- MD_CACHE_MSG_IPC_UPCALL_FAILED, "Registering the list "
- "of xattrs that needs invalidaton, with upcall, failed");
- }
+mdc_register_xattr_inval(xlator_t *this)
+{
+ dict_t *xattr = NULL;
+ int ret = 0;
+ struct mdc_conf *conf = NULL;
+ call_frame_t *frame = NULL;
+ struct mdc_ipc *data = NULL;
+
+ conf = this->private;
+
+ LOCK(&conf->lock);
+ {
+ if (!conf->mdc_invalidation) {
+ UNLOCK(&conf->lock);
+ goto out;
+ }
+ }
+ UNLOCK(&conf->lock);
+
+ xattr = dict_new();
+ if (!xattr) {
+ gf_msg(this->name, GF_LOG_WARNING, ENOMEM, MD_CACHE_MSG_NO_MEMORY,
+ "dict_new failed");
+ ret = -1;
+ goto out;
+ }
+
+ mdc_load_reqs(this, xattr);
+
+ frame = create_frame(this, this->ctx->pool);
+ if (!frame) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, MD_CACHE_MSG_NO_MEMORY,
+ "failed to create the frame");
+ ret = -1;
+ goto out;
+ }
+
+ data = GF_CALLOC(1, sizeof(struct mdc_ipc), gf_mdc_mt_mdc_ipc);
+ if (!data) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, MD_CACHE_MSG_NO_MEMORY,
+ "failed to allocate memory");
+ ret = -1;
+ goto out;
+ }
+
+ data->this = this;
+ data->xattr = xattr;
+ ret = synctask_new(this->ctx->env, mdc_send_xattrs, mdc_send_xattrs_cbk,
+ frame, data);
+ if (ret < 0) {
+ gf_msg(this->name, GF_LOG_WARNING, errno,
+ MD_CACHE_MSG_IPC_UPCALL_FAILED,
+ "Registering the list "
+ "of xattrs that needs invalidaton, with upcall, failed");
+ }
out:
- if (ret < 0) {
- mdc_key_unload_all (conf);
- if (xattr)
- dict_unref (xattr);
- if (frame)
- STACK_DESTROY (frame->root);
- GF_FREE (data);
- gf_msg (this->name, GF_LOG_INFO, 0, MD_CACHE_MSG_NO_XATTR_CACHE,
- "Disabled cache for all xattrs, as registering for "
- "xattr cache invalidation failed");
- }
+ if (ret < 0) {
+ mdc_key_unload_all(conf);
+ if (xattr)
+ dict_unref(xattr);
+ if (frame)
+ STACK_DESTROY(frame->root);
+ GF_FREE(data);
+ gf_msg(this->name, GF_LOG_INFO, 0, MD_CACHE_MSG_NO_XATTR_CACHE,
+ "Disabled cache for all xattrs, as registering for "
+ "xattr cache invalidation failed");
+ }
- return ret;
+ return ret;
}
-
int
-mdc_reconfigure (xlator_t *this, dict_t *options)
+mdc_reconfigure(xlator_t *this, dict_t *options)
{
- struct mdc_conf *conf = NULL;
- int timeout = 0;
- char *tmp_str = NULL;
-
- conf = this->private;
+ struct mdc_conf *conf = NULL;
+ int timeout = 0;
+ char *tmp_str = NULL;
- GF_OPTION_RECONF ("md-cache-timeout", timeout, options, int32, out);
+ conf = this->private;
- GF_OPTION_RECONF ("cache-selinux", conf->cache_selinux, options, bool, out);
+ GF_OPTION_RECONF("md-cache-timeout", timeout, options, int32, out);
- GF_OPTION_RECONF ("cache-capability-xattrs", conf->cache_capability,
- options, bool, out);
+ GF_OPTION_RECONF("cache-selinux", conf->cache_selinux, options, bool, out);
- GF_OPTION_RECONF ("cache-ima-xattrs", conf->cache_ima, options, bool,
- out);
+ GF_OPTION_RECONF("cache-capability-xattrs", conf->cache_capability, options,
+ bool, out);
- GF_OPTION_RECONF ("cache-posix-acl", conf->cache_posix_acl, options,
- bool, out);
+ GF_OPTION_RECONF("cache-ima-xattrs", conf->cache_ima, options, bool, out);
- GF_OPTION_RECONF ("cache-swift-metadata", conf->cache_swift_metadata,
- options, bool, out);
+ GF_OPTION_RECONF("cache-posix-acl", conf->cache_posix_acl, options, bool,
+ out);
- GF_OPTION_RECONF ("cache-samba-metadata", conf->cache_samba_metadata,
- options, bool, out);
+ GF_OPTION_RECONF("cache-swift-metadata", conf->cache_swift_metadata,
+ options, bool, out);
- GF_OPTION_RECONF ("force-readdirp", conf->force_readdirp, options, bool,
- out);
+ GF_OPTION_RECONF("cache-samba-metadata", conf->cache_samba_metadata,
+ options, bool, out);
- GF_OPTION_RECONF ("cache-invalidation", conf->mdc_invalidation, options,
- bool, out);
+ GF_OPTION_RECONF("force-readdirp", conf->force_readdirp, options, bool,
+ out);
- GF_OPTION_RECONF ("pass-through", this->pass_through, options, bool,
- out);
+ GF_OPTION_RECONF("cache-invalidation", conf->mdc_invalidation, options,
+ bool, out);
- GF_OPTION_RECONF ("md-cache-statfs", conf->cache_statfs, options,
- bool, out);
+ GF_OPTION_RECONF("pass-through", this->pass_through, options, bool, out);
- GF_OPTION_RECONF ("xattr-cache-list", tmp_str, options, str, out);
- mdc_xattr_list_populate (conf, tmp_str);
+ GF_OPTION_RECONF("md-cache-statfs", conf->cache_statfs, options, bool, out);
+ GF_OPTION_RECONF("xattr-cache-list", tmp_str, options, str, out);
+ mdc_xattr_list_populate(conf, tmp_str);
- /* If timeout is greater than 60s (default before the patch that added
- * cache invalidation support was added) then, cache invalidation
- * feature for md-cache needs to be enabled, if not set timeout to the
- * previous max which is 60s
- */
- if ((timeout > 60) && (!conf->mdc_invalidation)) {
- conf->timeout = 60;
- goto out;
- }
- conf->timeout = timeout;
+ /* If timeout is greater than 60s (default before the patch that added
+ * cache invalidation support was added) then, cache invalidation
+ * feature for md-cache needs to be enabled, if not set timeout to the
+ * previous max which is 60s
+ */
+ if ((timeout > 60) && (!conf->mdc_invalidation)) {
+ conf->timeout = 60;
+ goto out;
+ }
+ conf->timeout = timeout;
- (void) mdc_register_xattr_inval (this);
+ (void)mdc_register_xattr_inval(this);
out:
- return 0;
+ return 0;
}
int32_t
-mdc_mem_acct_init (xlator_t *this)
+mdc_mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- ret = xlator_mem_acct_init (this, gf_mdc_mt_end + 1);
- return ret;
+ ret = xlator_mem_acct_init(this, gf_mdc_mt_end + 1);
+ return ret;
}
int
-mdc_init (xlator_t *this)
+mdc_init(xlator_t *this)
{
- struct mdc_conf *conf = NULL;
- int timeout = 0;
- char *tmp_str = NULL;
+ struct mdc_conf *conf = NULL;
+ int timeout = 0;
+ char *tmp_str = NULL;
- conf = GF_CALLOC (sizeof (*conf), 1, gf_mdc_mt_mdc_conf_t);
- if (!conf) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- MD_CACHE_MSG_NO_MEMORY, "out of memory");
- return -1;
- }
+ conf = GF_CALLOC(sizeof(*conf), 1, gf_mdc_mt_mdc_conf_t);
+ if (!conf) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, MD_CACHE_MSG_NO_MEMORY,
+ "out of memory");
+ return -1;
+ }
- LOCK_INIT (&conf->lock);
+ LOCK_INIT(&conf->lock);
- GF_OPTION_INIT ("md-cache-timeout", timeout, int32, out);
+ GF_OPTION_INIT("md-cache-timeout", timeout, int32, out);
- GF_OPTION_INIT ("cache-selinux", conf->cache_selinux, bool, out);
+ GF_OPTION_INIT("cache-selinux", conf->cache_selinux, bool, out);
- GF_OPTION_INIT ("cache-capability-xattrs", conf->cache_capability,
- bool, out);
+ GF_OPTION_INIT("cache-capability-xattrs", conf->cache_capability, bool,
+ out);
- GF_OPTION_INIT ("cache-ima-xattrs", conf->cache_ima, bool, out);
+ GF_OPTION_INIT("cache-ima-xattrs", conf->cache_ima, bool, out);
- GF_OPTION_INIT ("cache-posix-acl", conf->cache_posix_acl, bool, out);
+ GF_OPTION_INIT("cache-posix-acl", conf->cache_posix_acl, bool, out);
- GF_OPTION_INIT ("cache-swift-metadata",
- conf->cache_swift_metadata, bool, out);
+ GF_OPTION_INIT("cache-swift-metadata", conf->cache_swift_metadata, bool,
+ out);
- GF_OPTION_INIT ("cache-samba-metadata", conf->cache_samba_metadata,
- bool, out);
+ GF_OPTION_INIT("cache-samba-metadata", conf->cache_samba_metadata, bool,
+ out);
- GF_OPTION_INIT("force-readdirp", conf->force_readdirp, bool, out);
+ GF_OPTION_INIT("force-readdirp", conf->force_readdirp, bool, out);
- GF_OPTION_INIT("cache-invalidation", conf->mdc_invalidation, bool, out);
+ GF_OPTION_INIT("cache-invalidation", conf->mdc_invalidation, bool, out);
- GF_OPTION_INIT ("pass-through", this->pass_through, bool, out);
+ GF_OPTION_INIT("pass-through", this->pass_through, bool, out);
- pthread_mutex_init (&conf->statfs_cache.lock, NULL);
- GF_OPTION_INIT ("md-cache-statfs", conf->cache_statfs, bool, out);
+ pthread_mutex_init(&conf->statfs_cache.lock, NULL);
+ GF_OPTION_INIT("md-cache-statfs", conf->cache_statfs, bool, out);
- GF_OPTION_INIT("xattr-cache-list", tmp_str, str, out);
- mdc_xattr_list_populate (conf, tmp_str);
+ GF_OPTION_INIT("xattr-cache-list", tmp_str, str, out);
+ mdc_xattr_list_populate(conf, tmp_str);
- time (&conf->last_child_down);
- /* initialize gf_atomic_t counters */
- GF_ATOMIC_INIT (conf->mdc_counter.stat_hit, 0);
- GF_ATOMIC_INIT (conf->mdc_counter.stat_miss, 0);
- GF_ATOMIC_INIT (conf->mdc_counter.xattr_hit, 0);
- GF_ATOMIC_INIT (conf->mdc_counter.xattr_miss, 0);
- GF_ATOMIC_INIT (conf->mdc_counter.negative_lookup, 0);
- GF_ATOMIC_INIT (conf->mdc_counter.nameless_lookup, 0);
- GF_ATOMIC_INIT (conf->mdc_counter.stat_invals, 0);
- GF_ATOMIC_INIT (conf->mdc_counter.xattr_invals, 0);
- GF_ATOMIC_INIT (conf->mdc_counter.need_lookup, 0);
- GF_ATOMIC_INIT (conf->generation, 0);
+ time(&conf->last_child_down);
+ /* initialize gf_atomic_t counters */
+ GF_ATOMIC_INIT(conf->mdc_counter.stat_hit, 0);
+ GF_ATOMIC_INIT(conf->mdc_counter.stat_miss, 0);
+ GF_ATOMIC_INIT(conf->mdc_counter.xattr_hit, 0);
+ GF_ATOMIC_INIT(conf->mdc_counter.xattr_miss, 0);
+ GF_ATOMIC_INIT(conf->mdc_counter.negative_lookup, 0);
+ GF_ATOMIC_INIT(conf->mdc_counter.nameless_lookup, 0);
+ GF_ATOMIC_INIT(conf->mdc_counter.stat_invals, 0);
+ GF_ATOMIC_INIT(conf->mdc_counter.xattr_invals, 0);
+ GF_ATOMIC_INIT(conf->mdc_counter.need_lookup, 0);
+ GF_ATOMIC_INIT(conf->generation, 0);
- /* If timeout is greater than 60s (default before the patch that added
- * cache invalidation support was added) then, cache invalidation
- * feature for md-cache needs to be enabled, if not set timeout to the
- * previous max which is 60s
- */
- if ((timeout > 60) && (!conf->mdc_invalidation)) {
- conf->timeout = 60;
- goto out;
- }
- conf->timeout = timeout;
+ /* If timeout is greater than 60s (default before the patch that added
+ * cache invalidation support was added) then, cache invalidation
+ * feature for md-cache needs to be enabled, if not set timeout to the
+ * previous max which is 60s
+ */
+ if ((timeout > 60) && (!conf->mdc_invalidation)) {
+ conf->timeout = 60;
+ goto out;
+ }
+ conf->timeout = timeout;
out:
- this->private = conf;
+ this->private = conf;
- return 0;
+ return 0;
}
-
void
-mdc_update_child_down_time (xlator_t *this, time_t *now)
+mdc_update_child_down_time(xlator_t *this, time_t *now)
{
- struct mdc_conf *conf = NULL;
+ struct mdc_conf *conf = NULL;
- conf = this->private;
+ conf = this->private;
- LOCK (&conf->lock);
- {
- conf->last_child_down = *now;
- }
- UNLOCK (&conf->lock);
+ LOCK(&conf->lock);
+ {
+ conf->last_child_down = *now;
+ }
+ UNLOCK(&conf->lock);
}
-
int
-mdc_notify (xlator_t *this, int event, void *data, ...)
+mdc_notify(xlator_t *this, int event, void *data, ...)
{
- int ret = 0;
- struct mdc_conf *conf = NULL;
- time_t now = 0;
+ int ret = 0;
+ struct mdc_conf *conf = NULL;
+ time_t now = 0;
- conf = this->private;
- switch (event) {
+ conf = this->private;
+ switch (event) {
case GF_EVENT_CHILD_DOWN:
case GF_EVENT_SOME_DESCENDENT_DOWN:
- time (&now);
- mdc_update_child_down_time (this, &now);
- break;
+ time(&now);
+ mdc_update_child_down_time(this, &now);
+ break;
case GF_EVENT_UPCALL:
- if (conf->mdc_invalidation)
- ret = mdc_invalidate (this, data);
- break;
+ if (conf->mdc_invalidation)
+ ret = mdc_invalidate(this, data);
+ break;
case GF_EVENT_CHILD_UP:
case GF_EVENT_SOME_DESCENDENT_UP:
- ret = mdc_register_xattr_inval (this);
- break;
+ ret = mdc_register_xattr_inval(this);
+ break;
default:
- break;
- }
+ break;
+ }
- if (default_notify (this, event, data) != 0)
- ret = -1;
+ if (default_notify(this, event, data) != 0)
+ ret = -1;
- return ret;
+ return ret;
}
-
void
-mdc_fini (xlator_t *this)
+mdc_fini(xlator_t *this)
{
- GF_FREE (this->private);
+ GF_FREE(this->private);
}
-
struct xlator_fops mdc_fops = {
- .lookup = mdc_lookup,
- .stat = mdc_stat,
- .fstat = mdc_fstat,
- .truncate = mdc_truncate,
- .ftruncate = mdc_ftruncate,
- .mknod = mdc_mknod,
- .mkdir = mdc_mkdir,
- .unlink = mdc_unlink,
- .rmdir = mdc_rmdir,
- .symlink = mdc_symlink,
- .rename = mdc_rename,
- .link = mdc_link,
- .create = mdc_create,
- .open = mdc_open,
- .readv = mdc_readv,
- .writev = mdc_writev,
- .setattr = mdc_setattr,
- .fsetattr = mdc_fsetattr,
- .fsync = mdc_fsync,
- .setxattr = mdc_setxattr,
- .fsetxattr = mdc_fsetxattr,
- .getxattr = mdc_getxattr,
- .fgetxattr = mdc_fgetxattr,
- .removexattr = mdc_removexattr,
- .fremovexattr= mdc_fremovexattr,
- .opendir = mdc_opendir,
- .readdirp = mdc_readdirp,
- .readdir = mdc_readdir,
- .fallocate = mdc_fallocate,
- .discard = mdc_discard,
- .zerofill = mdc_zerofill,
- .statfs = mdc_statfs,
- .readlink = mdc_readlink,
- .fsyncdir = mdc_fsyncdir,
- .access = mdc_access,
+ .lookup = mdc_lookup,
+ .stat = mdc_stat,
+ .fstat = mdc_fstat,
+ .truncate = mdc_truncate,
+ .ftruncate = mdc_ftruncate,
+ .mknod = mdc_mknod,
+ .mkdir = mdc_mkdir,
+ .unlink = mdc_unlink,
+ .rmdir = mdc_rmdir,
+ .symlink = mdc_symlink,
+ .rename = mdc_rename,
+ .link = mdc_link,
+ .create = mdc_create,
+ .open = mdc_open,
+ .readv = mdc_readv,
+ .writev = mdc_writev,
+ .setattr = mdc_setattr,
+ .fsetattr = mdc_fsetattr,
+ .fsync = mdc_fsync,
+ .setxattr = mdc_setxattr,
+ .fsetxattr = mdc_fsetxattr,
+ .getxattr = mdc_getxattr,
+ .fgetxattr = mdc_fgetxattr,
+ .removexattr = mdc_removexattr,
+ .fremovexattr = mdc_fremovexattr,
+ .opendir = mdc_opendir,
+ .readdirp = mdc_readdirp,
+ .readdir = mdc_readdir,
+ .fallocate = mdc_fallocate,
+ .discard = mdc_discard,
+ .zerofill = mdc_zerofill,
+ .statfs = mdc_statfs,
+ .readlink = mdc_readlink,
+ .fsyncdir = mdc_fsyncdir,
+ .access = mdc_access,
};
-
struct xlator_cbks mdc_cbks = {
- .forget = mdc_forget,
+ .forget = mdc_forget,
};
-
struct xlator_dumpops mdc_dumpops = {
- .priv = mdc_priv_dump,
+ .priv = mdc_priv_dump,
};
-
struct volume_options mdc_options[] = {
- { .key = {"cache-selinux"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {2},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Cache selinux xattr(security.selinux) on client side",
- },
- { .key = {"cache-capability-xattrs"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "true",
- .op_version = {GD_OP_VERSION_3_10_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Cache capability xattr(security.capability) on "
- "client side",
- },
- { .key = {"cache-ima-xattrs"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "true",
- .op_version = {GD_OP_VERSION_3_10_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Cache Linux integrity subsystem xattr(security.ima) "
- "on client side",
- },
- { .key = {"cache-swift-metadata"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "true",
- .op_version = {GD_OP_VERSION_3_7_10},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Cache swift metadata (user.swift.metadata xattr)",
- },
- { .key = {"cache-samba-metadata"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_3_9_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Cache samba metadata (user.DOSATTRIB, security.NTACL,"
- " org.netatalk.Metadata, org.netatalk.ResourceFork, "
- "and user.DosStream. xattrs)",
- },
- { .key = {"cache-posix-acl"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {2},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Cache posix ACL xattrs (system.posix_acl_access, "
- "system.posix_acl_default) on client side",
- },
- { .key = {"md-cache-timeout"},
- .type = GF_OPTION_TYPE_INT,
- .min = 0,
- .max = 600,
- .default_value = SITE_H_MD_CACHE_TIMEOUT,
- .op_version = {2},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Time period after which cache has to be refreshed",
- },
- { .key = {"force-readdirp"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "true",
- .op_version = {2},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Convert all readdir requests to readdirplus to "
- "collect stat info on each entry.",
- },
- { .key = {"cache-invalidation"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_3_9_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "When \"on\", invalidates/updates the metadata cache,"
- " on receiving the cache-invalidation notifications",
- },
- { .key = {"md-cache-statfs"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "off",
- .op_version = {GD_OP_VERSION_4_0_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Cache statfs information of filesystem on the client",
- },
- { .key = {"xattr-cache-list"},
- .type = GF_OPTION_TYPE_STR,
- .default_value = "",
- .op_version = {GD_OP_VERSION_4_0_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "A comma separated list of xattrs that shall be "
- "cached by md-cache. The only wildcard allowed is '*'",
- },
- { .key = {"pass-through"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"md-cache"},
- .description = "Enable/Disable md cache translator"
- },
- { .key = {NULL} },
+ {
+ .key = {"cache-selinux"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {2},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Cache selinux xattr(security.selinux) on client side",
+ },
+ {
+ .key = {"cache-capability-xattrs"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "true",
+ .op_version = {GD_OP_VERSION_3_10_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Cache capability xattr(security.capability) on "
+ "client side",
+ },
+ {
+ .key = {"cache-ima-xattrs"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "true",
+ .op_version = {GD_OP_VERSION_3_10_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Cache Linux integrity subsystem xattr(security.ima) "
+ "on client side",
+ },
+ {
+ .key = {"cache-swift-metadata"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "true",
+ .op_version = {GD_OP_VERSION_3_7_10},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Cache swift metadata (user.swift.metadata xattr)",
+ },
+ {
+ .key = {"cache-samba-metadata"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_3_9_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Cache samba metadata (user.DOSATTRIB, security.NTACL,"
+ " org.netatalk.Metadata, org.netatalk.ResourceFork, "
+ "and user.DosStream. xattrs)",
+ },
+ {
+ .key = {"cache-posix-acl"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {2},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Cache posix ACL xattrs (system.posix_acl_access, "
+ "system.posix_acl_default) on client side",
+ },
+ {
+ .key = {"md-cache-timeout"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = 0,
+ .max = 600,
+ .default_value = SITE_H_MD_CACHE_TIMEOUT,
+ .op_version = {2},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Time period after which cache has to be refreshed",
+ },
+ {
+ .key = {"force-readdirp"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "true",
+ .op_version = {2},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Convert all readdir requests to readdirplus to "
+ "collect stat info on each entry.",
+ },
+ {
+ .key = {"cache-invalidation"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_3_9_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "When \"on\", invalidates/updates the metadata cache,"
+ " on receiving the cache-invalidation notifications",
+ },
+ {
+ .key = {"md-cache-statfs"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .op_version = {GD_OP_VERSION_4_0_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Cache statfs information of filesystem on the client",
+ },
+ {
+ .key = {"xattr-cache-list"},
+ .type = GF_OPTION_TYPE_STR,
+ .default_value = "",
+ .op_version = {GD_OP_VERSION_4_0_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "A comma separated list of xattrs that shall be "
+ "cached by md-cache. The only wildcard allowed is '*'",
+ },
+ {.key = {"pass-through"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"md-cache"},
+ .description = "Enable/Disable md cache translator"},
+ {.key = {NULL}},
};
-
xlator_api_t xlator_api = {
- .init = mdc_init,
- .fini = mdc_fini,
- .notify = mdc_notify,
- .reconfigure = mdc_reconfigure,
- .mem_acct_init = mdc_mem_acct_init,
- .dump_metrics = mdc_dump_metrics,
- .op_version = {1}, /* Present from the initial version */
- .dumpops = &mdc_dumpops,
- .fops = &mdc_fops,
- .cbks = &mdc_cbks,
- .options = mdc_options,
- .identifier = "md-cache",
- .category = GF_MAINTAINED,
+ .init = mdc_init,
+ .fini = mdc_fini,
+ .notify = mdc_notify,
+ .reconfigure = mdc_reconfigure,
+ .mem_acct_init = mdc_mem_acct_init,
+ .dump_metrics = mdc_dump_metrics,
+ .op_version = {1}, /* Present from the initial version */
+ .dumpops = &mdc_dumpops,
+ .fops = &mdc_fops,
+ .cbks = &mdc_cbks,
+ .options = mdc_options,
+ .identifier = "md-cache",
+ .category = GF_MAINTAINED,
};
diff --git a/xlators/performance/nl-cache/src/nl-cache-helper.c b/xlators/performance/nl-cache/src/nl-cache-helper.c
index b6b60a74918..063172019b1 100644
--- a/xlators/performance/nl-cache/src/nl-cache-helper.c
+++ b/xlators/performance/nl-cache/src/nl-cache-helper.c
@@ -62,1158 +62,1141 @@
* - Special handling for .meta and .trashcan?
*/
-int __nlc_inode_ctx_timer_start (xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx);
-int __nlc_add_to_lru (xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx);
-void nlc_remove_from_lru (xlator_t *this, inode_t *inode);
-void __nlc_inode_ctx_timer_delete (xlator_t *this, nlc_ctx_t *nlc_ctx);
-gf_boolean_t __nlc_search_ne (nlc_ctx_t *nlc_ctx, const char *name);
-void __nlc_free_pe (xlator_t *this, nlc_ctx_t *nlc_ctx, nlc_pe_t *pe);
-void __nlc_free_ne (xlator_t *this, nlc_ctx_t *nlc_ctx, nlc_ne_t *ne);
+int
+__nlc_inode_ctx_timer_start(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx);
+int
+__nlc_add_to_lru(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx);
+void
+nlc_remove_from_lru(xlator_t *this, inode_t *inode);
+void
+__nlc_inode_ctx_timer_delete(xlator_t *this, nlc_ctx_t *nlc_ctx);
+gf_boolean_t
+__nlc_search_ne(nlc_ctx_t *nlc_ctx, const char *name);
+void
+__nlc_free_pe(xlator_t *this, nlc_ctx_t *nlc_ctx, nlc_pe_t *pe);
+void
+__nlc_free_ne(xlator_t *this, nlc_ctx_t *nlc_ctx, nlc_ne_t *ne);
static int32_t
-nlc_get_cache_timeout (xlator_t *this)
+nlc_get_cache_timeout(xlator_t *this)
{
- nlc_conf_t *conf = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- /* Cache timeout is generally not meant to be changed often,
- * once set, hence not within locks */
- return conf->cache_timeout;
+ /* Cache timeout is generally not meant to be changed often,
+ * once set, hence not within locks */
+ return conf->cache_timeout;
}
-
static gf_boolean_t
-__nlc_is_cache_valid (xlator_t *this, nlc_ctx_t *nlc_ctx)
+__nlc_is_cache_valid(xlator_t *this, nlc_ctx_t *nlc_ctx)
{
- nlc_conf_t *conf = NULL;
- time_t last_val_time;
- gf_boolean_t ret = _gf_false;
+ nlc_conf_t *conf = NULL;
+ time_t last_val_time;
+ gf_boolean_t ret = _gf_false;
- GF_VALIDATE_OR_GOTO (this->name, nlc_ctx, out);
+ GF_VALIDATE_OR_GOTO(this->name, nlc_ctx, out);
- conf = this->private;
+ conf = this->private;
- LOCK (&conf->lock);
- {
- last_val_time = conf->last_child_down;
- }
- UNLOCK (&conf->lock);
+ LOCK(&conf->lock);
+ {
+ last_val_time = conf->last_child_down;
+ }
+ UNLOCK(&conf->lock);
- if ((last_val_time <= nlc_ctx->cache_time) &&
- (nlc_ctx->cache_time != 0))
- ret = _gf_true;
+ if ((last_val_time <= nlc_ctx->cache_time) && (nlc_ctx->cache_time != 0))
+ ret = _gf_true;
out:
- return ret;
+ return ret;
}
-
void
-nlc_update_child_down_time (xlator_t *this, time_t *now)
+nlc_update_child_down_time(xlator_t *this, time_t *now)
{
- nlc_conf_t *conf = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- LOCK (&conf->lock);
- {
- conf->last_child_down = *now;
- }
- UNLOCK (&conf->lock);
+ LOCK(&conf->lock);
+ {
+ conf->last_child_down = *now;
+ }
+ UNLOCK(&conf->lock);
- return;
+ return;
}
-
void
-nlc_disable_cache (xlator_t *this)
+nlc_disable_cache(xlator_t *this)
{
- nlc_conf_t *conf = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- LOCK (&conf->lock);
- {
- conf->disable_cache = _gf_true;
- }
- UNLOCK (&conf->lock);
+ LOCK(&conf->lock);
+ {
+ conf->disable_cache = _gf_true;
+ }
+ UNLOCK(&conf->lock);
- return;
+ return;
}
-
static int
-__nlc_inode_ctx_get (xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p,
- nlc_pe_t **nlc_pe_p)
+__nlc_inode_ctx_get(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p,
+ nlc_pe_t **nlc_pe_p)
{
- int ret = 0;
- nlc_ctx_t *nlc_ctx = NULL;
- nlc_pe_t *nlc_pe = NULL;
- uint64_t nlc_ctx_int = 0;
- uint64_t nlc_pe_int = 0;
-
- ret = __inode_ctx_get2 (inode, this, &nlc_ctx_int, &nlc_pe_int);
- if (ret == 0 && nlc_ctx_p) {
- nlc_ctx = (void *) (long) (nlc_ctx_int);
- *nlc_ctx_p = nlc_ctx;
- }
- if (ret == 0 && nlc_pe_p) {
- nlc_pe = (void *) (long) (nlc_pe_int);
- *nlc_pe_p = nlc_pe;
- }
- return ret;
+ int ret = 0;
+ nlc_ctx_t *nlc_ctx = NULL;
+ nlc_pe_t *nlc_pe = NULL;
+ uint64_t nlc_ctx_int = 0;
+ uint64_t nlc_pe_int = 0;
+
+ ret = __inode_ctx_get2(inode, this, &nlc_ctx_int, &nlc_pe_int);
+ if (ret == 0 && nlc_ctx_p) {
+ nlc_ctx = (void *)(long)(nlc_ctx_int);
+ *nlc_ctx_p = nlc_ctx;
+ }
+ if (ret == 0 && nlc_pe_p) {
+ nlc_pe = (void *)(long)(nlc_pe_int);
+ *nlc_pe_p = nlc_pe;
+ }
+ return ret;
}
-
static int
-nlc_inode_ctx_set (xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx,
- nlc_pe_t *nlc_pe_p)
+nlc_inode_ctx_set(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx,
+ nlc_pe_t *nlc_pe_p)
{
- int ret = -1;
-
- /* The caller may choose to set one of the ctxs, hence check
- * if the ctx1/2 is non zero and then send the address. If we
- * blindly send the address of both the ctxs, it may reset the
- * ctx the caller had sent NULL(intended as leave untouched) for.*/
- LOCK(&inode->lock);
- {
- ret = __inode_ctx_set2 (inode, this,
- nlc_ctx ? (uint64_t *) &nlc_ctx : 0,
- nlc_pe_p ? (uint64_t *) &nlc_pe_p : 0);
- }
- UNLOCK(&inode->lock);
- return ret;
+ int ret = -1;
+
+ /* The caller may choose to set one of the ctxs, hence check
+ * if the ctx1/2 is non zero and then send the address. If we
+ * blindly send the address of both the ctxs, it may reset the
+ * ctx the caller had sent NULL(intended as leave untouched) for.*/
+ LOCK(&inode->lock);
+ {
+ ret = __inode_ctx_set2(inode, this, nlc_ctx ? (uint64_t *)&nlc_ctx : 0,
+ nlc_pe_p ? (uint64_t *)&nlc_pe_p : 0);
+ }
+ UNLOCK(&inode->lock);
+ return ret;
}
-
static void
-nlc_inode_ctx_get (xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p,
- nlc_pe_t **nlc_pe_p)
+nlc_inode_ctx_get(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p,
+ nlc_pe_t **nlc_pe_p)
{
- int ret = 0;
-
- LOCK (&inode->lock);
- {
- ret = __nlc_inode_ctx_get (this, inode, nlc_ctx_p, nlc_pe_p);
- if (ret < 0)
- gf_msg_debug (this->name, 0, "inode ctx get failed for "
- "inode:%p", inode);
- }
- UNLOCK (&inode->lock);
-
- return;
+ int ret = 0;
+
+ LOCK(&inode->lock);
+ {
+ ret = __nlc_inode_ctx_get(this, inode, nlc_ctx_p, nlc_pe_p);
+ if (ret < 0)
+ gf_msg_debug(this->name, 0,
+ "inode ctx get failed for "
+ "inode:%p",
+ inode);
+ }
+ UNLOCK(&inode->lock);
+
+ return;
}
-
static void
-__nlc_inode_clear_entries (xlator_t *this, nlc_ctx_t *nlc_ctx)
+__nlc_inode_clear_entries(xlator_t *this, nlc_ctx_t *nlc_ctx)
{
- nlc_pe_t *pe = NULL;
- nlc_pe_t *tmp = NULL;
- nlc_ne_t *ne = NULL;
- nlc_ne_t *tmp1 = NULL;
+ nlc_pe_t *pe = NULL;
+ nlc_pe_t *tmp = NULL;
+ nlc_ne_t *ne = NULL;
+ nlc_ne_t *tmp1 = NULL;
- if (!nlc_ctx)
- goto out;
+ if (!nlc_ctx)
+ goto out;
- if (IS_PE_VALID (nlc_ctx->state))
- list_for_each_entry_safe (pe, tmp, &nlc_ctx->pe, list) {
- __nlc_free_pe (this, nlc_ctx, pe);
- }
+ if (IS_PE_VALID(nlc_ctx->state))
+ list_for_each_entry_safe(pe, tmp, &nlc_ctx->pe, list)
+ {
+ __nlc_free_pe(this, nlc_ctx, pe);
+ }
- if (IS_NE_VALID (nlc_ctx->state))
- list_for_each_entry_safe (ne, tmp1, &nlc_ctx->ne, list) {
- __nlc_free_ne (this, nlc_ctx, ne);
- }
+ if (IS_NE_VALID(nlc_ctx->state))
+ list_for_each_entry_safe(ne, tmp1, &nlc_ctx->ne, list)
+ {
+ __nlc_free_ne(this, nlc_ctx, ne);
+ }
- nlc_ctx->cache_time = 0;
- nlc_ctx->state = 0;
- GF_ASSERT (nlc_ctx->cache_size == sizeof (*nlc_ctx));
- GF_ASSERT (nlc_ctx->refd_inodes == 0);
+ nlc_ctx->cache_time = 0;
+ nlc_ctx->state = 0;
+ GF_ASSERT(nlc_ctx->cache_size == sizeof(*nlc_ctx));
+ GF_ASSERT(nlc_ctx->refd_inodes == 0);
out:
- return;
+ return;
}
-
static void
-nlc_init_invalid_ctx (xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx)
+nlc_init_invalid_ctx(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx)
{
- nlc_conf_t *conf = NULL;
- int ret = -1;
+ nlc_conf_t *conf = NULL;
+ int ret = -1;
+
+ conf = this->private;
+
+ LOCK(&nlc_ctx->lock);
+ {
+ if (__nlc_is_cache_valid(this, nlc_ctx))
+ goto unlock;
+
+ /* The cache/nlc_ctx can be invalid for 2 reasons:
+ * - Because of a child-down/timer expiry, cache is
+ * invalid but the nlc_ctx is not yet cleaned up.
+ * - nlc_ctx is cleaned up, because of invalidations
+ * or lru prune etc.*/
+
+ /* If the cache is present but invalid, clear the cache and
+ * reset the timer. */
+ __nlc_inode_clear_entries(this, nlc_ctx);
+
+ /* If timer is present, then it is already part of lru as well
+ * Hence reset the timer and return.*/
+ if (nlc_ctx->timer) {
+ gf_tw_mod_timer_pending(conf->timer_wheel, nlc_ctx->timer,
+ conf->cache_timeout);
+ time(&nlc_ctx->cache_time);
+ goto unlock;
+ }
- conf = this->private;
+ /* If timer was NULL, the nlc_ctx is already cleanedup,
+ * and we need to start timer and add to lru, so that it is
+ * ready to cache entries a fresh */
+ ret = __nlc_inode_ctx_timer_start(this, inode, nlc_ctx);
+ if (ret < 0)
+ goto unlock;
- LOCK (&nlc_ctx->lock);
- {
- if (__nlc_is_cache_valid (this, nlc_ctx))
- goto unlock;
-
- /* The cache/nlc_ctx can be invalid for 2 reasons:
- * - Because of a child-down/timer expiry, cache is
- * invalid but the nlc_ctx is not yet cleaned up.
- * - nlc_ctx is cleaned up, because of invalidations
- * or lru prune etc.*/
-
- /* If the cache is present but invalid, clear the cache and
- * reset the timer. */
- __nlc_inode_clear_entries (this, nlc_ctx);
-
- /* If timer is present, then it is already part of lru as well
- * Hence reset the timer and return.*/
- if (nlc_ctx->timer) {
- gf_tw_mod_timer_pending (conf->timer_wheel,
- nlc_ctx->timer,
- conf->cache_timeout);
- time (&nlc_ctx->cache_time);
- goto unlock;
- }
-
- /* If timer was NULL, the nlc_ctx is already cleanedup,
- * and we need to start timer and add to lru, so that it is
- * ready to cache entries a fresh */
- ret = __nlc_inode_ctx_timer_start (this, inode, nlc_ctx);
- if (ret < 0)
- goto unlock;
-
- ret = __nlc_add_to_lru (this, inode, nlc_ctx);
- if (ret < 0) {
- __nlc_inode_ctx_timer_delete (this, nlc_ctx);
- goto unlock;
- }
+ ret = __nlc_add_to_lru(this, inode, nlc_ctx);
+ if (ret < 0) {
+ __nlc_inode_ctx_timer_delete(this, nlc_ctx);
+ goto unlock;
}
+ }
unlock:
- UNLOCK (&nlc_ctx->lock);
+ UNLOCK(&nlc_ctx->lock);
- return;
+ return;
}
static nlc_ctx_t *
-nlc_inode_ctx_get_set (xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p,
- nlc_pe_t **nlc_pe_p)
+nlc_inode_ctx_get_set(xlator_t *this, inode_t *inode, nlc_ctx_t **nlc_ctx_p,
+ nlc_pe_t **nlc_pe_p)
{
- int ret = 0;
- nlc_ctx_t *nlc_ctx = NULL;
- nlc_conf_t *conf = NULL;
+ int ret = 0;
+ nlc_ctx_t *nlc_ctx = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- LOCK (&inode->lock);
- {
- ret = __nlc_inode_ctx_get (this, inode, &nlc_ctx, nlc_pe_p);
- if (nlc_ctx)
- goto unlock;
-
- nlc_ctx = GF_CALLOC (sizeof (*nlc_ctx), 1, gf_nlc_mt_nlc_ctx_t);
- if (!nlc_ctx)
- goto unlock;
-
- LOCK_INIT (&nlc_ctx->lock);
- INIT_LIST_HEAD (&nlc_ctx->pe);
- INIT_LIST_HEAD (&nlc_ctx->ne);
-
- ret = __nlc_inode_ctx_timer_start (this, inode, nlc_ctx);
- if (ret < 0)
- goto unlock;
-
- ret = __nlc_add_to_lru (this, inode, nlc_ctx);
- if (ret < 0) {
- __nlc_inode_ctx_timer_delete (this, nlc_ctx);
- goto unlock;
- }
-
- ret = __inode_ctx_set2 (inode, this, (uint64_t *) &nlc_ctx, NULL);
- if (ret) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- NLC_MSG_NO_MEMORY, "inode ctx set failed");
- __nlc_inode_ctx_timer_delete (this, nlc_ctx);
- nlc_remove_from_lru (this, inode);
- goto unlock;
- }
-
- /*TODO: also sizeof (gf_tw_timer_list) + nlc_timer_data_t ?*/
- nlc_ctx->cache_size = sizeof (*nlc_ctx);
- GF_ATOMIC_ADD (conf->current_cache_size, nlc_ctx->cache_size);
- }
-unlock:
- UNLOCK (&inode->lock);
+ LOCK(&inode->lock);
+ {
+ ret = __nlc_inode_ctx_get(this, inode, &nlc_ctx, nlc_pe_p);
+ if (nlc_ctx)
+ goto unlock;
+
+ nlc_ctx = GF_CALLOC(sizeof(*nlc_ctx), 1, gf_nlc_mt_nlc_ctx_t);
+ if (!nlc_ctx)
+ goto unlock;
+
+ LOCK_INIT(&nlc_ctx->lock);
+ INIT_LIST_HEAD(&nlc_ctx->pe);
+ INIT_LIST_HEAD(&nlc_ctx->ne);
- if (ret == 0 && nlc_ctx_p) {
- *nlc_ctx_p = nlc_ctx;
- nlc_init_invalid_ctx (this, inode, nlc_ctx);
+ ret = __nlc_inode_ctx_timer_start(this, inode, nlc_ctx);
+ if (ret < 0)
+ goto unlock;
+
+ ret = __nlc_add_to_lru(this, inode, nlc_ctx);
+ if (ret < 0) {
+ __nlc_inode_ctx_timer_delete(this, nlc_ctx);
+ goto unlock;
}
- if (ret < 0 && nlc_ctx) {
- LOCK_DESTROY (&nlc_ctx->lock);
- GF_FREE (nlc_ctx);
- nlc_ctx = NULL;
- goto out;
+ ret = __inode_ctx_set2(inode, this, (uint64_t *)&nlc_ctx, NULL);
+ if (ret) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, NLC_MSG_NO_MEMORY,
+ "inode ctx set failed");
+ __nlc_inode_ctx_timer_delete(this, nlc_ctx);
+ nlc_remove_from_lru(this, inode);
+ goto unlock;
}
+ /*TODO: also sizeof (gf_tw_timer_list) + nlc_timer_data_t ?*/
+ nlc_ctx->cache_size = sizeof(*nlc_ctx);
+ GF_ATOMIC_ADD(conf->current_cache_size, nlc_ctx->cache_size);
+ }
+unlock:
+ UNLOCK(&inode->lock);
+
+ if (ret == 0 && nlc_ctx_p) {
+ *nlc_ctx_p = nlc_ctx;
+ nlc_init_invalid_ctx(this, inode, nlc_ctx);
+ }
+
+ if (ret < 0 && nlc_ctx) {
+ LOCK_DESTROY(&nlc_ctx->lock);
+ GF_FREE(nlc_ctx);
+ nlc_ctx = NULL;
+ goto out;
+ }
+
out:
- return nlc_ctx;
+ return nlc_ctx;
}
-
nlc_local_t *
-nlc_local_init (call_frame_t *frame, xlator_t *this, glusterfs_fop_t fop,
- loc_t *loc, loc_t *loc2)
+nlc_local_init(call_frame_t *frame, xlator_t *this, glusterfs_fop_t fop,
+ loc_t *loc, loc_t *loc2)
{
- nlc_local_t *local = NULL;
+ nlc_local_t *local = NULL;
- local = GF_CALLOC (sizeof (*local), 1, gf_nlc_mt_nlc_local_t);
- if (!local)
- goto out;
+ local = GF_CALLOC(sizeof(*local), 1, gf_nlc_mt_nlc_local_t);
+ if (!local)
+ goto out;
- if (loc)
- loc_copy (&local->loc, loc);
- if (loc2)
- loc_copy (&local->loc2, loc2);
+ if (loc)
+ loc_copy(&local->loc, loc);
+ if (loc2)
+ loc_copy(&local->loc2, loc2);
- local->fop = fop;
- frame->local = local;
+ local->fop = fop;
+ frame->local = local;
out:
- return local;
+ return local;
}
-
void
-nlc_local_wipe (xlator_t *this, nlc_local_t *local)
+nlc_local_wipe(xlator_t *this, nlc_local_t *local)
{
- if (!local)
- goto out;
+ if (!local)
+ goto out;
- loc_wipe (&local->loc);
+ loc_wipe(&local->loc);
- loc_wipe (&local->loc2);
+ loc_wipe(&local->loc2);
- GF_FREE (local);
+ GF_FREE(local);
out:
- return;
+ return;
}
-
static void
-__nlc_set_dir_state (nlc_ctx_t *nlc_ctx, uint64_t new_state)
+__nlc_set_dir_state(nlc_ctx_t *nlc_ctx, uint64_t new_state)
{
- nlc_ctx->state |= new_state;
+ nlc_ctx->state |= new_state;
- return;
+ return;
}
-
void
-nlc_set_dir_state (xlator_t *this, inode_t *inode, uint64_t state)
+nlc_set_dir_state(xlator_t *this, inode_t *inode, uint64_t state)
{
- nlc_ctx_t *nlc_ctx = NULL;
-
- if (inode->ia_type != IA_IFDIR) {
- gf_msg_callingfn (this->name, GF_LOG_ERROR, EINVAL,
- NLC_MSG_EINVAL, "inode is not of type dir");
- goto out;
- }
-
- nlc_inode_ctx_get_set (this, inode, &nlc_ctx, NULL);
- if (!nlc_ctx)
- goto out;
-
- LOCK (&nlc_ctx->lock);
- {
- __nlc_set_dir_state (nlc_ctx, state);
- }
- UNLOCK (&nlc_ctx->lock);
+ nlc_ctx_t *nlc_ctx = NULL;
+
+ if (inode->ia_type != IA_IFDIR) {
+ gf_msg_callingfn(this->name, GF_LOG_ERROR, EINVAL, NLC_MSG_EINVAL,
+ "inode is not of type dir");
+ goto out;
+ }
+
+ nlc_inode_ctx_get_set(this, inode, &nlc_ctx, NULL);
+ if (!nlc_ctx)
+ goto out;
+
+ LOCK(&nlc_ctx->lock);
+ {
+ __nlc_set_dir_state(nlc_ctx, state);
+ }
+ UNLOCK(&nlc_ctx->lock);
out:
- return;
+ return;
}
-
static void
-nlc_cache_timeout_handler (struct gf_tw_timer_list *timer,
- void *data, unsigned long calltime)
+nlc_cache_timeout_handler(struct gf_tw_timer_list *timer, void *data,
+ unsigned long calltime)
{
- nlc_timer_data_t *tmp = data;
- nlc_ctx_t *nlc_ctx = NULL;
-
- nlc_inode_ctx_get (tmp->this, tmp->inode, &nlc_ctx, NULL);
- if (!nlc_ctx)
- goto out;
-
- /* Taking nlc_ctx->lock will lead to deadlock, hence updating
- * the cache is invalid outside of lock, instead of clear_cache.
- * Since cache_time is assigned outside of lock, the value can
- * be invalid for short time, this may result in false negative
- * which is better than deadlock */
- nlc_ctx->cache_time = 0;
+ nlc_timer_data_t *tmp = data;
+ nlc_ctx_t *nlc_ctx = NULL;
+
+ nlc_inode_ctx_get(tmp->this, tmp->inode, &nlc_ctx, NULL);
+ if (!nlc_ctx)
+ goto out;
+
+ /* Taking nlc_ctx->lock will lead to deadlock, hence updating
+ * the cache is invalid outside of lock, instead of clear_cache.
+ * Since cache_time is assigned outside of lock, the value can
+ * be invalid for short time, this may result in false negative
+ * which is better than deadlock */
+ nlc_ctx->cache_time = 0;
out:
- return;
+ return;
}
-
void
-__nlc_inode_ctx_timer_delete (xlator_t *this, nlc_ctx_t *nlc_ctx)
+__nlc_inode_ctx_timer_delete(xlator_t *this, nlc_ctx_t *nlc_ctx)
{
- nlc_conf_t *conf = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- if (nlc_ctx->timer)
- gf_tw_del_timer (conf->timer_wheel, nlc_ctx->timer);
+ if (nlc_ctx->timer)
+ gf_tw_del_timer(conf->timer_wheel, nlc_ctx->timer);
- if (nlc_ctx->timer_data) {
- inode_unref (nlc_ctx->timer_data->inode);
- GF_FREE (nlc_ctx->timer_data);
- nlc_ctx->timer_data = NULL;
- }
+ if (nlc_ctx->timer_data) {
+ inode_unref(nlc_ctx->timer_data->inode);
+ GF_FREE(nlc_ctx->timer_data);
+ nlc_ctx->timer_data = NULL;
+ }
- GF_FREE (nlc_ctx->timer);
- nlc_ctx->timer = NULL;
+ GF_FREE(nlc_ctx->timer);
+ nlc_ctx->timer = NULL;
- return;
+ return;
}
-
int
-__nlc_inode_ctx_timer_start (xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx)
+__nlc_inode_ctx_timer_start(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx)
{
- struct gf_tw_timer_list *timer = NULL;
- nlc_timer_data_t *tmp = NULL;
- nlc_conf_t *conf = NULL;
- int ret = -1;
-
- conf = this->private;
-
- /* We are taking inode_table->lock within inode->lock
- * as the only other caller which takes inode->lock within
- * inode_table->lock and cause deadlock is inode_table_destroy.
- * Hopefully, there can be no fop when inode_table_destroy is
- * being called. */
- tmp = GF_CALLOC (1, sizeof (*tmp), gf_nlc_mt_nlc_timer_data_t);
- if (!tmp)
- goto out;
- tmp->inode = inode_ref (inode);
- tmp->this = this;
-
- timer = GF_CALLOC (1, sizeof (*timer),
- gf_common_mt_tw_timer_list);
- if (!timer)
- goto out;
-
- INIT_LIST_HEAD (&timer->entry);
- timer->expires = nlc_get_cache_timeout (this);
- timer->function = nlc_cache_timeout_handler;
- timer->data = tmp;
- nlc_ctx->timer = timer;
- nlc_ctx->timer_data = tmp;
- gf_tw_add_timer (conf->timer_wheel, timer);
-
- time (&nlc_ctx->cache_time);
- gf_msg_trace (this->name, 0, "Registering timer:%p, inode:%p, "
- "gfid:%s", timer, inode, uuid_utoa (inode->gfid));
-
- ret = 0;
+ struct gf_tw_timer_list *timer = NULL;
+ nlc_timer_data_t *tmp = NULL;
+ nlc_conf_t *conf = NULL;
+ int ret = -1;
+
+ conf = this->private;
+
+ /* We are taking inode_table->lock within inode->lock
+ * as the only other caller which takes inode->lock within
+ * inode_table->lock and cause deadlock is inode_table_destroy.
+ * Hopefully, there can be no fop when inode_table_destroy is
+ * being called. */
+ tmp = GF_CALLOC(1, sizeof(*tmp), gf_nlc_mt_nlc_timer_data_t);
+ if (!tmp)
+ goto out;
+ tmp->inode = inode_ref(inode);
+ tmp->this = this;
+
+ timer = GF_CALLOC(1, sizeof(*timer), gf_common_mt_tw_timer_list);
+ if (!timer)
+ goto out;
+
+ INIT_LIST_HEAD(&timer->entry);
+ timer->expires = nlc_get_cache_timeout(this);
+ timer->function = nlc_cache_timeout_handler;
+ timer->data = tmp;
+ nlc_ctx->timer = timer;
+ nlc_ctx->timer_data = tmp;
+ gf_tw_add_timer(conf->timer_wheel, timer);
+
+ time(&nlc_ctx->cache_time);
+ gf_msg_trace(this->name, 0,
+ "Registering timer:%p, inode:%p, "
+ "gfid:%s",
+ timer, inode, uuid_utoa(inode->gfid));
+
+ ret = 0;
out:
- if (ret < 0) {
- if (tmp && tmp->inode)
- inode_unref (tmp->inode);
- GF_FREE (tmp);
- GF_FREE (timer);
- }
-
- return ret;
+ if (ret < 0) {
+ if (tmp && tmp->inode)
+ inode_unref(tmp->inode);
+ GF_FREE(tmp);
+ GF_FREE(timer);
+ }
+
+ return ret;
}
-
int
-__nlc_add_to_lru (xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx)
+__nlc_add_to_lru(xlator_t *this, inode_t *inode, nlc_ctx_t *nlc_ctx)
{
- nlc_lru_node_t *lru_ino = NULL;
- uint64_t nlc_pe_int = 0;
- nlc_conf_t *conf = NULL;
- int ret = -1;
+ nlc_lru_node_t *lru_ino = NULL;
+ uint64_t nlc_pe_int = 0;
+ nlc_conf_t *conf = NULL;
+ int ret = -1;
- conf = this->private;
+ conf = this->private;
- lru_ino = GF_CALLOC (1, sizeof (*lru_ino), gf_nlc_mt_nlc_lru_node);
- if (!lru_ino)
- goto out;
+ lru_ino = GF_CALLOC(1, sizeof(*lru_ino), gf_nlc_mt_nlc_lru_node);
+ if (!lru_ino)
+ goto out;
- INIT_LIST_HEAD (&lru_ino->list);
- lru_ino->inode = inode_ref (inode);
- LOCK (&conf->lock);
- {
- list_add_tail (&lru_ino->list, &conf->lru);
- }
- UNLOCK (&conf->lock);
+ INIT_LIST_HEAD(&lru_ino->list);
+ lru_ino->inode = inode_ref(inode);
+ LOCK(&conf->lock);
+ {
+ list_add_tail(&lru_ino->list, &conf->lru);
+ }
+ UNLOCK(&conf->lock);
- nlc_ctx->refd_inodes = 0;
- ret = __inode_ctx_get2 (inode, this, NULL, &nlc_pe_int);
- if (nlc_pe_int == 0)
- GF_ATOMIC_ADD (conf->refd_inodes, 1);
+ nlc_ctx->refd_inodes = 0;
+ ret = __inode_ctx_get2(inode, this, NULL, &nlc_pe_int);
+ if (nlc_pe_int == 0)
+ GF_ATOMIC_ADD(conf->refd_inodes, 1);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
void
-nlc_remove_from_lru (xlator_t *this, inode_t *inode)
+nlc_remove_from_lru(xlator_t *this, inode_t *inode)
{
- nlc_lru_node_t *lru_node = NULL;
- nlc_lru_node_t *tmp = NULL;
- nlc_lru_node_t *tmp1 = NULL;
- nlc_conf_t *conf = NULL;
+ nlc_lru_node_t *lru_node = NULL;
+ nlc_lru_node_t *tmp = NULL;
+ nlc_lru_node_t *tmp1 = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- LOCK (&conf->lock);
+ LOCK(&conf->lock);
+ {
+ list_for_each_entry_safe(lru_node, tmp, &conf->lru, list)
{
- list_for_each_entry_safe (lru_node, tmp, &conf->lru, list) {
- if (inode == lru_node->inode) {
- list_del (&lru_node->list);
- tmp1 = lru_node;
- break;
- }
- }
+ if (inode == lru_node->inode) {
+ list_del(&lru_node->list);
+ tmp1 = lru_node;
+ break;
+ }
}
- UNLOCK (&conf->lock);
+ }
+ UNLOCK(&conf->lock);
- if (tmp1) {
- inode_unref (tmp1->inode);
- GF_FREE (tmp1);
- }
+ if (tmp1) {
+ inode_unref(tmp1->inode);
+ GF_FREE(tmp1);
+ }
- return;
+ return;
}
-
void
-nlc_lru_prune (xlator_t *this, inode_t *inode)
+nlc_lru_prune(xlator_t *this, inode_t *inode)
{
- nlc_lru_node_t *lru_node = NULL;
- nlc_lru_node_t *prune_node = NULL;
- nlc_lru_node_t *tmp = NULL;
- nlc_conf_t *conf = NULL;
+ nlc_lru_node_t *lru_node = NULL;
+ nlc_lru_node_t *prune_node = NULL;
+ nlc_lru_node_t *tmp = NULL;
+ nlc_conf_t *conf = NULL;
+
+ conf = this->private;
- conf = this->private;
+ LOCK(&conf->lock);
+ {
+ if ((GF_ATOMIC_GET(conf->refd_inodes) < conf->inode_limit) &&
+ (GF_ATOMIC_GET(conf->current_cache_size) < conf->cache_size))
+ goto unlock;
- LOCK (&conf->lock);
+ list_for_each_entry_safe(lru_node, tmp, &conf->lru, list)
{
- if ((GF_ATOMIC_GET(conf->refd_inodes) < conf->inode_limit) &&
- (GF_ATOMIC_GET(conf->current_cache_size) < conf->cache_size))
- goto unlock;
-
- list_for_each_entry_safe (lru_node, tmp, &conf->lru, list) {
- list_del (&lru_node->list);
- prune_node = lru_node;
- goto unlock;
- }
+ list_del(&lru_node->list);
+ prune_node = lru_node;
+ goto unlock;
}
+ }
unlock:
- UNLOCK (&conf->lock);
-
- if (prune_node) {
- nlc_inode_clear_cache (this, prune_node->inode, NLC_LRU_PRUNE);
- inode_unref (prune_node->inode);
- GF_FREE (prune_node);
- }
- return;
+ UNLOCK(&conf->lock);
+
+ if (prune_node) {
+ nlc_inode_clear_cache(this, prune_node->inode, NLC_LRU_PRUNE);
+ inode_unref(prune_node->inode);
+ GF_FREE(prune_node);
+ }
+ return;
}
-
void
-nlc_clear_all_cache (xlator_t *this)
+nlc_clear_all_cache(xlator_t *this)
{
- nlc_conf_t *conf = NULL;
- struct list_head clear_list;
- nlc_lru_node_t *prune_node = NULL;
- nlc_lru_node_t *tmp = NULL;
-
- conf = this->private;
-
- INIT_LIST_HEAD (&clear_list);
-
- LOCK (&conf->lock);
- {
- list_replace_init (&conf->lru, &clear_list);
- }
- UNLOCK (&conf->lock);
-
- list_for_each_entry_safe (prune_node, tmp, &clear_list, list) {
- list_del (&prune_node->list);
- nlc_inode_clear_cache (this, prune_node->inode, NLC_LRU_PRUNE);
- inode_unref (prune_node->inode);
- GF_FREE (prune_node);
- }
-
- return;
+ nlc_conf_t *conf = NULL;
+ struct list_head clear_list;
+ nlc_lru_node_t *prune_node = NULL;
+ nlc_lru_node_t *tmp = NULL;
+
+ conf = this->private;
+
+ INIT_LIST_HEAD(&clear_list);
+
+ LOCK(&conf->lock);
+ {
+ list_replace_init(&conf->lru, &clear_list);
+ }
+ UNLOCK(&conf->lock);
+
+ list_for_each_entry_safe(prune_node, tmp, &clear_list, list)
+ {
+ list_del(&prune_node->list);
+ nlc_inode_clear_cache(this, prune_node->inode, NLC_LRU_PRUNE);
+ inode_unref(prune_node->inode);
+ GF_FREE(prune_node);
+ }
+
+ return;
}
-
void
-__nlc_free_pe (xlator_t *this, nlc_ctx_t *nlc_ctx, nlc_pe_t *pe)
+__nlc_free_pe(xlator_t *this, nlc_ctx_t *nlc_ctx, nlc_pe_t *pe)
{
- uint64_t pe_int = 0;
- nlc_conf_t *conf = NULL;
- uint64_t nlc_ctx_int = 0;
+ uint64_t pe_int = 0;
+ nlc_conf_t *conf = NULL;
+ uint64_t nlc_ctx_int = 0;
- conf = this->private;
+ conf = this->private;
- if (pe->inode) {
- inode_ctx_reset1 (pe->inode, this, &pe_int);
- inode_ctx_get2 (pe->inode, this, &nlc_ctx_int, NULL);
- inode_unref (pe->inode);
- }
- list_del (&pe->list);
+ if (pe->inode) {
+ inode_ctx_reset1(pe->inode, this, &pe_int);
+ inode_ctx_get2(pe->inode, this, &nlc_ctx_int, NULL);
+ inode_unref(pe->inode);
+ }
+ list_del(&pe->list);
- nlc_ctx->cache_size -= sizeof (*pe) + sizeof (pe->name);
- GF_ATOMIC_SUB (conf->current_cache_size,
- (sizeof (*pe) + sizeof (pe->name)));
+ nlc_ctx->cache_size -= sizeof(*pe) + sizeof(pe->name);
+ GF_ATOMIC_SUB(conf->current_cache_size, (sizeof(*pe) + sizeof(pe->name)));
- nlc_ctx->refd_inodes -= 1;
- if (nlc_ctx_int == 0)
- GF_ATOMIC_SUB (conf->refd_inodes, 1);
+ nlc_ctx->refd_inodes -= 1;
+ if (nlc_ctx_int == 0)
+ GF_ATOMIC_SUB(conf->refd_inodes, 1);
- GF_FREE (pe->name);
- GF_FREE (pe);
+ GF_FREE(pe->name);
+ GF_FREE(pe);
- return;
+ return;
}
-
void
-__nlc_free_ne (xlator_t *this, nlc_ctx_t *nlc_ctx, nlc_ne_t *ne)
+__nlc_free_ne(xlator_t *this, nlc_ctx_t *nlc_ctx, nlc_ne_t *ne)
{
- nlc_conf_t *conf = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- list_del (&ne->list);
- GF_FREE (ne->name);
- GF_FREE (ne);
+ list_del(&ne->list);
+ GF_FREE(ne->name);
+ GF_FREE(ne);
- nlc_ctx->cache_size -= sizeof (*ne) + sizeof (ne->name);
- GF_ATOMIC_SUB (conf->current_cache_size,
- (sizeof (*ne) + sizeof (ne->name)));
+ nlc_ctx->cache_size -= sizeof(*ne) + sizeof(ne->name);
+ GF_ATOMIC_SUB(conf->current_cache_size, (sizeof(*ne) + sizeof(ne->name)));
- return;
+ return;
}
-
void
-nlc_inode_clear_cache (xlator_t *this, inode_t *inode, int reason)
+nlc_inode_clear_cache(xlator_t *this, inode_t *inode, int reason)
{
- nlc_ctx_t *nlc_ctx = NULL;
+ nlc_ctx_t *nlc_ctx = NULL;
- nlc_inode_ctx_get (this, inode, &nlc_ctx, NULL);
- if (!nlc_ctx)
- goto out;
+ nlc_inode_ctx_get(this, inode, &nlc_ctx, NULL);
+ if (!nlc_ctx)
+ goto out;
- LOCK (&nlc_ctx->lock);
- {
- __nlc_inode_ctx_timer_delete (this, nlc_ctx);
+ LOCK(&nlc_ctx->lock);
+ {
+ __nlc_inode_ctx_timer_delete(this, nlc_ctx);
- __nlc_inode_clear_entries (this, nlc_ctx);
- }
- UNLOCK (&nlc_ctx->lock);
+ __nlc_inode_clear_entries(this, nlc_ctx);
+ }
+ UNLOCK(&nlc_ctx->lock);
- if (reason != NLC_LRU_PRUNE)
- nlc_remove_from_lru (this, inode);
+ if (reason != NLC_LRU_PRUNE)
+ nlc_remove_from_lru(this, inode);
out:
- return;
+ return;
}
-
static void
-__nlc_del_pe (xlator_t *this, nlc_ctx_t *nlc_ctx, inode_t *entry_ino,
- const char *name, gf_boolean_t multilink)
+__nlc_del_pe(xlator_t *this, nlc_ctx_t *nlc_ctx, inode_t *entry_ino,
+ const char *name, gf_boolean_t multilink)
{
- nlc_pe_t *pe = NULL;
- nlc_pe_t *tmp = NULL;
- gf_boolean_t found = _gf_false;
- uint64_t pe_int = 0;
+ nlc_pe_t *pe = NULL;
+ nlc_pe_t *tmp = NULL;
+ gf_boolean_t found = _gf_false;
+ uint64_t pe_int = 0;
- if (!IS_PE_VALID (nlc_ctx->state))
- goto out;
+ if (!IS_PE_VALID(nlc_ctx->state))
+ goto out;
- if (!entry_ino)
- goto name_search;
-
- /* If there are hardlinks first search names, followed by inodes */
- if (multilink) {
- list_for_each_entry_safe (pe, tmp, &nlc_ctx->pe, list) {
- if (pe->name && (strcmp (pe->name, name) == 0)) {
- found = _gf_true;
- goto out;
- }
- }
- inode_ctx_reset1 (entry_ino, this, &pe_int);
- if (pe_int) {
- pe = (void *) (long) (pe_int);
- found = _gf_true;
- goto out;
- }
- goto out;
- }
+ if (!entry_ino)
+ goto name_search;
- inode_ctx_reset1 (entry_ino, this, &pe_int);
- if (pe_int) {
- pe = (void *) (long) (pe_int);
+ /* If there are hardlinks first search names, followed by inodes */
+ if (multilink) {
+ list_for_each_entry_safe(pe, tmp, &nlc_ctx->pe, list)
+ {
+ if (pe->name && (strcmp(pe->name, name) == 0)) {
found = _gf_true;
goto out;
+ }
+ }
+ inode_ctx_reset1(entry_ino, this, &pe_int);
+ if (pe_int) {
+ pe = (void *)(long)(pe_int);
+ found = _gf_true;
+ goto out;
}
+ goto out;
+ }
+
+ inode_ctx_reset1(entry_ino, this, &pe_int);
+ if (pe_int) {
+ pe = (void *)(long)(pe_int);
+ found = _gf_true;
+ goto out;
+ }
name_search:
- list_for_each_entry_safe (pe, tmp, &nlc_ctx->pe, list) {
- if (pe->name && (strcmp (pe->name, name) == 0)) {
- found = _gf_true;
- break;
- /* TODO: can there be duplicates? */
- }
+ list_for_each_entry_safe(pe, tmp, &nlc_ctx->pe, list)
+ {
+ if (pe->name && (strcmp(pe->name, name) == 0)) {
+ found = _gf_true;
+ break;
+ /* TODO: can there be duplicates? */
}
+ }
out:
- if (found)
- __nlc_free_pe (this, nlc_ctx, pe);
+ if (found)
+ __nlc_free_pe(this, nlc_ctx, pe);
- return;
+ return;
}
-
static void
-__nlc_del_ne (xlator_t *this, nlc_ctx_t *nlc_ctx, const char *name)
+__nlc_del_ne(xlator_t *this, nlc_ctx_t *nlc_ctx, const char *name)
{
- nlc_ne_t *ne = NULL;
- nlc_ne_t *tmp = NULL;
+ nlc_ne_t *ne = NULL;
+ nlc_ne_t *tmp = NULL;
- if (!IS_NE_VALID (nlc_ctx->state))
- goto out;
+ if (!IS_NE_VALID(nlc_ctx->state))
+ goto out;
- list_for_each_entry_safe (ne, tmp, &nlc_ctx->ne, list) {
- if (strcmp (ne->name, name) == 0) {
- __nlc_free_ne (this, nlc_ctx, ne);
- break;
- }
+ list_for_each_entry_safe(ne, tmp, &nlc_ctx->ne, list)
+ {
+ if (strcmp(ne->name, name) == 0) {
+ __nlc_free_ne(this, nlc_ctx, ne);
+ break;
}
+ }
out:
- return;
+ return;
}
-
static void
-__nlc_add_pe (xlator_t *this, nlc_ctx_t *nlc_ctx, inode_t *entry_ino,
- const char *name)
+__nlc_add_pe(xlator_t *this, nlc_ctx_t *nlc_ctx, inode_t *entry_ino,
+ const char *name)
{
- nlc_pe_t *pe = NULL;
- int ret = -1;
- nlc_conf_t *conf = NULL;
- uint64_t nlc_ctx_int = 0;
-
- conf = this->private;
-
- /* TODO: There can be no duplicate entries, as it is added only
- during create. In case there arises duplicate entries, search PE
- found = __nlc_search (entries, name, _gf_false);
- can use bit vector to have simple search than sequential search */
-
- pe = GF_CALLOC (sizeof (*pe), 1, gf_nlc_mt_nlc_pe_t);
- if (!pe)
- goto out;
-
- if (entry_ino) {
- pe->inode = inode_ref (entry_ino);
- nlc_inode_ctx_set (this, entry_ino, NULL, pe);
- } else if (name) {
- pe->name = gf_strdup (name);
- if (!pe->name)
- goto out;
- }
-
- list_add (&pe->list, &nlc_ctx->pe);
-
- nlc_ctx->cache_size += sizeof (*pe) + sizeof (pe->name);
- GF_ATOMIC_ADD (conf->current_cache_size,
- (sizeof (*pe) + sizeof (pe->name)));
-
- nlc_ctx->refd_inodes += 1;
- inode_ctx_get2 (entry_ino, this, &nlc_ctx_int, NULL);
- if (nlc_ctx_int == 0)
- GF_ATOMIC_ADD (conf->refd_inodes, 1);
-
- ret = 0;
+ nlc_pe_t *pe = NULL;
+ int ret = -1;
+ nlc_conf_t *conf = NULL;
+ uint64_t nlc_ctx_int = 0;
+
+ conf = this->private;
+
+ /* TODO: There can be no duplicate entries, as it is added only
+ during create. In case there arises duplicate entries, search PE
+ found = __nlc_search (entries, name, _gf_false);
+ can use bit vector to have simple search than sequential search */
+
+ pe = GF_CALLOC(sizeof(*pe), 1, gf_nlc_mt_nlc_pe_t);
+ if (!pe)
+ goto out;
+
+ if (entry_ino) {
+ pe->inode = inode_ref(entry_ino);
+ nlc_inode_ctx_set(this, entry_ino, NULL, pe);
+ } else if (name) {
+ pe->name = gf_strdup(name);
+ if (!pe->name)
+ goto out;
+ }
+
+ list_add(&pe->list, &nlc_ctx->pe);
+
+ nlc_ctx->cache_size += sizeof(*pe) + sizeof(pe->name);
+ GF_ATOMIC_ADD(conf->current_cache_size, (sizeof(*pe) + sizeof(pe->name)));
+
+ nlc_ctx->refd_inodes += 1;
+ inode_ctx_get2(entry_ino, this, &nlc_ctx_int, NULL);
+ if (nlc_ctx_int == 0)
+ GF_ATOMIC_ADD(conf->refd_inodes, 1);
+
+ ret = 0;
out:
- if (ret)
- GF_FREE (pe);
+ if (ret)
+ GF_FREE(pe);
- return;
+ return;
}
-
static void
-__nlc_add_ne (xlator_t *this, nlc_ctx_t *nlc_ctx, const char *name)
+__nlc_add_ne(xlator_t *this, nlc_ctx_t *nlc_ctx, const char *name)
{
- nlc_ne_t *ne = NULL;
- int ret = -1;
- nlc_conf_t *conf = NULL;
+ nlc_ne_t *ne = NULL;
+ int ret = -1;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- /* TODO: search ne before adding to get rid of duplicate entries
- found = __nlc_search (entries, name, _gf_false);
- can use bit vector to have faster search than sequential search */
+ /* TODO: search ne before adding to get rid of duplicate entries
+ found = __nlc_search (entries, name, _gf_false);
+ can use bit vector to have faster search than sequential search */
- ne = GF_CALLOC (sizeof (*ne), 1, gf_nlc_mt_nlc_ne_t);
- if (!ne)
- goto out;
+ ne = GF_CALLOC(sizeof(*ne), 1, gf_nlc_mt_nlc_ne_t);
+ if (!ne)
+ goto out;
- ne->name = gf_strdup (name);
- if (!ne->name)
- goto out;
+ ne->name = gf_strdup(name);
+ if (!ne->name)
+ goto out;
- list_add (&ne->list, &nlc_ctx->ne);
+ list_add(&ne->list, &nlc_ctx->ne);
- nlc_ctx->cache_size += sizeof (*ne) + sizeof (ne->name);
- GF_ATOMIC_ADD (conf->current_cache_size,
- (sizeof (*ne) + sizeof (ne->name)));
- ret = 0;
+ nlc_ctx->cache_size += sizeof(*ne) + sizeof(ne->name);
+ GF_ATOMIC_ADD(conf->current_cache_size, (sizeof(*ne) + sizeof(ne->name)));
+ ret = 0;
out:
- if (ret)
- GF_FREE (ne);
+ if (ret)
+ GF_FREE(ne);
- return;
+ return;
}
-
void
-nlc_dir_add_ne (xlator_t *this, inode_t *inode, const char *name)
+nlc_dir_add_ne(xlator_t *this, inode_t *inode, const char *name)
{
- nlc_ctx_t *nlc_ctx = NULL;
-
- if (inode->ia_type != IA_IFDIR) {
- gf_msg_callingfn (this->name, GF_LOG_ERROR, EINVAL,
- NLC_MSG_EINVAL, "inode is not of type dir");
- goto out;
+ nlc_ctx_t *nlc_ctx = NULL;
+
+ if (inode->ia_type != IA_IFDIR) {
+ gf_msg_callingfn(this->name, GF_LOG_ERROR, EINVAL, NLC_MSG_EINVAL,
+ "inode is not of type dir");
+ goto out;
+ }
+
+ nlc_inode_ctx_get_set(this, inode, &nlc_ctx, NULL);
+ if (!nlc_ctx)
+ goto out;
+
+ LOCK(&nlc_ctx->lock);
+ {
+ /* There is one possibility where we need to search before
+ * adding NE: when there are two parallel lookups on a non
+ * existent file */
+ if (!__nlc_search_ne(nlc_ctx, name)) {
+ __nlc_add_ne(this, nlc_ctx, name);
+ __nlc_set_dir_state(nlc_ctx, NLC_NE_VALID);
}
-
- nlc_inode_ctx_get_set (this, inode, &nlc_ctx, NULL);
- if (!nlc_ctx)
- goto out;
-
- LOCK (&nlc_ctx->lock);
- {
- /* There is one possibility where we need to search before
- * adding NE: when there are two parallel lookups on a non
- * existent file */
- if (!__nlc_search_ne (nlc_ctx, name)) {
- __nlc_add_ne (this, nlc_ctx, name);
- __nlc_set_dir_state (nlc_ctx, NLC_NE_VALID);
- }
- }
- UNLOCK (&nlc_ctx->lock);
+ }
+ UNLOCK(&nlc_ctx->lock);
out:
- return;
+ return;
}
-
void
-nlc_dir_remove_pe (xlator_t *this, inode_t *parent, inode_t *entry_ino,
- const char *name, gf_boolean_t multilink)
+nlc_dir_remove_pe(xlator_t *this, inode_t *parent, inode_t *entry_ino,
+ const char *name, gf_boolean_t multilink)
{
- nlc_ctx_t *nlc_ctx = NULL;
-
- if (parent->ia_type != IA_IFDIR) {
- gf_msg_callingfn (this->name, GF_LOG_ERROR, EINVAL,
- NLC_MSG_EINVAL, "inode is not of type dir");
- goto out;
- }
-
- nlc_inode_ctx_get (this, parent, &nlc_ctx, NULL);
- if (!nlc_ctx)
- goto out;
-
- LOCK (&nlc_ctx->lock);
- {
- if (!__nlc_is_cache_valid (this, nlc_ctx))
- goto unlock;
-
- __nlc_del_pe (this, nlc_ctx, entry_ino, name, multilink);
- __nlc_add_ne (this, nlc_ctx, name);
- __nlc_set_dir_state (nlc_ctx, NLC_NE_VALID);
- }
+ nlc_ctx_t *nlc_ctx = NULL;
+
+ if (parent->ia_type != IA_IFDIR) {
+ gf_msg_callingfn(this->name, GF_LOG_ERROR, EINVAL, NLC_MSG_EINVAL,
+ "inode is not of type dir");
+ goto out;
+ }
+
+ nlc_inode_ctx_get(this, parent, &nlc_ctx, NULL);
+ if (!nlc_ctx)
+ goto out;
+
+ LOCK(&nlc_ctx->lock);
+ {
+ if (!__nlc_is_cache_valid(this, nlc_ctx))
+ goto unlock;
+
+ __nlc_del_pe(this, nlc_ctx, entry_ino, name, multilink);
+ __nlc_add_ne(this, nlc_ctx, name);
+ __nlc_set_dir_state(nlc_ctx, NLC_NE_VALID);
+ }
unlock:
- UNLOCK (&nlc_ctx->lock);
+ UNLOCK(&nlc_ctx->lock);
out:
- return;
+ return;
}
-
void
-nlc_dir_add_pe (xlator_t *this, inode_t *inode, inode_t *entry_ino,
- const char *name)
+nlc_dir_add_pe(xlator_t *this, inode_t *inode, inode_t *entry_ino,
+ const char *name)
{
- nlc_ctx_t *nlc_ctx = NULL;
-
- if (inode->ia_type != IA_IFDIR) {
- gf_msg_callingfn (this->name, GF_LOG_ERROR, EINVAL,
- NLC_MSG_EINVAL, "inode is not of type dir");
- goto out;
- }
-
- nlc_inode_ctx_get_set (this, inode, &nlc_ctx, NULL);
- if (!nlc_ctx)
- goto out;
-
- LOCK (&nlc_ctx->lock);
- {
- __nlc_del_ne (this, nlc_ctx, name);
- __nlc_add_pe (this, nlc_ctx, entry_ino, name);
- if (!IS_PE_VALID (nlc_ctx->state))
- __nlc_set_dir_state (nlc_ctx, NLC_PE_PARTIAL);
- }
- UNLOCK (&nlc_ctx->lock);
+ nlc_ctx_t *nlc_ctx = NULL;
+
+ if (inode->ia_type != IA_IFDIR) {
+ gf_msg_callingfn(this->name, GF_LOG_ERROR, EINVAL, NLC_MSG_EINVAL,
+ "inode is not of type dir");
+ goto out;
+ }
+
+ nlc_inode_ctx_get_set(this, inode, &nlc_ctx, NULL);
+ if (!nlc_ctx)
+ goto out;
+
+ LOCK(&nlc_ctx->lock);
+ {
+ __nlc_del_ne(this, nlc_ctx, name);
+ __nlc_add_pe(this, nlc_ctx, entry_ino, name);
+ if (!IS_PE_VALID(nlc_ctx->state))
+ __nlc_set_dir_state(nlc_ctx, NLC_PE_PARTIAL);
+ }
+ UNLOCK(&nlc_ctx->lock);
out:
- return;
+ return;
}
-
gf_boolean_t
-__nlc_search_ne (nlc_ctx_t *nlc_ctx, const char *name)
+__nlc_search_ne(nlc_ctx_t *nlc_ctx, const char *name)
{
- gf_boolean_t found = _gf_false;
- nlc_ne_t *ne = NULL;
- nlc_ne_t *tmp = NULL;
-
- if (!IS_NE_VALID (nlc_ctx->state))
- goto out;
-
- list_for_each_entry_safe (ne, tmp, &nlc_ctx->ne, list) {
- if (strcmp (ne->name, name) == 0) {
- found = _gf_true;
- break;
- }
+ gf_boolean_t found = _gf_false;
+ nlc_ne_t *ne = NULL;
+ nlc_ne_t *tmp = NULL;
+
+ if (!IS_NE_VALID(nlc_ctx->state))
+ goto out;
+
+ list_for_each_entry_safe(ne, tmp, &nlc_ctx->ne, list)
+ {
+ if (strcmp(ne->name, name) == 0) {
+ found = _gf_true;
+ break;
}
+ }
out:
- return found;
+ return found;
}
-
static gf_boolean_t
-__nlc_search_pe (nlc_ctx_t *nlc_ctx, const char *name)
+__nlc_search_pe(nlc_ctx_t *nlc_ctx, const char *name)
{
- gf_boolean_t found = _gf_false;
- nlc_pe_t *pe = NULL;
- nlc_pe_t *tmp = NULL;
-
- if (!IS_PE_VALID (nlc_ctx->state))
- goto out;
-
- list_for_each_entry_safe (pe, tmp, &nlc_ctx->pe, list) {
- if (pe->name && (strcmp (pe->name, name) == 0)) {
- found = _gf_true;
- break;
- }
+ gf_boolean_t found = _gf_false;
+ nlc_pe_t *pe = NULL;
+ nlc_pe_t *tmp = NULL;
+
+ if (!IS_PE_VALID(nlc_ctx->state))
+ goto out;
+
+ list_for_each_entry_safe(pe, tmp, &nlc_ctx->pe, list)
+ {
+ if (pe->name && (strcmp(pe->name, name) == 0)) {
+ found = _gf_true;
+ break;
}
+ }
out:
- return found;
+ return found;
}
-
static char *
-__nlc_get_pe (nlc_ctx_t *nlc_ctx, const char *name, gf_boolean_t case_insensitive)
+__nlc_get_pe(nlc_ctx_t *nlc_ctx, const char *name,
+ gf_boolean_t case_insensitive)
{
- char *found = NULL;
- nlc_pe_t *pe = NULL;
- nlc_pe_t *tmp = NULL;
+ char *found = NULL;
+ nlc_pe_t *pe = NULL;
+ nlc_pe_t *tmp = NULL;
- if (!IS_PE_VALID (nlc_ctx->state))
- goto out;
+ if (!IS_PE_VALID(nlc_ctx->state))
+ goto out;
- if (case_insensitive) {
- list_for_each_entry_safe (pe, tmp, &nlc_ctx->pe, list) {
- if (pe->name &&
- (strcasecmp (pe->name, name) == 0)) {
- found = pe->name;
- break;
- }
- }
- } else {
- list_for_each_entry_safe (pe, tmp, &nlc_ctx->pe, list) {
- if (pe->name &&
- (strcmp (pe->name, name) == 0)) {
- found = pe->name;
- break;
- }
- }
+ if (case_insensitive) {
+ list_for_each_entry_safe(pe, tmp, &nlc_ctx->pe, list)
+ {
+ if (pe->name && (strcasecmp(pe->name, name) == 0)) {
+ found = pe->name;
+ break;
+ }
+ }
+ } else {
+ list_for_each_entry_safe(pe, tmp, &nlc_ctx->pe, list)
+ {
+ if (pe->name && (strcmp(pe->name, name) == 0)) {
+ found = pe->name;
+ break;
+ }
}
+ }
out:
- return found;
+ return found;
}
-
gf_boolean_t
-nlc_is_negative_lookup (xlator_t *this, loc_t *loc)
+nlc_is_negative_lookup(xlator_t *this, loc_t *loc)
{
- nlc_ctx_t *nlc_ctx = NULL;
- inode_t *inode = NULL;
- gf_boolean_t neg_entry = _gf_false;
-
- inode = loc->parent;
- GF_VALIDATE_OR_GOTO (this->name, inode, out);
-
- if (inode->ia_type != IA_IFDIR) {
- gf_msg_callingfn (this->name, GF_LOG_ERROR, EINVAL,
- NLC_MSG_EINVAL, "inode is not of type dir");
- goto out;
+ nlc_ctx_t *nlc_ctx = NULL;
+ inode_t *inode = NULL;
+ gf_boolean_t neg_entry = _gf_false;
+
+ inode = loc->parent;
+ GF_VALIDATE_OR_GOTO(this->name, inode, out);
+
+ if (inode->ia_type != IA_IFDIR) {
+ gf_msg_callingfn(this->name, GF_LOG_ERROR, EINVAL, NLC_MSG_EINVAL,
+ "inode is not of type dir");
+ goto out;
+ }
+
+ nlc_inode_ctx_get(this, inode, &nlc_ctx, NULL);
+ if (!nlc_ctx)
+ goto out;
+
+ LOCK(&nlc_ctx->lock);
+ {
+ if (!__nlc_is_cache_valid(this, nlc_ctx))
+ goto unlock;
+
+ if (__nlc_search_ne(nlc_ctx, loc->name)) {
+ neg_entry = _gf_true;
+ goto unlock;
}
-
- nlc_inode_ctx_get (this, inode, &nlc_ctx, NULL);
- if (!nlc_ctx)
- goto out;
-
- LOCK (&nlc_ctx->lock);
- {
- if (!__nlc_is_cache_valid (this, nlc_ctx))
- goto unlock;
-
- if (__nlc_search_ne (nlc_ctx, loc->name)) {
- neg_entry = _gf_true;
- goto unlock;
- }
- if ((nlc_ctx->state & NLC_PE_FULL) &&
- !__nlc_search_pe (nlc_ctx, loc->name)) {
- neg_entry = _gf_true;
- goto unlock;
- }
+ if ((nlc_ctx->state & NLC_PE_FULL) &&
+ !__nlc_search_pe(nlc_ctx, loc->name)) {
+ neg_entry = _gf_true;
+ goto unlock;
}
+ }
unlock:
- UNLOCK (&nlc_ctx->lock);
+ UNLOCK(&nlc_ctx->lock);
out:
- return neg_entry;
+ return neg_entry;
}
-
gf_boolean_t
-nlc_get_real_file_name (xlator_t *this, loc_t *loc, const char *fname,
- int32_t *op_ret, int32_t *op_errno, dict_t *dict)
+nlc_get_real_file_name(xlator_t *this, loc_t *loc, const char *fname,
+ int32_t *op_ret, int32_t *op_errno, dict_t *dict)
{
- nlc_ctx_t *nlc_ctx = NULL;
- inode_t *inode = NULL;
- gf_boolean_t hit = _gf_false;
- char *found_file = NULL;
- int ret = 0;
-
- GF_VALIDATE_OR_GOTO (this->name, loc, out);
- GF_VALIDATE_OR_GOTO (this->name, fname, out);
- GF_VALIDATE_OR_GOTO (this->name, op_ret, out);
- GF_VALIDATE_OR_GOTO (this->name, op_errno, out);
- GF_VALIDATE_OR_GOTO (this->name, dict, out);
-
- inode = loc->inode;
- GF_VALIDATE_OR_GOTO (this->name, inode, out);
-
- if (inode->ia_type != IA_IFDIR) {
- gf_msg_callingfn (this->name, GF_LOG_ERROR, EINVAL,
- NLC_MSG_EINVAL, "inode is not of type dir");
- goto out;
+ nlc_ctx_t *nlc_ctx = NULL;
+ inode_t *inode = NULL;
+ gf_boolean_t hit = _gf_false;
+ char *found_file = NULL;
+ int ret = 0;
+
+ GF_VALIDATE_OR_GOTO(this->name, loc, out);
+ GF_VALIDATE_OR_GOTO(this->name, fname, out);
+ GF_VALIDATE_OR_GOTO(this->name, op_ret, out);
+ GF_VALIDATE_OR_GOTO(this->name, op_errno, out);
+ GF_VALIDATE_OR_GOTO(this->name, dict, out);
+
+ inode = loc->inode;
+ GF_VALIDATE_OR_GOTO(this->name, inode, out);
+
+ if (inode->ia_type != IA_IFDIR) {
+ gf_msg_callingfn(this->name, GF_LOG_ERROR, EINVAL, NLC_MSG_EINVAL,
+ "inode is not of type dir");
+ goto out;
+ }
+
+ nlc_inode_ctx_get(this, inode, &nlc_ctx, NULL);
+ if (!nlc_ctx)
+ goto out;
+
+ LOCK(&nlc_ctx->lock);
+ {
+ if (!__nlc_is_cache_valid(this, nlc_ctx))
+ goto unlock;
+
+ found_file = __nlc_get_pe(nlc_ctx, fname, _gf_true);
+ if (found_file) {
+ ret = dict_set_dynstr(dict, GF_XATTR_GET_REAL_FILENAME_KEY,
+ gf_strdup(found_file));
+ if (ret < 0)
+ goto unlock;
+ *op_ret = strlen(found_file) + 1;
+ hit = _gf_true;
+ goto unlock;
}
-
- nlc_inode_ctx_get (this, inode, &nlc_ctx, NULL);
- if (!nlc_ctx)
- goto out;
-
- LOCK (&nlc_ctx->lock);
- {
- if (!__nlc_is_cache_valid (this, nlc_ctx))
- goto unlock;
-
- found_file = __nlc_get_pe (nlc_ctx, fname, _gf_true);
- if (found_file) {
- ret = dict_set_dynstr (dict, GF_XATTR_GET_REAL_FILENAME_KEY,
- gf_strdup (found_file));
- if (ret < 0)
- goto unlock;
- *op_ret = strlen (found_file) + 1;
- hit = _gf_true;
- goto unlock;
- }
- if (!found_file && (nlc_ctx->state & NLC_PE_FULL)) {
- *op_ret = -1;
- *op_errno = ENOENT;
- hit = _gf_true;
- goto unlock;
- }
+ if (!found_file && (nlc_ctx->state & NLC_PE_FULL)) {
+ *op_ret = -1;
+ *op_errno = ENOENT;
+ hit = _gf_true;
+ goto unlock;
}
+ }
unlock:
- UNLOCK (&nlc_ctx->lock);
+ UNLOCK(&nlc_ctx->lock);
out:
- return hit;
+ return hit;
}
-
void
-nlc_dump_inodectx (xlator_t *this, inode_t *inode)
+nlc_dump_inodectx(xlator_t *this, inode_t *inode)
{
- int32_t ret = -1;
- char *path = NULL;
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
- char uuid_str[64] = {0,};
- nlc_ctx_t *nlc_ctx = NULL;
- nlc_pe_t *pe = NULL;
- nlc_pe_t *tmp = NULL;
- nlc_ne_t *ne = NULL;
- nlc_ne_t *tmp1 = NULL;
-
- nlc_inode_ctx_get (this, inode, &nlc_ctx, NULL);
+ int32_t ret = -1;
+ char *path = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ char uuid_str[64] = {
+ 0,
+ };
+ nlc_ctx_t *nlc_ctx = NULL;
+ nlc_pe_t *pe = NULL;
+ nlc_pe_t *tmp = NULL;
+ nlc_ne_t *ne = NULL;
+ nlc_ne_t *tmp1 = NULL;
+
+ nlc_inode_ctx_get(this, inode, &nlc_ctx, NULL);
+
+ if (!nlc_ctx)
+ goto out;
+
+ ret = TRY_LOCK(&nlc_ctx->lock);
+ if (!ret) {
+ gf_proc_dump_build_key(key_prefix, "xlator.performance.nl-cache",
+ "nlc_inode");
+ gf_proc_dump_add_section(key_prefix);
+
+ __inode_path(inode, NULL, &path);
+ if (path != NULL) {
+ gf_proc_dump_write("path", "%s", path);
+ GF_FREE(path);
+ }
- if (!nlc_ctx)
- goto out;
+ uuid_utoa_r(inode->gfid, uuid_str);
- ret = TRY_LOCK (&nlc_ctx->lock);
- if (!ret) {
- gf_proc_dump_build_key (key_prefix,
- "xlator.performance.nl-cache",
- "nlc_inode");
- gf_proc_dump_add_section (key_prefix);
-
- __inode_path (inode, NULL, &path);
- if (path != NULL) {
- gf_proc_dump_write ("path", "%s", path);
- GF_FREE (path);
- }
-
- uuid_utoa_r (inode->gfid, uuid_str);
-
- gf_proc_dump_write ("inode", "%p", inode);
- gf_proc_dump_write ("gfid", "%s", uuid_str);
-
- gf_proc_dump_write ("state", "%"PRIu64, nlc_ctx->state);
- gf_proc_dump_write ("timer", "%p", nlc_ctx->timer);
- gf_proc_dump_write ("cache-time", "%lld", nlc_ctx->cache_time);
- gf_proc_dump_write ("cache-size", "%zu", nlc_ctx->cache_size);
- gf_proc_dump_write ("refd-inodes", "%"PRIu64, nlc_ctx->refd_inodes);
-
- if (IS_PE_VALID (nlc_ctx->state))
- list_for_each_entry_safe (pe, tmp, &nlc_ctx->pe, list) {
- gf_proc_dump_write ("pe", "%p, %s", pe,
- pe->inode, pe->name);
- }
-
- if (IS_NE_VALID (nlc_ctx->state))
- list_for_each_entry_safe (ne, tmp1, &nlc_ctx->ne, list) {
- gf_proc_dump_write ("ne", "%s", ne->name);
- }
-
- UNLOCK (&nlc_ctx->lock);
- }
+ gf_proc_dump_write("inode", "%p", inode);
+ gf_proc_dump_write("gfid", "%s", uuid_str);
+
+ gf_proc_dump_write("state", "%" PRIu64, nlc_ctx->state);
+ gf_proc_dump_write("timer", "%p", nlc_ctx->timer);
+ gf_proc_dump_write("cache-time", "%lld", nlc_ctx->cache_time);
+ gf_proc_dump_write("cache-size", "%zu", nlc_ctx->cache_size);
+ gf_proc_dump_write("refd-inodes", "%" PRIu64, nlc_ctx->refd_inodes);
+
+ if (IS_PE_VALID(nlc_ctx->state))
+ list_for_each_entry_safe(pe, tmp, &nlc_ctx->pe, list)
+ {
+ gf_proc_dump_write("pe", "%p, %s", pe, pe->inode, pe->name);
+ }
+
+ if (IS_NE_VALID(nlc_ctx->state))
+ list_for_each_entry_safe(ne, tmp1, &nlc_ctx->ne, list)
+ {
+ gf_proc_dump_write("ne", "%s", ne->name);
+ }
+
+ UNLOCK(&nlc_ctx->lock);
+ }
- if (ret && nlc_ctx)
- gf_proc_dump_write ("Unable to dump the inode information",
- "(Lock acquisition failed) %p (gfid: %s)",
- nlc_ctx, uuid_str);
+ if (ret && nlc_ctx)
+ gf_proc_dump_write("Unable to dump the inode information",
+ "(Lock acquisition failed) %p (gfid: %s)", nlc_ctx,
+ uuid_str);
out:
- return;
+ return;
}
diff --git a/xlators/performance/nl-cache/src/nl-cache.c b/xlators/performance/nl-cache/src/nl-cache.c
index 661f96bec14..efa54ee346b 100644
--- a/xlators/performance/nl-cache/src/nl-cache.c
+++ b/xlators/performance/nl-cache/src/nl-cache.c
@@ -8,866 +8,827 @@
* cases as published by the Free Software Foundation.
*/
-
#include "nl-cache.h"
#include "statedump.h"
#include "upcall-utils.h"
static void
-nlc_dentry_op (call_frame_t *frame, xlator_t *this, gf_boolean_t multilink)
+nlc_dentry_op(call_frame_t *frame, xlator_t *this, gf_boolean_t multilink)
{
- nlc_local_t *local = frame->local;
+ nlc_local_t *local = frame->local;
- GF_VALIDATE_OR_GOTO (this->name, local, out);
+ GF_VALIDATE_OR_GOTO(this->name, local, out);
- switch (local->fop) {
+ switch (local->fop) {
case GF_FOP_MKDIR:
- nlc_set_dir_state (this, local->loc.inode, NLC_PE_FULL);
- /*fall-through*/
+ nlc_set_dir_state(this, local->loc.inode, NLC_PE_FULL);
+ /*fall-through*/
case GF_FOP_MKNOD:
case GF_FOP_CREATE:
case GF_FOP_SYMLINK:
- nlc_dir_add_pe (this, local->loc.parent, local->loc.inode,
- local->loc.name);
- break;
+ nlc_dir_add_pe(this, local->loc.parent, local->loc.inode,
+ local->loc.name);
+ break;
case GF_FOP_LINK:
- nlc_dir_add_pe (this, local->loc2.parent, NULL,
- local->loc2.name);
- break;
+ nlc_dir_add_pe(this, local->loc2.parent, NULL, local->loc2.name);
+ break;
case GF_FOP_RMDIR:
- nlc_inode_clear_cache (this, local->loc.inode, _gf_false);
- /*fall-through*/
+ nlc_inode_clear_cache(this, local->loc.inode, _gf_false);
+ /*fall-through*/
case GF_FOP_UNLINK:
- nlc_dir_remove_pe (this, local->loc.parent, local->loc.inode,
- local->loc.name, multilink);
- break;
+ nlc_dir_remove_pe(this, local->loc.parent, local->loc.inode,
+ local->loc.name, multilink);
+ break;
case GF_FOP_RENAME:
- /* TBD: Should these be atomic ? In case of rename, the
- * newloc->inode can be NULL, and hence use oldloc->inode */
- nlc_dir_remove_pe (this, local->loc2.parent, local->loc2.inode,
- local->loc2.name, _gf_false);
+ /* TBD: Should these be atomic ? In case of rename, the
+ * newloc->inode can be NULL, and hence use oldloc->inode */
+ nlc_dir_remove_pe(this, local->loc2.parent, local->loc2.inode,
+ local->loc2.name, _gf_false);
- /*TODO: Remove old dentry from destination before adding this pe*/
- nlc_dir_add_pe (this, local->loc.parent, local->loc2.inode,
- local->loc.name);
+ /*TODO: Remove old dentry from destination before adding this pe*/
+ nlc_dir_add_pe(this, local->loc.parent, local->loc2.inode,
+ local->loc.name);
default:
- return;
- }
+ return;
+ }
- nlc_lru_prune (this, NULL);
+ nlc_lru_prune(this, NULL);
out:
- return;
+ return;
}
-#define NLC_FOP(_name, _op, loc1, loc2, frame, this, args ...) do { \
- nlc_local_t *__local = NULL; \
- nlc_conf_t *conf = NULL; \
- \
- conf = this->private; \
- \
- if (!IS_PEC_ENABLED (conf)) \
- goto disabled; \
- \
- __local = nlc_local_init (frame, this, _op, loc1, loc2); \
- GF_VALIDATE_OR_GOTO (this->name, __local, err); \
- \
- STACK_WIND (frame, nlc_##_name##_cbk, \
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->_name, \
- args); \
- break; \
-disabled: \
- default_##_name##_resume (frame, this, args); \
- break; \
-err: \
- default_##_name##_failure_cbk (frame, ENOMEM); \
- break; \
-} while (0)
-
-#define NLC_FOP_CBK(_name, multilink, frame, cookie, this, op_ret, op_errno, \
- args ...) do { \
- nlc_conf_t *conf = NULL; \
- \
- if (op_ret != 0) \
- goto out; \
- \
- conf = this->private; \
- \
- if (op_ret < 0 || !IS_PEC_ENABLED (conf)) \
- goto out; \
- nlc_dentry_op (frame, this, multilink); \
-out: \
- NLC_STACK_UNWIND (_name, frame, op_ret, op_errno, args); \
-} while (0)
+#define NLC_FOP(_name, _op, loc1, loc2, frame, this, args...) \
+ do { \
+ nlc_local_t *__local = NULL; \
+ nlc_conf_t *conf = NULL; \
+ \
+ conf = this->private; \
+ \
+ if (!IS_PEC_ENABLED(conf)) \
+ goto disabled; \
+ \
+ __local = nlc_local_init(frame, this, _op, loc1, loc2); \
+ GF_VALIDATE_OR_GOTO(this->name, __local, err); \
+ \
+ STACK_WIND(frame, nlc_##_name##_cbk, FIRST_CHILD(this), \
+ FIRST_CHILD(this)->fops->_name, args); \
+ break; \
+ disabled: \
+ default_##_name##_resume(frame, this, args); \
+ break; \
+ err: \
+ default_##_name##_failure_cbk(frame, ENOMEM); \
+ break; \
+ } while (0)
+
+#define NLC_FOP_CBK(_name, multilink, frame, cookie, this, op_ret, op_errno, \
+ args...) \
+ do { \
+ nlc_conf_t *conf = NULL; \
+ \
+ if (op_ret != 0) \
+ goto out; \
+ \
+ conf = this->private; \
+ \
+ if (op_ret < 0 || !IS_PEC_ENABLED(conf)) \
+ goto out; \
+ nlc_dentry_op(frame, this, multilink); \
+ out: \
+ NLC_STACK_UNWIND(_name, frame, op_ret, op_errno, args); \
+ } while (0)
static int32_t
-nlc_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf,
- struct iatt *preoldparent, struct iatt *postoldparent,
- struct iatt *prenewparent, struct iatt *postnewparent,
- dict_t *xdata)
+nlc_rename_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *buf,
+ struct iatt *preoldparent, struct iatt *postoldparent,
+ struct iatt *prenewparent, struct iatt *postnewparent,
+ dict_t *xdata)
{
- NLC_FOP_CBK (rename, _gf_false, frame, cookie, this, op_ret, op_errno,
- buf, preoldparent, postoldparent, prenewparent,
- postnewparent, xdata);
- return 0;
+ NLC_FOP_CBK(rename, _gf_false, frame, cookie, this, op_ret, op_errno, buf,
+ preoldparent, postoldparent, prenewparent, postnewparent,
+ xdata);
+ return 0;
}
-
static int32_t
-nlc_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
- dict_t *xdata)
+nlc_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
{
- NLC_FOP (rename, GF_FOP_RENAME, newloc, oldloc, frame, this, oldloc,
- newloc, xdata);
- return 0;
+ NLC_FOP(rename, GF_FOP_RENAME, newloc, oldloc, frame, this, oldloc, newloc,
+ xdata);
+ return 0;
}
-
static int32_t
-nlc_mknod_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
- int32_t op_errno, inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
+nlc_mknod_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- NLC_FOP_CBK(mknod, _gf_false, frame, cookie, this, op_ret, op_errno,
- inode, buf, preparent, postparent, xdata);
- return 0;
+ NLC_FOP_CBK(mknod, _gf_false, frame, cookie, this, op_ret, op_errno, inode,
+ buf, preparent, postparent, xdata);
+ return 0;
}
-
static int32_t
-nlc_mknod (call_frame_t *frame, xlator_t *this, loc_t *loc,
- mode_t mode, dev_t rdev, mode_t umask,
- dict_t *xdata)
+nlc_mknod(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
+ dev_t rdev, mode_t umask, dict_t *xdata)
{
- NLC_FOP(mknod, GF_FOP_MKNOD, loc, NULL, frame, this, loc, mode, rdev,
- umask, xdata);
- return 0;
+ NLC_FOP(mknod, GF_FOP_MKNOD, loc, NULL, frame, this, loc, mode, rdev, umask,
+ xdata);
+ return 0;
}
static int32_t
-nlc_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 iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+nlc_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 iatt *buf, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
{
- NLC_FOP_CBK (create, _gf_false, frame, cookie, this, op_ret, op_errno,
- fd, inode, buf, preparent, postparent, xdata);
- return 0;
+ NLC_FOP_CBK(create, _gf_false, frame, cookie, this, op_ret, op_errno, fd,
+ inode, buf, preparent, postparent, xdata);
+ return 0;
}
-
static int32_t
-nlc_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
+nlc_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
{
- NLC_FOP (create, GF_FOP_CREATE, loc, NULL, frame, this, loc, flags,
- mode, umask, fd, xdata);
- return 0;
+ NLC_FOP(create, GF_FOP_CREATE, loc, NULL, frame, this, loc, flags, mode,
+ umask, fd, xdata);
+ return 0;
}
static int32_t
-nlc_mkdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
- int32_t op_errno, inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
+nlc_mkdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- NLC_FOP_CBK (mkdir, _gf_false, frame, cookie, this, op_ret, op_errno,
- inode, buf, preparent, postparent, xdata);
- return 0;
+ NLC_FOP_CBK(mkdir, _gf_false, frame, cookie, this, op_ret, op_errno, inode,
+ buf, preparent, postparent, xdata);
+ return 0;
}
-
static int32_t
-nlc_mkdir (call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
- mode_t umask, dict_t *xdata)
+nlc_mkdir(call_frame_t *frame, xlator_t *this, loc_t *loc, mode_t mode,
+ mode_t umask, dict_t *xdata)
{
- NLC_FOP (mkdir, GF_FOP_MKDIR, loc, NULL, frame, this, loc, mode,
- umask, xdata);
- return 0;
+ NLC_FOP(mkdir, GF_FOP_MKDIR, loc, NULL, frame, this, loc, mode, umask,
+ xdata);
+ return 0;
}
-
static int32_t
-nlc_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, dict_t *xdata, struct iatt *postparent)
+nlc_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *buf, dict_t *xdata, struct iatt *postparent)
{
- nlc_local_t *local = NULL;
- nlc_conf_t *conf = NULL;
+ nlc_local_t *local = NULL;
+ nlc_conf_t *conf = NULL;
- local = frame->local;
- conf = this->private;
+ local = frame->local;
+ conf = this->private;
- if (!local)
- goto out;
+ if (!local)
+ goto out;
- /* Donot add to pe, this may lead to duplicate entry and
- * requires search before adding if list of strings */
- if (op_ret < 0 && op_errno == ENOENT) {
- nlc_dir_add_ne (this, local->loc.parent, local->loc.name);
- GF_ATOMIC_INC (conf->nlc_counter.nlc_miss);
- }
+ /* Donot add to pe, this may lead to duplicate entry and
+ * requires search before adding if list of strings */
+ if (op_ret < 0 && op_errno == ENOENT) {
+ nlc_dir_add_ne(this, local->loc.parent, local->loc.name);
+ GF_ATOMIC_INC(conf->nlc_counter.nlc_miss);
+ }
out:
- NLC_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode, buf, xdata,
- postparent);
- return 0;
+ NLC_STACK_UNWIND(lookup, frame, op_ret, op_errno, inode, buf, xdata,
+ postparent);
+ return 0;
}
-
static int32_t
-nlc_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+nlc_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- nlc_local_t *local = NULL;
- nlc_conf_t *conf = NULL;
- inode_t *inode = NULL;
-
- if (loc_is_nameless (loc))
- goto wind;
-
- local = nlc_local_init (frame, this, GF_FOP_LOOKUP, loc, NULL);
- if (!local)
- goto err;
-
- conf = this->private;
-
- inode = inode_grep (loc->inode->table, loc->parent, loc->name);
- if (inode) {
- inode_unref (inode);
- goto wind;
- }
-
- if (nlc_is_negative_lookup (this, loc)) {
- GF_ATOMIC_INC (conf->nlc_counter.nlc_hit);
- gf_msg_trace (this->name, 0, "Serving negative lookup from "
- "cache:%s", loc->name);
- goto unwind;
- }
+ nlc_local_t *local = NULL;
+ nlc_conf_t *conf = NULL;
+ inode_t *inode = NULL;
+
+ if (loc_is_nameless(loc))
+ goto wind;
+
+ local = nlc_local_init(frame, this, GF_FOP_LOOKUP, loc, NULL);
+ if (!local)
+ goto err;
+
+ conf = this->private;
+
+ inode = inode_grep(loc->inode->table, loc->parent, loc->name);
+ if (inode) {
+ inode_unref(inode);
+ goto wind;
+ }
+
+ if (nlc_is_negative_lookup(this, loc)) {
+ GF_ATOMIC_INC(conf->nlc_counter.nlc_hit);
+ gf_msg_trace(this->name, 0,
+ "Serving negative lookup from "
+ "cache:%s",
+ loc->name);
+ goto unwind;
+ }
wind:
- STACK_WIND (frame, nlc_lookup_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->lookup,
- loc, xdata);
- return 0;
+ STACK_WIND(frame, nlc_lookup_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, loc, xdata);
+ return 0;
unwind:
- NLC_STACK_UNWIND (lookup, frame, -1, ENOENT, NULL, NULL, NULL, NULL);
- return 0;
+ NLC_STACK_UNWIND(lookup, frame, -1, ENOENT, NULL, NULL, NULL, NULL);
+ return 0;
err:
- NLC_STACK_UNWIND (lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL);
- return 0;
+ NLC_STACK_UNWIND(lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL);
+ return 0;
}
static int32_t
-nlc_rmdir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+nlc_rmdir_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *preparent, struct iatt *postparent,
+ dict_t *xdata)
{
- NLC_FOP_CBK (rmdir, _gf_false, frame, cookie, this, op_ret, op_errno,
- preparent, postparent, xdata);
- return 0;
+ NLC_FOP_CBK(rmdir, _gf_false, frame, cookie, this, op_ret, op_errno,
+ preparent, postparent, xdata);
+ return 0;
}
-
static int32_t
-nlc_rmdir (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- dict_t *xdata)
+nlc_rmdir(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ dict_t *xdata)
{
- NLC_FOP (rmdir, GF_FOP_RMDIR, loc, NULL, frame, this, loc, flags,
- xdata);
- return 0;
+ NLC_FOP(rmdir, GF_FOP_RMDIR, loc, NULL, frame, this, loc, flags, xdata);
+ return 0;
}
-
static int32_t
-nlc_getxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *dict,
- dict_t *xdata)
+nlc_getxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *dict, dict_t *xdata)
{
- nlc_conf_t *conf = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
- GF_VALIDATE_OR_GOTO (this->name, conf, out);
+ conf = this->private;
+ GF_VALIDATE_OR_GOTO(this->name, conf, out);
- if (!IS_PEC_ENABLED (conf))
- goto out;
+ if (!IS_PEC_ENABLED(conf))
+ goto out;
- if (op_ret < 0 && op_errno == ENOENT) {
- GF_ATOMIC_INC (conf->nlc_counter.getrealfilename_miss);
- }
+ if (op_ret < 0 && op_errno == ENOENT) {
+ GF_ATOMIC_INC(conf->nlc_counter.getrealfilename_miss);
+ }
out:
- NLC_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, xdata);
- return 0;
+ NLC_STACK_UNWIND(getxattr, frame, op_ret, op_errno, dict, xdata);
+ return 0;
}
-
static int32_t
-nlc_getxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, const char *key,
- dict_t *xdata)
+nlc_getxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, const char *key,
+ dict_t *xdata)
{
- int32_t op_ret = -1;
- int32_t op_errno = 0;
- dict_t *dict = NULL;
- nlc_local_t *local = NULL;
- gf_boolean_t hit = _gf_false;
- const char *fname = NULL;
- nlc_conf_t *conf = NULL;
-
- conf = this->private;
-
- if (!IS_PEC_ENABLED (conf))
- goto wind;
-
- if (!key || (strncmp (key, GF_XATTR_GET_REAL_FILENAME_KEY,
- SLEN (GF_XATTR_GET_REAL_FILENAME_KEY)) != 0))
- goto wind;
-
- local = nlc_local_init (frame, this, GF_FOP_GETXATTR, loc, NULL);
- if (!local)
- goto err;
-
- if (loc->inode && key) {
- dict = dict_new ();
- if (!dict)
- goto err;
-
- fname = key + SLEN (GF_XATTR_GET_REAL_FILENAME_KEY);
- hit = nlc_get_real_file_name (this, loc, fname, &op_ret,
- &op_errno, dict);
- if (hit)
- goto unwind;
- else
- dict_unref (dict);
- }
+ int32_t op_ret = -1;
+ int32_t op_errno = 0;
+ dict_t *dict = NULL;
+ nlc_local_t *local = NULL;
+ gf_boolean_t hit = _gf_false;
+ const char *fname = NULL;
+ nlc_conf_t *conf = NULL;
+
+ conf = this->private;
+
+ if (!IS_PEC_ENABLED(conf))
+ goto wind;
+
+ if (!key || (strncmp(key, GF_XATTR_GET_REAL_FILENAME_KEY,
+ SLEN(GF_XATTR_GET_REAL_FILENAME_KEY)) != 0))
+ goto wind;
+
+ local = nlc_local_init(frame, this, GF_FOP_GETXATTR, loc, NULL);
+ if (!local)
+ goto err;
+
+ if (loc->inode && key) {
+ dict = dict_new();
+ if (!dict)
+ goto err;
+
+ fname = key + SLEN(GF_XATTR_GET_REAL_FILENAME_KEY);
+ hit = nlc_get_real_file_name(this, loc, fname, &op_ret, &op_errno,
+ dict);
+ if (hit)
+ goto unwind;
+ else
+ dict_unref(dict);
+ }
- STACK_WIND (frame, nlc_getxattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->getxattr,
- loc, key, xdata);
- return 0;
+ STACK_WIND(frame, nlc_getxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->getxattr, loc, key, xdata);
+ return 0;
wind:
- STACK_WIND (frame, default_getxattr_cbk,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->getxattr,
- loc, key, xdata);
- return 0;
+ STACK_WIND(frame, default_getxattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->getxattr, loc, key, xdata);
+ return 0;
unwind:
- GF_ATOMIC_INC (conf->nlc_counter.getrealfilename_hit);
- NLC_STACK_UNWIND (getxattr, frame, op_ret, op_errno, dict, NULL);
- dict_unref (dict);
- return 0;
+ GF_ATOMIC_INC(conf->nlc_counter.getrealfilename_hit);
+ NLC_STACK_UNWIND(getxattr, frame, op_ret, op_errno, dict, NULL);
+ dict_unref(dict);
+ return 0;
err:
- NLC_STACK_UNWIND (getxattr, frame, -1, ENOMEM, NULL, NULL);
- return 0;
+ NLC_STACK_UNWIND(getxattr, frame, -1, ENOMEM, NULL, NULL);
+ return 0;
}
-
static int32_t
-nlc_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+nlc_symlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, inode_t *inode,
+ struct iatt *buf, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
{
- NLC_FOP_CBK (symlink, _gf_false, frame, cookie, this, op_ret, op_errno,
- inode, buf, preparent, postparent, xdata);
- return 0;
+ NLC_FOP_CBK(symlink, _gf_false, frame, cookie, this, op_ret, op_errno,
+ inode, buf, preparent, postparent, xdata);
+ return 0;
}
-
static int32_t
-nlc_symlink (call_frame_t *frame, xlator_t *this, const char *linkpath,
- loc_t *loc, mode_t umask, dict_t *xdata)
+nlc_symlink(call_frame_t *frame, xlator_t *this, const char *linkpath,
+ loc_t *loc, mode_t umask, dict_t *xdata)
{
- NLC_FOP (symlink, GF_FOP_SYMLINK, loc, NULL, frame, this, linkpath,
- loc, umask, xdata);
- return 0;
+ NLC_FOP(symlink, GF_FOP_SYMLINK, loc, NULL, frame, this, linkpath, loc,
+ umask, xdata);
+ return 0;
}
-
static int32_t
-nlc_link_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
- int32_t op_errno, inode_t *inode, struct iatt *buf,
- struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
+nlc_link_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- NLC_FOP_CBK (link, _gf_false, frame, cookie, this, op_ret, op_errno,
- inode, buf, preparent, postparent, xdata);
- return 0;
+ NLC_FOP_CBK(link, _gf_false, frame, cookie, this, op_ret, op_errno, inode,
+ buf, preparent, postparent, xdata);
+ return 0;
}
-
static int32_t
-nlc_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
- dict_t *xdata)
+nlc_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
{
- NLC_FOP (link, GF_FOP_LINK, oldloc, newloc, frame, this, oldloc,
- newloc, xdata);
- return 0;
+ NLC_FOP(link, GF_FOP_LINK, oldloc, newloc, frame, this, oldloc, newloc,
+ xdata);
+ return 0;
}
-
static int32_t
-nlc_unlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+nlc_unlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *preparent,
+ struct iatt *postparent, dict_t *xdata)
{
- uint32_t link_count = 0;
- gf_boolean_t multilink = _gf_false;
-
- if (xdata && !dict_get_uint32 (xdata, GET_LINK_COUNT, &link_count)) {
- if (link_count > 1)
- multilink = _gf_true;
- } else {
- /* Don't touch cache if we don't know enough */
- gf_msg (this->name, GF_LOG_WARNING, 0, NLC_MSG_DICT_FAILURE,
- "Failed to get GET_LINK_COUNT from dict");
- NLC_STACK_UNWIND (unlink, frame, op_ret, op_errno, preparent,
- postparent, xdata);
- return 0;
- }
-
- NLC_FOP_CBK (unlink, multilink, frame, cookie, this, op_ret, op_errno,
- preparent, postparent, xdata);
+ uint32_t link_count = 0;
+ gf_boolean_t multilink = _gf_false;
+
+ if (xdata && !dict_get_uint32(xdata, GET_LINK_COUNT, &link_count)) {
+ if (link_count > 1)
+ multilink = _gf_true;
+ } else {
+ /* Don't touch cache if we don't know enough */
+ gf_msg(this->name, GF_LOG_WARNING, 0, NLC_MSG_DICT_FAILURE,
+ "Failed to get GET_LINK_COUNT from dict");
+ NLC_STACK_UNWIND(unlink, frame, op_ret, op_errno, preparent, postparent,
+ xdata);
return 0;
-}
+ }
+ NLC_FOP_CBK(unlink, multilink, frame, cookie, this, op_ret, op_errno,
+ preparent, postparent, xdata);
+ return 0;
+}
static int32_t
-nlc_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- dict_t *xdata)
+nlc_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ dict_t *xdata)
{
- nlc_conf_t *conf = NULL;
- gf_boolean_t new_dict = _gf_false;
+ nlc_conf_t *conf = NULL;
+ gf_boolean_t new_dict = _gf_false;
- conf = this->private;
+ conf = this->private;
- if (!IS_PEC_ENABLED (conf))
- goto do_fop;
+ if (!IS_PEC_ENABLED(conf))
+ goto do_fop;
- if (!xdata) {
- xdata = dict_new ();
- if (xdata)
- new_dict = _gf_true;
- }
+ if (!xdata) {
+ xdata = dict_new();
+ if (xdata)
+ new_dict = _gf_true;
+ }
- if (xdata && dict_set_uint32 (xdata, GET_LINK_COUNT, 0)) {
- gf_msg (this->name, GF_LOG_WARNING, 0, NLC_MSG_DICT_FAILURE,
- "Failed to set GET_LINK_COUNT in dict");
- goto err;
- }
+ if (xdata && dict_set_uint32(xdata, GET_LINK_COUNT, 0)) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, NLC_MSG_DICT_FAILURE,
+ "Failed to set GET_LINK_COUNT in dict");
+ goto err;
+ }
do_fop:
- NLC_FOP (unlink, GF_FOP_UNLINK, loc, NULL, frame, this, loc, flags,
- xdata);
+ NLC_FOP(unlink, GF_FOP_UNLINK, loc, NULL, frame, this, loc, flags, xdata);
- if (new_dict)
- dict_unref (xdata);
- return 0;
+ if (new_dict)
+ dict_unref(xdata);
+ return 0;
}
-
static int32_t
-nlc_invalidate (xlator_t *this, void *data)
+nlc_invalidate(xlator_t *this, void *data)
{
- struct gf_upcall *up_data = NULL;
- struct gf_upcall_cache_invalidation *up_ci = NULL;
- inode_t *inode = NULL;
- inode_t *parent1 = NULL;
- inode_t *parent2 = NULL;
- int ret = 0;
- inode_table_t *itable = NULL;
- nlc_conf_t *conf = NULL;
-
- up_data = (struct gf_upcall *)data;
-
- if (up_data->event_type != GF_UPCALL_CACHE_INVALIDATION)
- goto out;
-
- conf = this->private;
- if (!conf)
- goto out;
-
- up_ci = (struct gf_upcall_cache_invalidation *)up_data->data;
-
- /*TODO: Add he inodes found as a member in gf_upcall_cache_invalidation
- * so that it prevents subsequent xlators from doing inode_find again
- */
- itable = ((xlator_t *)this->graph->top)->itable;
- inode = inode_find (itable, up_data->gfid);
- if (!inode) {
- ret = -1;
- goto out;
- }
-
- if ((!((up_ci->flags & UP_TIMES) && inode->ia_type == IA_IFDIR)) &&
- (!(up_ci->flags & UP_PARENT_DENTRY_FLAGS))) {
- goto out;
- }
-
- if (!gf_uuid_is_null (up_ci->p_stat.ia_gfid)) {
- parent1 = inode_find (itable, up_ci->p_stat.ia_gfid);
- if (!parent1) {
- ret = -1;
- goto out;
- }
+ struct gf_upcall *up_data = NULL;
+ struct gf_upcall_cache_invalidation *up_ci = NULL;
+ inode_t *inode = NULL;
+ inode_t *parent1 = NULL;
+ inode_t *parent2 = NULL;
+ int ret = 0;
+ inode_table_t *itable = NULL;
+ nlc_conf_t *conf = NULL;
+
+ up_data = (struct gf_upcall *)data;
+
+ if (up_data->event_type != GF_UPCALL_CACHE_INVALIDATION)
+ goto out;
+
+ conf = this->private;
+ if (!conf)
+ goto out;
+
+ up_ci = (struct gf_upcall_cache_invalidation *)up_data->data;
+
+ /*TODO: Add he inodes found as a member in gf_upcall_cache_invalidation
+ * so that it prevents subsequent xlators from doing inode_find again
+ */
+ itable = ((xlator_t *)this->graph->top)->itable;
+ inode = inode_find(itable, up_data->gfid);
+ if (!inode) {
+ ret = -1;
+ goto out;
+ }
+
+ if ((!((up_ci->flags & UP_TIMES) && inode->ia_type == IA_IFDIR)) &&
+ (!(up_ci->flags & UP_PARENT_DENTRY_FLAGS))) {
+ goto out;
+ }
+
+ if (!gf_uuid_is_null(up_ci->p_stat.ia_gfid)) {
+ parent1 = inode_find(itable, up_ci->p_stat.ia_gfid);
+ if (!parent1) {
+ ret = -1;
+ goto out;
}
+ }
- if (!gf_uuid_is_null (up_ci->oldp_stat.ia_gfid)) {
- parent2 = inode_find (itable, up_ci->oldp_stat.ia_gfid);
- if (!parent2) {
- ret = -1;
- goto out;
- }
+ if (!gf_uuid_is_null(up_ci->oldp_stat.ia_gfid)) {
+ parent2 = inode_find(itable, up_ci->oldp_stat.ia_gfid);
+ if (!parent2) {
+ ret = -1;
+ goto out;
}
+ }
- /* TODO: get enough data in upcall so that we do not invalidate but
- * update */
- if (inode && inode->ia_type == IA_IFDIR)
- nlc_inode_clear_cache (this, inode, NLC_NONE);
- if (parent1)
- nlc_inode_clear_cache (this, parent1, NLC_NONE);
- if (parent2)
- nlc_inode_clear_cache (this, parent2, NLC_NONE);
+ /* TODO: get enough data in upcall so that we do not invalidate but
+ * update */
+ if (inode && inode->ia_type == IA_IFDIR)
+ nlc_inode_clear_cache(this, inode, NLC_NONE);
+ if (parent1)
+ nlc_inode_clear_cache(this, parent1, NLC_NONE);
+ if (parent2)
+ nlc_inode_clear_cache(this, parent2, NLC_NONE);
- GF_ATOMIC_INC (conf->nlc_counter.nlc_invals);
+ GF_ATOMIC_INC(conf->nlc_counter.nlc_invals);
out:
- if (inode)
- inode_unref (inode);
- if (parent1)
- inode_unref (parent1);
- if (parent2)
- inode_unref (parent2);
-
- return ret;
+ if (inode)
+ inode_unref(inode);
+ if (parent1)
+ inode_unref(parent1);
+ if (parent2)
+ inode_unref(parent2);
+
+ return ret;
}
-
int
-nlc_notify (xlator_t *this, int event, void *data, ...)
+nlc_notify(xlator_t *this, int event, void *data, ...)
{
- int ret = 0;
- time_t now = 0;
+ int ret = 0;
+ time_t now = 0;
- switch (event) {
+ switch (event) {
case GF_EVENT_CHILD_DOWN:
case GF_EVENT_SOME_DESCENDENT_DOWN:
case GF_EVENT_CHILD_UP:
case GF_EVENT_SOME_DESCENDENT_UP:
- time (&now);
- nlc_update_child_down_time (this, &now);
- /* TODO: nlc_clear_all_cache (this); else
- lru prune will lazily clear it*/
- break;
+ time(&now);
+ nlc_update_child_down_time(this, &now);
+ /* TODO: nlc_clear_all_cache (this); else
+ lru prune will lazily clear it*/
+ break;
case GF_EVENT_UPCALL:
- ret = nlc_invalidate (this, data);
- break;
+ ret = nlc_invalidate(this, data);
+ break;
case GF_EVENT_PARENT_DOWN:
- nlc_disable_cache (this);
- nlc_clear_all_cache (this);
+ nlc_disable_cache(this);
+ nlc_clear_all_cache(this);
default:
- break;
- }
+ break;
+ }
- if (default_notify (this, event, data) != 0)
- ret = -1;
+ if (default_notify(this, event, data) != 0)
+ ret = -1;
- return ret;
+ return ret;
}
-
static int32_t
-nlc_forget (xlator_t *this, inode_t *inode)
+nlc_forget(xlator_t *this, inode_t *inode)
{
- uint64_t pe_int = 0;
- uint64_t nlc_ctx_int = 0;
- nlc_ctx_t *nlc_ctx = NULL;
- nlc_conf_t *conf = NULL;
-
- conf = this->private;
-
- inode_ctx_reset1 (inode, this, &pe_int);
- GF_ASSERT (pe_int == 0);
-
- nlc_inode_clear_cache (this, inode, NLC_NONE);
- inode_ctx_reset0 (inode, this, &nlc_ctx_int);
- nlc_ctx = (void *) (long) nlc_ctx_int;
- if (nlc_ctx) {
- GF_FREE (nlc_ctx);
- GF_ATOMIC_SUB (conf->current_cache_size, sizeof (*nlc_ctx));
- }
+ uint64_t pe_int = 0;
+ uint64_t nlc_ctx_int = 0;
+ nlc_ctx_t *nlc_ctx = NULL;
+ nlc_conf_t *conf = NULL;
- return 0;
-}
+ conf = this->private;
+
+ inode_ctx_reset1(inode, this, &pe_int);
+ GF_ASSERT(pe_int == 0);
+ nlc_inode_clear_cache(this, inode, NLC_NONE);
+ inode_ctx_reset0(inode, this, &nlc_ctx_int);
+ nlc_ctx = (void *)(long)nlc_ctx_int;
+ if (nlc_ctx) {
+ GF_FREE(nlc_ctx);
+ GF_ATOMIC_SUB(conf->current_cache_size, sizeof(*nlc_ctx));
+ }
+
+ return 0;
+}
static int32_t
-nlc_inodectx (xlator_t *this, inode_t *inode)
+nlc_inodectx(xlator_t *this, inode_t *inode)
{
- nlc_dump_inodectx (this, inode);
- return 0;
+ nlc_dump_inodectx(this, inode);
+ return 0;
}
-
static int32_t
-nlc_priv_dump (xlator_t *this)
+nlc_priv_dump(xlator_t *this)
{
- nlc_conf_t *conf = NULL;
- char key_prefix[GF_DUMP_MAX_BUF_LEN];
-
- conf = this->private;
-
- snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type, this->name);
- gf_proc_dump_add_section(key_prefix);
-
- gf_proc_dump_write("negative_lookup_hit_count", "%"PRId64,
- GF_ATOMIC_GET(conf->nlc_counter.nlc_hit));
- gf_proc_dump_write("negative_lookup_miss_count", "%"PRId64,
- GF_ATOMIC_GET(conf->nlc_counter.nlc_miss));
- gf_proc_dump_write("get_real_filename_hit_count", "%"PRId64,
- GF_ATOMIC_GET(conf->nlc_counter.getrealfilename_hit));
- gf_proc_dump_write("get_real_filename_miss_count", "%"PRId64,
- GF_ATOMIC_GET(conf->nlc_counter.getrealfilename_miss));
- gf_proc_dump_write("nameless_lookup_count", "%"PRId64,
- GF_ATOMIC_GET(conf->nlc_counter.nameless_lookup));
- gf_proc_dump_write("inodes_with_positive_dentry_cache", "%"PRId64,
- GF_ATOMIC_GET(conf->nlc_counter.pe_inode_cnt));
- gf_proc_dump_write("inodes_with_negative_dentry_cache", "%"PRId64,
- GF_ATOMIC_GET(conf->nlc_counter.ne_inode_cnt));
- gf_proc_dump_write("dentry_invalidations_recieved", "%"PRId64,
- GF_ATOMIC_GET(conf->nlc_counter.nlc_invals));
- gf_proc_dump_write("cache_limit", "%"PRIu64,
- conf->cache_size);
- gf_proc_dump_write("consumed_cache_size", "%"PRId64,
- GF_ATOMIC_GET(conf->current_cache_size));
- gf_proc_dump_write("inode_limit", "%"PRIu64,
- conf->inode_limit);
- gf_proc_dump_write("consumed_inodes", "%"PRId64,
- GF_ATOMIC_GET(conf->refd_inodes));
-
- return 0;
+ nlc_conf_t *conf = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
+
+ conf = this->private;
+
+ snprintf(key_prefix, GF_DUMP_MAX_BUF_LEN, "%s.%s", this->type, this->name);
+ gf_proc_dump_add_section(key_prefix);
+
+ gf_proc_dump_write("negative_lookup_hit_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->nlc_counter.nlc_hit));
+ gf_proc_dump_write("negative_lookup_miss_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->nlc_counter.nlc_miss));
+ gf_proc_dump_write("get_real_filename_hit_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->nlc_counter.getrealfilename_hit));
+ gf_proc_dump_write("get_real_filename_miss_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->nlc_counter.getrealfilename_miss));
+ gf_proc_dump_write("nameless_lookup_count", "%" PRId64,
+ GF_ATOMIC_GET(conf->nlc_counter.nameless_lookup));
+ gf_proc_dump_write("inodes_with_positive_dentry_cache", "%" PRId64,
+ GF_ATOMIC_GET(conf->nlc_counter.pe_inode_cnt));
+ gf_proc_dump_write("inodes_with_negative_dentry_cache", "%" PRId64,
+ GF_ATOMIC_GET(conf->nlc_counter.ne_inode_cnt));
+ gf_proc_dump_write("dentry_invalidations_recieved", "%" PRId64,
+ GF_ATOMIC_GET(conf->nlc_counter.nlc_invals));
+ gf_proc_dump_write("cache_limit", "%" PRIu64, conf->cache_size);
+ gf_proc_dump_write("consumed_cache_size", "%" PRId64,
+ GF_ATOMIC_GET(conf->current_cache_size));
+ gf_proc_dump_write("inode_limit", "%" PRIu64, conf->inode_limit);
+ gf_proc_dump_write("consumed_inodes", "%" PRId64,
+ GF_ATOMIC_GET(conf->refd_inodes));
+
+ return 0;
}
-
static int32_t
-nlc_dump_metrics (xlator_t *this, int fd)
+nlc_dump_metrics(xlator_t *this, int fd)
{
- nlc_conf_t *conf = NULL;
-
- conf = this->private;
-
- dprintf (fd, "%s.negative_lookup_hit_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->nlc_counter.nlc_hit));
- dprintf (fd, "%s.negative_lookup_miss_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->nlc_counter.nlc_miss));
- dprintf (fd, "%s.get_real_filename_hit_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->nlc_counter.getrealfilename_hit));
- dprintf (fd, "%s.get_real_filename_miss_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->nlc_counter.getrealfilename_miss));
- dprintf (fd, "%s.nameless_lookup_count %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->nlc_counter.nameless_lookup));
- dprintf (fd, "%s.inodes_with_positive_dentry_cache %"PRId64"\n",
- this->name,
- GF_ATOMIC_GET(conf->nlc_counter.pe_inode_cnt));
- dprintf (fd, "%s.inodes_with_negative_dentry_cache %"PRId64"\n",
- this->name, GF_ATOMIC_GET(conf->nlc_counter.ne_inode_cnt));
- dprintf (fd, "%s.dentry_invalidations_recieved %"PRId64"\n",
- this->name, GF_ATOMIC_GET(conf->nlc_counter.nlc_invals));
- dprintf (fd, "%s.cache_limit %"PRIu64"\n", this->name,
- conf->cache_size);
- dprintf (fd, "%s.consumed_cache_size %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->current_cache_size));
- dprintf (fd, "%s.inode_limit %"PRIu64"\n", this->name,
- conf->inode_limit);
- dprintf (fd, "%s.consumed_inodes %"PRId64"\n", this->name,
- GF_ATOMIC_GET(conf->refd_inodes));
-
- return 0;
+ nlc_conf_t *conf = NULL;
+
+ conf = this->private;
+
+ dprintf(fd, "%s.negative_lookup_hit_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->nlc_counter.nlc_hit));
+ dprintf(fd, "%s.negative_lookup_miss_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->nlc_counter.nlc_miss));
+ dprintf(fd, "%s.get_real_filename_hit_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->nlc_counter.getrealfilename_hit));
+ dprintf(fd, "%s.get_real_filename_miss_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->nlc_counter.getrealfilename_miss));
+ dprintf(fd, "%s.nameless_lookup_count %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->nlc_counter.nameless_lookup));
+ dprintf(fd, "%s.inodes_with_positive_dentry_cache %" PRId64 "\n",
+ this->name, GF_ATOMIC_GET(conf->nlc_counter.pe_inode_cnt));
+ dprintf(fd, "%s.inodes_with_negative_dentry_cache %" PRId64 "\n",
+ this->name, GF_ATOMIC_GET(conf->nlc_counter.ne_inode_cnt));
+ dprintf(fd, "%s.dentry_invalidations_recieved %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->nlc_counter.nlc_invals));
+ dprintf(fd, "%s.cache_limit %" PRIu64 "\n", this->name, conf->cache_size);
+ dprintf(fd, "%s.consumed_cache_size %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->current_cache_size));
+ dprintf(fd, "%s.inode_limit %" PRIu64 "\n", this->name, conf->inode_limit);
+ dprintf(fd, "%s.consumed_inodes %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(conf->refd_inodes));
+
+ return 0;
}
-
void
-nlc_fini (xlator_t *this)
+nlc_fini(xlator_t *this)
{
- nlc_conf_t *conf = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
- GF_FREE (conf);
+ conf = this->private;
+ GF_FREE(conf);
- glusterfs_ctx_tw_put (this->ctx);
+ glusterfs_ctx_tw_put(this->ctx);
- return;
+ return;
}
-
int32_t
-nlc_mem_acct_init (xlator_t *this)
+nlc_mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- ret = xlator_mem_acct_init (this, gf_nlc_mt_end + 1);
- return ret;
+ ret = xlator_mem_acct_init(this, gf_nlc_mt_end + 1);
+ return ret;
}
-
int32_t
-nlc_reconfigure (xlator_t *this, dict_t *options)
+nlc_reconfigure(xlator_t *this, dict_t *options)
{
- nlc_conf_t *conf = NULL;
+ nlc_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- GF_OPTION_RECONF ("nl-cache-timeout", conf->cache_timeout, options,
- int32, out);
- GF_OPTION_RECONF ("nl-cache-positive-entry", conf->positive_entry_cache,
- options, bool, out);
- GF_OPTION_RECONF ("nl-cache-limit", conf->cache_size, options,
- size_uint64, out);
- GF_OPTION_RECONF ("pass-through", this->pass_through, options, bool,
- out);
+ GF_OPTION_RECONF("nl-cache-timeout", conf->cache_timeout, options, int32,
+ out);
+ GF_OPTION_RECONF("nl-cache-positive-entry", conf->positive_entry_cache,
+ options, bool, out);
+ GF_OPTION_RECONF("nl-cache-limit", conf->cache_size, options, size_uint64,
+ out);
+ GF_OPTION_RECONF("pass-through", this->pass_through, options, bool, out);
out:
- return 0;
+ return 0;
}
-
int32_t
-nlc_init (xlator_t *this)
+nlc_init(xlator_t *this)
{
- nlc_conf_t *conf = NULL;
- int ret = -1;
- inode_table_t *itable = NULL;
-
- conf = GF_CALLOC (sizeof (*conf), 1, gf_nlc_mt_nlc_conf_t);
- if (!conf)
- goto out;
-
- GF_OPTION_INIT ("nl-cache-timeout", conf->cache_timeout, int32, out);
- GF_OPTION_INIT ("nl-cache-positive-entry", conf->positive_entry_cache,
- bool, out);
- GF_OPTION_INIT ("nl-cache-limit", conf->cache_size, size_uint64, out);
- GF_OPTION_INIT ("pass-through", this->pass_through, bool, out);
-
- /* Since the positive entries are stored as list of refs on
- * existing inodes, we should not overflow the inode lru_limit.
- * Hence keep the limit of inodes that are refed by this xlator,
- * to 80% of inode_table->lru_limit. In fuse where the limit is
- * infinite, take 131072 as lru limit (as in gfapi). */
- itable = ((xlator_t *)this->graph->top)->itable;
- if (itable && itable->lru_limit)
- conf->inode_limit = itable->lru_limit * 80 / 100;
- else
- conf->inode_limit = 131072 * 80 / 100;
-
- LOCK_INIT (&conf->lock);
- GF_ATOMIC_INIT (conf->current_cache_size, 0);
- GF_ATOMIC_INIT (conf->refd_inodes, 0);
- GF_ATOMIC_INIT (conf->nlc_counter.nlc_hit, 0);
- GF_ATOMIC_INIT (conf->nlc_counter.nlc_miss, 0);
- GF_ATOMIC_INIT (conf->nlc_counter.nameless_lookup, 0);
- GF_ATOMIC_INIT (conf->nlc_counter.getrealfilename_hit, 0);
- GF_ATOMIC_INIT (conf->nlc_counter.getrealfilename_miss, 0);
- GF_ATOMIC_INIT (conf->nlc_counter.pe_inode_cnt, 0);
- GF_ATOMIC_INIT (conf->nlc_counter.ne_inode_cnt, 0);
- GF_ATOMIC_INIT (conf->nlc_counter.nlc_invals, 0);
-
- INIT_LIST_HEAD (&conf->lru);
- time (&conf->last_child_down);
-
- conf->timer_wheel = glusterfs_ctx_tw_get (this->ctx);
- if (!conf->timer_wheel) {
- gf_msg (this->name, GF_LOG_ERROR, 0, NLC_MSG_NO_TIMER_WHEEL,
- "Initing the global timer wheel failed");
- goto out;
- }
-
- this->private = conf;
-
- ret = 0;
+ nlc_conf_t *conf = NULL;
+ int ret = -1;
+ inode_table_t *itable = NULL;
+
+ conf = GF_CALLOC(sizeof(*conf), 1, gf_nlc_mt_nlc_conf_t);
+ if (!conf)
+ goto out;
+
+ GF_OPTION_INIT("nl-cache-timeout", conf->cache_timeout, int32, out);
+ GF_OPTION_INIT("nl-cache-positive-entry", conf->positive_entry_cache, bool,
+ out);
+ GF_OPTION_INIT("nl-cache-limit", conf->cache_size, size_uint64, out);
+ GF_OPTION_INIT("pass-through", this->pass_through, bool, out);
+
+ /* Since the positive entries are stored as list of refs on
+ * existing inodes, we should not overflow the inode lru_limit.
+ * Hence keep the limit of inodes that are refed by this xlator,
+ * to 80% of inode_table->lru_limit. In fuse where the limit is
+ * infinite, take 131072 as lru limit (as in gfapi). */
+ itable = ((xlator_t *)this->graph->top)->itable;
+ if (itable && itable->lru_limit)
+ conf->inode_limit = itable->lru_limit * 80 / 100;
+ else
+ conf->inode_limit = 131072 * 80 / 100;
+
+ LOCK_INIT(&conf->lock);
+ GF_ATOMIC_INIT(conf->current_cache_size, 0);
+ GF_ATOMIC_INIT(conf->refd_inodes, 0);
+ GF_ATOMIC_INIT(conf->nlc_counter.nlc_hit, 0);
+ GF_ATOMIC_INIT(conf->nlc_counter.nlc_miss, 0);
+ GF_ATOMIC_INIT(conf->nlc_counter.nameless_lookup, 0);
+ GF_ATOMIC_INIT(conf->nlc_counter.getrealfilename_hit, 0);
+ GF_ATOMIC_INIT(conf->nlc_counter.getrealfilename_miss, 0);
+ GF_ATOMIC_INIT(conf->nlc_counter.pe_inode_cnt, 0);
+ GF_ATOMIC_INIT(conf->nlc_counter.ne_inode_cnt, 0);
+ GF_ATOMIC_INIT(conf->nlc_counter.nlc_invals, 0);
+
+ INIT_LIST_HEAD(&conf->lru);
+ time(&conf->last_child_down);
+
+ conf->timer_wheel = glusterfs_ctx_tw_get(this->ctx);
+ if (!conf->timer_wheel) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, NLC_MSG_NO_TIMER_WHEEL,
+ "Initing the global timer wheel failed");
+ goto out;
+ }
+
+ this->private = conf;
+
+ ret = 0;
out:
- if (ret < 0)
- GF_FREE (conf);
+ if (ret < 0)
+ GF_FREE(conf);
- return ret;
+ return ret;
}
-
struct xlator_fops nlc_fops = {
- .rename = nlc_rename,
- .mknod = nlc_mknod,
- .create = nlc_create,
- .mkdir = nlc_mkdir,
- .lookup = nlc_lookup,
- .rmdir = nlc_rmdir,
- .getxattr = nlc_getxattr,
- .symlink = nlc_symlink,
- .link = nlc_link,
- .unlink = nlc_unlink,
- /* TODO:
- .readdir = nlc_readdir,
- .readdirp = nlc_readdirp,
- .seek = nlc_seek,
- .opendir = nlc_opendir, */
+ .rename = nlc_rename,
+ .mknod = nlc_mknod,
+ .create = nlc_create,
+ .mkdir = nlc_mkdir,
+ .lookup = nlc_lookup,
+ .rmdir = nlc_rmdir,
+ .getxattr = nlc_getxattr,
+ .symlink = nlc_symlink,
+ .link = nlc_link,
+ .unlink = nlc_unlink,
+ /* TODO:
+ .readdir = nlc_readdir,
+ .readdirp = nlc_readdirp,
+ .seek = nlc_seek,
+ .opendir = nlc_opendir, */
};
-
struct xlator_cbks nlc_cbks = {
- .forget = nlc_forget,
+ .forget = nlc_forget,
};
-
struct xlator_dumpops nlc_dumpops = {
- .inodectx = nlc_inodectx,
- .priv = nlc_priv_dump,
+ .inodectx = nlc_inodectx,
+ .priv = nlc_priv_dump,
};
struct volume_options nlc_options[] = {
- { .key = {"nl-cache-positive-entry"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_3_11_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Cache the name of the files/directories that was"
- " looked up and are present in a directory",
- },
- { .key = {"nl-cache-limit"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 0,
- .default_value = "131072",
- .op_version = {GD_OP_VERSION_3_11_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "the value over which caching will be disabled for"
- "a while and the cache is cleared based on LRU",
- },
- { .key = {"nl-cache-timeout"},
- .type = GF_OPTION_TYPE_TIME,
- .min = 0,
- .default_value = "60",
- .op_version = {GD_OP_VERSION_3_11_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .description = "Time period after which cache has to be refreshed",
- },
- { .key = {"pass-through"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"nl-cache"},
- .description = "Enable/Disable nl cache translator"
- },
-
- { .key = {NULL} },
+ {
+ .key = {"nl-cache-positive-entry"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_3_11_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Cache the name of the files/directories that was"
+ " looked up and are present in a directory",
+ },
+ {
+ .key = {"nl-cache-limit"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 0,
+ .default_value = "131072",
+ .op_version = {GD_OP_VERSION_3_11_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "the value over which caching will be disabled for"
+ "a while and the cache is cleared based on LRU",
+ },
+ {
+ .key = {"nl-cache-timeout"},
+ .type = GF_OPTION_TYPE_TIME,
+ .min = 0,
+ .default_value = "60",
+ .op_version = {GD_OP_VERSION_3_11_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .description = "Time period after which cache has to be refreshed",
+ },
+ {.key = {"pass-through"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"nl-cache"},
+ .description = "Enable/Disable nl cache translator"},
+
+ {.key = {NULL}},
};
xlator_api_t xlator_api = {
- .init = nlc_init,
- .fini = nlc_fini,
- .notify = nlc_notify,
- .reconfigure = nlc_reconfigure,
- .mem_acct_init = nlc_mem_acct_init,
- .dump_metrics = nlc_dump_metrics,
- .op_version = {1}, /* Present from the initial version */
- .dumpops = &nlc_dumpops,
- .fops = &nlc_fops,
- .cbks = &nlc_cbks,
- .options = nlc_options,
- .identifier = "nl-cache",
- .category = GF_TECH_PREVIEW,
+ .init = nlc_init,
+ .fini = nlc_fini,
+ .notify = nlc_notify,
+ .reconfigure = nlc_reconfigure,
+ .mem_acct_init = nlc_mem_acct_init,
+ .dump_metrics = nlc_dump_metrics,
+ .op_version = {1}, /* Present from the initial version */
+ .dumpops = &nlc_dumpops,
+ .fops = &nlc_fops,
+ .cbks = &nlc_cbks,
+ .options = nlc_options,
+ .identifier = "nl-cache",
+ .category = GF_TECH_PREVIEW,
};
diff --git a/xlators/performance/open-behind/src/open-behind.c b/xlators/performance/open-behind/src/open-behind.c
index ec2be508bda..c8f818717ef 100644
--- a/xlators/performance/open-behind/src/open-behind.c
+++ b/xlators/performance/open-behind/src/open-behind.c
@@ -17,1363 +17,1335 @@
#include "glusterfs-acl.h"
typedef struct ob_conf {
- gf_boolean_t use_anonymous_fd; /* use anonymous FDs wherever safe
- e.g - fstat() readv()
-
- whereas for fops like writev(), lk(),
- the fd is important for side effects
- like mandatory locks
- */
- gf_boolean_t lazy_open; /* delay backend open as much as possible */
- gf_boolean_t read_after_open; /* instead of sending readvs on
- anonymous fds, open the file
- first and then send readv i.e
- similar to what writev does
- */
+ gf_boolean_t use_anonymous_fd; /* use anonymous FDs wherever safe
+ e.g - fstat() readv()
+
+ whereas for fops like writev(), lk(),
+ the fd is important for side effects
+ like mandatory locks
+ */
+ gf_boolean_t lazy_open; /* delay backend open as much as possible */
+ gf_boolean_t read_after_open; /* instead of sending readvs on
+ anonymous fds, open the file
+ first and then send readv i.e
+ similar to what writev does
+ */
} ob_conf_t;
typedef struct ob_inode {
- inode_t *inode;
- struct list_head resume_fops;
- struct list_head ob_fds;
- int count;
- int op_ret;
- int op_errno;
- gf_boolean_t open_in_progress;
- int unlinked;
+ inode_t *inode;
+ struct list_head resume_fops;
+ struct list_head ob_fds;
+ int count;
+ int op_ret;
+ int op_errno;
+ gf_boolean_t open_in_progress;
+ int unlinked;
} ob_inode_t;
typedef struct ob_fd {
- call_frame_t *open_frame;
- loc_t loc;
- dict_t *xdata;
- int flags;
- int op_errno;
- ob_inode_t *ob_inode;
- fd_t *fd;
- gf_boolean_t opened;
- gf_boolean_t ob_inode_fops_waiting;
- struct list_head list;
- struct list_head ob_fds_on_inode;
+ call_frame_t *open_frame;
+ loc_t loc;
+ dict_t *xdata;
+ int flags;
+ int op_errno;
+ ob_inode_t *ob_inode;
+ fd_t *fd;
+ gf_boolean_t opened;
+ gf_boolean_t ob_inode_fops_waiting;
+ struct list_head list;
+ struct list_head ob_fds_on_inode;
} ob_fd_t;
ob_inode_t *
-ob_inode_alloc (inode_t *inode)
+ob_inode_alloc(inode_t *inode)
{
- ob_inode_t *ob_inode = NULL;
+ ob_inode_t *ob_inode = NULL;
- ob_inode = GF_CALLOC (1, sizeof (*ob_inode), gf_ob_mt_inode_t);
- if (ob_inode == NULL)
- goto out;
+ ob_inode = GF_CALLOC(1, sizeof(*ob_inode), gf_ob_mt_inode_t);
+ if (ob_inode == NULL)
+ goto out;
- ob_inode->inode = inode;
- INIT_LIST_HEAD (&ob_inode->resume_fops);
- INIT_LIST_HEAD (&ob_inode->ob_fds);
+ ob_inode->inode = inode;
+ INIT_LIST_HEAD(&ob_inode->resume_fops);
+ INIT_LIST_HEAD(&ob_inode->ob_fds);
out:
- return ob_inode;
+ return ob_inode;
}
void
-ob_inode_free (ob_inode_t *ob_inode)
+ob_inode_free(ob_inode_t *ob_inode)
{
- if (ob_inode == NULL)
- goto out;
+ if (ob_inode == NULL)
+ goto out;
- list_del_init (&ob_inode->resume_fops);
- list_del_init (&ob_inode->ob_fds);
+ list_del_init(&ob_inode->resume_fops);
+ list_del_init(&ob_inode->ob_fds);
- GF_FREE (ob_inode);
+ GF_FREE(ob_inode);
out:
- return;
+ return;
}
ob_inode_t *
-ob_inode_get (xlator_t *this, inode_t *inode)
+ob_inode_get(xlator_t *this, inode_t *inode)
{
- ob_inode_t *ob_inode = NULL;
- uint64_t value = 0;
- int ret = 0;
-
- if (!inode)
- goto out;
-
- LOCK (&inode->lock);
- {
- __inode_ctx_get (inode, this, &value);
- if (value == 0) {
- ob_inode = ob_inode_alloc (inode);
- if (ob_inode == NULL)
- goto unlock;
-
- value = (uint64_t)((void *)ob_inode);
- ret = __inode_ctx_set (inode, this, &value);
- if (ret < 0) {
- ob_inode_free (ob_inode);
- ob_inode = NULL;
- }
- } else {
- ob_inode = (ob_inode_t *) value;
- }
+ ob_inode_t *ob_inode = NULL;
+ uint64_t value = 0;
+ int ret = 0;
+
+ if (!inode)
+ goto out;
+
+ LOCK(&inode->lock);
+ {
+ __inode_ctx_get(inode, this, &value);
+ if (value == 0) {
+ ob_inode = ob_inode_alloc(inode);
+ if (ob_inode == NULL)
+ goto unlock;
+
+ value = (uint64_t)((void *)ob_inode);
+ ret = __inode_ctx_set(inode, this, &value);
+ if (ret < 0) {
+ ob_inode_free(ob_inode);
+ ob_inode = NULL;
+ }
+ } else {
+ ob_inode = (ob_inode_t *)value;
}
+ }
unlock:
- UNLOCK (&inode->lock);
+ UNLOCK(&inode->lock);
out:
- return ob_inode;
+ return ob_inode;
}
-
ob_fd_t *
-__ob_fd_ctx_get (xlator_t *this, fd_t *fd)
+__ob_fd_ctx_get(xlator_t *this, fd_t *fd)
{
- uint64_t value = 0;
- int ret = -1;
- ob_fd_t *ob_fd = NULL;
+ uint64_t value = 0;
+ int ret = -1;
+ ob_fd_t *ob_fd = NULL;
- ret = __fd_ctx_get (fd, this, &value);
- if (ret)
- return NULL;
+ ret = __fd_ctx_get(fd, this, &value);
+ if (ret)
+ return NULL;
- ob_fd = (void *) ((long) value);
+ ob_fd = (void *)((long)value);
- return ob_fd;
+ return ob_fd;
}
-
ob_fd_t *
-ob_fd_ctx_get (xlator_t *this, fd_t *fd)
+ob_fd_ctx_get(xlator_t *this, fd_t *fd)
{
- ob_fd_t *ob_fd = NULL;
+ ob_fd_t *ob_fd = NULL;
- LOCK (&fd->lock);
- {
- ob_fd = __ob_fd_ctx_get (this, fd);
- }
- UNLOCK (&fd->lock);
+ LOCK(&fd->lock);
+ {
+ ob_fd = __ob_fd_ctx_get(this, fd);
+ }
+ UNLOCK(&fd->lock);
- return ob_fd;
+ return ob_fd;
}
-
int
-__ob_fd_ctx_set (xlator_t *this, fd_t *fd, ob_fd_t *ob_fd)
+__ob_fd_ctx_set(xlator_t *this, fd_t *fd, ob_fd_t *ob_fd)
{
- uint64_t value = 0;
- int ret = -1;
+ uint64_t value = 0;
+ int ret = -1;
- value = (long) ((void *) ob_fd);
+ value = (long)((void *)ob_fd);
- ret = __fd_ctx_set (fd, this, value);
+ ret = __fd_ctx_set(fd, this, value);
- return ret;
+ return ret;
}
-
int
-ob_fd_ctx_set (xlator_t *this, fd_t *fd, ob_fd_t *ob_fd)
+ob_fd_ctx_set(xlator_t *this, fd_t *fd, ob_fd_t *ob_fd)
{
- int ret = -1;
+ int ret = -1;
- LOCK (&fd->lock);
- {
- ret = __ob_fd_ctx_set (this, fd, ob_fd);
- }
- UNLOCK (&fd->lock);
+ LOCK(&fd->lock);
+ {
+ ret = __ob_fd_ctx_set(this, fd, ob_fd);
+ }
+ UNLOCK(&fd->lock);
- return ret;
+ return ret;
}
-
ob_fd_t *
-ob_fd_new (void)
+ob_fd_new(void)
{
- ob_fd_t *ob_fd = NULL;
+ ob_fd_t *ob_fd = NULL;
- ob_fd = GF_CALLOC (1, sizeof (*ob_fd), gf_ob_mt_fd_t);
+ ob_fd = GF_CALLOC(1, sizeof(*ob_fd), gf_ob_mt_fd_t);
- INIT_LIST_HEAD (&ob_fd->list);
- INIT_LIST_HEAD (&ob_fd->ob_fds_on_inode);
+ INIT_LIST_HEAD(&ob_fd->list);
+ INIT_LIST_HEAD(&ob_fd->ob_fds_on_inode);
- return ob_fd;
+ return ob_fd;
}
-
void
-ob_fd_free (ob_fd_t *ob_fd)
+ob_fd_free(ob_fd_t *ob_fd)
{
- LOCK (&ob_fd->fd->inode->lock);
- {
- list_del_init (&ob_fd->ob_fds_on_inode);
- }
- UNLOCK (&ob_fd->fd->inode->lock);
+ LOCK(&ob_fd->fd->inode->lock);
+ {
+ list_del_init(&ob_fd->ob_fds_on_inode);
+ }
+ UNLOCK(&ob_fd->fd->inode->lock);
- loc_wipe (&ob_fd->loc);
+ loc_wipe(&ob_fd->loc);
- if (ob_fd->xdata)
- dict_unref (ob_fd->xdata);
+ if (ob_fd->xdata)
+ dict_unref(ob_fd->xdata);
- if (ob_fd->open_frame)
- STACK_DESTROY (ob_fd->open_frame->root);
+ if (ob_fd->open_frame)
+ STACK_DESTROY(ob_fd->open_frame->root);
- GF_FREE (ob_fd);
+ GF_FREE(ob_fd);
}
-
int
-ob_wake_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, fd_t *fd_ret, dict_t *xdata)
+ob_wake_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
+ int op_errno, fd_t *fd_ret, dict_t *xdata)
{
- fd_t *fd = NULL;
- int count = 0;
- int ob_inode_op_ret = 0;
- int ob_inode_op_errno = 0;
- ob_fd_t *ob_fd = NULL;
- call_stub_t *stub = NULL, *tmp = NULL;
- ob_inode_t *ob_inode = NULL;
- gf_boolean_t ob_inode_fops_waiting = _gf_false;
- struct list_head fops_waiting_on_fd, fops_waiting_on_inode;
-
- fd = frame->local;
- frame->local = NULL;
-
- INIT_LIST_HEAD (&fops_waiting_on_fd);
- INIT_LIST_HEAD (&fops_waiting_on_inode);
-
- ob_inode = ob_inode_get (this, fd->inode);
-
- LOCK (&fd->lock);
- {
- ob_fd = __ob_fd_ctx_get (this, fd);
- ob_fd->opened = _gf_true;
-
- ob_inode_fops_waiting = ob_fd->ob_inode_fops_waiting;
-
- list_splice_init (&ob_fd->list, &fops_waiting_on_fd);
-
- if (op_ret < 0) {
- /* mark fd BAD for ever */
- ob_fd->op_errno = op_errno;
- ob_fd = NULL; /*shouldn't be freed*/
- } else {
- __fd_ctx_del (fd, this, NULL);
- }
- }
- UNLOCK (&fd->lock);
-
- if (ob_inode_fops_waiting) {
- LOCK (&fd->inode->lock);
- {
- count = --ob_inode->count;
- if (op_ret < 0) {
- /* TODO: when to reset the error? */
- ob_inode->op_ret = -1;
- ob_inode->op_errno = op_errno;
- }
-
- if (count == 0) {
- ob_inode->open_in_progress = _gf_false;
- ob_inode_op_ret = ob_inode->op_ret;
- ob_inode_op_errno = ob_inode->op_errno;
- list_splice_init (&ob_inode->resume_fops,
- &fops_waiting_on_inode);
- }
- }
- UNLOCK (&fd->inode->lock);
- }
+ fd_t *fd = NULL;
+ int count = 0;
+ int ob_inode_op_ret = 0;
+ int ob_inode_op_errno = 0;
+ ob_fd_t *ob_fd = NULL;
+ call_stub_t *stub = NULL, *tmp = NULL;
+ ob_inode_t *ob_inode = NULL;
+ gf_boolean_t ob_inode_fops_waiting = _gf_false;
+ struct list_head fops_waiting_on_fd, fops_waiting_on_inode;
+
+ fd = frame->local;
+ frame->local = NULL;
- if (ob_fd)
- ob_fd_free (ob_fd);
+ INIT_LIST_HEAD(&fops_waiting_on_fd);
+ INIT_LIST_HEAD(&fops_waiting_on_inode);
- list_for_each_entry_safe (stub, tmp, &fops_waiting_on_fd, list) {
- list_del_init (&stub->list);
+ ob_inode = ob_inode_get(this, fd->inode);
- if (op_ret < 0)
- call_unwind_error (stub, -1, op_errno);
- else
- call_resume (stub);
- }
+ LOCK(&fd->lock);
+ {
+ ob_fd = __ob_fd_ctx_get(this, fd);
+ ob_fd->opened = _gf_true;
- list_for_each_entry_safe (stub, tmp, &fops_waiting_on_inode, list) {
- list_del_init (&stub->list);
+ ob_inode_fops_waiting = ob_fd->ob_inode_fops_waiting;
- if (ob_inode_op_ret < 0)
- call_unwind_error (stub, -1, ob_inode_op_errno);
- else
- call_resume (stub);
+ list_splice_init(&ob_fd->list, &fops_waiting_on_fd);
+
+ if (op_ret < 0) {
+ /* mark fd BAD for ever */
+ ob_fd->op_errno = op_errno;
+ ob_fd = NULL; /*shouldn't be freed*/
+ } else {
+ __fd_ctx_del(fd, this, NULL);
}
+ }
+ UNLOCK(&fd->lock);
- fd_unref (fd);
+ if (ob_inode_fops_waiting) {
+ LOCK(&fd->inode->lock);
+ {
+ count = --ob_inode->count;
+ if (op_ret < 0) {
+ /* TODO: when to reset the error? */
+ ob_inode->op_ret = -1;
+ ob_inode->op_errno = op_errno;
+ }
+
+ if (count == 0) {
+ ob_inode->open_in_progress = _gf_false;
+ ob_inode_op_ret = ob_inode->op_ret;
+ ob_inode_op_errno = ob_inode->op_errno;
+ list_splice_init(&ob_inode->resume_fops,
+ &fops_waiting_on_inode);
+ }
+ }
+ UNLOCK(&fd->inode->lock);
+ }
- STACK_DESTROY (frame->root);
+ if (ob_fd)
+ ob_fd_free(ob_fd);
- return 0;
-}
+ list_for_each_entry_safe(stub, tmp, &fops_waiting_on_fd, list)
+ {
+ list_del_init(&stub->list);
+
+ if (op_ret < 0)
+ call_unwind_error(stub, -1, op_errno);
+ else
+ call_resume(stub);
+ }
+
+ list_for_each_entry_safe(stub, tmp, &fops_waiting_on_inode, list)
+ {
+ list_del_init(&stub->list);
+
+ if (ob_inode_op_ret < 0)
+ call_unwind_error(stub, -1, ob_inode_op_errno);
+ else
+ call_resume(stub);
+ }
+
+ fd_unref(fd);
+ STACK_DESTROY(frame->root);
+
+ return 0;
+}
int
-ob_fd_wake (xlator_t *this, fd_t *fd, ob_fd_t *ob_fd)
+ob_fd_wake(xlator_t *this, fd_t *fd, ob_fd_t *ob_fd)
{
- call_frame_t *frame = NULL;
+ call_frame_t *frame = NULL;
- if (ob_fd == NULL) {
- LOCK (&fd->lock);
- {
- ob_fd = __ob_fd_ctx_get (this, fd);
- if (!ob_fd)
- goto unlock;
+ if (ob_fd == NULL) {
+ LOCK(&fd->lock);
+ {
+ ob_fd = __ob_fd_ctx_get(this, fd);
+ if (!ob_fd)
+ goto unlock;
- frame = ob_fd->open_frame;
- ob_fd->open_frame = NULL;
- }
- unlock:
- UNLOCK (&fd->lock);
- } else {
- LOCK (&fd->lock);
- {
- frame = ob_fd->open_frame;
- ob_fd->open_frame = NULL;
- }
- UNLOCK (&fd->lock);
+ frame = ob_fd->open_frame;
+ ob_fd->open_frame = NULL;
}
+ unlock:
+ UNLOCK(&fd->lock);
+ } else {
+ LOCK(&fd->lock);
+ {
+ frame = ob_fd->open_frame;
+ ob_fd->open_frame = NULL;
+ }
+ UNLOCK(&fd->lock);
+ }
- if (frame) {
- frame->local = fd_ref (fd);
+ if (frame) {
+ frame->local = fd_ref(fd);
- STACK_WIND (frame, ob_wake_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->open,
- &ob_fd->loc, ob_fd->flags, fd, ob_fd->xdata);
- }
+ STACK_WIND(frame, ob_wake_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open, &ob_fd->loc, ob_fd->flags, fd,
+ ob_fd->xdata);
+ }
- return 0;
+ return 0;
}
void
-ob_inode_wake (xlator_t *this, struct list_head *ob_fds)
+ob_inode_wake(xlator_t *this, struct list_head *ob_fds)
{
- ob_fd_t *ob_fd = NULL, *tmp = NULL;
- fd_t *fd = NULL;
-
- list_for_each_entry_safe (ob_fd, tmp, ob_fds, ob_fds_on_inode) {
- ob_fd_wake (this, ob_fd->fd, ob_fd);
- fd = ob_fd->fd;
- ob_fd_free (ob_fd);
- fd_unref (fd);
- }
+ ob_fd_t *ob_fd = NULL, *tmp = NULL;
+ fd_t *fd = NULL;
+
+ list_for_each_entry_safe(ob_fd, tmp, ob_fds, ob_fds_on_inode)
+ {
+ ob_fd_wake(this, ob_fd->fd, ob_fd);
+ fd = ob_fd->fd;
+ ob_fd_free(ob_fd);
+ fd_unref(fd);
+ }
}
/* called holding inode->lock and fd->lock */
void
-ob_fd_copy (ob_fd_t *src, ob_fd_t *dst)
+ob_fd_copy(ob_fd_t *src, ob_fd_t *dst)
{
- if (!src || !dst)
- goto out;
-
- dst->fd = __fd_ref (src->fd);
- dst->loc.inode = inode_ref (src->loc.inode);
- gf_uuid_copy (dst->loc.gfid, src->loc.gfid);
- dst->flags = src->flags;
- dst->xdata = dict_ref (src->xdata);
- dst->ob_inode = src->ob_inode;
+ if (!src || !dst)
+ goto out;
+
+ dst->fd = __fd_ref(src->fd);
+ dst->loc.inode = inode_ref(src->loc.inode);
+ gf_uuid_copy(dst->loc.gfid, src->loc.gfid);
+ dst->flags = src->flags;
+ dst->xdata = dict_ref(src->xdata);
+ dst->ob_inode = src->ob_inode;
out:
- return;
+ return;
}
int
-open_all_pending_fds_and_resume (xlator_t *this, inode_t *inode,
- call_stub_t *stub)
+open_all_pending_fds_and_resume(xlator_t *this, inode_t *inode,
+ call_stub_t *stub)
{
- ob_inode_t *ob_inode = NULL;
- ob_fd_t *ob_fd = NULL, *tmp = NULL;
- gf_boolean_t was_open_in_progress = _gf_false;
- gf_boolean_t wait_for_open = _gf_false;
- struct list_head ob_fds = {0, };
-
- ob_inode = ob_inode_get (this, inode);
- if (ob_inode == NULL)
- goto out;
-
- INIT_LIST_HEAD (&ob_fds);
+ ob_inode_t *ob_inode = NULL;
+ ob_fd_t *ob_fd = NULL, *tmp = NULL;
+ gf_boolean_t was_open_in_progress = _gf_false;
+ gf_boolean_t wait_for_open = _gf_false;
+ struct list_head ob_fds = {
+ 0,
+ };
+
+ ob_inode = ob_inode_get(this, inode);
+ if (ob_inode == NULL)
+ goto out;
+
+ INIT_LIST_HEAD(&ob_fds);
+
+ LOCK(&inode->lock);
+ {
+ was_open_in_progress = ob_inode->open_in_progress;
+ ob_inode->unlinked = 1;
+
+ if (was_open_in_progress) {
+ list_add_tail(&stub->list, &ob_inode->resume_fops);
+ goto inode_unlock;
+ }
- LOCK (&inode->lock);
+ list_for_each_entry(ob_fd, &ob_inode->ob_fds, ob_fds_on_inode)
{
- was_open_in_progress = ob_inode->open_in_progress;
- ob_inode->unlinked = 1;
+ LOCK(&ob_fd->fd->lock);
+ {
+ if (ob_fd->opened)
+ goto fd_unlock;
- if (was_open_in_progress) {
- list_add_tail (&stub->list, &ob_inode->resume_fops);
- goto inode_unlock;
- }
+ ob_inode->count++;
+ ob_fd->ob_inode_fops_waiting = _gf_true;
- list_for_each_entry (ob_fd, &ob_inode->ob_fds,
- ob_fds_on_inode) {
- LOCK (&ob_fd->fd->lock);
- {
- if (ob_fd->opened)
- goto fd_unlock;
-
- ob_inode->count++;
- ob_fd->ob_inode_fops_waiting = _gf_true;
-
- if (ob_fd->open_frame == NULL) {
- /* open in progress no need of wake */
- } else {
- tmp = ob_fd_new ();
- tmp->open_frame = ob_fd->open_frame;
- ob_fd->open_frame = NULL;
-
- ob_fd_copy (ob_fd, tmp);
- list_add_tail (&tmp->ob_fds_on_inode,
- &ob_fds);
- }
- }
- fd_unlock:
- UNLOCK (&ob_fd->fd->lock);
- }
+ if (ob_fd->open_frame == NULL) {
+ /* open in progress no need of wake */
+ } else {
+ tmp = ob_fd_new();
+ tmp->open_frame = ob_fd->open_frame;
+ ob_fd->open_frame = NULL;
- if (ob_inode->count) {
- wait_for_open = ob_inode->open_in_progress = _gf_true;
- list_add_tail (&stub->list, &ob_inode->resume_fops);
+ ob_fd_copy(ob_fd, tmp);
+ list_add_tail(&tmp->ob_fds_on_inode, &ob_fds);
}
+ }
+ fd_unlock:
+ UNLOCK(&ob_fd->fd->lock);
+ }
+
+ if (ob_inode->count) {
+ wait_for_open = ob_inode->open_in_progress = _gf_true;
+ list_add_tail(&stub->list, &ob_inode->resume_fops);
}
+ }
inode_unlock:
- UNLOCK (&inode->lock);
+ UNLOCK(&inode->lock);
out:
- if (!was_open_in_progress) {
- if (!wait_for_open) {
- call_resume (stub);
- } else {
- ob_inode_wake (this, &ob_fds);
- }
+ if (!was_open_in_progress) {
+ if (!wait_for_open) {
+ call_resume(stub);
+ } else {
+ ob_inode_wake(this, &ob_fds);
}
+ }
- return 0;
+ return 0;
}
int
-open_and_resume (xlator_t *this, fd_t *fd, call_stub_t *stub)
+open_and_resume(xlator_t *this, fd_t *fd, call_stub_t *stub)
{
- ob_fd_t *ob_fd = NULL;
- int op_errno = 0;
+ ob_fd_t *ob_fd = NULL;
+ int op_errno = 0;
- if (!fd)
- goto nofd;
+ if (!fd)
+ goto nofd;
- LOCK (&fd->lock);
- {
- ob_fd = __ob_fd_ctx_get (this, fd);
- if (!ob_fd)
- goto unlock;
+ LOCK(&fd->lock);
+ {
+ ob_fd = __ob_fd_ctx_get(this, fd);
+ if (!ob_fd)
+ goto unlock;
- if (ob_fd->op_errno) {
- op_errno = ob_fd->op_errno;
- goto unlock;
- }
+ if (ob_fd->op_errno) {
+ op_errno = ob_fd->op_errno;
+ goto unlock;
+ }
- list_add_tail (&stub->list, &ob_fd->list);
- }
+ list_add_tail(&stub->list, &ob_fd->list);
+ }
unlock:
- UNLOCK (&fd->lock);
+ UNLOCK(&fd->lock);
nofd:
- if (op_errno)
- call_unwind_error (stub, -1, op_errno);
- else if (ob_fd)
- ob_fd_wake (this, fd, NULL);
- else
- call_resume (stub);
-
- return 0;
+ if (op_errno)
+ call_unwind_error(stub, -1, op_errno);
+ else if (ob_fd)
+ ob_fd_wake(this, fd, NULL);
+ else
+ call_resume(stub);
+
+ return 0;
}
-
int
-ob_open_behind (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
- fd_t *fd, dict_t *xdata)
+ob_open_behind(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
+ fd_t *fd, dict_t *xdata)
{
- ob_fd_t *ob_fd = NULL;
- int ret = -1;
- ob_conf_t *conf = NULL;
- ob_inode_t *ob_inode = NULL;
- gf_boolean_t open_in_progress = _gf_false;
- int unlinked = 0;
-
- conf = this->private;
+ ob_fd_t *ob_fd = NULL;
+ int ret = -1;
+ ob_conf_t *conf = NULL;
+ ob_inode_t *ob_inode = NULL;
+ gf_boolean_t open_in_progress = _gf_false;
+ int unlinked = 0;
+
+ conf = this->private;
+
+ if (flags & O_TRUNC) {
+ STACK_WIND(frame, default_open_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata);
+ return 0;
+ }
- if (flags & O_TRUNC) {
- STACK_WIND (frame, default_open_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->open,
- loc, flags, fd, xdata);
- return 0;
- }
+ ob_inode = ob_inode_get(this, fd->inode);
- ob_inode = ob_inode_get (this, fd->inode);
+ ob_fd = ob_fd_new();
+ if (!ob_fd)
+ goto enomem;
- ob_fd = ob_fd_new ();
- if (!ob_fd)
- goto enomem;
+ ob_fd->ob_inode = ob_inode;
- ob_fd->ob_inode = ob_inode;
+ /* don't do fd_ref, it'll cause leaks */
+ ob_fd->fd = fd;
- /* don't do fd_ref, it'll cause leaks */
- ob_fd->fd = fd;
+ ob_fd->open_frame = copy_frame(frame);
+ if (!ob_fd->open_frame)
+ goto enomem;
+ ret = loc_copy(&ob_fd->loc, loc);
+ if (ret)
+ goto enomem;
- ob_fd->open_frame = copy_frame (frame);
- if (!ob_fd->open_frame)
- goto enomem;
- ret = loc_copy (&ob_fd->loc, loc);
- if (ret)
- goto enomem;
+ ob_fd->flags = flags;
+ if (xdata)
+ ob_fd->xdata = dict_ref(xdata);
- ob_fd->flags = flags;
- if (xdata)
- ob_fd->xdata = dict_ref (xdata);
+ LOCK(&fd->inode->lock);
+ {
+ open_in_progress = ob_inode->open_in_progress;
+ unlinked = ob_inode->unlinked;
+ if (!open_in_progress && !unlinked) {
+ ret = ob_fd_ctx_set(this, fd, ob_fd);
+ if (ret) {
+ UNLOCK(&fd->inode->lock);
+ goto enomem;
+ }
- LOCK (&fd->inode->lock);
- {
- open_in_progress = ob_inode->open_in_progress;
- unlinked = ob_inode->unlinked;
- if (!open_in_progress && !unlinked) {
- ret = ob_fd_ctx_set (this, fd, ob_fd);
- if (ret) {
- UNLOCK (&fd->inode->lock);
- goto enomem;
- }
-
- list_add (&ob_fd->ob_fds_on_inode, &ob_inode->ob_fds);
- }
+ list_add(&ob_fd->ob_fds_on_inode, &ob_inode->ob_fds);
}
- UNLOCK (&fd->inode->lock);
+ }
+ UNLOCK(&fd->inode->lock);
+ if (!open_in_progress && !unlinked) {
+ fd_ref(fd);
- if (!open_in_progress && !unlinked) {
- fd_ref (fd);
+ STACK_UNWIND_STRICT(open, frame, 0, 0, fd, xdata);
- STACK_UNWIND_STRICT (open, frame, 0, 0, fd, xdata);
+ if (!conf->lazy_open)
+ ob_fd_wake(this, fd, NULL);
- if (!conf->lazy_open)
- ob_fd_wake (this, fd, NULL);
+ fd_unref(fd);
+ } else {
+ ob_fd_free(ob_fd);
+ STACK_WIND(frame, default_open_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata);
+ }
- fd_unref (fd);
- } else {
- ob_fd_free (ob_fd);
- STACK_WIND (frame, default_open_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->open,
- loc, flags, fd, xdata);
- }
-
- return 0;
+ return 0;
enomem:
- if (ob_fd) {
- if (ob_fd->open_frame)
- STACK_DESTROY (ob_fd->open_frame->root);
+ if (ob_fd) {
+ if (ob_fd->open_frame)
+ STACK_DESTROY(ob_fd->open_frame->root);
- loc_wipe (&ob_fd->loc);
- if (ob_fd->xdata)
- dict_unref (ob_fd->xdata);
+ loc_wipe(&ob_fd->loc);
+ if (ob_fd->xdata)
+ dict_unref(ob_fd->xdata);
- GF_FREE (ob_fd);
- }
+ GF_FREE(ob_fd);
+ }
- return -1;
+ return -1;
}
-
int
-ob_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
- fd_t *fd, dict_t *xdata)
+ob_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, fd_t *fd,
+ dict_t *xdata)
{
- fd_t *old_fd = NULL;
- int ret = -1;
- int op_errno = 0;
- call_stub_t *stub = NULL;
-
- old_fd = fd_lookup (fd->inode, 0);
- if (old_fd) {
- /* open-behind only when this is the first FD */
- stub = fop_open_stub (frame, default_open_resume,
- loc, flags, fd, xdata);
- if (!stub) {
- op_errno = ENOMEM;
- fd_unref (old_fd);
- goto err;
- }
-
- open_and_resume (this, old_fd, stub);
-
- fd_unref (old_fd);
-
- return 0;
- }
-
- ret = ob_open_behind (frame, this, loc, flags, fd, xdata);
- if (ret) {
- op_errno = ENOMEM;
- goto err;
- }
-
- return 0;
+ fd_t *old_fd = NULL;
+ int ret = -1;
+ int op_errno = 0;
+ call_stub_t *stub = NULL;
+
+ old_fd = fd_lookup(fd->inode, 0);
+ if (old_fd) {
+ /* open-behind only when this is the first FD */
+ stub = fop_open_stub(frame, default_open_resume, loc, flags, fd, xdata);
+ if (!stub) {
+ op_errno = ENOMEM;
+ fd_unref(old_fd);
+ goto err;
+ }
+
+ open_and_resume(this, old_fd, stub);
+
+ fd_unref(old_fd);
+
+ return 0;
+ }
+
+ ret = ob_open_behind(frame, this, loc, flags, fd, xdata);
+ if (ret) {
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ return 0;
err:
- gf_msg (this->name, GF_LOG_ERROR, op_errno, OPEN_BEHIND_MSG_NO_MEMORY,
- "%s", loc->path);
+ gf_msg(this->name, GF_LOG_ERROR, op_errno, OPEN_BEHIND_MSG_NO_MEMORY, "%s",
+ loc->path);
- STACK_UNWIND_STRICT (open, frame, -1, op_errno, 0, 0);
+ STACK_UNWIND_STRICT(open, frame, -1, op_errno, 0, 0);
- return 0;
+ return 0;
}
-
fd_t *
-ob_get_wind_fd (xlator_t *this, fd_t *fd, uint32_t *flag)
+ob_get_wind_fd(xlator_t *this, fd_t *fd, uint32_t *flag)
{
- fd_t *wind_fd = NULL;
- ob_fd_t *ob_fd = NULL;
- ob_conf_t *conf = NULL;
+ fd_t *wind_fd = NULL;
+ ob_fd_t *ob_fd = NULL;
+ ob_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- ob_fd = ob_fd_ctx_get (this, fd);
+ ob_fd = ob_fd_ctx_get(this, fd);
- if (ob_fd && ob_fd->open_frame && conf->use_anonymous_fd) {
- wind_fd = fd_anonymous (fd->inode);
- if ((ob_fd->flags & O_DIRECT) && (flag))
- *flag = *flag | O_DIRECT;
- } else {
- wind_fd = fd_ref (fd);
- }
+ if (ob_fd && ob_fd->open_frame && conf->use_anonymous_fd) {
+ wind_fd = fd_anonymous(fd->inode);
+ if ((ob_fd->flags & O_DIRECT) && (flag))
+ *flag = *flag | O_DIRECT;
+ } else {
+ wind_fd = fd_ref(fd);
+ }
- return wind_fd;
+ return wind_fd;
}
-
int
-ob_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, uint32_t flags, dict_t *xdata)
+ob_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, uint32_t flags, dict_t *xdata)
{
- call_stub_t *stub = NULL;
- fd_t *wind_fd = NULL;
- ob_conf_t *conf = NULL;
+ call_stub_t *stub = NULL;
+ fd_t *wind_fd = NULL;
+ ob_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- if (!conf->read_after_open)
- wind_fd = ob_get_wind_fd (this, fd, &flags);
- else
- wind_fd = fd_ref (fd);
+ if (!conf->read_after_open)
+ wind_fd = ob_get_wind_fd(this, fd, &flags);
+ else
+ wind_fd = fd_ref(fd);
- stub = fop_readv_stub (frame, default_readv_resume, wind_fd,
- size, offset, flags, xdata);
- fd_unref (wind_fd);
+ stub = fop_readv_stub(frame, default_readv_resume, wind_fd, size, offset,
+ flags, xdata);
+ fd_unref(wind_fd);
- if (!stub)
- goto err;
+ if (!stub)
+ goto err;
- open_and_resume (this, wind_fd, stub);
+ open_and_resume(this, wind_fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (readv, frame, -1, ENOMEM, 0, 0, 0, 0, 0);
+ STACK_UNWIND_STRICT(readv, frame, -1, ENOMEM, 0, 0, 0, 0, 0);
- return 0;
+ return 0;
}
-
int
-ob_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *iov,
- int count, off_t offset, uint32_t flags, struct iobref *iobref,
- dict_t *xdata)
+ob_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *iov,
+ int count, off_t offset, uint32_t flags, struct iobref *iobref,
+ dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_writev_stub (frame, default_writev_resume, fd, iov, count,
- offset, flags, iobref, xdata);
- if (!stub)
- goto err;
+ stub = fop_writev_stub(frame, default_writev_resume, fd, iov, count, offset,
+ flags, iobref, xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (writev, frame, -1, ENOMEM, 0, 0, 0);
+ STACK_UNWIND_STRICT(writev, frame, -1, ENOMEM, 0, 0, 0);
- return 0;
+ return 0;
}
-
int
-ob_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+ob_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- call_stub_t *stub = NULL;
- fd_t *wind_fd = NULL;
+ call_stub_t *stub = NULL;
+ fd_t *wind_fd = NULL;
- wind_fd = ob_get_wind_fd (this, fd, NULL);
+ wind_fd = ob_get_wind_fd(this, fd, NULL);
- stub = fop_fstat_stub (frame, default_fstat_resume, wind_fd, xdata);
+ stub = fop_fstat_stub(frame, default_fstat_resume, wind_fd, xdata);
- fd_unref (wind_fd);
+ fd_unref(wind_fd);
- if (!stub)
- goto err;
+ if (!stub)
+ goto err;
- open_and_resume (this, wind_fd, stub);
+ open_and_resume(this, wind_fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (fstat, frame, -1, ENOMEM, 0, 0);
+ STACK_UNWIND_STRICT(fstat, frame, -1, ENOMEM, 0, 0);
- return 0;
+ return 0;
}
-
int
-ob_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+ob_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- call_stub_t *stub = NULL;
- ob_fd_t *ob_fd = NULL;
- gf_boolean_t unwind = _gf_false;
-
- LOCK (&fd->lock);
- {
- ob_fd = __ob_fd_ctx_get (this, fd);
- if (ob_fd && ob_fd->open_frame)
- /* if open() was never wound to backend,
- no need to wind flush() either.
- */
- unwind = _gf_true;
- }
- UNLOCK (&fd->lock);
-
- if (unwind)
- goto unwind;
-
- stub = fop_flush_stub (frame, default_flush_resume, fd, xdata);
- if (!stub)
- goto err;
-
- open_and_resume (this, fd, stub);
-
- return 0;
+ call_stub_t *stub = NULL;
+ ob_fd_t *ob_fd = NULL;
+ gf_boolean_t unwind = _gf_false;
+
+ LOCK(&fd->lock);
+ {
+ ob_fd = __ob_fd_ctx_get(this, fd);
+ if (ob_fd && ob_fd->open_frame)
+ /* if open() was never wound to backend,
+ no need to wind flush() either.
+ */
+ unwind = _gf_true;
+ }
+ UNLOCK(&fd->lock);
+
+ if (unwind)
+ goto unwind;
+
+ stub = fop_flush_stub(frame, default_flush_resume, fd, xdata);
+ if (!stub)
+ goto err;
+
+ open_and_resume(this, fd, stub);
+
+ return 0;
err:
- STACK_UNWIND_STRICT (flush, frame, -1, ENOMEM, 0);
+ STACK_UNWIND_STRICT(flush, frame, -1, ENOMEM, 0);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (flush, frame, 0, 0, 0);
+ STACK_UNWIND_STRICT(flush, frame, 0, 0, 0);
- return 0;
+ return 0;
}
-
int
-ob_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int flag,
- dict_t *xdata)
+ob_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int flag, dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_fsync_stub (frame, default_fsync_resume, fd, flag, xdata);
- if (!stub)
- goto err;
+ stub = fop_fsync_stub(frame, default_fsync_resume, fd, flag, xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (fsync, frame, -1, ENOMEM, 0, 0, 0);
+ STACK_UNWIND_STRICT(fsync, frame, -1, ENOMEM, 0, 0, 0);
- return 0;
+ return 0;
}
-
int
-ob_lk (call_frame_t *frame, xlator_t *this, fd_t *fd, int cmd,
- struct gf_flock *flock, dict_t *xdata)
+ob_lk(call_frame_t *frame, xlator_t *this, fd_t *fd, int cmd,
+ struct gf_flock *flock, dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_lk_stub (frame, default_lk_resume, fd, cmd, flock, xdata);
- if (!stub)
- goto err;
+ stub = fop_lk_stub(frame, default_lk_resume, fd, cmd, flock, xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (lk, frame, -1, ENOMEM, 0, 0);
+ STACK_UNWIND_STRICT(lk, frame, -1, ENOMEM, 0, 0);
- return 0;
+ return 0;
}
int
-ob_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- dict_t *xdata)
+ob_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_ftruncate_stub (frame, default_ftruncate_resume, fd, offset,
- xdata);
- if (!stub)
- goto err;
+ stub = fop_ftruncate_stub(frame, default_ftruncate_resume, fd, offset,
+ xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (ftruncate, frame, -1, ENOMEM, 0, 0, 0);
+ STACK_UNWIND_STRICT(ftruncate, frame, -1, ENOMEM, 0, 0, 0);
- return 0;
+ return 0;
}
-
int
-ob_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xattr,
- int flags, dict_t *xdata)
+ob_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xattr,
+ int flags, dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_fsetxattr_stub (frame, default_fsetxattr_resume, fd, xattr,
- flags, xdata);
- if (!stub)
- goto err;
+ stub = fop_fsetxattr_stub(frame, default_fsetxattr_resume, fd, xattr, flags,
+ xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (fsetxattr, frame, -1, ENOMEM, 0);
+ STACK_UNWIND_STRICT(fsetxattr, frame, -1, ENOMEM, 0);
- return 0;
+ return 0;
}
-
int
-ob_fgetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name,
- dict_t *xdata)
+ob_fgetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name,
+ dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_fgetxattr_stub (frame, default_fgetxattr_resume, fd, name,
- xdata);
- if (!stub)
- goto err;
+ stub = fop_fgetxattr_stub(frame, default_fgetxattr_resume, fd, name, xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (fgetxattr, frame, -1, ENOMEM, 0, 0);
+ STACK_UNWIND_STRICT(fgetxattr, frame, -1, ENOMEM, 0, 0);
- return 0;
+ return 0;
}
-
int
-ob_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
- const char *name, dict_t *xdata)
+ob_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd, const char *name,
+ dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_fremovexattr_stub (frame, default_fremovexattr_resume, fd,
- name, xdata);
- if (!stub)
- goto err;
+ stub = fop_fremovexattr_stub(frame, default_fremovexattr_resume, fd, name,
+ xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (fremovexattr, frame, -1, ENOMEM, 0);
+ STACK_UNWIND_STRICT(fremovexattr, frame, -1, ENOMEM, 0);
- return 0;
+ return 0;
}
-
int
-ob_finodelk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
- int cmd, struct gf_flock *flock, dict_t *xdata)
+ob_finodelk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
+ int cmd, struct gf_flock *flock, dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_finodelk_stub (frame, default_finodelk_resume, volume, fd,
- cmd, flock, xdata);
- if (!stub)
- goto err;
+ stub = fop_finodelk_stub(frame, default_finodelk_resume, volume, fd, cmd,
+ flock, xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (finodelk, frame, -1, ENOMEM, 0);
+ STACK_UNWIND_STRICT(finodelk, frame, -1, ENOMEM, 0);
- return 0;
+ return 0;
}
-
int
-ob_fentrylk (call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
- const char *basename, entrylk_cmd cmd, entrylk_type type,
- dict_t *xdata)
+ob_fentrylk(call_frame_t *frame, xlator_t *this, const char *volume, fd_t *fd,
+ const char *basename, entrylk_cmd cmd, entrylk_type type,
+ dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_fentrylk_stub (frame, default_fentrylk_resume, volume, fd,
- basename, cmd, type, xdata);
- if (!stub)
- goto err;
+ stub = fop_fentrylk_stub(frame, default_fentrylk_resume, volume, fd,
+ basename, cmd, type, xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (fentrylk, frame, -1, ENOMEM, 0);
+ STACK_UNWIND_STRICT(fentrylk, frame, -1, ENOMEM, 0);
- return 0;
+ return 0;
}
-
int
-ob_fxattrop (call_frame_t *frame, xlator_t *this, fd_t *fd,
- gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
+ob_fxattrop(call_frame_t *frame, xlator_t *this, fd_t *fd,
+ gf_xattrop_flags_t optype, dict_t *xattr, dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_fxattrop_stub (frame, default_fxattrop_resume, fd, optype,
- xattr, xdata);
- if (!stub)
- goto err;
+ stub = fop_fxattrop_stub(frame, default_fxattrop_resume, fd, optype, xattr,
+ xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (fxattrop, frame, -1, ENOMEM, 0, 0);
+ STACK_UNWIND_STRICT(fxattrop, frame, -1, ENOMEM, 0, 0);
- return 0;
+ return 0;
}
-
int
-ob_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iatt *iatt, int valid, dict_t *xdata)
+ob_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *iatt,
+ int valid, dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_fsetattr_stub (frame, default_fsetattr_resume, fd,
- iatt, valid, xdata);
- if (!stub)
- goto err;
+ stub = fop_fsetattr_stub(frame, default_fsetattr_resume, fd, iatt, valid,
+ xdata);
+ if (!stub)
+ goto err;
- open_and_resume (this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (fsetattr, frame, -1, ENOMEM, 0, 0, 0);
+ STACK_UNWIND_STRICT(fsetattr, frame, -1, ENOMEM, 0, 0, 0);
- return 0;
+ return 0;
}
int
ob_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t mode,
- off_t offset, size_t len, dict_t *xdata)
+ off_t offset, size_t len, dict_t *xdata)
{
- call_stub_t *stub;
+ call_stub_t *stub;
- stub = fop_fallocate_stub(frame, default_fallocate_resume, fd, mode,
- offset, len, xdata);
- if (!stub)
- goto err;
+ stub = fop_fallocate_stub(frame, default_fallocate_resume, fd, mode, offset,
+ len, xdata);
+ if (!stub)
+ goto err;
- open_and_resume(this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT(fallocate, frame, -1, ENOMEM, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(fallocate, frame, -1, ENOMEM, NULL, NULL, NULL);
+ return 0;
}
int
ob_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- size_t len, dict_t *xdata)
+ size_t len, dict_t *xdata)
{
- call_stub_t *stub;
+ call_stub_t *stub;
- stub = fop_discard_stub(frame, default_discard_resume, fd, offset, len,
- xdata);
- if (!stub)
- goto err;
+ stub = fop_discard_stub(frame, default_discard_resume, fd, offset, len,
+ xdata);
+ if (!stub)
+ goto err;
- open_and_resume(this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT(discard, frame, -1, ENOMEM, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(discard, frame, -1, ENOMEM, NULL, NULL, NULL);
+ return 0;
}
int
ob_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- off_t len, dict_t *xdata)
+ off_t len, dict_t *xdata)
{
- call_stub_t *stub;
+ call_stub_t *stub;
- stub = fop_zerofill_stub(frame, default_zerofill_resume, fd,
- offset, len, xdata);
- if (!stub)
- goto err;
+ stub = fop_zerofill_stub(frame, default_zerofill_resume, fd, offset, len,
+ xdata);
+ if (!stub)
+ goto err;
- open_and_resume(this, fd, stub);
+ open_and_resume(this, fd, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT(zerofill, frame, -1, ENOMEM, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(zerofill, frame, -1, ENOMEM, NULL, NULL, NULL);
+ return 0;
}
int
-ob_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflags,
- dict_t *xdata)
+ob_unlink(call_frame_t *frame, xlator_t *this, loc_t *loc, int xflags,
+ dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_unlink_stub (frame, default_unlink_resume, loc,
- xflags, xdata);
- if (!stub)
- goto err;
+ stub = fop_unlink_stub(frame, default_unlink_resume, loc, xflags, xdata);
+ if (!stub)
+ goto err;
- open_all_pending_fds_and_resume (this, loc->inode, stub);
+ open_all_pending_fds_and_resume(this, loc->inode, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (unlink, frame, -1, ENOMEM, 0, 0, 0);
+ STACK_UNWIND_STRICT(unlink, frame, -1, ENOMEM, 0, 0, 0);
- return 0;
+ return 0;
}
int
-ob_rename (call_frame_t *frame, xlator_t *this, loc_t *src, loc_t *dst,
- dict_t *xdata)
+ob_rename(call_frame_t *frame, xlator_t *this, loc_t *src, loc_t *dst,
+ dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_rename_stub (frame, default_rename_resume, src, dst, xdata);
- if (!stub)
- goto err;
+ stub = fop_rename_stub(frame, default_rename_resume, src, dst, xdata);
+ if (!stub)
+ goto err;
- open_all_pending_fds_and_resume (this, dst->inode, stub);
+ open_all_pending_fds_and_resume(this, dst->inode, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (rename, frame, -1, ENOMEM, 0, 0, 0, 0, 0, 0);
+ STACK_UNWIND_STRICT(rename, frame, -1, ENOMEM, 0, 0, 0, 0, 0, 0);
- return 0;
+ return 0;
}
int32_t
-ob_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- struct iatt *stbuf, int32_t valid, dict_t *xdata)
+ob_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf,
+ int32_t valid, dict_t *xdata)
{
- call_stub_t *stub = NULL;
+ call_stub_t *stub = NULL;
- stub = fop_setattr_stub (frame, default_setattr_resume, loc, stbuf,
- valid, xdata);
- if (!stub)
- goto err;
+ stub = fop_setattr_stub(frame, default_setattr_resume, loc, stbuf, valid,
+ xdata);
+ if (!stub)
+ goto err;
- open_all_pending_fds_and_resume (this, loc->inode, stub);
+ open_all_pending_fds_and_resume(this, loc->inode, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (setattr, frame, -1, ENOMEM, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(setattr, frame, -1, ENOMEM, NULL, NULL, NULL);
+ return 0;
}
-
int32_t
-ob_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
- int32_t flags, dict_t *xdata)
+ob_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
+ int32_t flags, dict_t *xdata)
{
- call_stub_t *stub = NULL;
- gf_boolean_t access_xattr = _gf_false;
+ call_stub_t *stub = NULL;
+ gf_boolean_t access_xattr = _gf_false;
- if (dict_get (dict, POSIX_ACL_DEFAULT_XATTR)
- || dict_get (dict, POSIX_ACL_ACCESS_XATTR)
- || dict_get (dict, GF_SELINUX_XATTR_KEY))
- access_xattr = _gf_true;
+ if (dict_get(dict, POSIX_ACL_DEFAULT_XATTR) ||
+ dict_get(dict, POSIX_ACL_ACCESS_XATTR) ||
+ dict_get(dict, GF_SELINUX_XATTR_KEY))
+ access_xattr = _gf_true;
- if (!access_xattr)
- return default_setxattr (frame, this, loc, dict, flags, xdata);
+ if (!access_xattr)
+ return default_setxattr(frame, this, loc, dict, flags, xdata);
- stub = fop_setxattr_stub (frame, default_setxattr_resume, loc, dict,
- flags, xdata);
- if (!stub)
- goto err;
+ stub = fop_setxattr_stub(frame, default_setxattr_resume, loc, dict, flags,
+ xdata);
+ if (!stub)
+ goto err;
- open_all_pending_fds_and_resume (this, loc->inode, stub);
+ open_all_pending_fds_and_resume(this, loc->inode, stub);
- return 0;
+ return 0;
err:
- STACK_UNWIND_STRICT (setxattr, frame, -1, ENOMEM, NULL);
- return 0;
+ STACK_UNWIND_STRICT(setxattr, frame, -1, ENOMEM, NULL);
+ return 0;
}
int
-ob_release (xlator_t *this, fd_t *fd)
+ob_release(xlator_t *this, fd_t *fd)
{
- ob_fd_t *ob_fd = NULL;
+ ob_fd_t *ob_fd = NULL;
- ob_fd = ob_fd_ctx_get (this, fd);
+ ob_fd = ob_fd_ctx_get(this, fd);
- ob_fd_free (ob_fd);
+ ob_fd_free(ob_fd);
- return 0;
+ return 0;
}
int
-ob_forget (xlator_t *this, inode_t *inode)
+ob_forget(xlator_t *this, inode_t *inode)
{
- ob_inode_t *ob_inode = NULL;
- uint64_t value = 0;
+ ob_inode_t *ob_inode = NULL;
+ uint64_t value = 0;
- inode_ctx_del (inode, this, &value);
+ inode_ctx_del(inode, this, &value);
- if (value) {
- ob_inode = (ob_inode_t *)((void *) value);
- ob_inode_free (ob_inode);
- }
+ if (value) {
+ ob_inode = (ob_inode_t *)((void *)value);
+ ob_inode_free(ob_inode);
+ }
- return 0;
+ return 0;
}
int
-ob_priv_dump (xlator_t *this)
+ob_priv_dump(xlator_t *this)
{
- ob_conf_t *conf = NULL;
- char key_prefix[GF_DUMP_MAX_BUF_LEN];
+ ob_conf_t *conf = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
- conf = this->private;
+ conf = this->private;
- if (!conf)
- return -1;
+ if (!conf)
+ return -1;
- gf_proc_dump_build_key (key_prefix, "xlator.performance.open-behind",
- "priv");
+ gf_proc_dump_build_key(key_prefix, "xlator.performance.open-behind",
+ "priv");
- gf_proc_dump_add_section (key_prefix);
+ gf_proc_dump_add_section(key_prefix);
- gf_proc_dump_write ("use_anonymous_fd", "%d", conf->use_anonymous_fd);
+ gf_proc_dump_write("use_anonymous_fd", "%d", conf->use_anonymous_fd);
- gf_proc_dump_write ("lazy_open", "%d", conf->lazy_open);
+ gf_proc_dump_write("lazy_open", "%d", conf->lazy_open);
- return 0;
+ return 0;
}
-
int
-ob_fdctx_dump (xlator_t *this, fd_t *fd)
+ob_fdctx_dump(xlator_t *this, fd_t *fd)
{
- ob_fd_t *ob_fd = NULL;
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
- int ret = 0;
+ ob_fd_t *ob_fd = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ int ret = 0;
+
+ ret = TRY_LOCK(&fd->lock);
+ if (ret)
+ return 0;
- ret = TRY_LOCK (&fd->lock);
- if (ret)
- return 0;
+ ob_fd = __ob_fd_ctx_get(this, fd);
+ if (!ob_fd) {
+ UNLOCK(&fd->lock);
+ return 0;
+ }
- ob_fd = __ob_fd_ctx_get (this, fd);
- if (!ob_fd) {
- UNLOCK (&fd->lock);
- return 0;
- }
+ gf_proc_dump_build_key(key_prefix, "xlator.performance.open-behind",
+ "file");
+ gf_proc_dump_add_section(key_prefix);
- gf_proc_dump_build_key (key_prefix, "xlator.performance.open-behind",
- "file");
- gf_proc_dump_add_section (key_prefix);
+ gf_proc_dump_write("fd", "%p", fd);
- gf_proc_dump_write ("fd", "%p", fd);
+ gf_proc_dump_write("open_frame", "%p", ob_fd->open_frame);
- gf_proc_dump_write ("open_frame", "%p", ob_fd->open_frame);
+ if (ob_fd->open_frame)
+ gf_proc_dump_write("open_frame.root.unique", "%p",
+ ob_fd->open_frame->root->unique);
- if (ob_fd->open_frame)
- gf_proc_dump_write ("open_frame.root.unique", "%p",
- ob_fd->open_frame->root->unique);
+ gf_proc_dump_write("loc.path", "%s", ob_fd->loc.path);
- gf_proc_dump_write ("loc.path", "%s", ob_fd->loc.path);
+ gf_proc_dump_write("loc.ino", "%s", uuid_utoa(ob_fd->loc.gfid));
- gf_proc_dump_write ("loc.ino", "%s", uuid_utoa (ob_fd->loc.gfid));
+ gf_proc_dump_write("flags", "%d", ob_fd->flags);
- gf_proc_dump_write ("flags", "%d", ob_fd->flags);
+ UNLOCK(&fd->lock);
- UNLOCK (&fd->lock);
-
- return 0;
+ return 0;
}
-
int
-mem_acct_init (xlator_t *this)
+mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- ret = xlator_mem_acct_init (this, gf_ob_mt_end + 1);
+ ret = xlator_mem_acct_init(this, gf_ob_mt_end + 1);
- if (ret)
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- OPEN_BEHIND_MSG_NO_MEMORY,
- "Memory accounting failed");
+ if (ret)
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, OPEN_BEHIND_MSG_NO_MEMORY,
+ "Memory accounting failed");
- return ret;
+ return ret;
}
-
int
-reconfigure (xlator_t *this, dict_t *options)
+reconfigure(xlator_t *this, dict_t *options)
{
- ob_conf_t *conf = NULL;
- int ret = -1;
+ ob_conf_t *conf = NULL;
+ int ret = -1;
- conf = this->private;
+ conf = this->private;
- GF_OPTION_RECONF ("use-anonymous-fd", conf->use_anonymous_fd, options,
- bool, out);
+ GF_OPTION_RECONF("use-anonymous-fd", conf->use_anonymous_fd, options, bool,
+ out);
- GF_OPTION_RECONF ("lazy-open", conf->lazy_open, options, bool, out);
+ GF_OPTION_RECONF("lazy-open", conf->lazy_open, options, bool, out);
- GF_OPTION_RECONF ("read-after-open", conf->read_after_open, options,
- bool, out);
+ GF_OPTION_RECONF("read-after-open", conf->read_after_open, options, bool,
+ out);
- GF_OPTION_RECONF ("pass-through", this->pass_through, options, bool,
- out);
- ret = 0;
+ GF_OPTION_RECONF("pass-through", this->pass_through, options, bool, out);
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
int
-init (xlator_t *this)
+init(xlator_t *this)
{
- ob_conf_t *conf = NULL;
-
- if (!this->children || this->children->next) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- OPEN_BEHIND_MSG_XLATOR_CHILD_MISCONFIGURED,
- "FATAL: volume (%s) not configured with exactly one "
- "child", this->name);
- return -1;
- }
+ ob_conf_t *conf = NULL;
+
+ if (!this->children || this->children->next) {
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ OPEN_BEHIND_MSG_XLATOR_CHILD_MISCONFIGURED,
+ "FATAL: volume (%s) not configured with exactly one "
+ "child",
+ this->name);
+ return -1;
+ }
- if (!this->parents)
- gf_msg (this->name, GF_LOG_WARNING, 0,
- OPEN_BEHIND_MSG_VOL_MISCONFIGURED,
- "dangling volume. check volfile ");
+ if (!this->parents)
+ gf_msg(this->name, GF_LOG_WARNING, 0, OPEN_BEHIND_MSG_VOL_MISCONFIGURED,
+ "dangling volume. check volfile ");
- conf = GF_CALLOC (1, sizeof (*conf), gf_ob_mt_conf_t);
- if (!conf)
- goto err;
+ conf = GF_CALLOC(1, sizeof(*conf), gf_ob_mt_conf_t);
+ if (!conf)
+ goto err;
- GF_OPTION_INIT ("use-anonymous-fd", conf->use_anonymous_fd, bool, err);
+ GF_OPTION_INIT("use-anonymous-fd", conf->use_anonymous_fd, bool, err);
- GF_OPTION_INIT ("lazy-open", conf->lazy_open, bool, err);
+ GF_OPTION_INIT("lazy-open", conf->lazy_open, bool, err);
- GF_OPTION_INIT ("read-after-open", conf->read_after_open, bool, err);
+ GF_OPTION_INIT("read-after-open", conf->read_after_open, bool, err);
- GF_OPTION_INIT ("pass-through", this->pass_through, bool, err);
+ GF_OPTION_INIT("pass-through", this->pass_through, bool, err);
- this->private = conf;
+ this->private = conf;
- return 0;
+ return 0;
err:
- if (conf)
- GF_FREE (conf);
+ if (conf)
+ GF_FREE(conf);
- return -1;
+ return -1;
}
-
void
-fini (xlator_t *this)
+fini(xlator_t *this)
{
- ob_conf_t *conf = NULL;
+ ob_conf_t *conf = NULL;
- conf = this->private;
+ conf = this->private;
- GF_FREE (conf);
+ GF_FREE(conf);
- return;
+ return;
}
struct xlator_fops fops = {
- .open = ob_open,
- .readv = ob_readv,
- .writev = ob_writev,
- .flush = ob_flush,
- .fsync = ob_fsync,
- .fstat = ob_fstat,
- .ftruncate = ob_ftruncate,
- .fsetxattr = ob_fsetxattr,
- .setxattr = ob_setxattr,
- .fgetxattr = ob_fgetxattr,
- .fremovexattr = ob_fremovexattr,
- .finodelk = ob_finodelk,
- .fentrylk = ob_fentrylk,
- .fxattrop = ob_fxattrop,
- .fsetattr = ob_fsetattr,
- .setattr = ob_setattr,
- .fallocate = ob_fallocate,
- .discard = ob_discard,
- .zerofill = ob_zerofill,
- .unlink = ob_unlink,
- .rename = ob_rename,
- .lk = ob_lk,
+ .open = ob_open,
+ .readv = ob_readv,
+ .writev = ob_writev,
+ .flush = ob_flush,
+ .fsync = ob_fsync,
+ .fstat = ob_fstat,
+ .ftruncate = ob_ftruncate,
+ .fsetxattr = ob_fsetxattr,
+ .setxattr = ob_setxattr,
+ .fgetxattr = ob_fgetxattr,
+ .fremovexattr = ob_fremovexattr,
+ .finodelk = ob_finodelk,
+ .fentrylk = ob_fentrylk,
+ .fxattrop = ob_fxattrop,
+ .fsetattr = ob_fsetattr,
+ .setattr = ob_setattr,
+ .fallocate = ob_fallocate,
+ .discard = ob_discard,
+ .zerofill = ob_zerofill,
+ .unlink = ob_unlink,
+ .rename = ob_rename,
+ .lk = ob_lk,
};
struct xlator_cbks cbks = {
- .release = ob_release,
- .forget = ob_forget,
+ .release = ob_release,
+ .forget = ob_forget,
};
struct xlator_dumpops dumpops = {
- .priv = ob_priv_dump,
- .fdctx = ob_fdctx_dump,
+ .priv = ob_priv_dump,
+ .fdctx = ob_fdctx_dump,
};
-
struct volume_options options[] = {
- { .key = {"use-anonymous-fd"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "no",
- .description = "For read operations, use anonymous FD when "
- "original FD is open-behind and not yet opened in the backend.",
- },
- { .key = {"lazy-open"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "yes",
- .description = "Perform open in the backend only when a necessary "
- "FOP arrives (e.g writev on the FD, unlink of the file). When option "
- "is disabled, perform backend open right after unwinding open().",
- .op_version = {3},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT,
- .tags = {},
- /* option_validation_fn validate_fn; */
- },
- { .key = {"read-after-open"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "yes",
- .description = "read is sent only after actual open happens and real "
- "fd is obtained, instead of doing on anonymous fd (similar to write)",
- .op_version = {3},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT,
- .tags = {},
- /* option_validation_fn validate_fn; */
- },
- { .key = {"pass-through"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"open-behind"},
- .description = "Enable/Disable open behind translator"
- },
- { .key = {NULL} }
+ {
+ .key = {"use-anonymous-fd"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "no",
+ .description =
+ "For read operations, use anonymous FD when "
+ "original FD is open-behind and not yet opened in the backend.",
+ },
+ {
+ .key = {"lazy-open"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "yes",
+ .description =
+ "Perform open in the backend only when a necessary "
+ "FOP arrives (e.g writev on the FD, unlink of the file). When "
+ "option "
+ "is disabled, perform backend open right after unwinding open().",
+ .op_version = {3},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT,
+ .tags = {},
+ /* option_validation_fn validate_fn; */
+ },
+ {
+ .key = {"read-after-open"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "yes",
+ .description = "read is sent only after actual open happens and real "
+ "fd is obtained, instead of doing on anonymous fd "
+ "(similar to write)",
+ .op_version = {3},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT,
+ .tags = {},
+ /* option_validation_fn validate_fn; */
+ },
+ {.key = {"pass-through"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"open-behind"},
+ .description = "Enable/Disable open behind translator"},
+ {.key = {NULL}}
};
diff --git a/xlators/performance/quick-read/src/quick-read.c b/xlators/performance/quick-read/src/quick-read.c
index 720c0c4e3b9..39ce428104b 100644
--- a/xlators/performance/quick-read/src/quick-read.c
+++ b/xlators/performance/quick-read/src/quick-read.c
@@ -16,1691 +16,1633 @@
#include "atomic.h"
typedef struct qr_local {
- inode_t *inode;
- uint64_t incident_gen;
- fd_t *fd;
+ inode_t *inode;
+ uint64_t incident_gen;
+ fd_t *fd;
} qr_local_t;
qr_inode_t *
-qr_inode_ctx_get (xlator_t *this, inode_t *inode);
+qr_inode_ctx_get(xlator_t *this, inode_t *inode);
void
-__qr_inode_prune_data (xlator_t *this, qr_inode_table_t *table,
- qr_inode_t *qr_inode);
+__qr_inode_prune_data(xlator_t *this, qr_inode_table_t *table,
+ qr_inode_t *qr_inode);
void
-qr_local_wipe (qr_local_t *local)
+qr_local_wipe(qr_local_t *local)
{
- if (!local)
- goto out;
+ if (!local)
+ goto out;
- if (local->inode)
- inode_unref (local->inode);
+ if (local->inode)
+ inode_unref(local->inode);
- if (local->fd)
- fd_unref (local->fd);
+ if (local->fd)
+ fd_unref(local->fd);
- GF_FREE (local);
+ GF_FREE(local);
out:
- return;
+ return;
}
uint64_t
-__qr_get_generation (xlator_t *this, qr_inode_t *qr_inode)
+__qr_get_generation(xlator_t *this, qr_inode_t *qr_inode)
{
- uint64_t gen = 0, rollover;
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
-
- priv = this->private;
- table = &priv->table;
-
- gen = GF_ATOMIC_INC (priv->generation);
- if (gen == 0) {
- qr_inode->gen_rollover = !qr_inode->gen_rollover;
- gen = GF_ATOMIC_INC (priv->generation);
- __qr_inode_prune_data (this, table, qr_inode);
- qr_inode->gen = qr_inode->invalidation_time = gen - 1;
- }
-
- rollover = qr_inode->gen_rollover;
- gen |= (rollover << 32);
- return gen;
+ uint64_t gen = 0, rollover;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+
+ priv = this->private;
+ table = &priv->table;
+
+ gen = GF_ATOMIC_INC(priv->generation);
+ if (gen == 0) {
+ qr_inode->gen_rollover = !qr_inode->gen_rollover;
+ gen = GF_ATOMIC_INC(priv->generation);
+ __qr_inode_prune_data(this, table, qr_inode);
+ qr_inode->gen = qr_inode->invalidation_time = gen - 1;
+ }
+
+ rollover = qr_inode->gen_rollover;
+ gen |= (rollover << 32);
+ return gen;
}
uint64_t
-qr_get_generation (xlator_t *this, inode_t *inode)
+qr_get_generation(xlator_t *this, inode_t *inode)
{
- qr_inode_t *qr_inode = NULL;
- uint64_t gen = 0;
- qr_inode_table_t *table = NULL;
- qr_private_t *priv = NULL;
-
- priv = this->private;
- table = &priv->table;
-
- qr_inode = qr_inode_ctx_get (this, inode);
-
- if (qr_inode) {
- LOCK (&table->lock);
- {
- gen = __qr_get_generation (this, qr_inode);
- }
- UNLOCK (&table->lock);
- } else {
- gen = GF_ATOMIC_INC (priv->generation);
- if (gen == 0) {
- gen = GF_ATOMIC_INC (priv->generation);
- }
+ qr_inode_t *qr_inode = NULL;
+ uint64_t gen = 0;
+ qr_inode_table_t *table = NULL;
+ qr_private_t *priv = NULL;
+
+ priv = this->private;
+ table = &priv->table;
+
+ qr_inode = qr_inode_ctx_get(this, inode);
+
+ if (qr_inode) {
+ LOCK(&table->lock);
+ {
+ gen = __qr_get_generation(this, qr_inode);
}
+ UNLOCK(&table->lock);
+ } else {
+ gen = GF_ATOMIC_INC(priv->generation);
+ if (gen == 0) {
+ gen = GF_ATOMIC_INC(priv->generation);
+ }
+ }
- return gen;
+ return gen;
}
qr_local_t *
-qr_local_get (xlator_t *this, inode_t *inode)
+qr_local_get(xlator_t *this, inode_t *inode)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = GF_CALLOC (1, sizeof (*local), gf_common_mt_char);
- if (!local)
- goto out;
+ local = GF_CALLOC(1, sizeof(*local), gf_common_mt_char);
+ if (!local)
+ goto out;
- local->incident_gen = qr_get_generation (this, inode);
+ local->incident_gen = qr_get_generation(this, inode);
out:
- return local;
+ return local;
}
-#define QR_STACK_UNWIND(fop, frame, params ...) do { \
- qr_local_t *__local = NULL; \
- if (frame) { \
- __local = frame->local; \
- frame->local = NULL; \
- } \
- STACK_UNWIND_STRICT (fop, frame, params); \
- qr_local_wipe (__local); \
- } while (0)
-
-
+#define QR_STACK_UNWIND(fop, frame, params...) \
+ do { \
+ qr_local_t *__local = NULL; \
+ if (frame) { \
+ __local = frame->local; \
+ frame->local = NULL; \
+ } \
+ STACK_UNWIND_STRICT(fop, frame, params); \
+ qr_local_wipe(__local); \
+ } while (0)
-void __qr_inode_prune (xlator_t *this, qr_inode_table_t *table,
- qr_inode_t *qr_inode, uint64_t gen);
+void
+__qr_inode_prune(xlator_t *this, qr_inode_table_t *table, qr_inode_t *qr_inode,
+ uint64_t gen);
int
-__qr_inode_ctx_set (xlator_t *this, inode_t *inode, qr_inode_t *qr_inode)
+__qr_inode_ctx_set(xlator_t *this, inode_t *inode, qr_inode_t *qr_inode)
{
- uint64_t value = 0;
- int ret = -1;
+ uint64_t value = 0;
+ int ret = -1;
- value = (long) qr_inode;
+ value = (long)qr_inode;
- ret = __inode_ctx_set (inode, this, &value);
+ ret = __inode_ctx_set(inode, this, &value);
- return ret;
+ return ret;
}
-
qr_inode_t *
-__qr_inode_ctx_get (xlator_t *this, inode_t *inode)
+__qr_inode_ctx_get(xlator_t *this, inode_t *inode)
{
- qr_inode_t *qr_inode = NULL;
- uint64_t value = 0;
- int ret = -1;
+ qr_inode_t *qr_inode = NULL;
+ uint64_t value = 0;
+ int ret = -1;
- ret = __inode_ctx_get (inode, this, &value);
- if (ret)
- return NULL;
+ ret = __inode_ctx_get(inode, this, &value);
+ if (ret)
+ return NULL;
- qr_inode = (void *) ((long) value);
+ qr_inode = (void *)((long)value);
- return qr_inode;
+ return qr_inode;
}
-
qr_inode_t *
-qr_inode_ctx_get (xlator_t *this, inode_t *inode)
+qr_inode_ctx_get(xlator_t *this, inode_t *inode)
{
- qr_inode_t *qr_inode = NULL;
+ qr_inode_t *qr_inode = NULL;
- if (inode == NULL)
- goto out;
+ if (inode == NULL)
+ goto out;
- LOCK (&inode->lock);
- {
- qr_inode = __qr_inode_ctx_get (this, inode);
- }
- UNLOCK (&inode->lock);
+ LOCK(&inode->lock);
+ {
+ qr_inode = __qr_inode_ctx_get(this, inode);
+ }
+ UNLOCK(&inode->lock);
out:
- return qr_inode;
+ return qr_inode;
}
-
qr_inode_t *
-qr_inode_new (xlator_t *this, inode_t *inode)
+qr_inode_new(xlator_t *this, inode_t *inode)
{
- qr_inode_t *qr_inode = NULL;
+ qr_inode_t *qr_inode = NULL;
- qr_inode = GF_CALLOC (1, sizeof (*qr_inode), gf_qr_mt_qr_inode_t);
- if (!qr_inode)
- return NULL;
+ qr_inode = GF_CALLOC(1, sizeof(*qr_inode), gf_qr_mt_qr_inode_t);
+ if (!qr_inode)
+ return NULL;
- INIT_LIST_HEAD (&qr_inode->lru);
+ INIT_LIST_HEAD(&qr_inode->lru);
- qr_inode->priority = 0; /* initial priority */
+ qr_inode->priority = 0; /* initial priority */
- return qr_inode;
+ return qr_inode;
}
-
qr_inode_t *
-qr_inode_ctx_get_or_new (xlator_t *this, inode_t *inode)
+qr_inode_ctx_get_or_new(xlator_t *this, inode_t *inode)
{
- qr_inode_t *qr_inode = NULL;
- int ret = -1;
- qr_private_t *priv = NULL;
-
- priv = this->private;
-
- LOCK (&inode->lock);
- {
- qr_inode = __qr_inode_ctx_get (this, inode);
- if (qr_inode)
- goto unlock;
-
- qr_inode = qr_inode_new (this, inode);
- if (!qr_inode)
- goto unlock;
-
- ret = __qr_inode_ctx_set (this, inode, qr_inode);
- if (ret) {
- __qr_inode_prune (this, &priv->table, qr_inode, 0);
- GF_FREE (qr_inode);
- qr_inode = NULL;
- }
- }
+ qr_inode_t *qr_inode = NULL;
+ int ret = -1;
+ qr_private_t *priv = NULL;
+
+ priv = this->private;
+
+ LOCK(&inode->lock);
+ {
+ qr_inode = __qr_inode_ctx_get(this, inode);
+ if (qr_inode)
+ goto unlock;
+
+ qr_inode = qr_inode_new(this, inode);
+ if (!qr_inode)
+ goto unlock;
+
+ ret = __qr_inode_ctx_set(this, inode, qr_inode);
+ if (ret) {
+ __qr_inode_prune(this, &priv->table, qr_inode, 0);
+ GF_FREE(qr_inode);
+ qr_inode = NULL;
+ }
+ }
unlock:
- UNLOCK (&inode->lock);
+ UNLOCK(&inode->lock);
- return qr_inode;
+ return qr_inode;
}
-
uint32_t
-qr_get_priority (qr_conf_t *conf, const char *path)
+qr_get_priority(qr_conf_t *conf, const char *path)
{
- uint32_t priority = 0;
- struct qr_priority *curr = NULL;
+ uint32_t priority = 0;
+ struct qr_priority *curr = NULL;
- list_for_each_entry (curr, &conf->priority_list, list) {
- if (fnmatch (curr->pattern, path, FNM_NOESCAPE) == 0)
- priority = curr->priority;
- }
+ list_for_each_entry(curr, &conf->priority_list, list)
+ {
+ if (fnmatch(curr->pattern, path, FNM_NOESCAPE) == 0)
+ priority = curr->priority;
+ }
- return priority;
+ return priority;
}
-
void
-__qr_inode_register (xlator_t *this, qr_inode_table_t *table,
- qr_inode_t *qr_inode)
+__qr_inode_register(xlator_t *this, qr_inode_table_t *table,
+ qr_inode_t *qr_inode)
{
- qr_private_t *priv = NULL;
+ qr_private_t *priv = NULL;
- if (!qr_inode->data)
- return;
+ if (!qr_inode->data)
+ return;
- priv = this->private;
- if (!priv)
- return;
+ priv = this->private;
+ if (!priv)
+ return;
- if (list_empty (&qr_inode->lru))
- /* first time addition of this qr_inode into table */
- table->cache_used += qr_inode->size;
- else
- list_del_init (&qr_inode->lru);
+ if (list_empty(&qr_inode->lru))
+ /* first time addition of this qr_inode into table */
+ table->cache_used += qr_inode->size;
+ else
+ list_del_init(&qr_inode->lru);
- list_add_tail (&qr_inode->lru, &table->lru[qr_inode->priority]);
+ list_add_tail(&qr_inode->lru, &table->lru[qr_inode->priority]);
- GF_ATOMIC_INC (priv->qr_counter.files_cached);
+ GF_ATOMIC_INC(priv->qr_counter.files_cached);
- return;
+ return;
}
-
void
-qr_inode_set_priority (xlator_t *this, inode_t *inode, const char *path)
+qr_inode_set_priority(xlator_t *this, inode_t *inode, const char *path)
{
- uint32_t priority = 0;
- qr_inode_table_t *table = NULL;
- qr_inode_t *qr_inode = NULL;
- qr_private_t *priv = NULL;
- qr_conf_t *conf = NULL;
-
- qr_inode = qr_inode_ctx_get (this, inode);
- if (!qr_inode)
- return;
-
- priv = this->private;
- table = &priv->table;
- conf = &priv->conf;
-
- if (path)
- priority = qr_get_priority (conf, path);
- else
- /* retain existing priority, just bump LRU */
- priority = qr_inode->priority;
-
- LOCK (&table->lock);
- {
- qr_inode->priority = priority;
-
- __qr_inode_register (this, table, qr_inode);
- }
- UNLOCK (&table->lock);
+ uint32_t priority = 0;
+ qr_inode_table_t *table = NULL;
+ qr_inode_t *qr_inode = NULL;
+ qr_private_t *priv = NULL;
+ qr_conf_t *conf = NULL;
+
+ qr_inode = qr_inode_ctx_get(this, inode);
+ if (!qr_inode)
+ return;
+
+ priv = this->private;
+ table = &priv->table;
+ conf = &priv->conf;
+
+ if (path)
+ priority = qr_get_priority(conf, path);
+ else
+ /* retain existing priority, just bump LRU */
+ priority = qr_inode->priority;
+
+ LOCK(&table->lock);
+ {
+ qr_inode->priority = priority;
+
+ __qr_inode_register(this, table, qr_inode);
+ }
+ UNLOCK(&table->lock);
}
void
-__qr_inode_prune_data (xlator_t *this, qr_inode_table_t *table,
- qr_inode_t *qr_inode)
+__qr_inode_prune_data(xlator_t *this, qr_inode_table_t *table,
+ qr_inode_t *qr_inode)
{
- qr_private_t *priv = NULL;
-
- priv = this->private;
+ qr_private_t *priv = NULL;
- GF_FREE (qr_inode->data);
- qr_inode->data = NULL;
+ priv = this->private;
- if (!list_empty (&qr_inode->lru)) {
- table->cache_used -= qr_inode->size;
- qr_inode->size = 0;
+ GF_FREE(qr_inode->data);
+ qr_inode->data = NULL;
- list_del_init (&qr_inode->lru);
+ if (!list_empty(&qr_inode->lru)) {
+ table->cache_used -= qr_inode->size;
+ qr_inode->size = 0;
- GF_ATOMIC_DEC (priv->qr_counter.files_cached);
- }
+ list_del_init(&qr_inode->lru);
- memset (&qr_inode->buf, 0, sizeof (qr_inode->buf));
+ GF_ATOMIC_DEC(priv->qr_counter.files_cached);
+ }
+ memset(&qr_inode->buf, 0, sizeof(qr_inode->buf));
}
/* To be called with priv->table.lock held */
void
-__qr_inode_prune (xlator_t *this, qr_inode_table_t *table, qr_inode_t *qr_inode,
- uint64_t gen)
+__qr_inode_prune(xlator_t *this, qr_inode_table_t *table, qr_inode_t *qr_inode,
+ uint64_t gen)
{
- __qr_inode_prune_data (this, table, qr_inode);
- if (gen)
- qr_inode->gen = gen;
- qr_inode->invalidation_time = __qr_get_generation (this, qr_inode);
+ __qr_inode_prune_data(this, table, qr_inode);
+ if (gen)
+ qr_inode->gen = gen;
+ qr_inode->invalidation_time = __qr_get_generation(this, qr_inode);
}
-
void
-qr_inode_prune (xlator_t *this, inode_t *inode, uint64_t gen)
+qr_inode_prune(xlator_t *this, inode_t *inode, uint64_t gen)
{
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
- qr_inode_t *qr_inode = NULL;
-
- qr_inode = qr_inode_ctx_get (this, inode);
- if (!qr_inode)
- return;
-
- priv = this->private;
- table = &priv->table;
-
- LOCK (&table->lock);
- {
- __qr_inode_prune (this, table, qr_inode, gen);
- }
- UNLOCK (&table->lock);
-}
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+ qr_inode_t *qr_inode = NULL;
+
+ qr_inode = qr_inode_ctx_get(this, inode);
+ if (!qr_inode)
+ return;
+ priv = this->private;
+ table = &priv->table;
+
+ LOCK(&table->lock);
+ {
+ __qr_inode_prune(this, table, qr_inode, gen);
+ }
+ UNLOCK(&table->lock);
+}
/* To be called with priv->table.lock held */
void
-__qr_cache_prune (xlator_t *this, qr_inode_table_t *table, qr_conf_t *conf)
+__qr_cache_prune(xlator_t *this, qr_inode_table_t *table, qr_conf_t *conf)
{
- qr_inode_t *curr = NULL;
- qr_inode_t *next = NULL;
- int index = 0;
- size_t size_pruned = 0;
-
- for (index = 0; index < conf->max_pri; index++) {
- list_for_each_entry_safe (curr, next, &table->lru[index], lru) {
+ qr_inode_t *curr = NULL;
+ qr_inode_t *next = NULL;
+ int index = 0;
+ size_t size_pruned = 0;
- size_pruned += curr->size;
+ for (index = 0; index < conf->max_pri; index++) {
+ list_for_each_entry_safe(curr, next, &table->lru[index], lru)
+ {
+ size_pruned += curr->size;
- __qr_inode_prune (this, table, curr, 0);
+ __qr_inode_prune(this, table, curr, 0);
- if (table->cache_used < conf->cache_size)
- return;
- }
+ if (table->cache_used < conf->cache_size)
+ return;
}
+ }
- return;
+ return;
}
-
void
-qr_cache_prune (xlator_t *this)
+qr_cache_prune(xlator_t *this)
{
- qr_private_t *priv = NULL;
- qr_conf_t *conf = NULL;
- qr_inode_table_t *table = NULL;
-
- priv = this->private;
- table = &priv->table;
- conf = &priv->conf;
-
- LOCK (&table->lock);
- {
- if (table->cache_used > conf->cache_size)
- __qr_cache_prune (this, table, conf);
- }
- UNLOCK (&table->lock);
+ qr_private_t *priv = NULL;
+ qr_conf_t *conf = NULL;
+ qr_inode_table_t *table = NULL;
+
+ priv = this->private;
+ table = &priv->table;
+ conf = &priv->conf;
+
+ LOCK(&table->lock);
+ {
+ if (table->cache_used > conf->cache_size)
+ __qr_cache_prune(this, table, conf);
+ }
+ UNLOCK(&table->lock);
}
-
void *
-qr_content_extract (dict_t *xdata)
+qr_content_extract(dict_t *xdata)
{
- data_t *data = NULL;
- void *content = NULL;
- int ret = 0;
+ data_t *data = NULL;
+ void *content = NULL;
+ int ret = 0;
- ret = dict_get_with_ref (xdata, GF_CONTENT_KEY, &data);
- if (ret < 0 || !data)
- return NULL;
+ ret = dict_get_with_ref(xdata, GF_CONTENT_KEY, &data);
+ if (ret < 0 || !data)
+ return NULL;
- content = GF_MALLOC (data->len, gf_qr_mt_content_t);
- if (!content)
- goto out;
+ content = GF_MALLOC(data->len, gf_qr_mt_content_t);
+ if (!content)
+ goto out;
- memcpy (content, data->data, data->len);
+ memcpy(content, data->data, data->len);
out:
- data_unref (data);
- return content;
+ data_unref(data);
+ return content;
}
-
void
-qr_content_update (xlator_t *this, qr_inode_t *qr_inode, void *data,
- struct iatt *buf, uint64_t gen)
+qr_content_update(xlator_t *this, qr_inode_t *qr_inode, void *data,
+ struct iatt *buf, uint64_t gen)
{
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
- uint32_t rollover = 0;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+ uint32_t rollover = 0;
- rollover = gen >> 32;
- gen = gen & 0xffffffff;
+ rollover = gen >> 32;
+ gen = gen & 0xffffffff;
- priv = this->private;
- table = &priv->table;
+ priv = this->private;
+ table = &priv->table;
- LOCK (&table->lock);
- {
- if ((rollover != qr_inode->gen_rollover) ||
- (gen && qr_inode->gen && (qr_inode->gen >= gen)))
- goto unlock;
+ LOCK(&table->lock);
+ {
+ if ((rollover != qr_inode->gen_rollover) ||
+ (gen && qr_inode->gen && (qr_inode->gen >= gen)))
+ goto unlock;
- if ((qr_inode->data == NULL) &&
- (qr_inode->invalidation_time >= gen))
- goto unlock;
+ if ((qr_inode->data == NULL) && (qr_inode->invalidation_time >= gen))
+ goto unlock;
- __qr_inode_prune (this, table, qr_inode, gen);
+ __qr_inode_prune(this, table, qr_inode, gen);
- qr_inode->data = data;
- data = NULL;
- qr_inode->size = buf->ia_size;
+ qr_inode->data = data;
+ data = NULL;
+ qr_inode->size = buf->ia_size;
- qr_inode->ia_mtime = buf->ia_mtime;
- qr_inode->ia_mtime_nsec = buf->ia_mtime_nsec;
- qr_inode->ia_ctime = buf->ia_ctime;
- qr_inode->ia_ctime_nsec = buf->ia_ctime_nsec;
+ qr_inode->ia_mtime = buf->ia_mtime;
+ qr_inode->ia_mtime_nsec = buf->ia_mtime_nsec;
+ qr_inode->ia_ctime = buf->ia_ctime;
+ qr_inode->ia_ctime_nsec = buf->ia_ctime_nsec;
- qr_inode->buf = *buf;
+ qr_inode->buf = *buf;
- gettimeofday (&qr_inode->last_refresh, NULL);
+ gettimeofday(&qr_inode->last_refresh, NULL);
- __qr_inode_register (this, table, qr_inode);
- }
+ __qr_inode_register(this, table, qr_inode);
+ }
unlock:
- UNLOCK (&table->lock);
+ UNLOCK(&table->lock);
- if (data)
- GF_FREE (data);
+ if (data)
+ GF_FREE(data);
- qr_cache_prune (this);
+ qr_cache_prune(this);
}
-
gf_boolean_t
-qr_size_fits (qr_conf_t *conf, struct iatt *buf)
+qr_size_fits(qr_conf_t *conf, struct iatt *buf)
{
- return (buf->ia_size <= conf->max_file_size);
+ return (buf->ia_size <= conf->max_file_size);
}
-
gf_boolean_t
-qr_mtime_equal (qr_inode_t *qr_inode, struct iatt *buf)
+qr_mtime_equal(qr_inode_t *qr_inode, struct iatt *buf)
{
- return (qr_inode->ia_mtime == buf->ia_mtime &&
- qr_inode->ia_mtime_nsec == buf->ia_mtime_nsec);
+ return (qr_inode->ia_mtime == buf->ia_mtime &&
+ qr_inode->ia_mtime_nsec == buf->ia_mtime_nsec);
}
-
gf_boolean_t
-qr_ctime_equal (qr_inode_t *qr_inode, struct iatt *buf)
+qr_ctime_equal(qr_inode_t *qr_inode, struct iatt *buf)
{
- return (qr_inode->ia_ctime == buf->ia_ctime &&
- qr_inode->ia_ctime_nsec == buf->ia_ctime_nsec);
+ return (qr_inode->ia_ctime == buf->ia_ctime &&
+ qr_inode->ia_ctime_nsec == buf->ia_ctime_nsec);
}
-
gf_boolean_t
-qr_time_equal (qr_conf_t *conf, qr_inode_t *qr_inode, struct iatt *buf)
+qr_time_equal(qr_conf_t *conf, qr_inode_t *qr_inode, struct iatt *buf)
{
- if (conf->ctime_invalidation)
- return qr_ctime_equal (qr_inode, buf);
- else
- return qr_mtime_equal (qr_inode, buf);
+ if (conf->ctime_invalidation)
+ return qr_ctime_equal(qr_inode, buf);
+ else
+ return qr_mtime_equal(qr_inode, buf);
}
-
void
-__qr_content_refresh (xlator_t *this, qr_inode_t *qr_inode, struct iatt *buf,
- uint64_t gen)
+__qr_content_refresh(xlator_t *this, qr_inode_t *qr_inode, struct iatt *buf,
+ uint64_t gen)
{
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
- qr_conf_t *conf = NULL;
- uint32_t rollover = 0;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+ qr_conf_t *conf = NULL;
+ uint32_t rollover = 0;
- rollover = gen >> 32;
- gen = gen & 0xffffffff;
+ rollover = gen >> 32;
+ gen = gen & 0xffffffff;
- priv = this->private;
- table = &priv->table;
- conf = &priv->conf;
+ priv = this->private;
+ table = &priv->table;
+ conf = &priv->conf;
- /* allow for rollover of frame->root->unique */
- if ((rollover != qr_inode->gen_rollover) ||
- (gen && qr_inode->gen && (qr_inode->gen >= gen)))
- goto done;
+ /* allow for rollover of frame->root->unique */
+ if ((rollover != qr_inode->gen_rollover) ||
+ (gen && qr_inode->gen && (qr_inode->gen >= gen)))
+ goto done;
- if ((qr_inode->data == NULL) && (qr_inode->invalidation_time >= gen))
- goto done;
+ if ((qr_inode->data == NULL) && (qr_inode->invalidation_time >= gen))
+ goto done;
- qr_inode->gen = gen;
+ qr_inode->gen = gen;
- if (qr_size_fits (conf, buf) && qr_time_equal (conf, qr_inode, buf)) {
- qr_inode->buf = *buf;
+ if (qr_size_fits(conf, buf) && qr_time_equal(conf, qr_inode, buf)) {
+ qr_inode->buf = *buf;
- gettimeofday (&qr_inode->last_refresh, NULL);
+ gettimeofday(&qr_inode->last_refresh, NULL);
- __qr_inode_register (this, table, qr_inode);
- } else {
- __qr_inode_prune (this, table, qr_inode, gen);
- }
+ __qr_inode_register(this, table, qr_inode);
+ } else {
+ __qr_inode_prune(this, table, qr_inode, gen);
+ }
done:
- return;
+ return;
}
-
void
-qr_content_refresh (xlator_t *this, qr_inode_t *qr_inode, struct iatt *buf,
- uint64_t gen)
+qr_content_refresh(xlator_t *this, qr_inode_t *qr_inode, struct iatt *buf,
+ uint64_t gen)
{
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
- priv = this->private;
- table = &priv->table;
+ priv = this->private;
+ table = &priv->table;
- LOCK (&table->lock);
- {
- __qr_content_refresh (this, qr_inode, buf, gen);
- }
- UNLOCK (&table->lock);
+ LOCK(&table->lock);
+ {
+ __qr_content_refresh(this, qr_inode, buf, gen);
+ }
+ UNLOCK(&table->lock);
}
-
gf_boolean_t
-__qr_cache_is_fresh (xlator_t *this, qr_inode_t *qr_inode)
+__qr_cache_is_fresh(xlator_t *this, qr_inode_t *qr_inode)
{
- qr_conf_t *conf = NULL;
- qr_private_t *priv = NULL;
- struct timeval now;
- struct timeval diff;
+ qr_conf_t *conf = NULL;
+ qr_private_t *priv = NULL;
+ struct timeval now;
+ struct timeval diff;
- priv = this->private;
- conf = &priv->conf;
+ priv = this->private;
+ conf = &priv->conf;
- gettimeofday (&now, NULL);
+ gettimeofday(&now, NULL);
- timersub (&now, &qr_inode->last_refresh, &diff);
+ timersub(&now, &qr_inode->last_refresh, &diff);
- if (qr_inode->last_refresh.tv_sec < priv->last_child_down)
- return _gf_false;
+ if (qr_inode->last_refresh.tv_sec < priv->last_child_down)
+ return _gf_false;
- if (diff.tv_sec >= conf->cache_timeout)
- return _gf_false;
+ if (diff.tv_sec >= conf->cache_timeout)
+ return _gf_false;
- return _gf_true;
+ return _gf_true;
}
-
int
-qr_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode_ret,
- struct iatt *buf, dict_t *xdata, struct iatt *postparent)
+qr_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode_ret, struct iatt *buf,
+ dict_t *xdata, struct iatt *postparent)
{
- void *content = NULL;
- qr_inode_t *qr_inode = NULL;
- inode_t *inode = NULL;
- qr_local_t *local = NULL;
-
- local = frame->local;
- inode = local->inode;
-
- if (op_ret == -1) {
- qr_inode_prune (this, inode, local->incident_gen);
- goto out;
- }
-
- if (dict_get (xdata, GLUSTERFS_BAD_INODE)) {
- qr_inode_prune (this, inode, local->incident_gen);
- goto out;
+ void *content = NULL;
+ qr_inode_t *qr_inode = NULL;
+ inode_t *inode = NULL;
+ qr_local_t *local = NULL;
+
+ local = frame->local;
+ inode = local->inode;
+
+ if (op_ret == -1) {
+ qr_inode_prune(this, inode, local->incident_gen);
+ goto out;
+ }
+
+ if (dict_get(xdata, GLUSTERFS_BAD_INODE)) {
+ qr_inode_prune(this, inode, local->incident_gen);
+ goto out;
+ }
+
+ if (dict_get(xdata, "sh-failed")) {
+ qr_inode_prune(this, inode, local->incident_gen);
+ goto out;
+ }
+
+ content = qr_content_extract(xdata);
+
+ if (content) {
+ /* new content came along, always replace old content */
+ qr_inode = qr_inode_ctx_get_or_new(this, inode);
+ if (!qr_inode) {
+ /* no harm done */
+ GF_FREE(content);
+ goto out;
}
- if (dict_get (xdata, "sh-failed")) {
- qr_inode_prune (this, inode, local->incident_gen);
- goto out;
- }
-
- content = qr_content_extract (xdata);
-
- if (content) {
- /* new content came along, always replace old content */
- qr_inode = qr_inode_ctx_get_or_new (this, inode);
- if (!qr_inode) {
- /* no harm done */
- GF_FREE (content);
- goto out;
- }
-
- qr_content_update (this, qr_inode, content, buf,
- local->incident_gen);
- } else {
- /* purge old content if necessary */
- qr_inode = qr_inode_ctx_get (this, inode);
- if (!qr_inode)
- /* usual path for large files */
- goto out;
-
- qr_content_refresh (this, qr_inode, buf, local->incident_gen);
- }
+ qr_content_update(this, qr_inode, content, buf, local->incident_gen);
+ } else {
+ /* purge old content if necessary */
+ qr_inode = qr_inode_ctx_get(this, inode);
+ if (!qr_inode)
+ /* usual path for large files */
+ goto out;
+
+ qr_content_refresh(this, qr_inode, buf, local->incident_gen);
+ }
out:
- QR_STACK_UNWIND (lookup, frame, op_ret, op_errno, inode_ret,
- buf, xdata, postparent);
- return 0;
+ QR_STACK_UNWIND(lookup, frame, op_ret, op_errno, inode_ret, buf, xdata,
+ postparent);
+ return 0;
}
-
int
-qr_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+qr_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- qr_private_t *priv = NULL;
- qr_conf_t *conf = NULL;
- qr_inode_t *qr_inode = NULL;
- int ret = -1;
- dict_t *new_xdata = NULL;
- qr_local_t *local = NULL;
-
- priv = this->private;
- conf = &priv->conf;
- local = qr_local_get (this, loc->inode);
- local->inode = inode_ref (loc->inode);
- frame->local = local;
-
- qr_inode = qr_inode_ctx_get (this, loc->inode);
- if (qr_inode && qr_inode->data)
- /* cached. only validate in qr_lookup_cbk */
- goto wind;
-
- if (!xdata)
- xdata = new_xdata = dict_new ();
-
- if (!xdata)
- goto wind;
-
- ret = 0;
- if (conf->max_file_size)
- ret = dict_set (xdata, GF_CONTENT_KEY,
- data_from_uint64 (conf->max_file_size));
- if (ret)
- gf_msg (this->name, GF_LOG_WARNING, 0,
- QUICK_READ_MSG_DICT_SET_FAILED,
- "cannot set key in request dict (%s)",
- loc->path);
+ qr_private_t *priv = NULL;
+ qr_conf_t *conf = NULL;
+ qr_inode_t *qr_inode = NULL;
+ int ret = -1;
+ dict_t *new_xdata = NULL;
+ qr_local_t *local = NULL;
+
+ priv = this->private;
+ conf = &priv->conf;
+ local = qr_local_get(this, loc->inode);
+ local->inode = inode_ref(loc->inode);
+ frame->local = local;
+
+ qr_inode = qr_inode_ctx_get(this, loc->inode);
+ if (qr_inode && qr_inode->data)
+ /* cached. only validate in qr_lookup_cbk */
+ goto wind;
+
+ if (!xdata)
+ xdata = new_xdata = dict_new();
+
+ if (!xdata)
+ goto wind;
+
+ ret = 0;
+ if (conf->max_file_size)
+ ret = dict_set(xdata, GF_CONTENT_KEY,
+ data_from_uint64(conf->max_file_size));
+ if (ret)
+ gf_msg(this->name, GF_LOG_WARNING, 0, QUICK_READ_MSG_DICT_SET_FAILED,
+ "cannot set key in request dict (%s)", loc->path);
wind:
- STACK_WIND (frame, qr_lookup_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->lookup, loc, xdata);
+ STACK_WIND(frame, qr_lookup_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, loc, xdata);
- if (new_xdata)
- dict_unref (new_xdata);
+ if (new_xdata)
+ dict_unref(new_xdata);
- return 0;
+ return 0;
}
-
int
-qr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int op_ret, int op_errno, gf_dirent_t *entries, dict_t *xdata)
+qr_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
+ int op_errno, gf_dirent_t *entries, dict_t *xdata)
{
- gf_dirent_t *entry = NULL;
- qr_inode_t *qr_inode = NULL;
- qr_local_t *local = NULL;
+ gf_dirent_t *entry = NULL;
+ qr_inode_t *qr_inode = NULL;
+ qr_local_t *local = NULL;
- local = frame->local;
+ local = frame->local;
- if (op_ret <= 0)
- goto unwind;
+ if (op_ret <= 0)
+ goto unwind;
- list_for_each_entry (entry, &entries->list, list) {
- if (!entry->inode)
- continue;
+ list_for_each_entry(entry, &entries->list, list)
+ {
+ if (!entry->inode)
+ continue;
- qr_inode = qr_inode_ctx_get (this, entry->inode);
- if (!qr_inode)
- /* no harm */
- continue;
+ qr_inode = qr_inode_ctx_get(this, entry->inode);
+ if (!qr_inode)
+ /* no harm */
+ continue;
- qr_content_refresh (this, qr_inode, &entry->d_stat,
- local->incident_gen);
- }
+ qr_content_refresh(this, qr_inode, &entry->d_stat, local->incident_gen);
+ }
unwind:
- QR_STACK_UNWIND (readdirp, frame, op_ret, op_errno, entries, xdata);
- return 0;
+ QR_STACK_UNWIND(readdirp, frame, op_ret, op_errno, entries, xdata);
+ return 0;
}
-
int
-qr_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd,
- size_t size, off_t offset, dict_t *xdata)
+qr_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = qr_local_get (this, NULL);
- frame->local = local;
+ local = qr_local_get(this, NULL);
+ frame->local = local;
- STACK_WIND (frame, qr_readdirp_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->readdirp,
- fd, size, offset, xdata);
- return 0;
+ STACK_WIND(frame, qr_readdirp_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp, fd, size, offset, xdata);
+ return 0;
}
-
int
-qr_readv_cached (call_frame_t *frame, qr_inode_t *qr_inode, size_t size,
- off_t offset, uint32_t flags, dict_t *xdata)
+qr_readv_cached(call_frame_t *frame, qr_inode_t *qr_inode, size_t size,
+ off_t offset, uint32_t flags, dict_t *xdata)
{
- xlator_t *this = NULL;
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
- int op_ret = -1;
- struct iobuf *iobuf = NULL;
- struct iobref *iobref = NULL;
- struct iovec iov = {0, };
- struct iatt buf = {0, };
-
- this = frame->this;
- priv = this->private;
- table = &priv->table;
-
- LOCK (&table->lock);
- {
- if (!qr_inode->data)
- goto unlock;
-
- if (offset >= qr_inode->size)
- goto unlock;
-
- if (!__qr_cache_is_fresh (this, qr_inode))
- goto unlock;
-
- op_ret = min (size, (qr_inode->size - offset));
-
- iobuf = iobuf_get2 (this->ctx->iobuf_pool, op_ret);
- if (!iobuf) {
- op_ret = -1;
- goto unlock;
- }
+ xlator_t *this = NULL;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+ int op_ret = -1;
+ struct iobuf *iobuf = NULL;
+ struct iobref *iobref = NULL;
+ struct iovec iov = {
+ 0,
+ };
+ struct iatt buf = {
+ 0,
+ };
+
+ this = frame->this;
+ priv = this->private;
+ table = &priv->table;
+
+ LOCK(&table->lock);
+ {
+ if (!qr_inode->data)
+ goto unlock;
+
+ if (offset >= qr_inode->size)
+ goto unlock;
+
+ if (!__qr_cache_is_fresh(this, qr_inode))
+ goto unlock;
+
+ op_ret = min(size, (qr_inode->size - offset));
+
+ iobuf = iobuf_get2(this->ctx->iobuf_pool, op_ret);
+ if (!iobuf) {
+ op_ret = -1;
+ goto unlock;
+ }
- iobref = iobref_new ();
- if (!iobref) {
- op_ret = -1;
- goto unlock;
- }
+ iobref = iobref_new();
+ if (!iobref) {
+ op_ret = -1;
+ goto unlock;
+ }
- iobref_add (iobref, iobuf);
+ iobref_add(iobref, iobuf);
- memcpy (iobuf->ptr, qr_inode->data + offset, op_ret);
+ memcpy(iobuf->ptr, qr_inode->data + offset, op_ret);
- buf = qr_inode->buf;
+ buf = qr_inode->buf;
- /* bump LRU */
- __qr_inode_register (frame->this, table, qr_inode);
- }
+ /* bump LRU */
+ __qr_inode_register(frame->this, table, qr_inode);
+ }
unlock:
- UNLOCK (&table->lock);
+ UNLOCK(&table->lock);
- if (op_ret >= 0) {
- iov.iov_base = iobuf->ptr;
- iov.iov_len = op_ret;
+ if (op_ret >= 0) {
+ iov.iov_base = iobuf->ptr;
+ iov.iov_len = op_ret;
- GF_ATOMIC_INC (priv->qr_counter.cache_hit);
- STACK_UNWIND_STRICT (readv, frame, op_ret, 0, &iov, 1,
- &buf, iobref, xdata);
- } else {
- GF_ATOMIC_INC (priv->qr_counter.cache_miss);
- }
+ GF_ATOMIC_INC(priv->qr_counter.cache_hit);
+ STACK_UNWIND_STRICT(readv, frame, op_ret, 0, &iov, 1, &buf, iobref,
+ xdata);
+ } else {
+ GF_ATOMIC_INC(priv->qr_counter.cache_miss);
+ }
- if (iobuf)
- iobuf_unref (iobuf);
+ if (iobuf)
+ iobuf_unref(iobuf);
- if (iobref)
- iobref_unref (iobref);
+ if (iobref)
+ iobref_unref(iobref);
- return op_ret;
+ return op_ret;
}
-
int
-qr_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, uint32_t flags, dict_t *xdata)
+qr_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, uint32_t flags, dict_t *xdata)
{
- qr_inode_t *qr_inode = NULL;
+ qr_inode_t *qr_inode = NULL;
- qr_inode = qr_inode_ctx_get (this, fd->inode);
- if (!qr_inode)
- goto wind;
+ qr_inode = qr_inode_ctx_get(this, fd->inode);
+ if (!qr_inode)
+ goto wind;
- if (qr_readv_cached (frame, qr_inode, size, offset, flags, xdata) < 0)
- goto wind;
+ if (qr_readv_cached(frame, qr_inode, size, offset, flags, xdata) < 0)
+ goto wind;
- return 0;
+ return 0;
wind:
- STACK_WIND (frame, default_readv_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->readv,
- fd, size, offset, flags, xdata);
- return 0;
+ STACK_WIND(frame, default_readv_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv, fd, size, offset, flags, xdata);
+ return 0;
}
int32_t
-qr_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, dict_t *xdata)
+qr_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,
+ dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = frame->local;
+ local = frame->local;
- qr_inode_prune (this, local->fd->inode, local->incident_gen);
+ qr_inode_prune(this, local->fd->inode, local->incident_gen);
- QR_STACK_UNWIND (writev, frame, op_ret, op_errno,
- prebuf, postbuf, xdata);
- return 0;
+ QR_STACK_UNWIND(writev, frame, op_ret, op_errno, prebuf, postbuf, xdata);
+ return 0;
}
int
-qr_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *iov,
- int count, off_t offset, uint32_t flags, struct iobref *iobref,
- dict_t *xdata)
+qr_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *iov,
+ int count, off_t offset, uint32_t flags, struct iobref *iobref,
+ dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = qr_local_get (this, fd->inode);
- local->fd = fd_ref (fd);
+ local = qr_local_get(this, fd->inode);
+ local->fd = fd_ref(fd);
- frame->local = local;
+ frame->local = local;
- STACK_WIND (frame, qr_writev_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev,
- fd, iov, count, offset, flags, iobref, xdata);
- return 0;
+ STACK_WIND(frame, qr_writev_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->writev, fd, iov, count, offset, flags,
+ iobref, xdata);
+ return 0;
}
int32_t
-qr_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+qr_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = frame->local;
- qr_inode_prune (this, local->inode, local->incident_gen);
+ local = frame->local;
+ qr_inode_prune(this, local->inode, local->incident_gen);
- QR_STACK_UNWIND (truncate, frame, op_ret, op_errno,
- prebuf, postbuf, xdata);
- return 0;
+ QR_STACK_UNWIND(truncate, frame, op_ret, op_errno, prebuf, postbuf, xdata);
+ return 0;
}
-
int
-qr_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
- dict_t *xdata)
+qr_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
+ dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = qr_local_get (this, loc->inode);
- local->inode = inode_ref (loc->inode);
- frame->local = local;
+ local = qr_local_get(this, loc->inode);
+ local->inode = inode_ref(loc->inode);
+ frame->local = local;
- STACK_WIND (frame, qr_truncate_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->truncate,
- loc, offset, xdata);
- return 0;
+ STACK_WIND(frame, qr_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
+ return 0;
}
int32_t
-qr_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+qr_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = frame->local;
- qr_inode_prune (this, local->fd->inode, local->incident_gen);
+ local = frame->local;
+ qr_inode_prune(this, local->fd->inode, local->incident_gen);
- QR_STACK_UNWIND (ftruncate, frame, op_ret, op_errno,
- prebuf, postbuf, xdata);
- return 0;
+ QR_STACK_UNWIND(ftruncate, frame, op_ret, op_errno, prebuf, postbuf, xdata);
+ return 0;
}
int
-qr_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- dict_t *xdata)
+qr_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = qr_local_get (this, fd->inode);
- local->fd = fd_ref (fd);
- frame->local = local;
+ local = qr_local_get(this, fd->inode);
+ local->fd = fd_ref(fd);
+ frame->local = local;
- STACK_WIND (frame, qr_ftruncate_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->ftruncate,
- fd, offset, xdata);
- return 0;
+ STACK_WIND(frame, qr_ftruncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata);
+ return 0;
}
int32_t
-qr_fallocate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *pre,
- struct iatt *post, dict_t *xdata)
+qr_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *pre,
+ struct iatt *post, dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = frame->local;
- qr_inode_prune (this, local->fd->inode, local->incident_gen);
+ local = frame->local;
+ qr_inode_prune(this, local->fd->inode, local->incident_gen);
- QR_STACK_UNWIND (fallocate, frame, op_ret, op_errno,
- pre, post, xdata);
- return 0;
+ QR_STACK_UNWIND(fallocate, frame, op_ret, op_errno, pre, post, xdata);
+ return 0;
}
static int
-qr_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int keep_size,
- off_t offset, size_t len, dict_t *xdata)
+qr_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int keep_size,
+ off_t offset, size_t len, dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = qr_local_get (this, fd->inode);
- local->fd = fd_ref (fd);
- frame->local = local;
+ local = qr_local_get(this, fd->inode);
+ local->fd = fd_ref(fd);
+ frame->local = local;
- STACK_WIND (frame, qr_fallocate_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->fallocate,
- fd, keep_size, offset, len, xdata);
- return 0;
+ STACK_WIND(frame, qr_fallocate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fallocate, fd, keep_size, offset, len,
+ xdata);
+ return 0;
}
int32_t
-qr_discard_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *pre,
- struct iatt *post, dict_t *xdata)
+qr_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *pre,
+ struct iatt *post, dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = frame->local;
- qr_inode_prune (this, local->fd->inode, local->incident_gen);
+ local = frame->local;
+ qr_inode_prune(this, local->fd->inode, local->incident_gen);
- QR_STACK_UNWIND (discard, frame, op_ret, op_errno,
- pre, post, xdata);
- return 0;
+ QR_STACK_UNWIND(discard, frame, op_ret, op_errno, pre, post, xdata);
+ return 0;
}
static int
-qr_discard (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- size_t len, dict_t *xdata)
+qr_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ size_t len, dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = qr_local_get (this, fd->inode);
- local->fd = fd_ref (fd);
- frame->local = local;
+ local = qr_local_get(this, fd->inode);
+ local->fd = fd_ref(fd);
+ frame->local = local;
- STACK_WIND (frame, qr_discard_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->discard,
- fd, offset, len, xdata);
- return 0;
+ STACK_WIND(frame, qr_discard_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->discard, fd, offset, len, xdata);
+ return 0;
}
int32_t
-qr_zerofill_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *pre,
- struct iatt *post, dict_t *xdata)
+qr_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *pre,
+ struct iatt *post, dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = frame->local;
- qr_inode_prune (this, local->fd->inode, local->incident_gen);
+ local = frame->local;
+ qr_inode_prune(this, local->fd->inode, local->incident_gen);
- QR_STACK_UNWIND (zerofill, frame, op_ret, op_errno,
- pre, post, xdata);
- return 0;
+ QR_STACK_UNWIND(zerofill, frame, op_ret, op_errno, pre, post, xdata);
+ return 0;
}
static int
-qr_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- off_t len, dict_t *xdata)
+qr_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ off_t len, dict_t *xdata)
{
- qr_local_t *local = NULL;
+ qr_local_t *local = NULL;
- local = qr_local_get (this, fd->inode);
- local->fd = fd_ref (fd);
- frame->local = local;
+ local = qr_local_get(this, fd->inode);
+ local->fd = fd_ref(fd);
+ frame->local = local;
- STACK_WIND (frame, qr_zerofill_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->zerofill,
- fd, offset, len, xdata);
- return 0;
+ STACK_WIND(frame, qr_zerofill_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->zerofill, fd, offset, len, xdata);
+ return 0;
}
int
-qr_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int flags,
- fd_t *fd, dict_t *xdata)
+qr_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int flags, fd_t *fd,
+ dict_t *xdata)
{
- qr_inode_set_priority (this, fd->inode, loc->path);
+ qr_inode_set_priority(this, fd->inode, loc->path);
- STACK_WIND (frame, default_open_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->open,
- loc, flags, fd, xdata);
- return 0;
+ STACK_WIND(frame, default_open_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata);
+ return 0;
}
int
-qr_forget (xlator_t *this, inode_t *inode)
+qr_forget(xlator_t *this, inode_t *inode)
{
- qr_inode_t *qr_inode = NULL;
+ qr_inode_t *qr_inode = NULL;
- qr_inode = qr_inode_ctx_get (this, inode);
+ qr_inode = qr_inode_ctx_get(this, inode);
- if (!qr_inode)
- return 0;
+ if (!qr_inode)
+ return 0;
- qr_inode_prune (this, inode, qr_get_generation (this, inode));
+ qr_inode_prune(this, inode, qr_get_generation(this, inode));
- GF_FREE (qr_inode);
+ GF_FREE(qr_inode);
- return 0;
+ return 0;
}
-
int32_t
-qr_inodectx_dump (xlator_t *this, inode_t *inode)
+qr_inodectx_dump(xlator_t *this, inode_t *inode)
{
- qr_inode_t *qr_inode = NULL;
- int32_t ret = -1;
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
- char buf[256] = {0, };
-
- qr_inode = qr_inode_ctx_get (this, inode);
- if (!qr_inode)
- goto out;
-
- gf_proc_dump_build_key (key_prefix, "xlator.performance.quick-read",
- "inodectx");
- gf_proc_dump_add_section (key_prefix);
-
- gf_proc_dump_write ("entire-file-cached", "%s", qr_inode->data ? "yes" : "no");
-
- if (qr_inode->last_refresh.tv_sec) {
- gf_time_fmt (buf, sizeof buf, qr_inode->last_refresh.tv_sec,
- gf_timefmt_FT);
- snprintf (buf + strlen (buf), sizeof buf - strlen (buf),
- ".%"GF_PRI_SUSECONDS, qr_inode->last_refresh.tv_usec);
-
- gf_proc_dump_write ("last-cache-validation-time", "%s", buf);
- }
-
- ret = 0;
+ qr_inode_t *qr_inode = NULL;
+ int32_t ret = -1;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ char buf[256] = {
+ 0,
+ };
+
+ qr_inode = qr_inode_ctx_get(this, inode);
+ if (!qr_inode)
+ goto out;
+
+ gf_proc_dump_build_key(key_prefix, "xlator.performance.quick-read",
+ "inodectx");
+ gf_proc_dump_add_section(key_prefix);
+
+ gf_proc_dump_write("entire-file-cached", "%s",
+ qr_inode->data ? "yes" : "no");
+
+ if (qr_inode->last_refresh.tv_sec) {
+ gf_time_fmt(buf, sizeof buf, qr_inode->last_refresh.tv_sec,
+ gf_timefmt_FT);
+ snprintf(buf + strlen(buf), sizeof buf - strlen(buf),
+ ".%" GF_PRI_SUSECONDS, qr_inode->last_refresh.tv_usec);
+
+ gf_proc_dump_write("last-cache-validation-time", "%s", buf);
+ }
+
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
int
-qr_priv_dump (xlator_t *this)
+qr_priv_dump(xlator_t *this)
{
- qr_conf_t *conf = NULL;
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
- uint32_t file_count = 0;
- uint32_t i = 0;
- qr_inode_t *curr = NULL;
- uint64_t total_size = 0;
- char key_prefix[GF_DUMP_MAX_BUF_LEN];
-
- if (!this) {
- return -1;
- }
+ qr_conf_t *conf = NULL;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+ uint32_t file_count = 0;
+ uint32_t i = 0;
+ qr_inode_t *curr = NULL;
+ uint64_t total_size = 0;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN];
- priv = this->private;
- conf = &priv->conf;
- if (!conf)
- return -1;
+ if (!this) {
+ return -1;
+ }
- table = &priv->table;
+ priv = this->private;
+ conf = &priv->conf;
+ if (!conf)
+ return -1;
- gf_proc_dump_build_key (key_prefix, "xlator.performance.quick-read",
- "priv");
+ table = &priv->table;
- gf_proc_dump_add_section (key_prefix);
+ gf_proc_dump_build_key(key_prefix, "xlator.performance.quick-read", "priv");
- gf_proc_dump_write ("max_file_size", "%d", conf->max_file_size);
- gf_proc_dump_write ("cache_timeout", "%d", conf->cache_timeout);
+ gf_proc_dump_add_section(key_prefix);
- if (!table) {
- goto out;
- } else {
- for (i = 0; i < conf->max_pri; i++) {
- list_for_each_entry (curr, &table->lru[i], lru) {
- file_count++;
- total_size += curr->size;
- }
- }
+ gf_proc_dump_write("max_file_size", "%d", conf->max_file_size);
+ gf_proc_dump_write("cache_timeout", "%d", conf->cache_timeout);
+
+ if (!table) {
+ goto out;
+ } else {
+ for (i = 0; i < conf->max_pri; i++) {
+ list_for_each_entry(curr, &table->lru[i], lru)
+ {
+ file_count++;
+ total_size += curr->size;
+ }
}
+ }
- gf_proc_dump_write ("total_files_cached", "%d", file_count);
- gf_proc_dump_write ("total_cache_used", "%d", total_size);
- gf_proc_dump_write ("cache-hit", "%"PRId64,
- priv->qr_counter.cache_hit);
- gf_proc_dump_write ("cache-miss", "%"PRId64,
- priv->qr_counter.cache_miss);
- gf_proc_dump_write ("cache-invalidations", "%"PRId64,
- priv->qr_counter.file_data_invals);
+ gf_proc_dump_write("total_files_cached", "%d", file_count);
+ gf_proc_dump_write("total_cache_used", "%d", total_size);
+ gf_proc_dump_write("cache-hit", "%" PRId64, priv->qr_counter.cache_hit);
+ gf_proc_dump_write("cache-miss", "%" PRId64, priv->qr_counter.cache_miss);
+ gf_proc_dump_write("cache-invalidations", "%" PRId64,
+ priv->qr_counter.file_data_invals);
out:
- return 0;
+ return 0;
}
-
static int32_t
-qr_dump_metrics (xlator_t *this, int fd)
+qr_dump_metrics(xlator_t *this, int fd)
{
- qr_private_t *priv = NULL;
- qr_inode_table_t *table = NULL;
-
- priv = this->private;
- table = &priv->table;
-
- dprintf (fd, "%s.total_files_cached %"PRId64"\n", this->name,
- GF_ATOMIC_GET(priv->qr_counter.files_cached));
- dprintf (fd, "%s.total_cache_used %"PRId64"\n", this->name,
- table->cache_used);
- dprintf (fd, "%s.cache-hit %"PRId64"\n", this->name,
- GF_ATOMIC_GET(priv->qr_counter.cache_hit));
- dprintf (fd, "%s.cache-miss %"PRId64"\n", this->name,
- GF_ATOMIC_GET(priv->qr_counter.cache_miss));
- dprintf (fd, "%s.cache-invalidations %"PRId64"\n", this->name,
- GF_ATOMIC_GET(priv->qr_counter.file_data_invals));
-
- return 0;
+ qr_private_t *priv = NULL;
+ qr_inode_table_t *table = NULL;
+
+ priv = this->private;
+ table = &priv->table;
+
+ dprintf(fd, "%s.total_files_cached %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(priv->qr_counter.files_cached));
+ dprintf(fd, "%s.total_cache_used %" PRId64 "\n", this->name,
+ table->cache_used);
+ dprintf(fd, "%s.cache-hit %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(priv->qr_counter.cache_hit));
+ dprintf(fd, "%s.cache-miss %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(priv->qr_counter.cache_miss));
+ dprintf(fd, "%s.cache-invalidations %" PRId64 "\n", this->name,
+ GF_ATOMIC_GET(priv->qr_counter.file_data_invals));
+
+ return 0;
}
-
int32_t
-qr_mem_acct_init (xlator_t *this)
+qr_mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- if (!this)
- return ret;
-
- ret = xlator_mem_acct_init (this, gf_qr_mt_end + 1);
+ if (!this)
+ return ret;
- if (ret != 0) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- QUICK_READ_MSG_NO_MEMORY,
- "Memory accounting init failed");
- return ret;
- }
+ ret = xlator_mem_acct_init(this, gf_qr_mt_end + 1);
+ if (ret != 0) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, QUICK_READ_MSG_NO_MEMORY,
+ "Memory accounting init failed");
return ret;
-}
+ }
+ return ret;
+}
static gf_boolean_t
-check_cache_size_ok (xlator_t *this, int64_t cache_size)
+check_cache_size_ok(xlator_t *this, int64_t cache_size)
{
- int ret = _gf_true;
- uint64_t total_mem = 0;
- uint64_t max_cache_size = 0;
- volume_option_t *opt = NULL;
-
- GF_ASSERT (this);
- opt = xlator_volume_option_get (this, "cache-size");
- if (!opt) {
- ret = _gf_false;
- gf_msg (this->name, GF_LOG_ERROR, EINVAL,
- QUICK_READ_MSG_INVALID_ARGUMENT,
- "could not get cache-size option");
- goto out;
- }
-
- total_mem = get_mem_size ();
- if (-1 == total_mem)
- max_cache_size = opt->max;
- else
- max_cache_size = total_mem;
-
- gf_msg_debug (this->name, 0, "Max cache size is %"PRIu64,
- max_cache_size);
- if (cache_size > max_cache_size) {
- ret = _gf_false;
- gf_msg (this->name, GF_LOG_ERROR, 0,
- QUICK_READ_MSG_INVALID_ARGUMENT, "Cache size %"PRIu64
- " is greater than the max size of %"PRIu64,
- cache_size, max_cache_size);
- goto out;
- }
+ int ret = _gf_true;
+ uint64_t total_mem = 0;
+ uint64_t max_cache_size = 0;
+ volume_option_t *opt = NULL;
+
+ GF_ASSERT(this);
+ opt = xlator_volume_option_get(this, "cache-size");
+ if (!opt) {
+ ret = _gf_false;
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL,
+ QUICK_READ_MSG_INVALID_ARGUMENT,
+ "could not get cache-size option");
+ goto out;
+ }
+
+ total_mem = get_mem_size();
+ if (-1 == total_mem)
+ max_cache_size = opt->max;
+ else
+ max_cache_size = total_mem;
+
+ gf_msg_debug(this->name, 0, "Max cache size is %" PRIu64, max_cache_size);
+ if (cache_size > max_cache_size) {
+ ret = _gf_false;
+ gf_msg(this->name, GF_LOG_ERROR, 0, QUICK_READ_MSG_INVALID_ARGUMENT,
+ "Cache size %" PRIu64
+ " is greater than the max size of %" PRIu64,
+ cache_size, max_cache_size);
+ goto out;
+ }
out:
- return ret;
+ return ret;
}
int
-qr_reconfigure (xlator_t *this, dict_t *options)
+qr_reconfigure(xlator_t *this, dict_t *options)
{
- int32_t ret = -1;
- qr_private_t *priv = NULL;
- qr_conf_t *conf = NULL;
- uint64_t cache_size_new = 0;
+ int32_t ret = -1;
+ qr_private_t *priv = NULL;
+ qr_conf_t *conf = NULL;
+ uint64_t cache_size_new = 0;
- GF_VALIDATE_OR_GOTO ("quick-read", this, out);
- GF_VALIDATE_OR_GOTO (this->name, this->private, out);
- GF_VALIDATE_OR_GOTO (this->name, options, out);
+ GF_VALIDATE_OR_GOTO("quick-read", this, out);
+ GF_VALIDATE_OR_GOTO(this->name, this->private, out);
+ GF_VALIDATE_OR_GOTO(this->name, options, out);
- priv = this->private;
+ priv = this->private;
- conf = &priv->conf;
- if (!conf) {
- goto out;
- }
+ conf = &priv->conf;
+ if (!conf) {
+ goto out;
+ }
- GF_OPTION_RECONF ("cache-timeout", conf->cache_timeout, options, int32,
- out);
+ GF_OPTION_RECONF("cache-timeout", conf->cache_timeout, options, int32, out);
- GF_OPTION_RECONF ("cache-invalidation", conf->qr_invalidation, options,
- bool, out);
+ GF_OPTION_RECONF("cache-invalidation", conf->qr_invalidation, options, bool,
+ out);
- GF_OPTION_RECONF ("ctime-invalidation", conf->ctime_invalidation,
- options, bool, out);
+ GF_OPTION_RECONF("ctime-invalidation", conf->ctime_invalidation, options,
+ bool, out);
- GF_OPTION_RECONF ("cache-size", cache_size_new, options, size_uint64, out);
- if (!check_cache_size_ok (this, cache_size_new)) {
- ret = -1;
- gf_msg (this->name, GF_LOG_ERROR, EINVAL,
- QUICK_READ_MSG_INVALID_CONFIG,
- "Not reconfiguring cache-size");
- goto out;
- }
- conf->cache_size = cache_size_new;
+ GF_OPTION_RECONF("cache-size", cache_size_new, options, size_uint64, out);
+ if (!check_cache_size_ok(this, cache_size_new)) {
+ ret = -1;
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL, QUICK_READ_MSG_INVALID_CONFIG,
+ "Not reconfiguring cache-size");
+ goto out;
+ }
+ conf->cache_size = cache_size_new;
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
int32_t
-qr_get_priority_list (const char *opt_str, struct list_head *first)
+qr_get_priority_list(const char *opt_str, struct list_head *first)
{
- int32_t max_pri = 1;
- char *tmp_str = NULL;
- char *tmp_str1 = NULL;
- char *tmp_str2 = NULL;
- char *dup_str = NULL;
- char *priority_str = NULL;
- char *pattern = NULL;
- char *priority = NULL;
- char *string = NULL;
- struct qr_priority *curr = NULL, *tmp = NULL;
-
- GF_VALIDATE_OR_GOTO ("quick-read", opt_str, out);
- GF_VALIDATE_OR_GOTO ("quick-read", first, out);
-
- string = gf_strdup (opt_str);
- if (string == NULL) {
- max_pri = -1;
- goto out;
- }
-
- /* Get the pattern for cache priority.
- * "option priority *.jpg:1,abc*:2" etc
- */
- /* TODO: inode_lru in table is statically hard-coded to 5,
- * should be changed to run-time configuration
- */
- priority_str = strtok_r (string, ",", &tmp_str);
- while (priority_str) {
- curr = GF_CALLOC (1, sizeof (*curr), gf_qr_mt_qr_priority_t);
- if (curr == NULL) {
- max_pri = -1;
- goto out;
- }
-
- list_add_tail (&curr->list, first);
-
- dup_str = gf_strdup (priority_str);
- if (dup_str == NULL) {
- max_pri = -1;
- goto out;
- }
-
- pattern = strtok_r (dup_str, ":", &tmp_str1);
- if (!pattern) {
- max_pri = -1;
- goto out;
- }
-
- priority = strtok_r (NULL, ":", &tmp_str1);
- if (!priority) {
- max_pri = -1;
- goto out;
- }
-
- gf_msg_trace ("quick-read", 0,
- "quick-read priority : pattern %s : priority %s",
- pattern, priority);
-
- curr->pattern = gf_strdup (pattern);
- if (curr->pattern == NULL) {
- max_pri = -1;
- goto out;
- }
-
- curr->priority = strtol (priority, &tmp_str2, 0);
- if (tmp_str2 && (*tmp_str2)) {
- max_pri = -1;
- goto out;
- } else {
- max_pri = max (max_pri, curr->priority);
- }
-
- GF_FREE (dup_str);
- dup_str = NULL;
-
- priority_str = strtok_r (NULL, ",", &tmp_str);
+ int32_t max_pri = 1;
+ char *tmp_str = NULL;
+ char *tmp_str1 = NULL;
+ char *tmp_str2 = NULL;
+ char *dup_str = NULL;
+ char *priority_str = NULL;
+ char *pattern = NULL;
+ char *priority = NULL;
+ char *string = NULL;
+ struct qr_priority *curr = NULL, *tmp = NULL;
+
+ GF_VALIDATE_OR_GOTO("quick-read", opt_str, out);
+ GF_VALIDATE_OR_GOTO("quick-read", first, out);
+
+ string = gf_strdup(opt_str);
+ if (string == NULL) {
+ max_pri = -1;
+ goto out;
+ }
+
+ /* Get the pattern for cache priority.
+ * "option priority *.jpg:1,abc*:2" etc
+ */
+ /* TODO: inode_lru in table is statically hard-coded to 5,
+ * should be changed to run-time configuration
+ */
+ priority_str = strtok_r(string, ",", &tmp_str);
+ while (priority_str) {
+ curr = GF_CALLOC(1, sizeof(*curr), gf_qr_mt_qr_priority_t);
+ if (curr == NULL) {
+ max_pri = -1;
+ goto out;
}
-out:
- GF_FREE (string);
- GF_FREE (dup_str);
+ list_add_tail(&curr->list, first);
- if (max_pri == -1) {
- list_for_each_entry_safe (curr, tmp, first, list) {
- list_del_init (&curr->list);
- GF_FREE (curr->pattern);
- GF_FREE (curr);
- }
+ dup_str = gf_strdup(priority_str);
+ if (dup_str == NULL) {
+ max_pri = -1;
+ goto out;
}
- return max_pri;
-}
-
-
-int32_t
-qr_init (xlator_t *this)
-{
- int32_t ret = -1, i = 0;
- qr_private_t *priv = NULL;
- qr_conf_t *conf = NULL;
-
- if (!this->children || this->children->next) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- QUICK_READ_MSG_XLATOR_CHILD_MISCONFIGURED,
- "FATAL: volume (%s) not configured with exactly one "
- "child", this->name);
- return -1;
+ pattern = strtok_r(dup_str, ":", &tmp_str1);
+ if (!pattern) {
+ max_pri = -1;
+ goto out;
}
- if (!this->parents) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- QUICK_READ_MSG_VOL_MISCONFIGURED,
- "dangling volume. check volfile ");
+ priority = strtok_r(NULL, ":", &tmp_str1);
+ if (!priority) {
+ max_pri = -1;
+ goto out;
}
- priv = GF_CALLOC (1, sizeof (*priv), gf_qr_mt_qr_private_t);
- if (priv == NULL) {
- ret = -1;
- goto out;
+ gf_msg_trace("quick-read", 0,
+ "quick-read priority : pattern %s : priority %s", pattern,
+ priority);
+
+ curr->pattern = gf_strdup(pattern);
+ if (curr->pattern == NULL) {
+ max_pri = -1;
+ goto out;
}
- LOCK_INIT (&priv->table.lock);
- conf = &priv->conf;
+ curr->priority = strtol(priority, &tmp_str2, 0);
+ if (tmp_str2 && (*tmp_str2)) {
+ max_pri = -1;
+ goto out;
+ } else {
+ max_pri = max(max_pri, curr->priority);
+ }
- GF_OPTION_INIT ("max-file-size", conf->max_file_size, size_uint64, out);
+ GF_FREE(dup_str);
+ dup_str = NULL;
- GF_OPTION_INIT ("cache-timeout", conf->cache_timeout, int32, out);
+ priority_str = strtok_r(NULL, ",", &tmp_str);
+ }
+out:
+ GF_FREE(string);
- GF_OPTION_INIT ("cache-invalidation", conf->qr_invalidation, bool, out);
+ GF_FREE(dup_str);
- GF_OPTION_INIT ("cache-size", conf->cache_size, size_uint64, out);
- if (!check_cache_size_ok (this, conf->cache_size)) {
- ret = -1;
- goto out;
+ if (max_pri == -1) {
+ list_for_each_entry_safe(curr, tmp, first, list)
+ {
+ list_del_init(&curr->list);
+ GF_FREE(curr->pattern);
+ GF_FREE(curr);
}
+ }
- GF_OPTION_INIT ("ctime-invalidation", conf->ctime_invalidation, bool,
- out);
-
- INIT_LIST_HEAD (&conf->priority_list);
- conf->max_pri = 1;
- if (dict_get (this->options, "priority")) {
- char *option_list = data_to_str (dict_get (this->options,
- "priority"));
- gf_msg_trace (this->name, 0,
- "option path %s", option_list);
- /* parse the list of pattern:priority */
- conf->max_pri = qr_get_priority_list (option_list,
- &conf->priority_list);
-
- if (conf->max_pri == -1) {
- goto out;
- }
- conf->max_pri ++;
- }
+ return max_pri;
+}
- priv->table.lru = GF_CALLOC (conf->max_pri, sizeof (*priv->table.lru),
- gf_common_mt_list_head);
- if (priv->table.lru == NULL) {
- ret = -1;
- goto out;
+int32_t
+qr_init(xlator_t *this)
+{
+ int32_t ret = -1, i = 0;
+ qr_private_t *priv = NULL;
+ qr_conf_t *conf = NULL;
+
+ if (!this->children || this->children->next) {
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ QUICK_READ_MSG_XLATOR_CHILD_MISCONFIGURED,
+ "FATAL: volume (%s) not configured with exactly one "
+ "child",
+ this->name);
+ return -1;
+ }
+
+ if (!this->parents) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, QUICK_READ_MSG_VOL_MISCONFIGURED,
+ "dangling volume. check volfile ");
+ }
+
+ priv = GF_CALLOC(1, sizeof(*priv), gf_qr_mt_qr_private_t);
+ if (priv == NULL) {
+ ret = -1;
+ goto out;
+ }
+
+ LOCK_INIT(&priv->table.lock);
+ conf = &priv->conf;
+
+ GF_OPTION_INIT("max-file-size", conf->max_file_size, size_uint64, out);
+
+ GF_OPTION_INIT("cache-timeout", conf->cache_timeout, int32, out);
+
+ GF_OPTION_INIT("cache-invalidation", conf->qr_invalidation, bool, out);
+
+ GF_OPTION_INIT("cache-size", conf->cache_size, size_uint64, out);
+ if (!check_cache_size_ok(this, conf->cache_size)) {
+ ret = -1;
+ goto out;
+ }
+
+ GF_OPTION_INIT("ctime-invalidation", conf->ctime_invalidation, bool, out);
+
+ INIT_LIST_HEAD(&conf->priority_list);
+ conf->max_pri = 1;
+ if (dict_get(this->options, "priority")) {
+ char *option_list = data_to_str(dict_get(this->options, "priority"));
+ gf_msg_trace(this->name, 0, "option path %s", option_list);
+ /* parse the list of pattern:priority */
+ conf->max_pri = qr_get_priority_list(option_list, &conf->priority_list);
+
+ if (conf->max_pri == -1) {
+ goto out;
}
+ conf->max_pri++;
+ }
- for (i = 0; i < conf->max_pri; i++) {
- INIT_LIST_HEAD (&priv->table.lru[i]);
- }
+ priv->table.lru = GF_CALLOC(conf->max_pri, sizeof(*priv->table.lru),
+ gf_common_mt_list_head);
+ if (priv->table.lru == NULL) {
+ ret = -1;
+ goto out;
+ }
- ret = 0;
+ for (i = 0; i < conf->max_pri; i++) {
+ INIT_LIST_HEAD(&priv->table.lru[i]);
+ }
- time (&priv->last_child_down);
- GF_ATOMIC_INIT (priv->generation, 0);
- this->private = priv;
+ ret = 0;
+
+ time(&priv->last_child_down);
+ GF_ATOMIC_INIT(priv->generation, 0);
+ this->private = priv;
out:
- if ((ret == -1) && priv) {
- GF_FREE (priv);
- }
+ if ((ret == -1) && priv) {
+ GF_FREE(priv);
+ }
- return ret;
+ return ret;
}
-
void
-qr_inode_table_destroy (qr_private_t *priv)
+qr_inode_table_destroy(qr_private_t *priv)
{
- int i = 0;
- qr_conf_t *conf = NULL;
-
- conf = &priv->conf;
-
- for (i = 0; i < conf->max_pri; i++) {
- /* There is a known leak of inodes, hence until
- * that is fixed, log the assert as warning.
- GF_ASSERT (list_empty (&priv->table.lru[i]));*/
- if (!list_empty (&priv->table.lru[i])) {
- gf_msg ("quick-read", GF_LOG_INFO, 0,
- QUICK_READ_MSG_LRU_NOT_EMPTY,
- "quick read inode table lru not empty");
- }
+ int i = 0;
+ qr_conf_t *conf = NULL;
+
+ conf = &priv->conf;
+
+ for (i = 0; i < conf->max_pri; i++) {
+ /* There is a known leak of inodes, hence until
+ * that is fixed, log the assert as warning.
+ GF_ASSERT (list_empty (&priv->table.lru[i]));*/
+ if (!list_empty(&priv->table.lru[i])) {
+ gf_msg("quick-read", GF_LOG_INFO, 0, QUICK_READ_MSG_LRU_NOT_EMPTY,
+ "quick read inode table lru not empty");
}
+ }
- LOCK_DESTROY (&priv->table.lock);
+ LOCK_DESTROY(&priv->table.lock);
- return;
+ return;
}
-
void
-qr_conf_destroy (qr_conf_t *conf)
+qr_conf_destroy(qr_conf_t *conf)
{
- struct qr_priority *curr = NULL, *tmp = NULL;
+ struct qr_priority *curr = NULL, *tmp = NULL;
- list_for_each_entry_safe (curr, tmp, &conf->priority_list, list) {
- list_del (&curr->list);
- GF_FREE (curr->pattern);
- GF_FREE (curr);
- }
+ list_for_each_entry_safe(curr, tmp, &conf->priority_list, list)
+ {
+ list_del(&curr->list);
+ GF_FREE(curr->pattern);
+ GF_FREE(curr);
+ }
- return;
+ return;
}
-
void
-qr_update_child_down_time (xlator_t *this, time_t *now)
+qr_update_child_down_time(xlator_t *this, time_t *now)
{
- qr_private_t *priv = NULL;
+ qr_private_t *priv = NULL;
- priv = this->private;
+ priv = this->private;
- LOCK (&priv->lock);
- {
- priv->last_child_down = *now;
- }
- UNLOCK (&priv->lock);
+ LOCK(&priv->lock);
+ {
+ priv->last_child_down = *now;
+ }
+ UNLOCK(&priv->lock);
}
-
static int
-qr_invalidate (xlator_t *this, void *data)
+qr_invalidate(xlator_t *this, void *data)
{
- struct gf_upcall *up_data = NULL;
- struct gf_upcall_cache_invalidation *up_ci = NULL;
- inode_t *inode = NULL;
- int ret = 0;
- inode_table_t *itable = NULL;
- qr_private_t *priv = NULL;
-
- up_data = (struct gf_upcall *)data;
-
- if (up_data->event_type != GF_UPCALL_CACHE_INVALIDATION)
- goto out;
-
- priv = this->private;
- up_ci = (struct gf_upcall_cache_invalidation *)up_data->data;
-
- if (up_ci && (up_ci->flags & UP_WRITE_FLAGS)) {
- GF_ATOMIC_INC (priv->qr_counter.file_data_invals);
- itable = ((xlator_t *)this->graph->top)->itable;
- inode = inode_find (itable, up_data->gfid);
- if (!inode) {
- ret = -1;
- goto out;
- }
- qr_inode_prune (this, inode, qr_get_generation (this, inode));
+ struct gf_upcall *up_data = NULL;
+ struct gf_upcall_cache_invalidation *up_ci = NULL;
+ inode_t *inode = NULL;
+ int ret = 0;
+ inode_table_t *itable = NULL;
+ qr_private_t *priv = NULL;
+
+ up_data = (struct gf_upcall *)data;
+
+ if (up_data->event_type != GF_UPCALL_CACHE_INVALIDATION)
+ goto out;
+
+ priv = this->private;
+ up_ci = (struct gf_upcall_cache_invalidation *)up_data->data;
+
+ if (up_ci && (up_ci->flags & UP_WRITE_FLAGS)) {
+ GF_ATOMIC_INC(priv->qr_counter.file_data_invals);
+ itable = ((xlator_t *)this->graph->top)->itable;
+ inode = inode_find(itable, up_data->gfid);
+ if (!inode) {
+ ret = -1;
+ goto out;
}
+ qr_inode_prune(this, inode, qr_get_generation(this, inode));
+ }
out:
- if (inode)
- inode_unref (inode);
+ if (inode)
+ inode_unref(inode);
- return ret;
+ return ret;
}
-
int
-qr_notify (xlator_t *this, int event, void *data, ...)
+qr_notify(xlator_t *this, int event, void *data, ...)
{
- int ret = 0;
- qr_private_t *priv = NULL;
- time_t now = 0;
- qr_conf_t *conf = NULL;
+ int ret = 0;
+ qr_private_t *priv = NULL;
+ time_t now = 0;
+ qr_conf_t *conf = NULL;
- priv = this->private;
- conf = &priv->conf;
+ priv = this->private;
+ conf = &priv->conf;
- switch (event) {
+ switch (event) {
case GF_EVENT_CHILD_DOWN:
case GF_EVENT_SOME_DESCENDENT_DOWN:
- time (&now);
- qr_update_child_down_time (this, &now);
- break;
+ time(&now);
+ qr_update_child_down_time(this, &now);
+ break;
case GF_EVENT_UPCALL:
- if (conf->qr_invalidation)
- ret = qr_invalidate (this, data);
- break;
+ if (conf->qr_invalidation)
+ ret = qr_invalidate(this, data);
+ break;
default:
- break;
- }
+ break;
+ }
- if (default_notify (this, event, data) != 0)
- ret = -1;
+ if (default_notify(this, event, data) != 0)
+ ret = -1;
- return ret;
+ return ret;
}
-
void
-qr_fini (xlator_t *this)
+qr_fini(xlator_t *this)
{
- qr_private_t *priv = NULL;
+ qr_private_t *priv = NULL;
- if (this == NULL) {
- goto out;
- }
+ if (this == NULL) {
+ goto out;
+ }
- priv = this->private;
- if (priv == NULL) {
- goto out;
- }
+ priv = this->private;
+ if (priv == NULL) {
+ goto out;
+ }
- qr_inode_table_destroy (priv);
- qr_conf_destroy (&priv->conf);
+ qr_inode_table_destroy(priv);
+ qr_conf_destroy(&priv->conf);
- this->private = NULL;
+ this->private = NULL;
- GF_FREE (priv);
+ GF_FREE(priv);
out:
- return;
+ return;
}
-struct xlator_fops qr_fops = {
- .lookup = qr_lookup,
- .readdirp = qr_readdirp,
- .open = qr_open,
- .readv = qr_readv,
- .writev = qr_writev,
- .truncate = qr_truncate,
- .ftruncate = qr_ftruncate,
- .fallocate = qr_fallocate,
- .discard = qr_discard,
- .zerofill = qr_zerofill
-};
+struct xlator_fops qr_fops = {.lookup = qr_lookup,
+ .readdirp = qr_readdirp,
+ .open = qr_open,
+ .readv = qr_readv,
+ .writev = qr_writev,
+ .truncate = qr_truncate,
+ .ftruncate = qr_ftruncate,
+ .fallocate = qr_fallocate,
+ .discard = qr_discard,
+ .zerofill = qr_zerofill};
struct xlator_cbks qr_cbks = {
- .forget = qr_forget,
+ .forget = qr_forget,
};
struct xlator_dumpops qr_dumpops = {
- .priv = qr_priv_dump,
- .inodectx = qr_inodectx_dump,
+ .priv = qr_priv_dump,
+ .inodectx = qr_inodectx_dump,
};
struct volume_options qr_options[] = {
- { .key = {"priority"},
- .type = GF_OPTION_TYPE_ANY
- },
- { .key = {"cache-size"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 0,
- .max = INFINITY,
- .default_value = "128MB",
- .op_version = {1},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .description = "Size of small file read cache."
- },
- { .key = {"cache-timeout"},
- .type = GF_OPTION_TYPE_INT,
- .default_value = "1",
- .op_version = {1},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- },
- { .key = {"max-file-size"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 0,
- .max = 1 * GF_UNIT_KB * 1000,
- .default_value = "64KB",
- .op_version = {1},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- },
- { .key = {"cache-invalidation"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_4_0_0},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .description = "When \"on\", invalidates/updates the metadata cache,"
- " on receiving the cache-invalidation notifications",
- },
- { .key = {"ctime-invalidation"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_4_2_0},
- .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
- .description = "Quick-read by default uses mtime to identify changes "
- "to file data. However there are applications like "
- "rsync which explicitly set mtime making it unreliable "
- "for the purpose of identifying change in file content "
- ". Since ctime also changes when content of a file "
- " changes and it cannot be set explicitly, it becomes "
- " suitable for identifying staleness of cached data. "
- "This option makes quick-read to prefer ctime over "
- "mtime to validate its cache. However, using ctime "
- "can result in false positives as ctime changes with "
- "just attribute changes like permission without "
- "changes to file data. So, use this only when mtime "
- "is not reliable",
- },
- { .key = {NULL} }
-};
+ {.key = {"priority"}, .type = GF_OPTION_TYPE_ANY},
+ {.key = {"cache-size"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 0,
+ .max = INFINITY,
+ .default_value = "128MB",
+ .op_version = {1},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .description = "Size of small file read cache."},
+ {
+ .key = {"cache-timeout"},
+ .type = GF_OPTION_TYPE_INT,
+ .default_value = "1",
+ .op_version = {1},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ },
+ {
+ .key = {"max-file-size"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 0,
+ .max = 1 * GF_UNIT_KB * 1000,
+ .default_value = "64KB",
+ .op_version = {1},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ },
+ {
+ .key = {"cache-invalidation"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_4_0_0},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .description = "When \"on\", invalidates/updates the metadata cache,"
+ " on receiving the cache-invalidation notifications",
+ },
+ {
+ .key = {"ctime-invalidation"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_4_2_0},
+ .flags = OPT_FLAG_CLIENT_OPT | OPT_FLAG_SETTABLE | OPT_FLAG_DOC,
+ .description = "Quick-read by default uses mtime to identify changes "
+ "to file data. However there are applications like "
+ "rsync which explicitly set mtime making it unreliable "
+ "for the purpose of identifying change in file content "
+ ". Since ctime also changes when content of a file "
+ " changes and it cannot be set explicitly, it becomes "
+ " suitable for identifying staleness of cached data. "
+ "This option makes quick-read to prefer ctime over "
+ "mtime to validate its cache. However, using ctime "
+ "can result in false positives as ctime changes with "
+ "just attribute changes like permission without "
+ "changes to file data. So, use this only when mtime "
+ "is not reliable",
+ },
+ {.key = {NULL}}};
xlator_api_t xlator_api = {
- .init = qr_init,
- .fini = qr_fini,
- .notify = qr_notify,
- .reconfigure = qr_reconfigure,
- .mem_acct_init = qr_mem_acct_init,
- .dump_metrics = qr_dump_metrics,
- .op_version = {1}, /* Present from the initial version */
- .dumpops = &qr_dumpops,
- .fops = &qr_fops,
- .cbks = &qr_cbks,
- .options = qr_options,
- .identifier = "quick-read",
- .category = GF_MAINTAINED,
+ .init = qr_init,
+ .fini = qr_fini,
+ .notify = qr_notify,
+ .reconfigure = qr_reconfigure,
+ .mem_acct_init = qr_mem_acct_init,
+ .dump_metrics = qr_dump_metrics,
+ .op_version = {1}, /* Present from the initial version */
+ .dumpops = &qr_dumpops,
+ .fops = &qr_fops,
+ .cbks = &qr_cbks,
+ .options = qr_options,
+ .identifier = "quick-read",
+ .category = GF_MAINTAINED,
};
diff --git a/xlators/performance/read-ahead/src/page.c b/xlators/performance/read-ahead/src/page.c
index 17e346ec947..c4071393c95 100644
--- a/xlators/performance/read-ahead/src/page.c
+++ b/xlators/performance/read-ahead/src/page.c
@@ -17,458 +17,443 @@
#include "read-ahead-messages.h"
ra_page_t *
-ra_page_get (ra_file_t *file, off_t offset)
+ra_page_get(ra_file_t *file, off_t offset)
{
- ra_page_t *page = NULL;
- off_t rounded_offset = 0;
+ ra_page_t *page = NULL;
+ off_t rounded_offset = 0;
- GF_VALIDATE_OR_GOTO ("read-ahead", file, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", file, out);
- page = file->pages.next;
- rounded_offset = floor (offset, file->page_size);
+ page = file->pages.next;
+ rounded_offset = floor(offset, file->page_size);
- while (page != &file->pages && page->offset < rounded_offset)
- page = page->next;
+ while (page != &file->pages && page->offset < rounded_offset)
+ page = page->next;
- if (page == &file->pages || page->offset != rounded_offset)
- page = NULL;
+ if (page == &file->pages || page->offset != rounded_offset)
+ page = NULL;
out:
- return page;
+ return page;
}
-
ra_page_t *
-ra_page_create (ra_file_t *file, off_t offset)
+ra_page_create(ra_file_t *file, off_t offset)
{
- ra_page_t *page = NULL;
- off_t rounded_offset = 0;
- ra_page_t *newpage = NULL;
+ ra_page_t *page = NULL;
+ off_t rounded_offset = 0;
+ ra_page_t *newpage = NULL;
- GF_VALIDATE_OR_GOTO ("read-ahead", file, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", file, out);
- page = file->pages.next;
- rounded_offset = floor (offset, file->page_size);
+ page = file->pages.next;
+ rounded_offset = floor(offset, file->page_size);
- while (page != &file->pages && page->offset < rounded_offset)
- page = page->next;
+ while (page != &file->pages && page->offset < rounded_offset)
+ page = page->next;
- if (page == &file->pages || page->offset != rounded_offset) {
- newpage = GF_CALLOC (1, sizeof (*newpage), gf_ra_mt_ra_page_t);
- if (!newpage) {
- goto out;
- }
+ if (page == &file->pages || page->offset != rounded_offset) {
+ newpage = GF_CALLOC(1, sizeof(*newpage), gf_ra_mt_ra_page_t);
+ if (!newpage) {
+ goto out;
+ }
- newpage->offset = rounded_offset;
- newpage->prev = page->prev;
- newpage->next = page;
- newpage->file = file;
- page->prev->next = newpage;
- page->prev = newpage;
+ newpage->offset = rounded_offset;
+ newpage->prev = page->prev;
+ newpage->next = page;
+ newpage->file = file;
+ page->prev->next = newpage;
+ page->prev = newpage;
- page = newpage;
- }
+ page = newpage;
+ }
out:
- return page;
+ return page;
}
-
void
-ra_wait_on_page (ra_page_t *page, call_frame_t *frame)
+ra_wait_on_page(ra_page_t *page, call_frame_t *frame)
{
- ra_waitq_t *waitq = NULL;
- ra_local_t *local = NULL;
+ ra_waitq_t *waitq = NULL;
+ ra_local_t *local = NULL;
- GF_VALIDATE_OR_GOTO ("read-ahead", frame, out);
- GF_VALIDATE_OR_GOTO (frame->this->name, page, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", frame, out);
+ GF_VALIDATE_OR_GOTO(frame->this->name, page, out);
- local = frame->local;
+ local = frame->local;
- waitq = GF_CALLOC (1, sizeof (*waitq), gf_ra_mt_ra_waitq_t);
- if (!waitq) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- goto out;
- }
+ waitq = GF_CALLOC(1, sizeof(*waitq), gf_ra_mt_ra_waitq_t);
+ if (!waitq) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ goto out;
+ }
- waitq->data = frame;
- waitq->next = page->waitq;
- page->waitq = waitq;
+ waitq->data = frame;
+ waitq->next = page->waitq;
+ page->waitq = waitq;
- ra_local_lock (local);
- {
- local->wait_count++;
- }
- ra_local_unlock (local);
+ ra_local_lock(local);
+ {
+ local->wait_count++;
+ }
+ ra_local_unlock(local);
out:
- return;
+ return;
}
-
void
-ra_waitq_return (ra_waitq_t *waitq)
+ra_waitq_return(ra_waitq_t *waitq)
{
- ra_waitq_t *trav = NULL;
- ra_waitq_t *next = NULL;
- call_frame_t *frame = NULL;
+ ra_waitq_t *trav = NULL;
+ ra_waitq_t *next = NULL;
+ call_frame_t *frame = NULL;
- for (trav = waitq; trav; trav = next) {
- next = trav->next;
+ for (trav = waitq; trav; trav = next) {
+ next = trav->next;
- frame = trav->data;
- ra_frame_return (frame);
- GF_FREE (trav);
- }
+ frame = trav->data;
+ ra_frame_return(frame);
+ GF_FREE(trav);
+ }
- return;
+ return;
}
-
int
-ra_fault_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iovec *vector,
- int32_t count, struct iatt *stbuf, struct iobref *iobref,
- dict_t *xdata)
+ra_fault_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iovec *vector, int32_t count,
+ struct iatt *stbuf, struct iobref *iobref, dict_t *xdata)
{
- ra_local_t *local = NULL;
- off_t pending_offset = 0;
- ra_file_t *file = NULL;
- ra_page_t *page = NULL;
- ra_waitq_t *waitq = NULL;
- fd_t *fd = NULL;
- uint64_t tmp_file = 0;
- gf_boolean_t stale = _gf_false;
-
- GF_ASSERT (frame);
+ ra_local_t *local = NULL;
+ off_t pending_offset = 0;
+ ra_file_t *file = NULL;
+ ra_page_t *page = NULL;
+ ra_waitq_t *waitq = NULL;
+ fd_t *fd = NULL;
+ uint64_t tmp_file = 0;
+ gf_boolean_t stale = _gf_false;
+
+ GF_ASSERT(frame);
+
+ local = frame->local;
+ fd = local->fd;
+
+ fd_ctx_get(fd, this, &tmp_file);
+
+ file = (ra_file_t *)(long)tmp_file;
+ pending_offset = local->pending_offset;
+
+ if (file == NULL) {
+ gf_msg(this->name, GF_LOG_WARNING, EBADF,
+ READ_AHEAD_MSG_FD_CONTEXT_NOT_SET,
+ "read-ahead context not set in fd (%p)", fd);
+ op_ret = -1;
+ op_errno = EBADF;
+ goto out;
+ }
+
+ ra_file_lock(file);
+ {
+ if (op_ret >= 0)
+ file->stbuf = *stbuf;
+
+ page = ra_page_get(file, pending_offset);
+
+ if (!page) {
+ gf_msg_trace(this->name, 0,
+ "wasted copy: "
+ "%" PRId64 "[+%" PRId64 "] file=%p",
+ pending_offset, file->page_size, file);
+ goto unlock;
+ }
- local = frame->local;
- fd = local->fd;
+ if (page->stale) {
+ page->stale = 0;
+ page->ready = 0;
+ stale = 1;
+ goto unlock;
+ }
- fd_ctx_get (fd, this, &tmp_file);
+ /*
+ * "Dirty" means that the request was a pure read-ahead; it's
+ * set for requests we issue ourselves, and cleared when user
+ * requests are issued or put on the waitq. "Poisoned" means
+ * that we got a write while a read was still in flight, and we
+ * couldn't stop it so we marked it instead. If it's both
+ * dirty and poisoned by the time we get here, we cancel its
+ * effect so that a subsequent user read doesn't get data that
+ * we know is stale (because we made it stale ourselves). We
+ * can't use ESTALE because that has special significance.
+ * ECANCELED has no such special meaning, and is close to what
+ * we're trying to indicate.
+ */
+ if (page->dirty && page->poisoned) {
+ op_ret = -1;
+ op_errno = ECANCELED;
+ }
- file = (ra_file_t *)(long)tmp_file;
- pending_offset = local->pending_offset;
+ if (op_ret < 0) {
+ waitq = ra_page_error(page, op_ret, op_errno);
+ goto unlock;
+ }
- if (file == NULL) {
- gf_msg (this->name, GF_LOG_WARNING, EBADF,
- READ_AHEAD_MSG_FD_CONTEXT_NOT_SET,
- "read-ahead context not set in fd (%p)", fd);
- op_ret = -1;
- op_errno = EBADF;
- goto out;
+ if (page->vector) {
+ iobref_unref(page->iobref);
+ GF_FREE(page->vector);
}
- ra_file_lock (file);
- {
- if (op_ret >= 0)
- file->stbuf = *stbuf;
-
- page = ra_page_get (file, pending_offset);
-
- if (!page) {
- gf_msg_trace (this->name, 0,
- "wasted copy: "
- "%"PRId64"[+%"PRId64"] file=%p",
- pending_offset, file->page_size, file);
- goto unlock;
- }
-
- if (page->stale) {
- page->stale = 0;
- page->ready = 0;
- stale = 1;
- goto unlock;
- }
-
- /*
- * "Dirty" means that the request was a pure read-ahead; it's
- * set for requests we issue ourselves, and cleared when user
- * requests are issued or put on the waitq. "Poisoned" means
- * that we got a write while a read was still in flight, and we
- * couldn't stop it so we marked it instead. If it's both
- * dirty and poisoned by the time we get here, we cancel its
- * effect so that a subsequent user read doesn't get data that
- * we know is stale (because we made it stale ourselves). We
- * can't use ESTALE because that has special significance.
- * ECANCELED has no such special meaning, and is close to what
- * we're trying to indicate.
- */
- if (page->dirty && page->poisoned) {
- op_ret = -1;
- op_errno = ECANCELED;
- }
-
- if (op_ret < 0) {
- waitq = ra_page_error (page, op_ret, op_errno);
- goto unlock;
- }
-
- if (page->vector) {
- iobref_unref (page->iobref);
- GF_FREE (page->vector);
- }
-
- page->vector = iov_dup (vector, count);
- if (page->vector == NULL) {
- waitq = ra_page_error (page, -1, ENOMEM);
- goto unlock;
- }
-
- page->count = count;
- page->iobref = iobref_ref (iobref);
- page->ready = 1;
-
- page->size = iov_length (vector, count);
-
- waitq = ra_page_wakeup (page);
+ page->vector = iov_dup(vector, count);
+ if (page->vector == NULL) {
+ waitq = ra_page_error(page, -1, ENOMEM);
+ goto unlock;
}
+
+ page->count = count;
+ page->iobref = iobref_ref(iobref);
+ page->ready = 1;
+
+ page->size = iov_length(vector, count);
+
+ waitq = ra_page_wakeup(page);
+ }
unlock:
- ra_file_unlock (file);
+ ra_file_unlock(file);
- if (stale) {
- STACK_WIND (frame, ra_fault_cbk,
- FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->readv,
- local->fd, local->pending_size,
- local->pending_offset, 0, NULL);
+ if (stale) {
+ STACK_WIND(frame, ra_fault_cbk, FIRST_CHILD(frame->this),
+ FIRST_CHILD(frame->this)->fops->readv, local->fd,
+ local->pending_size, local->pending_offset, 0, NULL);
- return 0;
- }
+ return 0;
+ }
- ra_waitq_return (waitq);
+ ra_waitq_return(waitq);
- fd_unref (local->fd);
+ fd_unref(local->fd);
- mem_put (frame->local);
- frame->local = NULL;
+ mem_put(frame->local);
+ frame->local = NULL;
out:
- STACK_DESTROY (frame->root);
- return 0;
+ STACK_DESTROY(frame->root);
+ return 0;
}
-
void
-ra_page_fault (ra_file_t *file, call_frame_t *frame, off_t offset)
+ra_page_fault(ra_file_t *file, call_frame_t *frame, off_t offset)
{
- call_frame_t *fault_frame = NULL;
- ra_local_t *fault_local = NULL;
- ra_page_t *page = NULL;
- ra_waitq_t *waitq = NULL;
- int32_t op_ret = -1, op_errno = -1;
-
- GF_VALIDATE_OR_GOTO ("read-ahead", frame, out);
- GF_VALIDATE_OR_GOTO (frame->this->name, file, out);
-
- fault_frame = copy_frame (frame);
- if (fault_frame == NULL) {
- op_ret = -1;
- op_errno = ENOMEM;
- goto err;
- }
-
- fault_local = mem_get0 (THIS->local_pool);
- if (fault_local == NULL) {
- STACK_DESTROY (fault_frame->root);
- op_ret = -1;
- op_errno = ENOMEM;
- goto err;
- }
-
- fault_frame->local = fault_local;
- fault_local->pending_offset = offset;
- fault_local->pending_size = file->page_size;
-
- fault_local->fd = fd_ref (file->fd);
-
- STACK_WIND (fault_frame, ra_fault_cbk,
- FIRST_CHILD (fault_frame->this),
- FIRST_CHILD (fault_frame->this)->fops->readv,
- file->fd, file->page_size, offset, 0, NULL);
-
- return;
+ call_frame_t *fault_frame = NULL;
+ ra_local_t *fault_local = NULL;
+ ra_page_t *page = NULL;
+ ra_waitq_t *waitq = NULL;
+ int32_t op_ret = -1, op_errno = -1;
+
+ GF_VALIDATE_OR_GOTO("read-ahead", frame, out);
+ GF_VALIDATE_OR_GOTO(frame->this->name, file, out);
+
+ fault_frame = copy_frame(frame);
+ if (fault_frame == NULL) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ fault_local = mem_get0(THIS->local_pool);
+ if (fault_local == NULL) {
+ STACK_DESTROY(fault_frame->root);
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto err;
+ }
+
+ fault_frame->local = fault_local;
+ fault_local->pending_offset = offset;
+ fault_local->pending_size = file->page_size;
+
+ fault_local->fd = fd_ref(file->fd);
+
+ STACK_WIND(fault_frame, ra_fault_cbk, FIRST_CHILD(fault_frame->this),
+ FIRST_CHILD(fault_frame->this)->fops->readv, file->fd,
+ file->page_size, offset, 0, NULL);
+
+ return;
err:
- ra_file_lock (file);
- {
- page = ra_page_get (file, offset);
- if (page)
- waitq = ra_page_error (page, op_ret,
- op_errno);
- }
- ra_file_unlock (file);
-
- if (waitq != NULL) {
- ra_waitq_return (waitq);
- }
+ ra_file_lock(file);
+ {
+ page = ra_page_get(file, offset);
+ if (page)
+ waitq = ra_page_error(page, op_ret, op_errno);
+ }
+ ra_file_unlock(file);
+
+ if (waitq != NULL) {
+ ra_waitq_return(waitq);
+ }
out:
- return;
+ return;
}
-
void
-ra_frame_fill (ra_page_t *page, call_frame_t *frame)
+ra_frame_fill(ra_page_t *page, call_frame_t *frame)
{
- ra_local_t *local = NULL;
- ra_fill_t *fill = NULL;
- off_t src_offset = 0;
- off_t dst_offset = 0;
- ssize_t copy_size = 0;
- ra_fill_t *new = NULL;
-
- GF_VALIDATE_OR_GOTO ("read-ahead", frame, out);
- GF_VALIDATE_OR_GOTO (frame->this->name, page, out);
-
- local = frame->local;
- fill = &local->fill;
-
- if (local->op_ret != -1 && page->size) {
- if (local->offset > page->offset)
- src_offset = local->offset - page->offset;
- else
- dst_offset = page->offset - local->offset;
-
- copy_size = min (page->size - src_offset,
- local->size - dst_offset);
-
- if (copy_size < 0) {
- /* if page contains fewer bytes and the required offset
- is beyond the page size in the page */
- copy_size = src_offset = 0;
- }
-
- fill = fill->next;
- while (fill != &local->fill) {
- if (fill->offset > page->offset) {
- break;
- }
- fill = fill->next;
- }
-
- new = GF_CALLOC (1, sizeof (*new), gf_ra_mt_ra_fill_t);
- if (new == NULL) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- goto out;
- }
-
- new->offset = page->offset;
- new->size = copy_size;
- new->iobref = iobref_ref (page->iobref);
- new->count = iov_subset (page->vector, page->count,
- src_offset, src_offset+copy_size,
- NULL);
- new->vector = GF_CALLOC (new->count, sizeof (struct iovec),
- gf_ra_mt_iovec);
- if (new->vector == NULL) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- GF_FREE (new);
- goto out;
- }
-
- new->count = iov_subset (page->vector, page->count,
- src_offset, src_offset+copy_size,
- new->vector);
-
- new->next = fill;
- new->prev = new->next->prev;
- new->next->prev = new;
- new->prev->next = new;
-
- local->op_ret += copy_size;
+ ra_local_t *local = NULL;
+ ra_fill_t *fill = NULL;
+ off_t src_offset = 0;
+ off_t dst_offset = 0;
+ ssize_t copy_size = 0;
+ ra_fill_t *new = NULL;
+
+ GF_VALIDATE_OR_GOTO("read-ahead", frame, out);
+ GF_VALIDATE_OR_GOTO(frame->this->name, page, out);
+
+ local = frame->local;
+ fill = &local->fill;
+
+ if (local->op_ret != -1 && page->size) {
+ if (local->offset > page->offset)
+ src_offset = local->offset - page->offset;
+ else
+ dst_offset = page->offset - local->offset;
+
+ copy_size = min(page->size - src_offset, local->size - dst_offset);
+
+ if (copy_size < 0) {
+ /* if page contains fewer bytes and the required offset
+ is beyond the page size in the page */
+ copy_size = src_offset = 0;
}
-out:
- return;
-}
+ fill = fill->next;
+ while (fill != &local->fill) {
+ if (fill->offset > page->offset) {
+ break;
+ }
+ fill = fill->next;
+ }
+ new = GF_CALLOC(1, sizeof(*new), gf_ra_mt_ra_fill_t);
+ if (new == NULL) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ goto out;
+ }
-void
-ra_frame_unwind (call_frame_t *frame)
-{
- ra_local_t *local = NULL;
- ra_fill_t *fill = NULL;
- int32_t count = 0;
- struct iovec *vector = NULL;
- int32_t copied = 0;
- struct iobref *iobref = NULL;
- ra_fill_t *next = NULL;
- fd_t *fd = NULL;
- ra_file_t *file = NULL;
- uint64_t tmp_file = 0;
-
- GF_VALIDATE_OR_GOTO ("read-ahead", frame, out);
+ new->offset = page->offset;
+ new->size = copy_size;
+ new->iobref = iobref_ref(page->iobref);
+ new->count = iov_subset(page->vector, page->count, src_offset,
+ src_offset + copy_size, NULL);
+ new->vector = GF_CALLOC(new->count, sizeof(struct iovec),
+ gf_ra_mt_iovec);
+ if (new->vector == NULL) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ GF_FREE(new);
+ goto out;
+ }
- local = frame->local;
- fill = local->fill.next;
+ new->count = iov_subset(page->vector, page->count, src_offset,
+ src_offset + copy_size, new->vector);
- iobref = iobref_new ();
- if (iobref == NULL) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- }
+ new->next = fill;
+ new->prev = new->next->prev;
+ new->next->prev = new;
+ new->prev->next = new;
- frame->local = NULL;
+ local->op_ret += copy_size;
+ }
- while (fill != &local->fill) {
- count += fill->count;
- fill = fill->next;
- }
+out:
+ return;
+}
- vector = GF_CALLOC (count, sizeof (*vector), gf_ra_mt_iovec);
- if (vector == NULL) {
+void
+ra_frame_unwind(call_frame_t *frame)
+{
+ ra_local_t *local = NULL;
+ ra_fill_t *fill = NULL;
+ int32_t count = 0;
+ struct iovec *vector = NULL;
+ int32_t copied = 0;
+ struct iobref *iobref = NULL;
+ ra_fill_t *next = NULL;
+ fd_t *fd = NULL;
+ ra_file_t *file = NULL;
+ uint64_t tmp_file = 0;
+
+ GF_VALIDATE_OR_GOTO("read-ahead", frame, out);
+
+ local = frame->local;
+ fill = local->fill.next;
+
+ iobref = iobref_new();
+ if (iobref == NULL) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ }
+
+ frame->local = NULL;
+
+ while (fill != &local->fill) {
+ count += fill->count;
+ fill = fill->next;
+ }
+
+ vector = GF_CALLOC(count, sizeof(*vector), gf_ra_mt_iovec);
+ if (vector == NULL) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ iobref_unref(iobref);
+ iobref = NULL;
+ }
+
+ fill = local->fill.next;
+
+ while (fill != &local->fill) {
+ next = fill->next;
+
+ if ((vector != NULL) && (iobref != NULL)) {
+ memcpy(((char *)vector) + copied, fill->vector,
+ fill->count * sizeof(*vector));
+
+ copied += (fill->count * sizeof(*vector));
+ if (iobref_merge(iobref, fill->iobref)) {
local->op_ret = -1;
local->op_errno = ENOMEM;
- iobref_unref (iobref);
+ iobref_unref(iobref);
iobref = NULL;
+ }
}
- fill = local->fill.next;
-
- while (fill != &local->fill) {
- next = fill->next;
+ fill->next->prev = fill->prev;
+ fill->prev->next = fill->prev;
- if ((vector != NULL) && (iobref != NULL)) {
- memcpy (((char *)vector) + copied, fill->vector,
- fill->count * sizeof (*vector));
+ iobref_unref(fill->iobref);
+ GF_FREE(fill->vector);
+ GF_FREE(fill);
- copied += (fill->count * sizeof (*vector));
- if (iobref_merge (iobref, fill->iobref)) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- iobref_unref (iobref);
- iobref = NULL;
- }
- }
-
- fill->next->prev = fill->prev;
- fill->prev->next = fill->prev;
-
- iobref_unref (fill->iobref);
- GF_FREE (fill->vector);
- GF_FREE (fill);
-
- fill = next;
- }
+ fill = next;
+ }
- fd = local->fd;
- fd_ctx_get (fd, frame->this, &tmp_file);
- file = (ra_file_t *)(long)tmp_file;
+ fd = local->fd;
+ fd_ctx_get(fd, frame->this, &tmp_file);
+ file = (ra_file_t *)(long)tmp_file;
- STACK_UNWIND_STRICT (readv, frame, local->op_ret, local->op_errno,
- vector, count, &file->stbuf, iobref, NULL);
+ STACK_UNWIND_STRICT(readv, frame, local->op_ret, local->op_errno, vector,
+ count, &file->stbuf, iobref, NULL);
- iobref_unref (iobref);
- pthread_mutex_destroy (&local->local_lock);
- mem_put (local);
- GF_FREE (vector);
+ iobref_unref(iobref);
+ pthread_mutex_destroy(&local->local_lock);
+ mem_put(local);
+ GF_FREE(vector);
out:
- return;
+ return;
}
/*
@@ -477,27 +462,27 @@ out:
*
*/
void
-ra_frame_return (call_frame_t *frame)
+ra_frame_return(call_frame_t *frame)
{
- ra_local_t *local = NULL;
- int32_t wait_count = 0;
+ ra_local_t *local = NULL;
+ int32_t wait_count = 0;
- GF_VALIDATE_OR_GOTO ("read-ahead", frame, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", frame, out);
- local = frame->local;
- GF_ASSERT (local->wait_count > 0);
+ local = frame->local;
+ GF_ASSERT(local->wait_count > 0);
- ra_local_lock (local);
- {
- wait_count = --local->wait_count;
- }
- ra_local_unlock (local);
+ ra_local_lock(local);
+ {
+ wait_count = --local->wait_count;
+ }
+ ra_local_unlock(local);
- if (!wait_count)
- ra_frame_unwind (frame);
+ if (!wait_count)
+ ra_frame_unwind(frame);
out:
- return;
+ return;
}
/*
@@ -506,26 +491,26 @@ out:
*
*/
ra_waitq_t *
-ra_page_wakeup (ra_page_t *page)
+ra_page_wakeup(ra_page_t *page)
{
- ra_waitq_t *waitq = NULL, *trav = NULL;
- call_frame_t *frame = NULL;
+ ra_waitq_t *waitq = NULL, *trav = NULL;
+ call_frame_t *frame = NULL;
- GF_VALIDATE_OR_GOTO ("read-ahead", page, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", page, out);
- waitq = page->waitq;
- page->waitq = NULL;
+ waitq = page->waitq;
+ page->waitq = NULL;
- for (trav = waitq; trav; trav = trav->next) {
- frame = trav->data;
- ra_frame_fill (page, frame);
- }
+ for (trav = waitq; trav; trav = trav->next) {
+ frame = trav->data;
+ ra_frame_fill(page, frame);
+ }
- if (page->stale) {
- ra_page_purge (page);
- }
+ if (page->stale) {
+ ra_page_purge(page);
+ }
out:
- return waitq;
+ return waitq;
}
/*
@@ -534,22 +519,22 @@ out:
*
*/
void
-ra_page_purge (ra_page_t *page)
+ra_page_purge(ra_page_t *page)
{
- GF_VALIDATE_OR_GOTO ("read-ahead", page, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", page, out);
- page->prev->next = page->next;
- page->next->prev = page->prev;
+ page->prev->next = page->next;
+ page->next->prev = page->prev;
- if (page->iobref) {
- iobref_unref (page->iobref);
- }
+ if (page->iobref) {
+ iobref_unref(page->iobref);
+ }
- GF_FREE (page->vector);
- GF_FREE (page);
+ GF_FREE(page->vector);
+ GF_FREE(page);
out:
- return;
+ return;
}
/*
@@ -560,32 +545,32 @@ out:
*
*/
ra_waitq_t *
-ra_page_error (ra_page_t *page, int32_t op_ret, int32_t op_errno)
+ra_page_error(ra_page_t *page, int32_t op_ret, int32_t op_errno)
{
- ra_waitq_t *waitq = NULL;
- ra_waitq_t *trav = NULL;
- call_frame_t *frame = NULL;
- ra_local_t *local = NULL;
+ ra_waitq_t *waitq = NULL;
+ ra_waitq_t *trav = NULL;
+ call_frame_t *frame = NULL;
+ ra_local_t *local = NULL;
- GF_VALIDATE_OR_GOTO ("read-ahead", page, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", page, out);
- waitq = page->waitq;
- page->waitq = NULL;
+ waitq = page->waitq;
+ page->waitq = NULL;
- for (trav = waitq; trav; trav = trav->next) {
- frame = trav->data;
+ for (trav = waitq; trav; trav = trav->next) {
+ frame = trav->data;
- local = frame->local;
- if (local->op_ret != -1) {
- local->op_ret = op_ret;
- local->op_errno = op_errno;
- }
+ local = frame->local;
+ if (local->op_ret != -1) {
+ local->op_ret = op_ret;
+ local->op_errno = op_errno;
}
+ }
- ra_page_purge (page);
+ ra_page_purge(page);
out:
- return waitq;
+ return waitq;
}
/*
@@ -594,31 +579,31 @@ out:
*
*/
void
-ra_file_destroy (ra_file_t *file)
+ra_file_destroy(ra_file_t *file)
{
- ra_conf_t *conf = NULL;
- ra_page_t *trav = NULL;
+ ra_conf_t *conf = NULL;
+ ra_page_t *trav = NULL;
- GF_VALIDATE_OR_GOTO ("read-ahead", file, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", file, out);
- conf = file->conf;
+ conf = file->conf;
- ra_conf_lock (conf);
- {
- file->prev->next = file->next;
- file->next->prev = file->prev;
- }
- ra_conf_unlock (conf);
+ ra_conf_lock(conf);
+ {
+ file->prev->next = file->next;
+ file->next->prev = file->prev;
+ }
+ ra_conf_unlock(conf);
+ trav = file->pages.next;
+ while (trav != &file->pages) {
+ ra_page_error(trav, -1, EINVAL);
trav = file->pages.next;
- while (trav != &file->pages) {
- ra_page_error (trav, -1, EINVAL);
- trav = file->pages.next;
- }
+ }
- pthread_mutex_destroy (&file->file_lock);
- GF_FREE (file);
+ pthread_mutex_destroy(&file->file_lock);
+ GF_FREE(file);
out:
- return;
+ return;
}
diff --git a/xlators/performance/read-ahead/src/read-ahead.c b/xlators/performance/read-ahead/src/read-ahead.c
index 652b001129b..2fdb56479ab 100644
--- a/xlators/performance/read-ahead/src/read-ahead.c
+++ b/xlators/performance/read-ahead/src/read-ahead.c
@@ -26,186 +26,176 @@
#include "read-ahead-messages.h"
static void
-read_ahead (call_frame_t *frame, ra_file_t *file);
-
+read_ahead(call_frame_t *frame, ra_file_t *file);
int
-ra_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
+ra_open_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, fd_t *fd, dict_t *xdata)
{
- ra_conf_t *conf = NULL;
- ra_file_t *file = NULL;
- int ret = 0;
-
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
-
- conf = this->private;
-
- if (op_ret == -1) {
- goto unwind;
- }
-
- file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t);
- if (!file) {
- op_ret = -1;
- op_errno = ENOMEM;
- goto unwind;
- }
-
- /* If O_DIRECT open, we disable caching on it */
-
- if ((fd->flags & O_DIRECT) || ((fd->flags & O_ACCMODE) == O_WRONLY))
- file->disabled = 1;
-
- file->offset = (unsigned long long) 0;
- file->conf = conf;
- file->pages.next = &file->pages;
- file->pages.prev = &file->pages;
- file->pages.offset = (unsigned long long) 0;
- file->pages.file = file;
-
- ra_conf_lock (conf);
- {
- file->next = conf->files.next;
- conf->files.next = file;
- file->next->prev = file;
- file->prev = &conf->files;
- }
- ra_conf_unlock (conf);
-
- file->fd = fd;
- file->page_count = conf->page_count;
- file->page_size = conf->page_size;
- pthread_mutex_init (&file->file_lock, NULL);
-
- if (!file->disabled) {
- file->page_count = 1;
- }
-
- ret = fd_ctx_set (fd, this, (uint64_t)(long)file);
- if (ret == -1) {
- gf_msg (frame->this->name, GF_LOG_WARNING,
- 0, READ_AHEAD_MSG_NO_MEMORY,
- "cannot set read-ahead context"
- "information in fd (%p)",
- fd);
- ra_file_destroy (file);
- op_ret = -1;
- op_errno = ENOMEM;
- }
+ ra_conf_t *conf = NULL;
+ ra_file_t *file = NULL;
+ int ret = 0;
+
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+
+ conf = this->private;
+
+ if (op_ret == -1) {
+ goto unwind;
+ }
+
+ file = GF_CALLOC(1, sizeof(*file), gf_ra_mt_ra_file_t);
+ if (!file) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto unwind;
+ }
+
+ /* If O_DIRECT open, we disable caching on it */
+
+ if ((fd->flags & O_DIRECT) || ((fd->flags & O_ACCMODE) == O_WRONLY))
+ file->disabled = 1;
+
+ file->offset = (unsigned long long)0;
+ file->conf = conf;
+ file->pages.next = &file->pages;
+ file->pages.prev = &file->pages;
+ file->pages.offset = (unsigned long long)0;
+ file->pages.file = file;
+
+ ra_conf_lock(conf);
+ {
+ file->next = conf->files.next;
+ conf->files.next = file;
+ file->next->prev = file;
+ file->prev = &conf->files;
+ }
+ ra_conf_unlock(conf);
+
+ file->fd = fd;
+ file->page_count = conf->page_count;
+ file->page_size = conf->page_size;
+ pthread_mutex_init(&file->file_lock, NULL);
+
+ if (!file->disabled) {
+ file->page_count = 1;
+ }
+
+ ret = fd_ctx_set(fd, this, (uint64_t)(long)file);
+ if (ret == -1) {
+ gf_msg(frame->this->name, GF_LOG_WARNING, 0, READ_AHEAD_MSG_NO_MEMORY,
+ "cannot set read-ahead context"
+ "information in fd (%p)",
+ fd);
+ ra_file_destroy(file);
+ op_ret = -1;
+ op_errno = ENOMEM;
+ }
unwind:
- frame->local = NULL;
+ frame->local = NULL;
- STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd, xdata);
+ STACK_UNWIND_STRICT(open, frame, op_ret, op_errno, fd, xdata);
- return 0;
+ return 0;
}
-
int
-ra_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 iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+ra_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 iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- ra_conf_t *conf = NULL;
- ra_file_t *file = NULL;
- int ret = 0;
-
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
-
- conf = this->private;
-
- if (op_ret == -1) {
- goto unwind;
- }
-
- file = GF_CALLOC (1, sizeof (*file), gf_ra_mt_ra_file_t);
- if (!file) {
- op_ret = -1;
- op_errno = ENOMEM;
- goto unwind;
- }
-
- /* If O_DIRECT open, we disable caching on it */
-
- if ((fd->flags & O_DIRECT) || ((fd->flags & O_ACCMODE) == O_WRONLY))
- file->disabled = 1;
-
- file->offset = (unsigned long long) 0;
- //file->size = fd->inode->buf.ia_size;
- file->conf = conf;
- file->pages.next = &file->pages;
- file->pages.prev = &file->pages;
- file->pages.offset = (unsigned long long) 0;
- file->pages.file = file;
-
- ra_conf_lock (conf);
- {
- file->next = conf->files.next;
- conf->files.next = file;
- file->next->prev = file;
- file->prev = &conf->files;
- }
- ra_conf_unlock (conf);
-
- file->fd = fd;
- file->page_count = conf->page_count;
- 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) {
- gf_msg (this->name, GF_LOG_WARNING,
- 0, READ_AHEAD_MSG_NO_MEMORY,
- "cannot set read ahead context"
- "information in fd (%p)",
- fd);
- ra_file_destroy (file);
- op_ret = -1;
- op_errno = ENOMEM;
- }
+ ra_conf_t *conf = NULL;
+ ra_file_t *file = NULL;
+ int ret = 0;
+
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+
+ conf = this->private;
+
+ if (op_ret == -1) {
+ goto unwind;
+ }
+
+ file = GF_CALLOC(1, sizeof(*file), gf_ra_mt_ra_file_t);
+ if (!file) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto unwind;
+ }
+
+ /* If O_DIRECT open, we disable caching on it */
+
+ if ((fd->flags & O_DIRECT) || ((fd->flags & O_ACCMODE) == O_WRONLY))
+ file->disabled = 1;
+
+ file->offset = (unsigned long long)0;
+ // file->size = fd->inode->buf.ia_size;
+ file->conf = conf;
+ file->pages.next = &file->pages;
+ file->pages.prev = &file->pages;
+ file->pages.offset = (unsigned long long)0;
+ file->pages.file = file;
+
+ ra_conf_lock(conf);
+ {
+ file->next = conf->files.next;
+ conf->files.next = file;
+ file->next->prev = file;
+ file->prev = &conf->files;
+ }
+ ra_conf_unlock(conf);
+
+ file->fd = fd;
+ file->page_count = conf->page_count;
+ 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) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, READ_AHEAD_MSG_NO_MEMORY,
+ "cannot set read ahead context"
+ "information in fd (%p)",
+ fd);
+ 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, xdata);
+ STACK_UNWIND_STRICT(create, frame, op_ret, op_errno, fd, inode, buf,
+ preparent, postparent, xdata);
- return 0;
+ return 0;
}
-
int
-ra_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- fd_t *fd, dict_t *xdata)
+ra_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ fd_t *fd, dict_t *xdata)
{
- GF_ASSERT (frame);
- GF_ASSERT (this);
+ GF_ASSERT(frame);
+ GF_ASSERT(this);
- STACK_WIND (frame, ra_open_cbk,
- FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->open,
- loc, flags, fd, xdata);
+ STACK_WIND(frame, ra_open_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata);
- return 0;
+ return 0;
}
-
int
-ra_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
+ra_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
{
- GF_ASSERT (frame);
- GF_ASSERT (this);
+ GF_ASSERT(frame);
+ GF_ASSERT(this);
- STACK_WIND (frame, ra_create_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->create,
- loc, flags, mode, umask, fd, xdata);
+ STACK_WIND(frame, ra_create_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->create, loc, flags, mode, umask, fd,
+ xdata);
- return 0;
+ return 0;
}
/* free cache pages between offset and offset+size,
@@ -213,743 +203,714 @@ ra_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
*/
static void
-flush_region (call_frame_t *frame, ra_file_t *file, off_t offset, off_t size,
- int for_write)
+flush_region(call_frame_t *frame, ra_file_t *file, off_t offset, off_t size,
+ int for_write)
{
- ra_page_t *trav = NULL;
- ra_page_t *next = NULL;
-
- ra_file_lock (file);
- {
- trav = file->pages.next;
- while (trav != &file->pages
- && trav->offset < (offset + size)) {
-
- next = trav->next;
- if (trav->offset >= offset) {
- if (!trav->waitq) {
- ra_page_purge (trav);
- }
- else {
- trav->stale = 1;
-
- if (for_write) {
- trav->poisoned = 1;
- }
- }
- }
- trav = next;
+ ra_page_t *trav = NULL;
+ ra_page_t *next = NULL;
+
+ ra_file_lock(file);
+ {
+ trav = file->pages.next;
+ while (trav != &file->pages && trav->offset < (offset + size)) {
+ next = trav->next;
+ if (trav->offset >= offset) {
+ if (!trav->waitq) {
+ ra_page_purge(trav);
+ } else {
+ trav->stale = 1;
+
+ if (for_write) {
+ trav->poisoned = 1;
+ }
}
+ }
+ trav = next;
}
- ra_file_unlock (file);
+ }
+ ra_file_unlock(file);
}
-
int
-ra_release (xlator_t *this, fd_t *fd)
+ra_release(xlator_t *this, fd_t *fd)
{
- uint64_t tmp_file = 0;
- int ret = 0;
+ uint64_t tmp_file = 0;
+ int ret = 0;
- GF_VALIDATE_OR_GOTO ("read-ahead", this, out);
- GF_VALIDATE_OR_GOTO (this->name, fd, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", this, out);
+ GF_VALIDATE_OR_GOTO(this->name, fd, out);
- ret = fd_ctx_del (fd, this, &tmp_file);
+ ret = fd_ctx_del(fd, this, &tmp_file);
- if (!ret) {
- ra_file_destroy ((ra_file_t *)(long)tmp_file);
- }
+ if (!ret) {
+ ra_file_destroy((ra_file_t *)(long)tmp_file);
+ }
out:
- return 0;
+ return 0;
}
-
void
-read_ahead (call_frame_t *frame, ra_file_t *file)
+read_ahead(call_frame_t *frame, ra_file_t *file)
{
- off_t ra_offset = 0;
- size_t ra_size = 0;
- off_t trav_offset = 0;
- ra_page_t *trav = NULL;
- off_t cap = 0;
- char fault = 0;
-
- GF_VALIDATE_OR_GOTO ("read-ahead", frame, out);
- GF_VALIDATE_OR_GOTO (frame->this->name, file, out);
-
- if (!file->page_count) {
- goto out;
+ off_t ra_offset = 0;
+ size_t ra_size = 0;
+ off_t trav_offset = 0;
+ ra_page_t *trav = NULL;
+ off_t cap = 0;
+ char fault = 0;
+
+ GF_VALIDATE_OR_GOTO("read-ahead", frame, out);
+ GF_VALIDATE_OR_GOTO(frame->this->name, file, out);
+
+ if (!file->page_count) {
+ goto out;
+ }
+
+ ra_size = file->page_size * file->page_count;
+ ra_offset = floor(file->offset, file->page_size);
+ cap = file->size ? file->size : file->offset + ra_size;
+
+ while (ra_offset < min(file->offset + ra_size, cap)) {
+ ra_file_lock(file);
+ {
+ trav = ra_page_get(file, ra_offset);
}
+ ra_file_unlock(file);
- ra_size = file->page_size * file->page_count;
- ra_offset = floor (file->offset, file->page_size);
- cap = file->size ? file->size : file->offset + ra_size;
+ if (!trav)
+ break;
- while (ra_offset < min (file->offset + ra_size, cap)) {
+ ra_offset += file->page_size;
+ }
- ra_file_lock (file);
- {
- trav = ra_page_get (file, ra_offset);
- }
- ra_file_unlock (file);
+ if (trav) {
+ /* comfortable enough */
+ goto out;
+ }
- if (!trav)
- break;
+ trav_offset = ra_offset;
- ra_offset += file->page_size;
- }
+ cap = file->size ? file->size : ra_offset + ra_size;
- if (trav) {
- /* comfortable enough */
- goto out;
+ while (trav_offset < min(ra_offset + ra_size, cap)) {
+ fault = 0;
+ ra_file_lock(file);
+ {
+ trav = ra_page_get(file, trav_offset);
+ if (!trav) {
+ fault = 1;
+ trav = ra_page_create(file, trav_offset);
+ if (trav)
+ trav->dirty = 1;
+ }
}
+ ra_file_unlock(file);
- trav_offset = ra_offset;
-
- cap = file->size ? file->size : ra_offset + ra_size;
-
- while (trav_offset < min(ra_offset + ra_size, cap)) {
- fault = 0;
- ra_file_lock (file);
- {
- trav = ra_page_get (file, trav_offset);
- if (!trav) {
- fault = 1;
- trav = ra_page_create (file, trav_offset);
- if (trav)
- trav->dirty = 1;
- }
- }
- ra_file_unlock (file);
-
- if (!trav) {
- /* OUT OF MEMORY */
- break;
- }
+ if (!trav) {
+ /* OUT OF MEMORY */
+ break;
+ }
- if (fault) {
- gf_msg_trace (frame->this->name, 0,
- "RA at offset=%"PRId64, trav_offset);
- ra_page_fault (file, frame, trav_offset);
- }
- trav_offset += file->page_size;
+ if (fault) {
+ gf_msg_trace(frame->this->name, 0, "RA at offset=%" PRId64,
+ trav_offset);
+ ra_page_fault(file, frame, trav_offset);
}
+ trav_offset += file->page_size;
+ }
out:
- return;
+ return;
}
-
int
-ra_need_atime_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iovec *vector,
- int32_t count, struct iatt *stbuf, struct iobref *iobref,
- dict_t *xdata)
+ra_need_atime_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iovec *vector,
+ int32_t count, struct iatt *stbuf, struct iobref *iobref,
+ dict_t *xdata)
{
- GF_ASSERT (frame);
- STACK_DESTROY (frame->root);
- return 0;
+ GF_ASSERT(frame);
+ STACK_DESTROY(frame->root);
+ return 0;
}
-
static void
-dispatch_requests (call_frame_t *frame, ra_file_t *file)
+dispatch_requests(call_frame_t *frame, ra_file_t *file)
{
- ra_local_t *local = NULL;
- ra_conf_t *conf = NULL;
- off_t rounded_offset = 0;
- off_t rounded_end = 0;
- off_t trav_offset = 0;
- ra_page_t *trav = NULL;
- call_frame_t *ra_frame = NULL;
- char need_atime_update = 1;
- char fault = 0;
-
- GF_VALIDATE_OR_GOTO ("read-ahead", frame, out);
- GF_VALIDATE_OR_GOTO (frame->this->name, file, out);
-
- local = frame->local;
- conf = file->conf;
-
- rounded_offset = floor (local->offset, file->page_size);
- rounded_end = roof (local->offset + local->size, file->page_size);
-
- trav_offset = rounded_offset;
-
- while (trav_offset < rounded_end) {
- fault = 0;
-
- ra_file_lock (file);
- {
- trav = ra_page_get (file, trav_offset);
- if (!trav) {
- trav = ra_page_create (file, trav_offset);
- if (!trav) {
- local->op_ret = -1;
- local->op_errno = ENOMEM;
- goto unlock;
- }
- fault = 1;
- need_atime_update = 0;
- }
- trav->dirty = 0;
-
- if (trav->ready) {
- gf_msg_trace (frame->this->name, 0,
- "HIT at offset=%"PRId64".",
- trav_offset);
- ra_frame_fill (trav, frame);
- } else {
- gf_msg_trace (frame->this->name, 0,
- "IN-TRANSIT at "
- "offset=%"PRId64".",
- trav_offset);
- ra_wait_on_page (trav, frame);
- need_atime_update = 0;
- }
- }
- unlock:
- ra_file_unlock (file);
+ ra_local_t *local = NULL;
+ ra_conf_t *conf = NULL;
+ off_t rounded_offset = 0;
+ off_t rounded_end = 0;
+ off_t trav_offset = 0;
+ ra_page_t *trav = NULL;
+ call_frame_t *ra_frame = NULL;
+ char need_atime_update = 1;
+ char fault = 0;
- if (local->op_ret == -1) {
- goto out;
- }
+ GF_VALIDATE_OR_GOTO("read-ahead", frame, out);
+ GF_VALIDATE_OR_GOTO(frame->this->name, file, out);
+
+ local = frame->local;
+ conf = file->conf;
+
+ rounded_offset = floor(local->offset, file->page_size);
+ rounded_end = roof(local->offset + local->size, file->page_size);
+
+ trav_offset = rounded_offset;
+
+ while (trav_offset < rounded_end) {
+ fault = 0;
- if (fault) {
- gf_msg_trace (frame->this->name, 0,
- "MISS at offset=%"PRId64".",
- trav_offset);
- ra_page_fault (file, frame, trav_offset);
+ ra_file_lock(file);
+ {
+ trav = ra_page_get(file, trav_offset);
+ if (!trav) {
+ trav = ra_page_create(file, trav_offset);
+ if (!trav) {
+ local->op_ret = -1;
+ local->op_errno = ENOMEM;
+ goto unlock;
}
+ fault = 1;
+ need_atime_update = 0;
+ }
+ trav->dirty = 0;
+
+ if (trav->ready) {
+ gf_msg_trace(frame->this->name, 0, "HIT at offset=%" PRId64 ".",
+ trav_offset);
+ ra_frame_fill(trav, frame);
+ } else {
+ gf_msg_trace(frame->this->name, 0,
+ "IN-TRANSIT at "
+ "offset=%" PRId64 ".",
+ trav_offset);
+ ra_wait_on_page(trav, frame);
+ need_atime_update = 0;
+ }
+ }
+ unlock:
+ ra_file_unlock(file);
- trav_offset += file->page_size;
+ if (local->op_ret == -1) {
+ goto out;
}
- if (need_atime_update && conf->force_atime_update) {
- /* TODO: use untimens() since readv() can confuse underlying
- io-cache and others */
- ra_frame = copy_frame (frame);
- if (ra_frame == NULL) {
- goto out;
- }
+ if (fault) {
+ gf_msg_trace(frame->this->name, 0, "MISS at offset=%" PRId64 ".",
+ trav_offset);
+ ra_page_fault(file, frame, trav_offset);
+ }
- STACK_WIND (ra_frame, ra_need_atime_cbk,
- FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->readv,
- file->fd, 1, 1, 0, NULL);
+ trav_offset += file->page_size;
+ }
+
+ if (need_atime_update && conf->force_atime_update) {
+ /* TODO: use untimens() since readv() can confuse underlying
+ io-cache and others */
+ ra_frame = copy_frame(frame);
+ if (ra_frame == NULL) {
+ goto out;
}
+ STACK_WIND(ra_frame, ra_need_atime_cbk, FIRST_CHILD(frame->this),
+ FIRST_CHILD(frame->this)->fops->readv, file->fd, 1, 1, 0,
+ NULL);
+ }
+
out:
- return ;
+ return;
}
-
int
-ra_readv_disabled_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iovec *vector,
- int32_t count, struct iatt *stbuf, struct iobref *iobref,
- dict_t *xdata)
+ra_readv_disabled_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iovec *vector,
+ int32_t count, struct iatt *stbuf, struct iobref *iobref,
+ dict_t *xdata)
{
- GF_ASSERT (frame);
+ GF_ASSERT(frame);
- STACK_UNWIND_STRICT (readv, frame, op_ret, op_errno, vector, count,
- stbuf, iobref, xdata);
+ STACK_UNWIND_STRICT(readv, frame, op_ret, op_errno, vector, count, stbuf,
+ iobref, xdata);
- return 0;
+ return 0;
}
-
int
-ra_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, uint32_t flags, dict_t *xdata)
+ra_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, uint32_t flags, dict_t *xdata)
{
- ra_file_t *file = NULL;
- ra_local_t *local = NULL;
- ra_conf_t *conf = NULL;
- int op_errno = EINVAL;
- char expected_offset = 1;
- uint64_t tmp_file = 0;
-
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
- GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind);
-
- conf = this->private;
-
- gf_msg_trace (this->name, 0,
- "NEW REQ at offset=%"PRId64" for size=%"GF_PRI_SIZET"",
- offset, size);
-
- fd_ctx_get (fd, this, &tmp_file);
- file = (ra_file_t *)(long)tmp_file;
-
- if (!file || file->disabled) {
- goto disabled;
+ ra_file_t *file = NULL;
+ ra_local_t *local = NULL;
+ ra_conf_t *conf = NULL;
+ int op_errno = EINVAL;
+ char expected_offset = 1;
+ uint64_t tmp_file = 0;
+
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+ GF_VALIDATE_OR_GOTO(frame->this->name, fd, unwind);
+
+ conf = this->private;
+
+ gf_msg_trace(this->name, 0,
+ "NEW REQ at offset=%" PRId64 " for size=%" GF_PRI_SIZET "",
+ offset, size);
+
+ fd_ctx_get(fd, this, &tmp_file);
+ file = (ra_file_t *)(long)tmp_file;
+
+ if (!file || file->disabled) {
+ goto disabled;
+ }
+
+ if (file->offset != offset) {
+ gf_msg_trace(this->name, 0,
+ "unexpected offset (%" PRId64 " != %" PRId64
+ ") "
+ "resetting",
+ file->offset, offset);
+
+ expected_offset = file->expected = file->page_count = 0;
+ } else {
+ gf_msg_trace(this->name, 0,
+ "expected offset (%" PRId64 ") when page_count=%d", offset,
+ file->page_count);
+
+ if (file->expected < (file->page_size * conf->page_count)) {
+ file->expected += size;
+ file->page_count = min((file->expected / file->page_size),
+ conf->page_count);
}
+ }
- if (file->offset != offset) {
- gf_msg_trace (this->name, 0,
- "unexpected offset (%"PRId64" != %"PRId64") "
- "resetting",
- file->offset, offset);
-
- expected_offset = file->expected = file->page_count = 0;
- } else {
- gf_msg_trace (this->name, 0,
- "expected offset (%"PRId64") when page_count=%d",
- offset, file->page_count);
-
- if (file->expected < (file->page_size * conf->page_count)) {
- file->expected += size;
- file->page_count = min ((file->expected
- / file->page_size),
- conf->page_count);
- }
- }
-
- if (!expected_offset) {
- flush_region (frame, file, 0, file->pages.prev->offset + 1, 0);
- }
+ if (!expected_offset) {
+ flush_region(frame, file, 0, file->pages.prev->offset + 1, 0);
+ }
- local = mem_get0 (this->local_pool);
- if (!local) {
- op_errno = ENOMEM;
- goto unwind;
- }
+ local = mem_get0(this->local_pool);
+ if (!local) {
+ op_errno = ENOMEM;
+ goto unwind;
+ }
- local->fd = fd;
- local->offset = offset;
- local->size = size;
- local->wait_count = 1;
+ local->fd = fd;
+ local->offset = offset;
+ local->size = size;
+ local->wait_count = 1;
- local->fill.next = &local->fill;
- local->fill.prev = &local->fill;
+ local->fill.next = &local->fill;
+ local->fill.prev = &local->fill;
- pthread_mutex_init (&local->local_lock, NULL);
+ pthread_mutex_init(&local->local_lock, NULL);
- frame->local = local;
+ frame->local = local;
- dispatch_requests (frame, file);
+ dispatch_requests(frame, file);
- flush_region (frame, file, 0, floor (offset, file->page_size), 0);
+ flush_region(frame, file, 0, floor(offset, file->page_size), 0);
- read_ahead (frame, file);
+ read_ahead(frame, file);
- ra_frame_return (frame);
+ ra_frame_return(frame);
- file->offset = offset + size;
+ file->offset = offset + size;
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (readv, frame, -1, op_errno, NULL, 0, NULL, NULL,
- NULL);
+ STACK_UNWIND_STRICT(readv, frame, -1, op_errno, NULL, 0, NULL, NULL, NULL);
- return 0;
+ return 0;
disabled:
- STACK_WIND (frame, ra_readv_disabled_cbk,
- FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->readv,
- fd, size, offset, flags, xdata);
- return 0;
+ STACK_WIND(frame, ra_readv_disabled_cbk, FIRST_CHILD(frame->this),
+ FIRST_CHILD(frame->this)->fops->readv, fd, size, offset, flags,
+ xdata);
+ return 0;
}
-
int
-ra_flush_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
- int32_t op_errno, dict_t *xdata)
+ra_flush_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, dict_t *xdata)
{
- GF_ASSERT (frame);
- STACK_UNWIND_STRICT (flush, frame, op_ret, op_errno, xdata);
- return 0;
+ GF_ASSERT(frame);
+ STACK_UNWIND_STRICT(flush, frame, op_ret, op_errno, xdata);
+ return 0;
}
-
-
int
-ra_fsync_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
- int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf,
- dict_t *xdata)
+ra_fsync_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *prebuf, struct iatt *postbuf,
+ dict_t *xdata)
{
- GF_ASSERT (frame);
- STACK_UNWIND_STRICT (fsync, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
- return 0;
+ GF_ASSERT(frame);
+ STACK_UNWIND_STRICT(fsync, frame, op_ret, op_errno, prebuf, postbuf, xdata);
+ return 0;
}
-
int
-ra_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+ra_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- int32_t op_errno = EINVAL;
+ int32_t op_errno = EINVAL;
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
- GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind);
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+ GF_VALIDATE_OR_GOTO(frame->this->name, fd, unwind);
- STACK_WIND (frame, ra_flush_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->flush, fd, xdata);
- return 0;
+ STACK_WIND(frame, ra_flush_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->flush, fd, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT (flush, frame, -1, op_errno, NULL);
- return 0;
+ STACK_UNWIND_STRICT(flush, frame, -1, op_errno, NULL);
+ return 0;
}
-
int
-ra_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync,
- dict_t *xdata)
+ra_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync,
+ dict_t *xdata)
{
- int32_t op_errno = EINVAL;
+ int32_t op_errno = EINVAL;
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
- GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind);
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+ GF_VALIDATE_OR_GOTO(frame->this->name, fd, unwind);
- STACK_WIND (frame, ra_fsync_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->fsync, fd, datasync, xdata);
- return 0;
+ STACK_WIND(frame, ra_fsync_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsync, fd, datasync, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT (fsync, frame, -1, op_errno, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(fsync, frame, -1, op_errno, NULL, NULL, NULL);
+ return 0;
}
-
int
-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, dict_t *xdata)
+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,
+ dict_t *xdata)
{
- ra_file_t *file = NULL;
+ ra_file_t *file = NULL;
- GF_ASSERT (frame);
+ GF_ASSERT(frame);
- file = frame->local;
+ file = frame->local;
- if (file) {
- flush_region (frame, file, 0, file->pages.prev->offset+1, 1);
- }
+ if (file) {
+ flush_region(frame, file, 0, file->pages.prev->offset + 1, 1);
+ }
- frame->local = NULL;
- STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
- return 0;
+ frame->local = NULL;
+ STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
-
int
-ra_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
- int32_t count, off_t offset, uint32_t flags, struct iobref *iobref,
- dict_t *xdata)
+ra_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
+ int32_t count, off_t offset, uint32_t flags, struct iobref *iobref,
+ dict_t *xdata)
{
- ra_file_t *file = NULL;
- uint64_t tmp_file = 0;
- int32_t op_errno = EINVAL;
- inode_t *inode = NULL;
- fd_t *iter_fd = NULL;
+ ra_file_t *file = NULL;
+ uint64_t tmp_file = 0;
+ int32_t op_errno = EINVAL;
+ inode_t *inode = NULL;
+ fd_t *iter_fd = NULL;
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
- GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind);
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+ GF_VALIDATE_OR_GOTO(frame->this->name, fd, unwind);
- inode = fd->inode;
+ inode = fd->inode;
- LOCK (&inode->lock);
+ LOCK(&inode->lock);
+ {
+ list_for_each_entry(iter_fd, &inode->fd_list, inode_list)
{
- list_for_each_entry (iter_fd, &inode->fd_list, inode_list) {
- tmp_file = 0;
- fd_ctx_get (iter_fd, this, &tmp_file);
- file = (ra_file_t *)(long)tmp_file;
+ tmp_file = 0;
+ fd_ctx_get(iter_fd, this, &tmp_file);
+ file = (ra_file_t *)(long)tmp_file;
- if (!file)
- continue;
+ if (!file)
+ continue;
- if (iter_fd == fd)
- frame->local = file;
+ if (iter_fd == fd)
+ frame->local = file;
- flush_region (frame, file, 0,
- file->pages.prev->offset + 1, 1);
+ flush_region(frame, file, 0, file->pages.prev->offset + 1, 1);
- /* reset the read-ahead counters too */
- file->expected = file->page_count = 0;
- }
+ /* reset the read-ahead counters too */
+ file->expected = file->page_count = 0;
}
- UNLOCK (&inode->lock);
+ }
+ UNLOCK(&inode->lock);
- STACK_WIND (frame, ra_writev_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->writev,
- fd, vector, count, offset, flags, iobref, xdata);
+ STACK_WIND(frame, ra_writev_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->writev, fd, vector, count, offset,
+ flags, iobref, xdata);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (writev, frame, -1, op_errno, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(writev, frame, -1, op_errno, NULL, NULL, NULL);
+ return 0;
}
-
int
-ra_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+ra_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- GF_ASSERT (frame);
+ GF_ASSERT(frame);
- STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, prebuf,
- postbuf, xdata);
- return 0;
+ STACK_UNWIND_STRICT(truncate, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
-
int
-ra_attr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *buf, dict_t *xdata)
+ra_attr_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, struct iatt *buf, dict_t *xdata)
{
- GF_ASSERT (frame);
+ GF_ASSERT(frame);
- STACK_UNWIND_STRICT (stat, frame, op_ret, op_errno, buf, xdata);
- return 0;
+ STACK_UNWIND_STRICT(stat, frame, op_ret, op_errno, buf, xdata);
+ return 0;
}
-
int
-ra_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
- dict_t *xdata)
+ra_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
+ dict_t *xdata)
{
- ra_file_t *file = NULL;
- fd_t *iter_fd = NULL;
- inode_t *inode = NULL;
- uint64_t tmp_file = 0;
- int32_t op_errno = EINVAL;
+ ra_file_t *file = NULL;
+ fd_t *iter_fd = NULL;
+ inode_t *inode = NULL;
+ uint64_t tmp_file = 0;
+ int32_t op_errno = EINVAL;
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
- GF_VALIDATE_OR_GOTO (frame->this->name, loc, unwind);
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+ GF_VALIDATE_OR_GOTO(frame->this->name, loc, unwind);
- inode = loc->inode;
+ inode = loc->inode;
- LOCK (&inode->lock);
+ LOCK(&inode->lock);
+ {
+ list_for_each_entry(iter_fd, &inode->fd_list, inode_list)
{
- list_for_each_entry (iter_fd, &inode->fd_list, inode_list) {
- tmp_file = 0;
- fd_ctx_get (iter_fd, this, &tmp_file);
- file = (ra_file_t *)(long)tmp_file;
-
- if (!file)
- continue;
- /*
- * Truncation invalidates reads just like writing does.
- * TBD: this seems to flush more than it should. The
- * only time we should flush at all is when we're
- * shortening (not lengthening) the file, and then only
- * from new EOF to old EOF. The same problem exists in
- * ra_ftruncate.
- */
- flush_region (frame, file, 0,
- file->pages.prev->offset + 1, 1);
- }
+ tmp_file = 0;
+ fd_ctx_get(iter_fd, this, &tmp_file);
+ file = (ra_file_t *)(long)tmp_file;
+
+ if (!file)
+ continue;
+ /*
+ * Truncation invalidates reads just like writing does.
+ * TBD: this seems to flush more than it should. The
+ * only time we should flush at all is when we're
+ * shortening (not lengthening) the file, and then only
+ * from new EOF to old EOF. The same problem exists in
+ * ra_ftruncate.
+ */
+ flush_region(frame, file, 0, file->pages.prev->offset + 1, 1);
}
- UNLOCK (&inode->lock);
+ }
+ UNLOCK(&inode->lock);
- STACK_WIND (frame, ra_truncate_cbk,
- FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->truncate,
- loc, offset, xdata);
- return 0;
+ STACK_WIND(frame, ra_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT (truncate, frame, -1, op_errno, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(truncate, frame, -1, op_errno, NULL, NULL, NULL);
+ return 0;
}
-
void
-ra_page_dump (struct ra_page *page)
+ra_page_dump(struct ra_page *page)
{
- int i = 0;
- call_frame_t *frame = NULL;
- char key[GF_DUMP_MAX_BUF_LEN] = {0, };
- ra_waitq_t *trav = NULL;
+ int i = 0;
+ call_frame_t *frame = NULL;
+ char key[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ ra_waitq_t *trav = NULL;
- if (page == NULL) {
- goto out;
- }
+ if (page == NULL) {
+ goto out;
+ }
- gf_proc_dump_write ("offset", "%"PRId64, page->offset);
+ gf_proc_dump_write("offset", "%" PRId64, page->offset);
- gf_proc_dump_write ("size", "%"PRId64, page->size);
+ gf_proc_dump_write("size", "%" PRId64, page->size);
- gf_proc_dump_write ("dirty", "%s", page->dirty ? "yes" : "no");
+ gf_proc_dump_write("dirty", "%s", page->dirty ? "yes" : "no");
- gf_proc_dump_write ("poisoned", "%s", page->poisoned ? "yes" : "no");
+ gf_proc_dump_write("poisoned", "%s", page->poisoned ? "yes" : "no");
- gf_proc_dump_write ("ready", "%s", page->ready ? "yes" : "no");
+ gf_proc_dump_write("ready", "%s", page->ready ? "yes" : "no");
- for (trav = page->waitq; trav; trav = trav->next) {
- frame = trav->data;
- sprintf (key, "waiting-frame[%d]", i++);
- gf_proc_dump_write (key, "%"PRId64, frame->root->unique);
- }
+ for (trav = page->waitq; trav; trav = trav->next) {
+ frame = trav->data;
+ sprintf(key, "waiting-frame[%d]", i++);
+ gf_proc_dump_write(key, "%" PRId64, frame->root->unique);
+ }
out:
- return;
+ return;
}
int32_t
-ra_fdctx_dump (xlator_t *this, fd_t *fd)
+ra_fdctx_dump(xlator_t *this, fd_t *fd)
{
- ra_file_t *file = NULL;
- ra_page_t *page = NULL;
- int32_t ret = 0, i = 0;
- uint64_t tmp_file = 0;
- char *path = NULL;
- char key[GF_DUMP_MAX_BUF_LEN] = {0, };
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
-
- fd_ctx_get (fd, this, &tmp_file);
- file = (ra_file_t *)(long)tmp_file;
-
- if (file == NULL) {
- ret = 0;
- goto out;
- }
+ ra_file_t *file = NULL;
+ ra_page_t *page = NULL;
+ int32_t ret = 0, i = 0;
+ uint64_t tmp_file = 0;
+ char *path = NULL;
+ char key[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+
+ fd_ctx_get(fd, this, &tmp_file);
+ file = (ra_file_t *)(long)tmp_file;
+
+ if (file == NULL) {
+ ret = 0;
+ goto out;
+ }
- gf_proc_dump_build_key (key_prefix,
- "xlator.performance.read-ahead",
- "file");
+ gf_proc_dump_build_key(key_prefix, "xlator.performance.read-ahead", "file");
- gf_proc_dump_add_section (key_prefix);
+ gf_proc_dump_add_section(key_prefix);
- ret = __inode_path (fd->inode, NULL, &path);
- if (path != NULL) {
- gf_proc_dump_write ("path", "%s", path);
- GF_FREE (path);
- }
+ ret = __inode_path(fd->inode, NULL, &path);
+ if (path != NULL) {
+ gf_proc_dump_write("path", "%s", path);
+ GF_FREE(path);
+ }
- gf_proc_dump_write ("fd", "%p", fd);
+ gf_proc_dump_write("fd", "%p", fd);
- gf_proc_dump_write ("disabled", "%s", file->disabled ? "yes" : "no");
+ gf_proc_dump_write("disabled", "%s", file->disabled ? "yes" : "no");
- if (file->disabled) {
- ret = 0;
- goto out;
- }
+ if (file->disabled) {
+ ret = 0;
+ goto out;
+ }
- gf_proc_dump_write ("page-size", "%"PRId64, file->page_size);
+ gf_proc_dump_write("page-size", "%" PRId64, file->page_size);
- gf_proc_dump_write ("page-count", "%u", file->page_count);
+ gf_proc_dump_write("page-count", "%u", file->page_count);
- gf_proc_dump_write ("next-expected-offset-for-sequential-reads",
- "%"PRId64, file->offset);
+ gf_proc_dump_write("next-expected-offset-for-sequential-reads", "%" PRId64,
+ file->offset);
- for (page = file->pages.next; page != &file->pages;
- page = page->next) {
- sprintf (key, "page[%d]", i);
- gf_proc_dump_write (key, "%p", page[i++]);
- ra_page_dump (page);
- }
+ for (page = file->pages.next; page != &file->pages; page = page->next) {
+ sprintf(key, "page[%d]", i);
+ gf_proc_dump_write(key, "%p", page[i++]);
+ ra_page_dump(page);
+ }
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
int
-ra_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+ra_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- ra_file_t *file = NULL;
- fd_t *iter_fd = NULL;
- inode_t *inode = NULL;
- uint64_t tmp_file = 0;
- int32_t op_errno = EINVAL;
- ra_conf_t *conf = NULL;
-
- conf = this->private;
-
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
- GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind);
-
- inode = fd->inode;
-
- if (conf->force_atime_update) {
- LOCK (&inode->lock);
- {
- list_for_each_entry (iter_fd, &inode->fd_list,
- inode_list) {
- tmp_file = 0;
- fd_ctx_get (iter_fd, this, &tmp_file);
- file = (ra_file_t *)(long)tmp_file;
-
- if (!file)
- continue;
- flush_region (frame, file, 0,
- file->pages.prev->offset + 1, 0);
- }
- }
- UNLOCK (&inode->lock);
+ ra_file_t *file = NULL;
+ fd_t *iter_fd = NULL;
+ inode_t *inode = NULL;
+ uint64_t tmp_file = 0;
+ int32_t op_errno = EINVAL;
+ ra_conf_t *conf = NULL;
+
+ conf = this->private;
+
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+ GF_VALIDATE_OR_GOTO(frame->this->name, fd, unwind);
+
+ inode = fd->inode;
+
+ if (conf->force_atime_update) {
+ LOCK(&inode->lock);
+ {
+ list_for_each_entry(iter_fd, &inode->fd_list, inode_list)
+ {
+ tmp_file = 0;
+ fd_ctx_get(iter_fd, this, &tmp_file);
+ file = (ra_file_t *)(long)tmp_file;
+
+ if (!file)
+ continue;
+ flush_region(frame, file, 0, file->pages.prev->offset + 1, 0);
+ }
}
+ UNLOCK(&inode->lock);
+ }
- STACK_WIND (frame, ra_attr_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->fstat, fd, xdata);
- return 0;
+ STACK_WIND(frame, ra_attr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fstat, fd, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT (stat, frame, -1, op_errno, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(stat, frame, -1, op_errno, NULL, NULL);
+ return 0;
}
-
int
-ra_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- dict_t *xdata)
+ra_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ dict_t *xdata)
{
- ra_file_t *file = NULL;
- fd_t *iter_fd = NULL;
- inode_t *inode = NULL;
- uint64_t tmp_file = 0;
- int32_t op_errno = EINVAL;
+ ra_file_t *file = NULL;
+ fd_t *iter_fd = NULL;
+ inode_t *inode = NULL;
+ uint64_t tmp_file = 0;
+ int32_t op_errno = EINVAL;
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
- GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind);
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+ GF_VALIDATE_OR_GOTO(frame->this->name, fd, unwind);
- inode = fd->inode;
+ inode = fd->inode;
- LOCK (&inode->lock);
+ LOCK(&inode->lock);
+ {
+ list_for_each_entry(iter_fd, &inode->fd_list, inode_list)
{
- list_for_each_entry (iter_fd, &inode->fd_list, inode_list) {
- tmp_file = 0;
- fd_ctx_get (iter_fd, this, &tmp_file);
- file = (ra_file_t *)(long)tmp_file;
- if (!file)
- continue;
- /*
- * Truncation invalidates reads just like writing does.
- * TBD: this seems to flush more than it should. The
- * only time we should flush at all is when we're
- * shortening (not lengthening) the file, and then only
- * from new EOF to old EOF. The same problem exists in
- * ra_truncate.
- */
- flush_region (frame, file, 0,
- file->pages.prev->offset + 1, 1);
- }
+ tmp_file = 0;
+ fd_ctx_get(iter_fd, this, &tmp_file);
+ file = (ra_file_t *)(long)tmp_file;
+ if (!file)
+ continue;
+ /*
+ * Truncation invalidates reads just like writing does.
+ * TBD: this seems to flush more than it should. The
+ * only time we should flush at all is when we're
+ * shortening (not lengthening) the file, and then only
+ * from new EOF to old EOF. The same problem exists in
+ * ra_truncate.
+ */
+ flush_region(frame, file, 0, file->pages.prev->offset + 1, 1);
}
- UNLOCK (&inode->lock);
+ }
+ UNLOCK(&inode->lock);
- STACK_WIND (frame, ra_truncate_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->ftruncate, fd, offset, xdata);
- return 0;
+ STACK_WIND(frame, ra_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT (truncate, frame, -1, op_errno, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(truncate, frame, -1, op_errno, NULL, NULL, NULL);
+ return 0;
}
int
@@ -957,351 +918,342 @@ ra_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
struct iatt *postbuf, dict_t *xdata)
{
- GF_ASSERT (frame);
+ GF_ASSERT(frame);
- STACK_UNWIND_STRICT (discard, frame, op_ret, op_errno, prebuf,
- postbuf, xdata);
- return 0;
+ STACK_UNWIND_STRICT(discard, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
static int
ra_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- size_t len, dict_t *xdata)
+ size_t len, dict_t *xdata)
{
- ra_file_t *file = NULL;
- fd_t *iter_fd = NULL;
- inode_t *inode = NULL;
- uint64_t tmp_file = 0;
- int32_t op_errno = EINVAL;
+ ra_file_t *file = NULL;
+ fd_t *iter_fd = NULL;
+ inode_t *inode = NULL;
+ uint64_t tmp_file = 0;
+ int32_t op_errno = EINVAL;
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
- GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind);
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+ GF_VALIDATE_OR_GOTO(frame->this->name, fd, unwind);
- inode = fd->inode;
+ inode = fd->inode;
- LOCK (&inode->lock);
+ LOCK(&inode->lock);
+ {
+ list_for_each_entry(iter_fd, &inode->fd_list, inode_list)
{
- list_for_each_entry (iter_fd, &inode->fd_list, inode_list) {
- tmp_file = 0;
- fd_ctx_get (iter_fd, this, &tmp_file);
- file = (ra_file_t *)(long)tmp_file;
- if (!file)
- continue;
-
- flush_region(frame, file, offset, len, 1);
- }
+ tmp_file = 0;
+ fd_ctx_get(iter_fd, this, &tmp_file);
+ file = (ra_file_t *)(long)tmp_file;
+ if (!file)
+ continue;
+
+ flush_region(frame, file, offset, len, 1);
}
- UNLOCK (&inode->lock);
+ }
+ UNLOCK(&inode->lock);
- STACK_WIND (frame, ra_discard_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->discard, fd, offset, len, xdata);
- return 0;
+ STACK_WIND(frame, ra_discard_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->discard, fd, offset, len, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT (discard, frame, -1, op_errno, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(discard, frame, -1, op_errno, NULL, NULL, NULL);
+ return 0;
}
int
ra_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- GF_ASSERT (frame);
+ GF_ASSERT(frame);
- STACK_UNWIND_STRICT (zerofill, frame, op_ret, op_errno, prebuf,
- postbuf, xdata);
- return 0;
+ STACK_UNWIND_STRICT(zerofill, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
static int
ra_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- off_t len, dict_t *xdata)
+ off_t len, dict_t *xdata)
{
- ra_file_t *file = NULL;
- fd_t *iter_fd = NULL;
- inode_t *inode = NULL;
- uint64_t tmp_file = 0;
- int32_t op_errno = EINVAL;
+ ra_file_t *file = NULL;
+ fd_t *iter_fd = NULL;
+ inode_t *inode = NULL;
+ uint64_t tmp_file = 0;
+ int32_t op_errno = EINVAL;
- GF_ASSERT (frame);
- GF_VALIDATE_OR_GOTO (frame->this->name, this, unwind);
- GF_VALIDATE_OR_GOTO (frame->this->name, fd, unwind);
+ GF_ASSERT(frame);
+ GF_VALIDATE_OR_GOTO(frame->this->name, this, unwind);
+ GF_VALIDATE_OR_GOTO(frame->this->name, fd, unwind);
- inode = fd->inode;
+ inode = fd->inode;
- LOCK (&inode->lock);
+ LOCK(&inode->lock);
+ {
+ list_for_each_entry(iter_fd, &inode->fd_list, inode_list)
{
- list_for_each_entry (iter_fd, &inode->fd_list, inode_list) {
- tmp_file = 0;
- fd_ctx_get (iter_fd, this, &tmp_file);
- file = (ra_file_t *)(long)tmp_file;
- if (!file)
- continue;
-
- flush_region(frame, file, offset, len, 1);
- }
+ tmp_file = 0;
+ fd_ctx_get(iter_fd, this, &tmp_file);
+ file = (ra_file_t *)(long)tmp_file;
+ if (!file)
+ continue;
+
+ flush_region(frame, file, offset, len, 1);
}
- UNLOCK (&inode->lock);
+ }
+ UNLOCK(&inode->lock);
- STACK_WIND (frame, ra_zerofill_cbk, FIRST_CHILD (this),
- FIRST_CHILD (this)->fops->zerofill, fd,
- offset, len, xdata);
- return 0;
+ STACK_WIND(frame, ra_zerofill_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->zerofill, fd, offset, len, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT (zerofill, frame, -1, op_errno, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(zerofill, frame, -1, op_errno, NULL, NULL, NULL);
+ return 0;
}
int
-ra_priv_dump (xlator_t *this)
+ra_priv_dump(xlator_t *this)
{
- ra_conf_t *conf = NULL;
- int ret = -1;
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
- gf_boolean_t add_section = _gf_false;
-
- if (!this) {
- goto out;
- }
-
- conf = this->private;
- if (!conf) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- READ_AHEAD_MSG_XLATOR_CONF_NULL,
- "conf null in xlator");
- goto out;
- }
-
- gf_proc_dump_build_key (key_prefix, "xlator.performance.read-ahead",
- "priv");
-
- gf_proc_dump_add_section (key_prefix);
- add_section = _gf_true;
-
- ret = pthread_mutex_trylock (&conf->conf_lock);
- if (ret)
- goto out;
- {
- gf_proc_dump_write ("page_size", "%d", conf->page_size);
- gf_proc_dump_write ("page_count", "%d", conf->page_count);
- gf_proc_dump_write ("force_atime_update", "%d",
- conf->force_atime_update);
- }
- pthread_mutex_unlock (&conf->conf_lock);
-
- ret = 0;
+ ra_conf_t *conf = NULL;
+ int ret = -1;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ gf_boolean_t add_section = _gf_false;
+
+ if (!this) {
+ goto out;
+ }
+
+ conf = this->private;
+ if (!conf) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, READ_AHEAD_MSG_XLATOR_CONF_NULL,
+ "conf null in xlator");
+ goto out;
+ }
+
+ gf_proc_dump_build_key(key_prefix, "xlator.performance.read-ahead", "priv");
+
+ gf_proc_dump_add_section(key_prefix);
+ add_section = _gf_true;
+
+ ret = pthread_mutex_trylock(&conf->conf_lock);
+ if (ret)
+ goto out;
+ {
+ gf_proc_dump_write("page_size", "%d", conf->page_size);
+ gf_proc_dump_write("page_count", "%d", conf->page_count);
+ gf_proc_dump_write("force_atime_update", "%d",
+ conf->force_atime_update);
+ }
+ pthread_mutex_unlock(&conf->conf_lock);
+
+ ret = 0;
out:
- if (ret && conf) {
- if (add_section == _gf_false)
- gf_proc_dump_add_section (key_prefix);
-
- gf_proc_dump_write ("Unable to dump priv",
- "(Lock acquisition failed) %s", this->name);
- }
- return ret;
+ if (ret && conf) {
+ if (add_section == _gf_false)
+ gf_proc_dump_add_section(key_prefix);
+
+ gf_proc_dump_write("Unable to dump priv",
+ "(Lock acquisition failed) %s", this->name);
+ }
+ return ret;
}
-
int32_t
-mem_acct_init (xlator_t *this)
+mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- if (!this) {
- goto out;
- }
+ if (!this) {
+ goto out;
+ }
- ret = xlator_mem_acct_init (this, gf_ra_mt_end + 1);
+ ret = xlator_mem_acct_init(this, gf_ra_mt_end + 1);
- if (ret != 0) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- READ_AHEAD_MSG_NO_MEMORY, "Memory accounting init"
- "failed");
- }
+ if (ret != 0) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, READ_AHEAD_MSG_NO_MEMORY,
+ "Memory accounting init"
+ "failed");
+ }
out:
- return ret;
+ return ret;
}
int
-reconfigure (xlator_t *this, dict_t *options)
+reconfigure(xlator_t *this, dict_t *options)
{
- ra_conf_t *conf = NULL;
- int ret = -1;
+ ra_conf_t *conf = NULL;
+ int ret = -1;
- GF_VALIDATE_OR_GOTO ("read-ahead", this, out);
- GF_VALIDATE_OR_GOTO ("read-ahead", this->private, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", this, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", this->private, out);
- conf = this->private;
+ conf = this->private;
- GF_OPTION_RECONF ("page-count", conf->page_count, options, uint32, out);
+ GF_OPTION_RECONF("page-count", conf->page_count, options, uint32, out);
- GF_OPTION_RECONF ("page-size", conf->page_size, options, size_uint64,
- out);
+ GF_OPTION_RECONF("page-size", conf->page_size, options, size_uint64, out);
- GF_OPTION_RECONF ("pass-through", this->pass_through, options, bool,
- out);
+ GF_OPTION_RECONF("pass-through", this->pass_through, options, bool, out);
- ret = 0;
- out:
- return ret;
+ ret = 0;
+out:
+ return ret;
}
int
-init (xlator_t *this)
+init(xlator_t *this)
{
- ra_conf_t *conf = NULL;
- int32_t ret = -1;
+ ra_conf_t *conf = NULL;
+ int32_t ret = -1;
- GF_VALIDATE_OR_GOTO ("read-ahead", this, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", this, out);
- if (!this->children || this->children->next) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- READ_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED,
- "FATAL: read-ahead not configured with exactly one"
- " child");
- goto out;
- }
+ if (!this->children || this->children->next) {
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ READ_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED,
+ "FATAL: read-ahead not configured with exactly one"
+ " child");
+ goto out;
+ }
- if (!this->parents) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- READ_AHEAD_MSG_VOL_MISCONFIGURED,
- "dangling volume. check volfile ");
- }
+ if (!this->parents) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, READ_AHEAD_MSG_VOL_MISCONFIGURED,
+ "dangling volume. check volfile ");
+ }
- conf = (void *) GF_CALLOC (1, sizeof (*conf), gf_ra_mt_ra_conf_t);
- if (conf == NULL) {
- goto out;
- }
+ conf = (void *)GF_CALLOC(1, sizeof(*conf), gf_ra_mt_ra_conf_t);
+ if (conf == NULL) {
+ goto out;
+ }
- conf->page_size = this->ctx->page_size;
+ conf->page_size = this->ctx->page_size;
- GF_OPTION_INIT ("page-size", conf->page_size, size_uint64, out);
+ GF_OPTION_INIT("page-size", conf->page_size, size_uint64, out);
- GF_OPTION_INIT ("page-count", conf->page_count, uint32, out);
+ GF_OPTION_INIT("page-count", conf->page_count, uint32, out);
- GF_OPTION_INIT ("force-atime-update", conf->force_atime_update, bool, out);
+ GF_OPTION_INIT("force-atime-update", conf->force_atime_update, bool, out);
- GF_OPTION_INIT ("pass-through", this->pass_through, bool, out);
+ GF_OPTION_INIT("pass-through", this->pass_through, bool, out);
- conf->files.next = &conf->files;
- conf->files.prev = &conf->files;
+ conf->files.next = &conf->files;
+ conf->files.prev = &conf->files;
- pthread_mutex_init (&conf->conf_lock, NULL);
+ pthread_mutex_init(&conf->conf_lock, NULL);
- this->local_pool = mem_pool_new (ra_local_t, 64);
- if (!this->local_pool) {
- ret = -1;
- gf_msg (this->name, GF_LOG_ERROR,
- ENOMEM, READ_AHEAD_MSG_NO_MEMORY,
- "failed to create local_t's memory pool");
- goto out;
- }
+ this->local_pool = mem_pool_new(ra_local_t, 64);
+ if (!this->local_pool) {
+ ret = -1;
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, READ_AHEAD_MSG_NO_MEMORY,
+ "failed to create local_t's memory pool");
+ goto out;
+ }
- this->private = conf;
- ret = 0;
+ this->private = conf;
+ ret = 0;
out:
- if (ret == -1) {
- GF_FREE (conf);
- }
+ if (ret == -1) {
+ GF_FREE(conf);
+ }
- return ret;
+ return ret;
}
-
void
-fini (xlator_t *this)
+fini(xlator_t *this)
{
- ra_conf_t *conf = NULL;
+ ra_conf_t *conf = NULL;
- GF_VALIDATE_OR_GOTO ("read-ahead", this, out);
+ GF_VALIDATE_OR_GOTO("read-ahead", this, out);
- conf = this->private;
- if (conf == NULL) {
- goto out;
- }
+ conf = this->private;
+ if (conf == NULL) {
+ goto out;
+ }
- this->private = NULL;
-
- /* The files structures allocated in open and create are not deleted.
- * until that is freed, marking the below assert as warning.
- GF_ASSERT ((conf->files.next == &conf->files)
- && (conf->files.prev == &conf->files));
- */
- if (!((conf->files.next == &conf->files)
- && (conf->files.prev == &conf->files))) {
- gf_msg (this->name, GF_LOG_INFO, 0,
- READ_AHEAD_MSG_UNDESTROYED_FILE_FOUND,
- "undestroyed read ahead file structures found");
- }
+ this->private = NULL;
+
+ /* The files structures allocated in open and create are not deleted.
+ * until that is freed, marking the below assert as warning.
+ GF_ASSERT ((conf->files.next == &conf->files)
+ && (conf->files.prev == &conf->files));
+ */
+ if (!((conf->files.next == &conf->files) &&
+ (conf->files.prev == &conf->files))) {
+ gf_msg(this->name, GF_LOG_INFO, 0,
+ READ_AHEAD_MSG_UNDESTROYED_FILE_FOUND,
+ "undestroyed read ahead file structures found");
+ }
- pthread_mutex_destroy (&conf->conf_lock);
- GF_FREE (conf);
+ pthread_mutex_destroy(&conf->conf_lock);
+ GF_FREE(conf);
out:
- return;
+ return;
}
struct xlator_fops fops = {
- .open = ra_open,
- .create = ra_create,
- .readv = ra_readv,
- .writev = ra_writev,
- .flush = ra_flush,
- .fsync = ra_fsync,
- .truncate = ra_truncate,
- .ftruncate = ra_ftruncate,
- .fstat = ra_fstat,
- .discard = ra_discard,
- .zerofill = ra_zerofill,
+ .open = ra_open,
+ .create = ra_create,
+ .readv = ra_readv,
+ .writev = ra_writev,
+ .flush = ra_flush,
+ .fsync = ra_fsync,
+ .truncate = ra_truncate,
+ .ftruncate = ra_ftruncate,
+ .fstat = ra_fstat,
+ .discard = ra_discard,
+ .zerofill = ra_zerofill,
};
struct xlator_cbks cbks = {
- .release = ra_release,
+ .release = ra_release,
};
struct xlator_dumpops dumpops = {
- .priv = ra_priv_dump,
- .fdctx = ra_fdctx_dump,
+ .priv = ra_priv_dump,
+ .fdctx = ra_fdctx_dump,
};
struct volume_options options[] = {
- { .key = {"force-atime-update"},
- .type = GF_OPTION_TYPE_BOOL,
- .op_version = {1},
- .tags = {"read-ahead"},
- .default_value = "false"
- },
- { .key = {"page-count"},
- .type = GF_OPTION_TYPE_INT,
- .min = 1,
- .max = 16,
- .default_value = "4",
- .op_version = {1},
- .tags = {"read-ahead"},
- .description = "Number of pages that will be pre-fetched"
- },
- { .key = {"page-size"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 4096,
- .max = 1048576 * 64,
- .default_value = "131072",
- .op_version = {1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"read-ahead"},
- .description = "Page size with which read-ahead performs server I/O"
- },
- { .key = {"pass-through"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"read-ahead"},
- .description = "Enable/Disable read ahead translator"
- },
- { .key = {NULL} },
+ {.key = {"force-atime-update"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .op_version = {1},
+ .tags = {"read-ahead"},
+ .default_value = "false"},
+ {.key = {"page-count"},
+ .type = GF_OPTION_TYPE_INT,
+ .min = 1,
+ .max = 16,
+ .default_value = "4",
+ .op_version = {1},
+ .tags = {"read-ahead"},
+ .description = "Number of pages that will be pre-fetched"},
+ {.key = {"page-size"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 4096,
+ .max = 1048576 * 64,
+ .default_value = "131072",
+ .op_version = {1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"read-ahead"},
+ .description = "Page size with which read-ahead performs server I/O"},
+ {.key = {"pass-through"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"read-ahead"},
+ .description = "Enable/Disable read ahead translator"},
+ {.key = {NULL}},
};
diff --git a/xlators/performance/readdir-ahead/src/readdir-ahead.c b/xlators/performance/readdir-ahead/src/readdir-ahead.c
index 72ab64c5974..7a5f989eb73 100644
--- a/xlators/performance/readdir-ahead/src/readdir-ahead.c
+++ b/xlators/performance/readdir-ahead/src/readdir-ahead.c
@@ -31,150 +31,149 @@
#include "readdir-ahead-mem-types.h"
#include "defaults.h"
#include "readdir-ahead-messages.h"
-static int rda_fill_fd(call_frame_t *, xlator_t *, fd_t *);
+static int
+rda_fill_fd(call_frame_t *, xlator_t *, fd_t *);
static void
-rda_local_wipe (struct rda_local *local)
+rda_local_wipe(struct rda_local *local)
{
- if (local->fd)
- fd_unref (local->fd);
- if (local->xattrs)
- dict_unref (local->xattrs);
- if (local->inode)
- inode_unref (local->inode);
+ if (local->fd)
+ fd_unref(local->fd);
+ if (local->xattrs)
+ dict_unref(local->xattrs);
+ if (local->inode)
+ inode_unref(local->inode);
}
/*
* Get (or create) the fd context for storing prepopulated directory
* entries.
*/
-static struct
-rda_fd_ctx *get_rda_fd_ctx(fd_t *fd, xlator_t *this)
+static struct rda_fd_ctx *
+get_rda_fd_ctx(fd_t *fd, xlator_t *this)
{
- uint64_t val;
- struct rda_fd_ctx *ctx;
-
- LOCK(&fd->lock);
-
- if (__fd_ctx_get(fd, this, &val) < 0) {
- ctx = GF_CALLOC(1, sizeof(struct rda_fd_ctx),
- gf_rda_mt_rda_fd_ctx);
- if (!ctx)
- goto out;
-
- LOCK_INIT(&ctx->lock);
- INIT_LIST_HEAD(&ctx->entries.list);
- ctx->state = RDA_FD_NEW;
- /* ctx offset values initialized to 0 */
- ctx->xattrs = NULL;
-
- if (__fd_ctx_set(fd, this, (uint64_t) ctx) < 0) {
- GF_FREE(ctx);
- ctx = NULL;
- goto out;
- }
- } else {
- ctx = (struct rda_fd_ctx *) val;
- }
+ uint64_t val;
+ struct rda_fd_ctx *ctx;
+
+ LOCK(&fd->lock);
+
+ if (__fd_ctx_get(fd, this, &val) < 0) {
+ ctx = GF_CALLOC(1, sizeof(struct rda_fd_ctx), gf_rda_mt_rda_fd_ctx);
+ if (!ctx)
+ goto out;
+
+ LOCK_INIT(&ctx->lock);
+ INIT_LIST_HEAD(&ctx->entries.list);
+ ctx->state = RDA_FD_NEW;
+ /* ctx offset values initialized to 0 */
+ ctx->xattrs = NULL;
+
+ if (__fd_ctx_set(fd, this, (uint64_t)ctx) < 0) {
+ GF_FREE(ctx);
+ ctx = NULL;
+ goto out;
+ }
+ } else {
+ ctx = (struct rda_fd_ctx *)val;
+ }
out:
- UNLOCK(&fd->lock);
- return ctx;
+ UNLOCK(&fd->lock);
+ return ctx;
}
static rda_inode_ctx_t *
-__rda_inode_ctx_get (inode_t *inode, xlator_t *this)
+__rda_inode_ctx_get(inode_t *inode, xlator_t *this)
{
- int ret = -1;
- uint64_t ctx_uint = 0;
- rda_inode_ctx_t *ctx_p = NULL;
+ int ret = -1;
+ uint64_t ctx_uint = 0;
+ rda_inode_ctx_t *ctx_p = NULL;
- ret = __inode_ctx_get1 (inode, this, &ctx_uint);
- if (ret == 0)
- return (rda_inode_ctx_t *)ctx_uint;
+ ret = __inode_ctx_get1(inode, this, &ctx_uint);
+ if (ret == 0)
+ return (rda_inode_ctx_t *)ctx_uint;
- ctx_p = GF_CALLOC (1, sizeof (*ctx_p), gf_rda_mt_inode_ctx_t);
- if (!ctx_p)
- return NULL;
+ ctx_p = GF_CALLOC(1, sizeof(*ctx_p), gf_rda_mt_inode_ctx_t);
+ if (!ctx_p)
+ return NULL;
- GF_ATOMIC_INIT (ctx_p->generation, 0);
+ GF_ATOMIC_INIT(ctx_p->generation, 0);
- ret = __inode_ctx_set1 (inode, this, (uint64_t *)&ctx_p);
- if (ret < 0) {
- GF_FREE (ctx_p);
- return NULL;
- }
+ ret = __inode_ctx_set1(inode, this, (uint64_t *)&ctx_p);
+ if (ret < 0) {
+ GF_FREE(ctx_p);
+ return NULL;
+ }
- return ctx_p;
+ return ctx_p;
}
static int
-__rda_inode_ctx_update_iatts (inode_t *inode, xlator_t *this,
- struct iatt *stbuf_in, struct iatt *stbuf_out,
- uint64_t generation)
+__rda_inode_ctx_update_iatts(inode_t *inode, xlator_t *this,
+ struct iatt *stbuf_in, struct iatt *stbuf_out,
+ uint64_t generation)
{
- rda_inode_ctx_t *ctx_p = NULL;
- struct iatt tmp_stat = {0, };
-
- ctx_p = __rda_inode_ctx_get (inode, this);
- if (!ctx_p)
- return -1;
-
- if ((!stbuf_in) || (stbuf_in->ia_ctime == 0)) {
- /* A fop modified a file but valid stbuf is not provided.
- * Can't update iatt to reflect results of fop and hence
- * invalidate the iatt stored in dentry.
- *
- * An example of this case can be response of write request
- * that is cached in write-behind.
- */
- tmp_stat = ctx_p->statbuf;
- memset (&ctx_p->statbuf, 0,
- sizeof (ctx_p->statbuf));
- gf_uuid_copy (ctx_p->statbuf.ia_gfid,
- tmp_stat.ia_gfid);
- ctx_p->statbuf.ia_type = tmp_stat.ia_type;
- GF_ATOMIC_INC (ctx_p->generation);
+ rda_inode_ctx_t *ctx_p = NULL;
+ struct iatt tmp_stat = {
+ 0,
+ };
+
+ ctx_p = __rda_inode_ctx_get(inode, this);
+ if (!ctx_p)
+ return -1;
+
+ if ((!stbuf_in) || (stbuf_in->ia_ctime == 0)) {
+ /* A fop modified a file but valid stbuf is not provided.
+ * Can't update iatt to reflect results of fop and hence
+ * invalidate the iatt stored in dentry.
+ *
+ * An example of this case can be response of write request
+ * that is cached in write-behind.
+ */
+ tmp_stat = ctx_p->statbuf;
+ memset(&ctx_p->statbuf, 0, sizeof(ctx_p->statbuf));
+ gf_uuid_copy(ctx_p->statbuf.ia_gfid, tmp_stat.ia_gfid);
+ ctx_p->statbuf.ia_type = tmp_stat.ia_type;
+ GF_ATOMIC_INC(ctx_p->generation);
+ } else {
+ if (ctx_p->statbuf.ia_ctime) {
+ if (stbuf_in->ia_ctime < ctx_p->statbuf.ia_ctime) {
+ goto out;
+ }
+
+ if ((stbuf_in->ia_ctime == ctx_p->statbuf.ia_ctime) &&
+ (stbuf_in->ia_ctime_nsec < ctx_p->statbuf.ia_ctime_nsec)) {
+ goto out;
+ }
} else {
- if (ctx_p->statbuf.ia_ctime) {
- if (stbuf_in->ia_ctime < ctx_p->statbuf.ia_ctime) {
- goto out;
- }
-
- if ((stbuf_in->ia_ctime == ctx_p->statbuf.ia_ctime) &&
- (stbuf_in->ia_ctime_nsec
- < ctx_p->statbuf.ia_ctime_nsec)) {
- goto out;
- }
- } else {
- if (generation != GF_ATOMIC_GET (ctx_p->generation))
- goto out;
- }
-
- ctx_p->statbuf = *stbuf_in;
+ if (generation != GF_ATOMIC_GET(ctx_p->generation))
+ goto out;
}
+ ctx_p->statbuf = *stbuf_in;
+ }
+
out:
- if (stbuf_out)
- *stbuf_out = ctx_p->statbuf;
+ if (stbuf_out)
+ *stbuf_out = ctx_p->statbuf;
- return 0;
+ return 0;
}
static int
-rda_inode_ctx_update_iatts (inode_t *inode, xlator_t *this,
- struct iatt *stbuf_in, struct iatt *stbuf_out,
- uint64_t generation)
+rda_inode_ctx_update_iatts(inode_t *inode, xlator_t *this,
+ struct iatt *stbuf_in, struct iatt *stbuf_out,
+ uint64_t generation)
{
- int ret = -1;
+ int ret = -1;
- LOCK(&inode->lock);
- {
- ret = __rda_inode_ctx_update_iatts (inode, this, stbuf_in,
- stbuf_out, generation);
- }
- UNLOCK(&inode->lock);
+ LOCK(&inode->lock);
+ {
+ ret = __rda_inode_ctx_update_iatts(inode, this, stbuf_in, stbuf_out,
+ generation);
+ }
+ UNLOCK(&inode->lock);
- return ret;
+ return ret;
}
/*
@@ -183,23 +182,23 @@ rda_inode_ctx_update_iatts (inode_t *inode, xlator_t *this,
static void
rda_reset_ctx(xlator_t *this, struct rda_fd_ctx *ctx)
{
- struct rda_priv *priv = NULL;
+ struct rda_priv *priv = NULL;
- priv = this->private;
+ priv = this->private;
- ctx->state = RDA_FD_NEW;
- ctx->cur_offset = 0;
- ctx->next_offset = 0;
- ctx->op_errno = 0;
+ ctx->state = RDA_FD_NEW;
+ ctx->cur_offset = 0;
+ ctx->next_offset = 0;
+ ctx->op_errno = 0;
- gf_dirent_free(&ctx->entries);
- GF_ATOMIC_SUB (priv->rda_cache_size, ctx->cur_size);
- ctx->cur_size = 0;
+ gf_dirent_free(&ctx->entries);
+ GF_ATOMIC_SUB(priv->rda_cache_size, ctx->cur_size);
+ ctx->cur_size = 0;
- if (ctx->xattrs) {
- dict_unref (ctx->xattrs);
- ctx->xattrs = NULL;
- }
+ if (ctx->xattrs) {
+ dict_unref(ctx->xattrs);
+ ctx->xattrs = NULL;
+ }
}
/*
@@ -210,34 +209,33 @@ rda_reset_ctx(xlator_t *this, struct rda_fd_ctx *ctx)
static gf_boolean_t
rda_can_serve_readdirp(struct rda_fd_ctx *ctx, size_t request_size)
{
- if ((ctx->state & RDA_FD_EOD) ||
- (ctx->state & RDA_FD_ERROR) ||
- (!(ctx->state & RDA_FD_PLUGGED) && (ctx->cur_size > 0)) ||
- (request_size && ctx->cur_size >= request_size))
- return _gf_true;
+ if ((ctx->state & RDA_FD_EOD) || (ctx->state & RDA_FD_ERROR) ||
+ (!(ctx->state & RDA_FD_PLUGGED) && (ctx->cur_size > 0)) ||
+ (request_size && ctx->cur_size >= request_size))
+ return _gf_true;
- return _gf_false;
+ return _gf_false;
}
void
-rda_inode_ctx_get_iatt (inode_t *inode, xlator_t *this, struct iatt *attr)
+rda_inode_ctx_get_iatt(inode_t *inode, xlator_t *this, struct iatt *attr)
{
- rda_inode_ctx_t *ctx_p = NULL;
+ rda_inode_ctx_t *ctx_p = NULL;
- if (!inode || !this || !attr)
- goto out;
+ if (!inode || !this || !attr)
+ goto out;
- LOCK (&inode->lock);
- {
- ctx_p = __rda_inode_ctx_get (inode, this);
- if (ctx_p) {
- *attr = ctx_p->statbuf;
- }
+ LOCK(&inode->lock);
+ {
+ ctx_p = __rda_inode_ctx_get(inode, this);
+ if (ctx_p) {
+ *attr = ctx_p->statbuf;
}
- UNLOCK (&inode->lock);
+ }
+ UNLOCK(&inode->lock);
out:
- return;
+ return;
}
/*
@@ -245,309 +243,307 @@ out:
* buffer. ctx must be locked.
*/
static int32_t
-__rda_fill_readdirp (xlator_t *this, gf_dirent_t *entries, size_t request_size,
- struct rda_fd_ctx *ctx)
+__rda_fill_readdirp(xlator_t *this, gf_dirent_t *entries, size_t request_size,
+ struct rda_fd_ctx *ctx)
{
- gf_dirent_t *dirent, *tmp;
- size_t dirent_size, size = 0;
- int32_t count = 0;
- struct rda_priv *priv = NULL;
- struct iatt tmp_stat = {0,};
-
- priv = this->private;
-
- list_for_each_entry_safe(dirent, tmp, &ctx->entries.list, list) {
- dirent_size = gf_dirent_size(dirent->d_name);
- if (size + dirent_size > request_size)
- break;
-
- memset (&tmp_stat, 0, sizeof (tmp_stat));
-
- if (dirent->inode) {
- rda_inode_ctx_get_iatt (dirent->inode, this, &tmp_stat);
- dirent->d_stat = tmp_stat;
- }
+ gf_dirent_t *dirent, *tmp;
+ size_t dirent_size, size = 0;
+ int32_t count = 0;
+ struct rda_priv *priv = NULL;
+ struct iatt tmp_stat = {
+ 0,
+ };
+
+ priv = this->private;
+
+ list_for_each_entry_safe(dirent, tmp, &ctx->entries.list, list)
+ {
+ dirent_size = gf_dirent_size(dirent->d_name);
+ if (size + dirent_size > request_size)
+ break;
+
+ memset(&tmp_stat, 0, sizeof(tmp_stat));
+
+ if (dirent->inode) {
+ rda_inode_ctx_get_iatt(dirent->inode, this, &tmp_stat);
+ dirent->d_stat = tmp_stat;
+ }
- size += dirent_size;
- list_del_init(&dirent->list);
- ctx->cur_size -= dirent_size;
+ size += dirent_size;
+ list_del_init(&dirent->list);
+ ctx->cur_size -= dirent_size;
- GF_ATOMIC_SUB(priv->rda_cache_size, dirent_size);
+ GF_ATOMIC_SUB(priv->rda_cache_size, dirent_size);
- list_add_tail(&dirent->list, &entries->list);
- ctx->cur_offset = dirent->d_off;
- count++;
- }
+ list_add_tail(&dirent->list, &entries->list);
+ ctx->cur_offset = dirent->d_off;
+ count++;
+ }
- if (ctx->cur_size <= priv->rda_low_wmark)
- ctx->state |= RDA_FD_PLUGGED;
+ if (ctx->cur_size <= priv->rda_low_wmark)
+ ctx->state |= RDA_FD_PLUGGED;
- return count;
+ return count;
}
static int32_t
-__rda_serve_readdirp (xlator_t *this, struct rda_fd_ctx *ctx, size_t size,
- gf_dirent_t *entries, int *op_errno)
+__rda_serve_readdirp(xlator_t *this, struct rda_fd_ctx *ctx, size_t size,
+ gf_dirent_t *entries, int *op_errno)
{
- int32_t ret = 0;
+ int32_t ret = 0;
- ret = __rda_fill_readdirp (this, entries, size, ctx);
+ ret = __rda_fill_readdirp(this, entries, size, ctx);
- if (!ret && (ctx->state & RDA_FD_ERROR)) {
- ret = -1;
- ctx->state &= ~RDA_FD_ERROR;
+ if (!ret && (ctx->state & RDA_FD_ERROR)) {
+ ret = -1;
+ ctx->state &= ~RDA_FD_ERROR;
- /*
- * the preload has stopped running in the event of an error, so
- * pass all future requests along
- */
- ctx->state |= RDA_FD_BYPASS;
- }
/*
- * Use the op_errno sent by lower layers as xlators above will check
- * the op_errno for identifying whether readdir is completed or not.
+ * the preload has stopped running in the event of an error, so
+ * pass all future requests along
*/
- *op_errno = ctx->op_errno;
-
- return ret;
+ ctx->state |= RDA_FD_BYPASS;
+ }
+ /*
+ * Use the op_errno sent by lower layers as xlators above will check
+ * the op_errno for identifying whether readdir is completed or not.
+ */
+ *op_errno = ctx->op_errno;
+
+ return ret;
}
static int32_t
rda_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t off, dict_t *xdata)
+ off_t off, dict_t *xdata)
{
- struct rda_fd_ctx *ctx = NULL;
- int fill = 0;
- gf_dirent_t entries;
- int ret = 0;
- int op_errno = 0;
- gf_boolean_t serve = _gf_false;
-
- ctx = get_rda_fd_ctx(fd, this);
- if (!ctx)
- goto err;
-
- if (ctx->state & RDA_FD_BYPASS)
- goto bypass;
-
- INIT_LIST_HEAD (&entries.list);
- LOCK(&ctx->lock);
-
- /* recheck now that we have the lock */
- if (ctx->state & RDA_FD_BYPASS) {
- UNLOCK(&ctx->lock);
- goto bypass;
- }
-
- /*
- * If a new read comes in at offset 0 and the buffer has been
- * completed, reset the context and kickstart the filler again.
- */
- if (!off && (ctx->state & RDA_FD_EOD) && (ctx->cur_size == 0)) {
- rda_reset_ctx(this, ctx);
- /*
- * Unref and discard the 'list of xattrs to be fetched'
- * stored during opendir call. This is done above - inside
- * rda_reset_ctx().
- * Now, ref the xdata passed by md-cache in actual readdirp()
- * call and use that for all subsequent internal readdirp()
- * requests issued by this xlator.
- */
- ctx->xattrs = dict_ref (xdata);
- fill = 1;
- }
-
- /*
- * If a readdir occurs at an unexpected offset or we already have a
- * request pending, admit defeat and just get out of the way.
- */
- if (off != ctx->cur_offset || ctx->stub) {
- ctx->state |= RDA_FD_BYPASS;
- UNLOCK(&ctx->lock);
- goto bypass;
- }
-
- /*
- * If we haven't bypassed the preload, this means we can either serve
- * the request out of the preload or the request that enables us to do
- * so is in flight...
- */
- if (rda_can_serve_readdirp (ctx, size)) {
- ret = __rda_serve_readdirp (this, ctx, size, &entries,
- &op_errno);
- serve = _gf_true;
-
- if (op_errno == ENOENT && !((ctx->state & RDA_FD_EOD) &&
- (ctx->cur_size == 0)))
- op_errno = 0;
- } else {
- ctx->stub = fop_readdirp_stub (frame, NULL, fd, size, off,
- xdata);
- if (!ctx->stub) {
- UNLOCK(&ctx->lock);
- goto err;
- }
-
- if (!(ctx->state & RDA_FD_RUNNING)) {
- fill = 1;
- if (!ctx->xattrs)
- ctx->xattrs = dict_ref (xdata);
- ctx->state |= RDA_FD_RUNNING;
- }
+ struct rda_fd_ctx *ctx = NULL;
+ int fill = 0;
+ gf_dirent_t entries;
+ int ret = 0;
+ int op_errno = 0;
+ gf_boolean_t serve = _gf_false;
+
+ ctx = get_rda_fd_ctx(fd, this);
+ if (!ctx)
+ goto err;
+
+ if (ctx->state & RDA_FD_BYPASS)
+ goto bypass;
+
+ INIT_LIST_HEAD(&entries.list);
+ LOCK(&ctx->lock);
+
+ /* recheck now that we have the lock */
+ if (ctx->state & RDA_FD_BYPASS) {
+ UNLOCK(&ctx->lock);
+ goto bypass;
+ }
+
+ /*
+ * If a new read comes in at offset 0 and the buffer has been
+ * completed, reset the context and kickstart the filler again.
+ */
+ if (!off && (ctx->state & RDA_FD_EOD) && (ctx->cur_size == 0)) {
+ rda_reset_ctx(this, ctx);
+ /*
+ * Unref and discard the 'list of xattrs to be fetched'
+ * stored during opendir call. This is done above - inside
+ * rda_reset_ctx().
+ * Now, ref the xdata passed by md-cache in actual readdirp()
+ * call and use that for all subsequent internal readdirp()
+ * requests issued by this xlator.
+ */
+ ctx->xattrs = dict_ref(xdata);
+ fill = 1;
+ }
+
+ /*
+ * If a readdir occurs at an unexpected offset or we already have a
+ * request pending, admit defeat and just get out of the way.
+ */
+ if (off != ctx->cur_offset || ctx->stub) {
+ ctx->state |= RDA_FD_BYPASS;
+ UNLOCK(&ctx->lock);
+ goto bypass;
+ }
+
+ /*
+ * If we haven't bypassed the preload, this means we can either serve
+ * the request out of the preload or the request that enables us to do
+ * so is in flight...
+ */
+ if (rda_can_serve_readdirp(ctx, size)) {
+ ret = __rda_serve_readdirp(this, ctx, size, &entries, &op_errno);
+ serve = _gf_true;
+
+ if (op_errno == ENOENT &&
+ !((ctx->state & RDA_FD_EOD) && (ctx->cur_size == 0)))
+ op_errno = 0;
+ } else {
+ ctx->stub = fop_readdirp_stub(frame, NULL, fd, size, off, xdata);
+ if (!ctx->stub) {
+ UNLOCK(&ctx->lock);
+ goto err;
}
- UNLOCK(&ctx->lock);
-
- if (serve) {
- STACK_UNWIND_STRICT (readdirp, frame, ret, op_errno, &entries,
- xdata);
- gf_dirent_free(&entries);
+ if (!(ctx->state & RDA_FD_RUNNING)) {
+ fill = 1;
+ if (!ctx->xattrs)
+ ctx->xattrs = dict_ref(xdata);
+ ctx->state |= RDA_FD_RUNNING;
}
+ }
+
+ UNLOCK(&ctx->lock);
- if (fill)
- rda_fill_fd(frame, this, fd);
+ if (serve) {
+ STACK_UNWIND_STRICT(readdirp, frame, ret, op_errno, &entries, xdata);
+ gf_dirent_free(&entries);
+ }
- return 0;
+ if (fill)
+ rda_fill_fd(frame, this, fd);
+
+ return 0;
bypass:
- STACK_WIND(frame, default_readdirp_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdirp, fd, size, off, xdata);
- return 0;
+ STACK_WIND(frame, default_readdirp_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp, fd, size, off, xdata);
+ return 0;
err:
- STACK_UNWIND_STRICT(readdirp, frame, -1, ENOMEM, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(readdirp, frame, -1, ENOMEM, NULL, NULL);
+ return 0;
}
static int32_t
-rda_fill_fd_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
- dict_t *xdata)
+rda_fill_fd_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
+ dict_t *xdata)
{
- gf_dirent_t *dirent = NULL;
- gf_dirent_t *tmp = NULL;
- gf_dirent_t serve_entries;
- struct rda_local *local = frame->local;
- struct rda_fd_ctx *ctx = local->ctx;
- struct rda_priv *priv = this->private;
- int fill = 1;
- size_t dirent_size = 0;
- int ret = 0;
- gf_boolean_t serve = _gf_false;
- call_stub_t *stub = NULL;
-
- INIT_LIST_HEAD (&serve_entries.list);
- LOCK(&ctx->lock);
-
- /* Verify that the preload buffer is still pending on this data. */
- if (ctx->next_offset != local->offset) {
- gf_msg(this->name, GF_LOG_ERROR,
- 0, READDIR_AHEAD_MSG_OUT_OF_SEQUENCE,
- "Out of sequence directory preload.");
- ctx->state |= (RDA_FD_BYPASS|RDA_FD_ERROR);
- ctx->op_errno = EUCLEAN;
-
- goto out;
- }
-
- if (entries) {
- list_for_each_entry_safe(dirent, tmp, &entries->list, list) {
- list_del_init(&dirent->list);
- /* must preserve entry order */
- list_add_tail(&dirent->list, &ctx->entries.list);
- if (dirent->inode) {
- /* If ctxp->stat is invalidated, don't update it
- * with dirent->d_stat as we don't have
- * generation number of the inode when readdirp
- * request was initiated. So, we pass 0 for
- * generation number
- */
- rda_inode_ctx_update_iatts (dirent->inode, this,
- &dirent->d_stat,
- &dirent->d_stat, 0);
- }
-
- dirent_size = gf_dirent_size (dirent->d_name);
-
- ctx->cur_size += dirent_size;
-
- GF_ATOMIC_ADD(priv->rda_cache_size, dirent_size);
-
- ctx->next_offset = dirent->d_off;
- }
- }
-
- if (ctx->cur_size >= priv->rda_high_wmark)
- ctx->state &= ~RDA_FD_PLUGGED;
-
- if (!op_ret || op_errno == ENOENT) {
- /* we've hit eod */
- ctx->state &= ~RDA_FD_RUNNING;
- ctx->state |= RDA_FD_EOD;
- ctx->op_errno = op_errno;
- } else if (op_ret == -1) {
- /* kill the preload and pend the error */
- ctx->state &= ~RDA_FD_RUNNING;
- ctx->state |= RDA_FD_ERROR;
- ctx->op_errno = op_errno;
- }
-
- /*
- * NOTE: The strict bypass logic in readdirp() means a pending request
- * is always based on ctx->cur_offset.
- */
- if (ctx->stub &&
- rda_can_serve_readdirp (ctx, ctx->stub->args.size)) {
- ret = __rda_serve_readdirp (this, ctx, ctx->stub->args.size,
- &serve_entries, &op_errno);
- serve = _gf_true;
- stub = ctx->stub;
- ctx->stub = NULL;
- }
+ gf_dirent_t *dirent = NULL;
+ gf_dirent_t *tmp = NULL;
+ gf_dirent_t serve_entries;
+ struct rda_local *local = frame->local;
+ struct rda_fd_ctx *ctx = local->ctx;
+ struct rda_priv *priv = this->private;
+ int fill = 1;
+ size_t dirent_size = 0;
+ int ret = 0;
+ gf_boolean_t serve = _gf_false;
+ call_stub_t *stub = NULL;
+
+ INIT_LIST_HEAD(&serve_entries.list);
+ LOCK(&ctx->lock);
+
+ /* Verify that the preload buffer is still pending on this data. */
+ if (ctx->next_offset != local->offset) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, READDIR_AHEAD_MSG_OUT_OF_SEQUENCE,
+ "Out of sequence directory preload.");
+ ctx->state |= (RDA_FD_BYPASS | RDA_FD_ERROR);
+ ctx->op_errno = EUCLEAN;
+
+ goto out;
+ }
+
+ if (entries) {
+ list_for_each_entry_safe(dirent, tmp, &entries->list, list)
+ {
+ list_del_init(&dirent->list);
+ /* must preserve entry order */
+ list_add_tail(&dirent->list, &ctx->entries.list);
+ if (dirent->inode) {
+ /* If ctxp->stat is invalidated, don't update it
+ * with dirent->d_stat as we don't have
+ * generation number of the inode when readdirp
+ * request was initiated. So, we pass 0 for
+ * generation number
+ */
+ rda_inode_ctx_update_iatts(dirent->inode, this, &dirent->d_stat,
+ &dirent->d_stat, 0);
+ }
+
+ dirent_size = gf_dirent_size(dirent->d_name);
+
+ ctx->cur_size += dirent_size;
+
+ GF_ATOMIC_ADD(priv->rda_cache_size, dirent_size);
+
+ ctx->next_offset = dirent->d_off;
+ }
+ }
+
+ if (ctx->cur_size >= priv->rda_high_wmark)
+ ctx->state &= ~RDA_FD_PLUGGED;
+
+ if (!op_ret || op_errno == ENOENT) {
+ /* we've hit eod */
+ ctx->state &= ~RDA_FD_RUNNING;
+ ctx->state |= RDA_FD_EOD;
+ ctx->op_errno = op_errno;
+ } else if (op_ret == -1) {
+ /* kill the preload and pend the error */
+ ctx->state &= ~RDA_FD_RUNNING;
+ ctx->state |= RDA_FD_ERROR;
+ ctx->op_errno = op_errno;
+ }
+
+ /*
+ * NOTE: The strict bypass logic in readdirp() means a pending request
+ * is always based on ctx->cur_offset.
+ */
+ if (ctx->stub && rda_can_serve_readdirp(ctx, ctx->stub->args.size)) {
+ ret = __rda_serve_readdirp(this, ctx, ctx->stub->args.size,
+ &serve_entries, &op_errno);
+ serve = _gf_true;
+ stub = ctx->stub;
+ ctx->stub = NULL;
+ }
out:
- /*
- * If we have been marked for bypass and have no pending stub, clear the
- * run state so we stop preloading the context with entries.
- */
- if (!ctx->stub &&
- ((ctx->state & RDA_FD_BYPASS) ||
- GF_ATOMIC_GET(priv->rda_cache_size) > priv->rda_cache_limit))
- ctx->state &= ~RDA_FD_RUNNING;
-
- if (!(ctx->state & RDA_FD_RUNNING)) {
- fill = 0;
- if (ctx->xattrs) {
- /*
- * fill = 0 and hence rda_fill_fd() won't be invoked.
- * unref for ref taken in rda_fill_fd()
- */
- dict_unref (ctx->xattrs);
- ctx->xattrs = NULL;
- }
-
- rda_local_wipe (ctx->fill_frame->local);
- STACK_DESTROY(ctx->fill_frame->root);
- ctx->fill_frame = NULL;
- }
-
- if (op_errno == ENOENT && !((ctx->state & RDA_FD_EOD) &&
- (ctx->cur_size == 0)))
- op_errno = 0;
-
- UNLOCK(&ctx->lock);
-
- if (serve) {
- STACK_UNWIND_STRICT (readdirp, stub->frame, ret, op_errno,
- &serve_entries, xdata);
- gf_dirent_free (&serve_entries);
- call_stub_destroy (stub);
+ /*
+ * If we have been marked for bypass and have no pending stub, clear the
+ * run state so we stop preloading the context with entries.
+ */
+ if (!ctx->stub &&
+ ((ctx->state & RDA_FD_BYPASS) ||
+ GF_ATOMIC_GET(priv->rda_cache_size) > priv->rda_cache_limit))
+ ctx->state &= ~RDA_FD_RUNNING;
+
+ if (!(ctx->state & RDA_FD_RUNNING)) {
+ fill = 0;
+ if (ctx->xattrs) {
+ /*
+ * fill = 0 and hence rda_fill_fd() won't be invoked.
+ * unref for ref taken in rda_fill_fd()
+ */
+ dict_unref(ctx->xattrs);
+ ctx->xattrs = NULL;
}
- if (fill)
- rda_fill_fd(frame, this, local->fd);
+ rda_local_wipe(ctx->fill_frame->local);
+ STACK_DESTROY(ctx->fill_frame->root);
+ ctx->fill_frame = NULL;
+ }
- return 0;
+ if (op_errno == ENOENT &&
+ !((ctx->state & RDA_FD_EOD) && (ctx->cur_size == 0)))
+ op_errno = 0;
+
+ UNLOCK(&ctx->lock);
+
+ if (serve) {
+ STACK_UNWIND_STRICT(readdirp, stub->frame, ret, op_errno,
+ &serve_entries, xdata);
+ gf_dirent_free(&serve_entries);
+ call_stub_destroy(stub);
+ }
+
+ if (fill)
+ rda_fill_fd(frame, this, local->fd);
+
+ return 0;
}
/*
@@ -556,725 +552,736 @@ out:
static int
rda_fill_fd(call_frame_t *frame, xlator_t *this, fd_t *fd)
{
- call_frame_t *nframe = NULL;
- struct rda_local *local = NULL;
- struct rda_local *orig_local = frame->local;
- struct rda_fd_ctx *ctx;
- off_t offset;
- struct rda_priv *priv = this->private;
-
- ctx = get_rda_fd_ctx(fd, this);
- if (!ctx)
- goto err;
-
- LOCK(&ctx->lock);
-
- if (ctx->state & RDA_FD_NEW) {
- ctx->state &= ~RDA_FD_NEW;
- ctx->state |= RDA_FD_RUNNING;
- if (priv->rda_low_wmark)
- ctx->state |= RDA_FD_PLUGGED;
- }
-
- offset = ctx->next_offset;
-
- if (!ctx->fill_frame) {
- nframe = copy_frame(frame);
- if (!nframe) {
- UNLOCK(&ctx->lock);
- goto err;
- }
-
- local = mem_get0(this->local_pool);
- if (!local) {
- UNLOCK(&ctx->lock);
- goto err;
- }
-
- local->ctx = ctx;
- local->fd = fd_ref (fd);
- nframe->local = local;
-
- ctx->fill_frame = nframe;
-
- if (!ctx->xattrs && orig_local && orig_local->xattrs) {
- /* when this function is invoked by rda_opendir_cbk */
- ctx->xattrs = dict_ref(orig_local->xattrs);
- }
- } else {
- nframe = ctx->fill_frame;
- local = nframe->local;
- }
-
- local->offset = offset;
-
- UNLOCK(&ctx->lock);
-
- STACK_WIND(nframe, rda_fill_fd_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdirp, fd,
- priv->rda_req_size, offset, ctx->xattrs);
-
- return 0;
+ call_frame_t *nframe = NULL;
+ struct rda_local *local = NULL;
+ struct rda_local *orig_local = frame->local;
+ struct rda_fd_ctx *ctx;
+ off_t offset;
+ struct rda_priv *priv = this->private;
+
+ ctx = get_rda_fd_ctx(fd, this);
+ if (!ctx)
+ goto err;
+
+ LOCK(&ctx->lock);
+
+ if (ctx->state & RDA_FD_NEW) {
+ ctx->state &= ~RDA_FD_NEW;
+ ctx->state |= RDA_FD_RUNNING;
+ if (priv->rda_low_wmark)
+ ctx->state |= RDA_FD_PLUGGED;
+ }
+
+ offset = ctx->next_offset;
+
+ if (!ctx->fill_frame) {
+ nframe = copy_frame(frame);
+ if (!nframe) {
+ UNLOCK(&ctx->lock);
+ goto err;
+ }
-err:
- if (nframe) {
- rda_local_wipe (nframe->local);
- FRAME_DESTROY(nframe);
+ local = mem_get0(this->local_pool);
+ if (!local) {
+ UNLOCK(&ctx->lock);
+ goto err;
}
- return -1;
+ local->ctx = ctx;
+ local->fd = fd_ref(fd);
+ nframe->local = local;
+
+ ctx->fill_frame = nframe;
+
+ if (!ctx->xattrs && orig_local && orig_local->xattrs) {
+ /* when this function is invoked by rda_opendir_cbk */
+ ctx->xattrs = dict_ref(orig_local->xattrs);
+ }
+ } else {
+ nframe = ctx->fill_frame;
+ local = nframe->local;
+ }
+
+ local->offset = offset;
+
+ UNLOCK(&ctx->lock);
+
+ STACK_WIND(nframe, rda_fill_fd_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp, fd, priv->rda_req_size,
+ offset, ctx->xattrs);
+
+ return 0;
+
+err:
+ if (nframe) {
+ rda_local_wipe(nframe->local);
+ FRAME_DESTROY(nframe);
+ }
+
+ return -1;
}
static int32_t
rda_opendir_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
+ int32_t op_ret, int32_t op_errno, fd_t *fd, dict_t *xdata)
{
- if (!op_ret)
- rda_fill_fd(frame, this, fd);
+ if (!op_ret)
+ rda_fill_fd(frame, this, fd);
- RDA_STACK_UNWIND(opendir, frame, op_ret, op_errno, fd, xdata);
- return 0;
+ RDA_STACK_UNWIND(opendir, frame, op_ret, op_errno, fd, xdata);
+ return 0;
}
static int32_t
rda_opendir(call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd,
- dict_t *xdata)
+ dict_t *xdata)
{
- int op_errno = 0;
- struct rda_local *local = NULL;
- dict_t *xdata_from_req = NULL;
-
- if (xdata) {
- xdata_from_req = dict_new();
- if (!xdata_from_req) {
- op_errno = ENOMEM;
- goto unwind;
- }
-
- local = mem_get0(this->local_pool);
- if (!local) {
- dict_unref(xdata_from_req);
- op_errno = ENOMEM;
- goto unwind;
- }
-
- /*
- * Retrieve list of keys set by md-cache xlator and store it
- * in local to be consumed in rda_opendir_cbk
- */
- local->xattrs = dict_copy_with_ref (xdata, NULL);
- frame->local = local;
+ int op_errno = 0;
+ struct rda_local *local = NULL;
+ dict_t *xdata_from_req = NULL;
+
+ if (xdata) {
+ xdata_from_req = dict_new();
+ if (!xdata_from_req) {
+ op_errno = ENOMEM;
+ goto unwind;
}
- STACK_WIND(frame, rda_opendir_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->opendir, loc, fd, xdata);
- return 0;
+ local = mem_get0(this->local_pool);
+ if (!local) {
+ dict_unref(xdata_from_req);
+ op_errno = ENOMEM;
+ goto unwind;
+ }
+
+ /*
+ * Retrieve list of keys set by md-cache xlator and store it
+ * in local to be consumed in rda_opendir_cbk
+ */
+ local->xattrs = dict_copy_with_ref(xdata, NULL);
+ frame->local = local;
+ }
+
+ STACK_WIND(frame, rda_opendir_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->opendir, loc, fd, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT(opendir, frame, -1, op_errno, fd, xdata);
- return 0;
+ STACK_UNWIND_STRICT(opendir, frame, -1, op_errno, fd, xdata);
+ return 0;
}
static int32_t
-rda_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, dict_t *xdata)
+rda_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, dict_t *xdata)
{
- struct rda_local *local = NULL;
- struct iatt postbuf_out = {0,};
+ struct rda_local *local = NULL;
+ struct iatt postbuf_out = {
+ 0,
+ };
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, postbuf, &postbuf_out,
- local->generation);
+ local = frame->local;
+ rda_inode_ctx_update_iatts(local->inode, this, postbuf, &postbuf_out,
+ local->generation);
- if (postbuf_out.ia_ctime == 0)
- memset (&postbuf_out, 0, sizeof (postbuf_out));
+ if (postbuf_out.ia_ctime == 0)
+ memset(&postbuf_out, 0, sizeof(postbuf_out));
unwind:
- RDA_STACK_UNWIND (writev, frame, op_ret, op_errno, prebuf,
- &postbuf_out, xdata);
- return 0;
+ RDA_STACK_UNWIND(writev, frame, op_ret, op_errno, prebuf, &postbuf_out,
+ xdata);
+ return 0;
}
static int32_t
-rda_writev (call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iovec *vector, int32_t count, off_t off, uint32_t flags,
- struct iobref *iobref, dict_t *xdata)
+rda_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
+ int32_t count, off_t off, uint32_t flags, struct iobref *iobref,
+ dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (writev, frame, this, fd->inode, xdata, fd,
- vector, count, off, flags, iobref);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(writev, frame, this, fd->inode, xdata, fd,
+ vector, count, off, flags, iobref);
+ return 0;
}
static int32_t
-rda_fallocate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+rda_fallocate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- struct rda_local *local = NULL;
- struct iatt postbuf_out = {0,};
+ struct rda_local *local = NULL;
+ struct iatt postbuf_out = {
+ 0,
+ };
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, postbuf, &postbuf_out,
- local->generation);
+ local = frame->local;
+ rda_inode_ctx_update_iatts(local->inode, this, postbuf, &postbuf_out,
+ local->generation);
- if (postbuf_out.ia_ctime == 0)
- memset (&postbuf_out, 0, sizeof (postbuf_out));
+ if (postbuf_out.ia_ctime == 0)
+ memset(&postbuf_out, 0, sizeof(postbuf_out));
unwind:
- RDA_STACK_UNWIND (fallocate, frame, op_ret, op_errno, prebuf,
- &postbuf_out, xdata);
- return 0;
+ RDA_STACK_UNWIND(fallocate, frame, op_ret, op_errno, prebuf, &postbuf_out,
+ xdata);
+ return 0;
}
static int32_t
-rda_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t keep_size,
- off_t offset, size_t len, dict_t *xdata)
+rda_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t keep_size,
+ off_t offset, size_t len, dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (fallocate, frame, this, fd->inode, xdata,
- fd, keep_size, offset, len);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(fallocate, frame, this, fd->inode, xdata, fd,
+ keep_size, offset, len);
+ return 0;
}
static int32_t
-rda_zerofill_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+rda_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- struct rda_local *local = NULL;
- struct iatt postbuf_out = {0,};
+ struct rda_local *local = NULL;
+ struct iatt postbuf_out = {
+ 0,
+ };
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, postbuf, &postbuf_out,
- local->generation);
+ local = frame->local;
+ rda_inode_ctx_update_iatts(local->inode, this, postbuf, &postbuf_out,
+ local->generation);
- if (postbuf_out.ia_ctime == 0)
- memset (&postbuf_out, 0, sizeof (postbuf_out));
+ if (postbuf_out.ia_ctime == 0)
+ memset(&postbuf_out, 0, sizeof(postbuf_out));
unwind:
- RDA_STACK_UNWIND (zerofill, frame, op_ret, op_errno, prebuf,
- &postbuf_out, xdata);
- return 0;
+ RDA_STACK_UNWIND(zerofill, frame, op_ret, op_errno, prebuf, &postbuf_out,
+ xdata);
+ return 0;
}
static int32_t
-rda_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- off_t len, dict_t *xdata)
+rda_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ off_t len, dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (zerofill, frame, this, fd->inode, xdata,
- fd, offset, len);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(zerofill, frame, this, fd->inode, xdata, fd,
+ offset, len);
+ return 0;
}
static int32_t
-rda_discard_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+rda_discard_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- struct rda_local *local = NULL;
- struct iatt postbuf_out = {0,};
+ struct rda_local *local = NULL;
+ struct iatt postbuf_out = {
+ 0,
+ };
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, postbuf, &postbuf_out,
- local->generation);
+ local = frame->local;
+ rda_inode_ctx_update_iatts(local->inode, this, postbuf, &postbuf_out,
+ local->generation);
- if (postbuf_out.ia_ctime == 0)
- memset (&postbuf_out, 0, sizeof (postbuf_out));
+ if (postbuf_out.ia_ctime == 0)
+ memset(&postbuf_out, 0, sizeof(postbuf_out));
unwind:
- RDA_STACK_UNWIND (discard, frame, op_ret, op_errno, prebuf,
- &postbuf_out, xdata);
- return 0;
+ RDA_STACK_UNWIND(discard, frame, op_ret, op_errno, prebuf, &postbuf_out,
+ xdata);
+ return 0;
}
static int32_t
-rda_discard (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- size_t len, dict_t *xdata)
+rda_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ size_t len, dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (discard, frame, this, fd->inode, xdata,
- fd, offset, len);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(discard, frame, this, fd->inode, xdata, fd,
+ offset, len);
+ return 0;
}
static int32_t
-rda_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+rda_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- struct rda_local *local = NULL;
- struct iatt postbuf_out = {0,};
+ struct rda_local *local = NULL;
+ struct iatt postbuf_out = {
+ 0,
+ };
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, postbuf, &postbuf_out,
- local->generation);
+ local = frame->local;
+ rda_inode_ctx_update_iatts(local->inode, this, postbuf, &postbuf_out,
+ local->generation);
- if (postbuf_out.ia_ctime == 0)
- memset (&postbuf_out, 0, sizeof (postbuf_out));
+ if (postbuf_out.ia_ctime == 0)
+ memset(&postbuf_out, 0, sizeof(postbuf_out));
unwind:
- RDA_STACK_UNWIND (ftruncate, frame, op_ret, op_errno, prebuf,
- &postbuf_out, xdata);
- return 0;
+ RDA_STACK_UNWIND(ftruncate, frame, op_ret, op_errno, prebuf, &postbuf_out,
+ xdata);
+ return 0;
}
static int32_t
-rda_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- dict_t *xdata)
+rda_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (ftruncate, frame, this, fd->inode, xdata,
- fd, offset);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(ftruncate, frame, this, fd->inode, xdata, fd,
+ offset);
+ return 0;
}
static int32_t
-rda_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+rda_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- struct rda_local *local = NULL;
- struct iatt postbuf_out = {0,};
+ struct rda_local *local = NULL;
+ struct iatt postbuf_out = {
+ 0,
+ };
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, postbuf, &postbuf_out,
- local->generation);
- if (postbuf_out.ia_ctime == 0)
- memset (&postbuf_out, 0, sizeof (postbuf_out));
+ local = frame->local;
+ rda_inode_ctx_update_iatts(local->inode, this, postbuf, &postbuf_out,
+ local->generation);
+ if (postbuf_out.ia_ctime == 0)
+ memset(&postbuf_out, 0, sizeof(postbuf_out));
unwind:
- RDA_STACK_UNWIND (ftruncate, frame, op_ret, op_errno, prebuf,
- &postbuf_out, xdata);
- return 0;
+ RDA_STACK_UNWIND(ftruncate, frame, op_ret, op_errno, prebuf, &postbuf_out,
+ xdata);
+ return 0;
}
static int32_t
-rda_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
- dict_t *xdata)
+rda_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
+ dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (truncate, frame, this, loc->inode, xdata,
- loc, offset);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(truncate, frame, this, loc->inode, xdata, loc,
+ offset);
+ return 0;
}
static int32_t
-rda_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+rda_setxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- struct rda_local *local = NULL;
+ struct rda_local *local = NULL;
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
+ local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, NULL, NULL,
- local->generation);
+ rda_inode_ctx_update_iatts(local->inode, this, NULL, NULL,
+ local->generation);
unwind:
- RDA_STACK_UNWIND (setxattr, frame, op_ret, op_errno, xdata);
- return 0;
+ RDA_STACK_UNWIND(setxattr, frame, op_ret, op_errno, xdata);
+ return 0;
}
static int32_t
-rda_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
- int32_t flags, dict_t *xdata)
+rda_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
+ int32_t flags, dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (setxattr, frame, this, loc->inode,
- xdata, loc, dict, flags);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(setxattr, frame, this, loc->inode, xdata, loc,
+ dict, flags);
+ return 0;
}
static int32_t
-rda_fsetxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+rda_fsetxattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- struct rda_local *local = NULL;
+ struct rda_local *local = NULL;
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
+ local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, NULL, NULL,
- local->generation);
+ rda_inode_ctx_update_iatts(local->inode, this, NULL, NULL,
+ local->generation);
unwind:
- RDA_STACK_UNWIND (fsetxattr, frame, op_ret, op_errno, xdata);
- return 0;
+ RDA_STACK_UNWIND(fsetxattr, frame, op_ret, op_errno, xdata);
+ return 0;
}
static int32_t
-rda_fsetxattr (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
- int32_t flags, dict_t *xdata)
+rda_fsetxattr(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *dict,
+ int32_t flags, dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (fsetxattr, frame, this, fd->inode,
- xdata, fd, dict, flags);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(fsetxattr, frame, this, fd->inode, xdata, fd,
+ dict, flags);
+ return 0;
}
static int32_t
-rda_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *statpre,
- struct iatt *statpost, dict_t *xdata)
+rda_setattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *statpre,
+ struct iatt *statpost, dict_t *xdata)
{
- struct rda_local *local = NULL;
- struct iatt postbuf_out = {0,};
+ struct rda_local *local = NULL;
+ struct iatt postbuf_out = {
+ 0,
+ };
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, statpost, &postbuf_out,
- local->generation);
- if (postbuf_out.ia_ctime == 0)
- memset (&postbuf_out, 0, sizeof (postbuf_out));
+ local = frame->local;
+ rda_inode_ctx_update_iatts(local->inode, this, statpost, &postbuf_out,
+ local->generation);
+ if (postbuf_out.ia_ctime == 0)
+ memset(&postbuf_out, 0, sizeof(postbuf_out));
unwind:
- RDA_STACK_UNWIND (setattr, frame, op_ret, op_errno, statpre,
- &postbuf_out, xdata);
- return 0;
+ RDA_STACK_UNWIND(setattr, frame, op_ret, op_errno, statpre, &postbuf_out,
+ xdata);
+ return 0;
}
static int32_t
-rda_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- struct iatt *stbuf, int32_t valid, dict_t *xdata)
+rda_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf,
+ int32_t valid, dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (setattr, frame, this, loc->inode, xdata,
- loc, stbuf, valid);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(setattr, frame, this, loc->inode, xdata, loc,
+ stbuf, valid);
+ return 0;
}
static int32_t
-rda_fsetattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *statpre,
- struct iatt *statpost, dict_t *xdata)
+rda_fsetattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *statpre,
+ struct iatt *statpost, dict_t *xdata)
{
- struct rda_local *local = NULL;
- struct iatt postbuf_out = {0,};
+ struct rda_local *local = NULL;
+ struct iatt postbuf_out = {
+ 0,
+ };
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, statpost, &postbuf_out,
- local->generation);
- if (postbuf_out.ia_ctime == 0)
- memset (&postbuf_out, 0, sizeof (postbuf_out));
+ local = frame->local;
+ rda_inode_ctx_update_iatts(local->inode, this, statpost, &postbuf_out,
+ local->generation);
+ if (postbuf_out.ia_ctime == 0)
+ memset(&postbuf_out, 0, sizeof(postbuf_out));
unwind:
- RDA_STACK_UNWIND (fsetattr, frame, op_ret, op_errno, statpre,
- &postbuf_out, xdata);
- return 0;
+ RDA_STACK_UNWIND(fsetattr, frame, op_ret, op_errno, statpre, &postbuf_out,
+ xdata);
+ return 0;
}
static int32_t
-rda_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,
- int32_t valid, dict_t *xdata)
+rda_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,
+ int32_t valid, dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (fsetattr, frame, this, fd->inode, xdata,
- fd, stbuf, valid);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(fsetattr, frame, this, fd->inode, xdata, fd,
+ stbuf, valid);
+ return 0;
}
static int32_t
-rda_removexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+rda_removexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- struct rda_local *local = NULL;
+ struct rda_local *local = NULL;
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
+ local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, NULL, NULL,
- local->generation);
+ rda_inode_ctx_update_iatts(local->inode, this, NULL, NULL,
+ local->generation);
unwind:
- RDA_STACK_UNWIND (removexattr, frame, op_ret, op_errno, xdata);
- return 0;
+ RDA_STACK_UNWIND(removexattr, frame, op_ret, op_errno, xdata);
+ return 0;
}
static int32_t
-rda_removexattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- const char *name, dict_t *xdata)
+rda_removexattr(call_frame_t *frame, xlator_t *this, loc_t *loc,
+ const char *name, dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (removexattr, frame, this, loc->inode,
- xdata, loc, name);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(removexattr, frame, this, loc->inode, xdata,
+ loc, name);
+ return 0;
}
static int32_t
-rda_fremovexattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+rda_fremovexattr_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- struct rda_local *local = NULL;
+ struct rda_local *local = NULL;
- if (op_ret < 0)
- goto unwind;
+ if (op_ret < 0)
+ goto unwind;
- local = frame->local;
+ local = frame->local;
- rda_inode_ctx_update_iatts (local->inode, this, NULL, NULL,
- local->generation);
+ rda_inode_ctx_update_iatts(local->inode, this, NULL, NULL,
+ local->generation);
unwind:
- RDA_STACK_UNWIND (fremovexattr, frame, op_ret, op_errno, xdata);
- return 0;
+ RDA_STACK_UNWIND(fremovexattr, frame, op_ret, op_errno, xdata);
+ return 0;
}
static int32_t
-rda_fremovexattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
- const char *name, dict_t *xdata)
+rda_fremovexattr(call_frame_t *frame, xlator_t *this, fd_t *fd,
+ const char *name, dict_t *xdata)
{
- RDA_COMMON_MODIFICATION_FOP (fremovexattr, frame, this, fd->inode,
- xdata, fd, name);
- return 0;
+ RDA_COMMON_MODIFICATION_FOP(fremovexattr, frame, this, fd->inode, xdata, fd,
+ name);
+ return 0;
}
static int32_t
rda_releasedir(xlator_t *this, fd_t *fd)
{
- uint64_t val;
- struct rda_fd_ctx *ctx;
+ uint64_t val;
+ struct rda_fd_ctx *ctx;
- if (fd_ctx_del(fd, this, &val) < 0)
- return -1;
+ if (fd_ctx_del(fd, this, &val) < 0)
+ return -1;
- ctx = (struct rda_fd_ctx *) val;
- if (!ctx)
- return 0;
+ ctx = (struct rda_fd_ctx *)val;
+ if (!ctx)
+ return 0;
- rda_reset_ctx(this, ctx);
+ rda_reset_ctx(this, ctx);
- if (ctx->fill_frame)
- STACK_DESTROY(ctx->fill_frame->root);
+ if (ctx->fill_frame)
+ STACK_DESTROY(ctx->fill_frame->root);
- if (ctx->stub)
- gf_msg(this->name, GF_LOG_ERROR, 0,
- READDIR_AHEAD_MSG_DIR_RELEASE_PENDING_STUB,
- "released a directory with a pending stub");
+ if (ctx->stub)
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ READDIR_AHEAD_MSG_DIR_RELEASE_PENDING_STUB,
+ "released a directory with a pending stub");
- GF_FREE(ctx);
- return 0;
+ GF_FREE(ctx);
+ return 0;
}
static int
-rda_forget (xlator_t *this, inode_t *inode)
+rda_forget(xlator_t *this, inode_t *inode)
{
- uint64_t ctx_uint = 0;
- rda_inode_ctx_t *ctx = NULL;
+ uint64_t ctx_uint = 0;
+ rda_inode_ctx_t *ctx = NULL;
- inode_ctx_del1 (inode, this, &ctx_uint);
- if (!ctx_uint)
- return 0;
+ inode_ctx_del1(inode, this, &ctx_uint);
+ if (!ctx_uint)
+ return 0;
- ctx = (rda_inode_ctx_t *)ctx_uint;
+ ctx = (rda_inode_ctx_t *)ctx_uint;
- GF_FREE (ctx);
+ GF_FREE(ctx);
- return 0;
+ return 0;
}
int32_t
mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- if (!this)
- goto out;
+ if (!this)
+ goto out;
- ret = xlator_mem_acct_init(this, gf_rda_mt_end + 1);
+ ret = xlator_mem_acct_init(this, gf_rda_mt_end + 1);
- if (ret != 0)
- gf_msg(this->name, GF_LOG_ERROR, ENOMEM,
- READDIR_AHEAD_MSG_NO_MEMORY, "Memory accounting init"
- "failed");
+ if (ret != 0)
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, READDIR_AHEAD_MSG_NO_MEMORY,
+ "Memory accounting init"
+ "failed");
out:
- return ret;
+ return ret;
}
int
reconfigure(xlator_t *this, dict_t *options)
{
- struct rda_priv *priv = this->private;
-
- GF_OPTION_RECONF("rda-request-size", priv->rda_req_size, options,
- size_uint64, err);
- GF_OPTION_RECONF("rda-low-wmark", priv->rda_low_wmark, options,
- size_uint64, err);
- GF_OPTION_RECONF("rda-high-wmark", priv->rda_high_wmark, options,
- size_uint64, err);
- GF_OPTION_RECONF("rda-cache-limit", priv->rda_cache_limit, options,
- size_uint64, err);
- GF_OPTION_RECONF("parallel-readdir", priv->parallel_readdir, options,
- bool, err);
- GF_OPTION_RECONF ("pass-through", this->pass_through, options, bool,
- err);
-
- return 0;
+ struct rda_priv *priv = this->private;
+
+ GF_OPTION_RECONF("rda-request-size", priv->rda_req_size, options,
+ size_uint64, err);
+ GF_OPTION_RECONF("rda-low-wmark", priv->rda_low_wmark, options, size_uint64,
+ err);
+ GF_OPTION_RECONF("rda-high-wmark", priv->rda_high_wmark, options,
+ size_uint64, err);
+ GF_OPTION_RECONF("rda-cache-limit", priv->rda_cache_limit, options,
+ size_uint64, err);
+ GF_OPTION_RECONF("parallel-readdir", priv->parallel_readdir, options, bool,
+ err);
+ GF_OPTION_RECONF("pass-through", this->pass_through, options, bool, err);
+
+ return 0;
err:
- return -1;
+ return -1;
}
int
init(xlator_t *this)
{
- struct rda_priv *priv = NULL;
+ struct rda_priv *priv = NULL;
- GF_VALIDATE_OR_GOTO("readdir-ahead", this, err);
+ GF_VALIDATE_OR_GOTO("readdir-ahead", this, err);
- if (!this->children || this->children->next) {
- gf_msg(this->name, GF_LOG_ERROR, 0,
- READDIR_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED,
- "FATAL: readdir-ahead not configured with exactly one"
- " child");
- goto err;
- }
+ if (!this->children || this->children->next) {
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ READDIR_AHEAD_MSG_XLATOR_CHILD_MISCONFIGURED,
+ "FATAL: readdir-ahead not configured with exactly one"
+ " child");
+ goto err;
+ }
- if (!this->parents) {
- gf_msg(this->name, GF_LOG_WARNING, 0,
- READDIR_AHEAD_MSG_VOL_MISCONFIGURED,
- "dangling volume. check volfile ");
- }
+ if (!this->parents) {
+ gf_msg(this->name, GF_LOG_WARNING, 0,
+ READDIR_AHEAD_MSG_VOL_MISCONFIGURED,
+ "dangling volume. check volfile ");
+ }
- priv = GF_CALLOC(1, sizeof(struct rda_priv), gf_rda_mt_rda_priv);
- if (!priv)
- goto err;
- this->private = priv;
+ priv = GF_CALLOC(1, sizeof(struct rda_priv), gf_rda_mt_rda_priv);
+ if (!priv)
+ goto err;
+ this->private = priv;
- GF_ATOMIC_INIT (priv->rda_cache_size, 0);
+ GF_ATOMIC_INIT(priv->rda_cache_size, 0);
- this->local_pool = mem_pool_new(struct rda_local, 32);
- if (!this->local_pool)
- goto err;
+ this->local_pool = mem_pool_new(struct rda_local, 32);
+ if (!this->local_pool)
+ goto err;
- GF_OPTION_INIT("rda-request-size", priv->rda_req_size, size_uint64,
- err);
- GF_OPTION_INIT("rda-low-wmark", priv->rda_low_wmark, size_uint64, err);
- GF_OPTION_INIT("rda-high-wmark", priv->rda_high_wmark, size_uint64,
- err);
- GF_OPTION_INIT("rda-cache-limit", priv->rda_cache_limit, size_uint64,
- err);
- GF_OPTION_INIT("parallel-readdir", priv->parallel_readdir, bool,
- err);
- GF_OPTION_INIT ("pass-through", this->pass_through, bool, err);
+ GF_OPTION_INIT("rda-request-size", priv->rda_req_size, size_uint64, err);
+ GF_OPTION_INIT("rda-low-wmark", priv->rda_low_wmark, size_uint64, err);
+ GF_OPTION_INIT("rda-high-wmark", priv->rda_high_wmark, size_uint64, err);
+ GF_OPTION_INIT("rda-cache-limit", priv->rda_cache_limit, size_uint64, err);
+ GF_OPTION_INIT("parallel-readdir", priv->parallel_readdir, bool, err);
+ GF_OPTION_INIT("pass-through", this->pass_through, bool, err);
- return 0;
+ return 0;
err:
- if (this->local_pool)
- mem_pool_destroy(this->local_pool);
- if (priv)
- GF_FREE(priv);
+ if (this->local_pool)
+ mem_pool_destroy(this->local_pool);
+ if (priv)
+ GF_FREE(priv);
- return -1;
+ return -1;
}
-
void
fini(xlator_t *this)
{
- GF_VALIDATE_OR_GOTO ("readdir-ahead", this, out);
+ GF_VALIDATE_OR_GOTO("readdir-ahead", this, out);
- GF_FREE(this->private);
+ GF_FREE(this->private);
out:
- return;
+ return;
}
struct xlator_fops fops = {
- .opendir = rda_opendir,
- .readdirp = rda_readdirp,
- /* inode write */
- /* TODO: invalidate a dentry's stats if its pointing to a directory
- * when entry operations happen in that directory
- */
- .writev = rda_writev,
- .truncate = rda_truncate,
- .ftruncate = rda_ftruncate,
- .fallocate = rda_fallocate,
- .discard = rda_discard,
- .zerofill = rda_zerofill,
- /* metadata write */
- .setxattr = rda_setxattr,
- .fsetxattr = rda_fsetxattr,
- .setattr = rda_setattr,
- .fsetattr = rda_fsetattr,
- .removexattr = rda_removexattr,
- .fremovexattr = rda_fremovexattr,
+ .opendir = rda_opendir,
+ .readdirp = rda_readdirp,
+ /* inode write */
+ /* TODO: invalidate a dentry's stats if its pointing to a directory
+ * when entry operations happen in that directory
+ */
+ .writev = rda_writev,
+ .truncate = rda_truncate,
+ .ftruncate = rda_ftruncate,
+ .fallocate = rda_fallocate,
+ .discard = rda_discard,
+ .zerofill = rda_zerofill,
+ /* metadata write */
+ .setxattr = rda_setxattr,
+ .fsetxattr = rda_fsetxattr,
+ .setattr = rda_setattr,
+ .fsetattr = rda_fsetattr,
+ .removexattr = rda_removexattr,
+ .fremovexattr = rda_fremovexattr,
};
struct xlator_cbks cbks = {
- .releasedir = rda_releasedir,
- .forget = rda_forget,
+ .releasedir = rda_releasedir,
+ .forget = rda_forget,
};
struct volume_options options[] = {
- { .key = {"rda-request-size"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 4096,
- .max = 131072,
- .default_value = "131072",
- .description = "size of buffer in readdirp calls initiated by "
- "readdir-ahead ",
- },
- { .key = {"rda-low-wmark"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 0,
- .max = 10 * GF_UNIT_MB,
- .default_value = "4096",
- .description = "the value under which readdir-ahead plugs",
- },
- { .key = {"rda-high-wmark"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 0,
- .max = 100 * GF_UNIT_MB,
- .default_value = "128KB",
- .description = "the value over which readdir-ahead unplugs",
- },
- { .key = {"rda-cache-limit"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 0,
- .max = INFINITY,
- .default_value = "10MB",
- .description = "maximum size of cache consumed by readdir-ahead "
- "xlator. This value is global and total memory "
- "consumption by readdir-ahead is capped by this "
- "value, irrespective of the number/size of "
- "directories cached",
- },
- { .key = {"parallel-readdir"},
- .type = GF_OPTION_TYPE_BOOL,
- .op_version = {GD_OP_VERSION_3_10_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
- .default_value = "off",
- .description = "If this option is enabled, the readdir operation "
- "is performed in parallel on all the bricks, thus "
- "improving the performance of readdir. Note that "
- "the performance improvement is higher in large "
- "clusters"
- },
- { .key = {"pass-through"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "false",
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"readdir-ahead"},
- .description = "Enable/Disable readdir ahead translator"
- },
- { .key = {NULL} },
+ {
+ .key = {"rda-request-size"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 4096,
+ .max = 131072,
+ .default_value = "131072",
+ .description = "size of buffer in readdirp calls initiated by "
+ "readdir-ahead ",
+ },
+ {
+ .key = {"rda-low-wmark"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 0,
+ .max = 10 * GF_UNIT_MB,
+ .default_value = "4096",
+ .description = "the value under which readdir-ahead plugs",
+ },
+ {
+ .key = {"rda-high-wmark"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 0,
+ .max = 100 * GF_UNIT_MB,
+ .default_value = "128KB",
+ .description = "the value over which readdir-ahead unplugs",
+ },
+ {
+ .key = {"rda-cache-limit"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 0,
+ .max = INFINITY,
+ .default_value = "10MB",
+ .description = "maximum size of cache consumed by readdir-ahead "
+ "xlator. This value is global and total memory "
+ "consumption by readdir-ahead is capped by this "
+ "value, irrespective of the number/size of "
+ "directories cached",
+ },
+ {.key = {"parallel-readdir"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .op_version = {GD_OP_VERSION_3_10_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_CLIENT_OPT | OPT_FLAG_DOC,
+ .default_value = "off",
+ .description = "If this option is enabled, the readdir operation "
+ "is performed in parallel on all the bricks, thus "
+ "improving the performance of readdir. Note that "
+ "the performance improvement is higher in large "
+ "clusters"},
+ {.key = {"pass-through"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "false",
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"readdir-ahead"},
+ .description = "Enable/Disable readdir ahead translator"},
+ {.key = {NULL}},
};
-
diff --git a/xlators/performance/symlink-cache/src/symlink-cache.c b/xlators/performance/symlink-cache/src/symlink-cache.c
index 596b4c53b7b..2a686dcb87e 100644
--- a/xlators/performance/symlink-cache/src/symlink-cache.c
+++ b/xlators/performance/symlink-cache/src/symlink-cache.c
@@ -8,7 +8,6 @@
cases as published by the Free Software Foundation.
*/
-
#include "glusterfs.h"
#include "logging.h"
#include "dict.h"
@@ -20,383 +19,340 @@
#include "symlink-cache-messages.h"
struct symlink_cache {
- time_t ctime;
- char *readlink;
+ time_t ctime;
+ char *readlink;
};
-
static int
-symlink_inode_ctx_get (inode_t *inode, xlator_t *this, void **ctx)
+symlink_inode_ctx_get(inode_t *inode, xlator_t *this, void **ctx)
{
- int ret = 0;
- uint64_t tmp_ctx = 0;
- ret = inode_ctx_get (inode, this, &tmp_ctx);
- if (-1 == ret)
- gf_msg (this->name, GF_LOG_ERROR, EINVAL,
- SYMLINK_CACHE_MSG_DICT_GET_FAILED, "dict get failed");
- else
- *ctx = (void *)(long)tmp_ctx;
-
- return 0;
+ int ret = 0;
+ uint64_t tmp_ctx = 0;
+ ret = inode_ctx_get(inode, this, &tmp_ctx);
+ if (-1 == ret)
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL,
+ SYMLINK_CACHE_MSG_DICT_GET_FAILED, "dict get failed");
+ else
+ *ctx = (void *)(long)tmp_ctx;
+
+ return 0;
}
-
static int
-symlink_inode_ctx_set (inode_t *inode, xlator_t *this, void *ctx)
+symlink_inode_ctx_set(inode_t *inode, xlator_t *this, void *ctx)
{
- int ret = 0;
- ret = inode_ctx_put (inode, this, (uint64_t)(long) ctx);
- if (-1 == ret)
- gf_msg (this->name, GF_LOG_ERROR, EINVAL,
- SYMLINK_CACHE_MSG_DICT_SET_FAILED, "dict set failed");
+ int ret = 0;
+ ret = inode_ctx_put(inode, this, (uint64_t)(long)ctx);
+ if (-1 == ret)
+ gf_msg(this->name, GF_LOG_ERROR, EINVAL,
+ SYMLINK_CACHE_MSG_DICT_SET_FAILED, "dict set failed");
- return 0;
+ return 0;
}
-
int
-sc_cache_update (xlator_t *this, inode_t *inode, const char *link)
+sc_cache_update(xlator_t *this, inode_t *inode, const char *link)
{
- struct symlink_cache *sc = NULL;
+ struct symlink_cache *sc = NULL;
- symlink_inode_ctx_get (inode, this, VOID(&sc));
- if (!sc)
- return 0;
-
- if (!sc->readlink) {
- gf_msg_debug (this->name, 0,
- "updating cache: %s", link);
+ symlink_inode_ctx_get(inode, this, VOID(&sc));
+ if (!sc)
+ return 0;
- sc->readlink = strdup (link);
- } else
- gf_msg_debug (this->name, 0,
- "not updating existing cache: %s with %s",
- sc->readlink, link);
+ if (!sc->readlink) {
+ gf_msg_debug(this->name, 0, "updating cache: %s", link);
+ sc->readlink = strdup(link);
+ } else
+ gf_msg_debug(this->name, 0, "not updating existing cache: %s with %s",
+ sc->readlink, link);
- return 0;
+ return 0;
}
-
int
-sc_cache_set (xlator_t *this, inode_t *inode, struct iatt *buf,
- const char *link)
+sc_cache_set(xlator_t *this, inode_t *inode, struct iatt *buf, const char *link)
{
- struct symlink_cache *sc = NULL;
- int ret = -1;
- int need_set = 0;
-
-
- symlink_inode_ctx_get (inode, this, VOID(&sc));
- if (!sc) {
- need_set = 1;
- sc = CALLOC (1, sizeof (*sc));
- if (!sc) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- SYMLINK_CACHE_MSG_NO_MEMORY,
- "out of memory :(");
- goto err;
- }
- }
-
- if (sc->readlink) {
- gf_msg_debug (this->name, 0,
- "replacing old cache: %s with new cache: %s",
- sc->readlink, link);
- FREE (sc->readlink);
- sc->readlink = NULL;
- }
-
- if (link) {
- sc->readlink = strdup (link);
- if (!sc->readlink) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- SYMLINK_CACHE_MSG_NO_MEMORY,
- "out of memory :(");
- goto err;
- }
- }
-
- sc->ctime = buf->ia_ctime;
-
- gf_msg_debug (this->name, 0,
- "setting symlink cache: %s", link);
-
- if (need_set) {
- ret = symlink_inode_ctx_set (inode, this, sc);
-
- if (ret < 0) {
- gf_msg (this->name, GF_LOG_ERROR,
- -ret, SYMLINK_CACHE_MSG_NO_MEMORY,
- "could not set inode context ");
- goto err;
- }
- }
-
- return 0;
+ struct symlink_cache *sc = NULL;
+ int ret = -1;
+ int need_set = 0;
+
+ symlink_inode_ctx_get(inode, this, VOID(&sc));
+ if (!sc) {
+ need_set = 1;
+ sc = CALLOC(1, sizeof(*sc));
+ if (!sc) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM,
+ SYMLINK_CACHE_MSG_NO_MEMORY, "out of memory :(");
+ goto err;
+ }
+ }
+
+ if (sc->readlink) {
+ gf_msg_debug(this->name, 0,
+ "replacing old cache: %s with new cache: %s", sc->readlink,
+ link);
+ FREE(sc->readlink);
+ sc->readlink = NULL;
+ }
+
+ if (link) {
+ sc->readlink = strdup(link);
+ if (!sc->readlink) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM,
+ SYMLINK_CACHE_MSG_NO_MEMORY, "out of memory :(");
+ goto err;
+ }
+ }
+
+ sc->ctime = buf->ia_ctime;
+
+ gf_msg_debug(this->name, 0, "setting symlink cache: %s", link);
+
+ if (need_set) {
+ ret = symlink_inode_ctx_set(inode, this, sc);
+
+ if (ret < 0) {
+ gf_msg(this->name, GF_LOG_ERROR, -ret, SYMLINK_CACHE_MSG_NO_MEMORY,
+ "could not set inode context ");
+ goto err;
+ }
+ }
+
+ return 0;
err:
- if (sc) {
- FREE (sc->readlink);
- sc->readlink = NULL;
- FREE (sc);
- }
+ if (sc) {
+ FREE(sc->readlink);
+ sc->readlink = NULL;
+ FREE(sc);
+ }
- return -1;
+ return -1;
}
-
int
-sc_cache_flush (xlator_t *this, inode_t *inode)
+sc_cache_flush(xlator_t *this, inode_t *inode)
{
- struct symlink_cache *sc = NULL;
+ struct symlink_cache *sc = NULL;
- symlink_inode_ctx_get (inode, this, VOID(&sc));
- if (!sc)
- return 0;
+ symlink_inode_ctx_get(inode, this, VOID(&sc));
+ if (!sc)
+ return 0;
- if (sc->readlink) {
- gf_msg_debug (this->name, 0,
- "flushing cache: %s", sc->readlink);
+ if (sc->readlink) {
+ gf_msg_debug(this->name, 0, "flushing cache: %s", sc->readlink);
- FREE (sc->readlink);
- sc->readlink = NULL;
- }
+ FREE(sc->readlink);
+ sc->readlink = NULL;
+ }
- FREE (sc);
+ FREE(sc);
- return 0;
+ return 0;
}
-
int
-sc_cache_validate (xlator_t *this, inode_t *inode, struct iatt *buf)
+sc_cache_validate(xlator_t *this, inode_t *inode, struct iatt *buf)
{
- struct symlink_cache *sc = NULL;
- uint64_t tmp_sc = 0;
+ struct symlink_cache *sc = NULL;
+ uint64_t tmp_sc = 0;
- if (!IA_ISLNK (buf->ia_type)) {
- sc_cache_flush (this, inode);
- return 0;
- }
+ if (!IA_ISLNK(buf->ia_type)) {
+ sc_cache_flush(this, inode);
+ return 0;
+ }
- symlink_inode_ctx_get (inode, this, VOID(&sc));
+ symlink_inode_ctx_get(inode, this, VOID(&sc));
- if (!sc) {
- sc_cache_set (this, inode, buf, NULL);
- inode_ctx_get (inode, this, &tmp_sc);
+ if (!sc) {
+ sc_cache_set(this, inode, buf, NULL);
+ inode_ctx_get(inode, this, &tmp_sc);
- if (!tmp_sc) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- SYMLINK_CACHE_MSG_NO_MEMORY,
- "out of memory :(");
- return 0;
- }
- sc = (struct symlink_cache *)(long)tmp_sc;
- }
+ if (!tmp_sc) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, SYMLINK_CACHE_MSG_NO_MEMORY,
+ "out of memory :(");
+ return 0;
+ }
+ sc = (struct symlink_cache *)(long)tmp_sc;
+ }
- if (sc->ctime == buf->ia_ctime)
- return 0;
+ if (sc->ctime == buf->ia_ctime)
+ return 0;
- /* STALE */
- if (sc->readlink) {
- gf_msg_debug (this->name, 0,
- "flushing cache: %s", sc->readlink);
+ /* STALE */
+ if (sc->readlink) {
+ gf_msg_debug(this->name, 0, "flushing cache: %s", sc->readlink);
- FREE (sc->readlink);
- sc->readlink = NULL;
- }
+ FREE(sc->readlink);
+ sc->readlink = NULL;
+ }
- sc->ctime = buf->ia_ctime;
+ sc->ctime = buf->ia_ctime;
- return 0;
+ return 0;
}
-
-
int
-sc_cache_get (xlator_t *this, inode_t *inode, char **link)
+sc_cache_get(xlator_t *this, inode_t *inode, char **link)
{
- struct symlink_cache *sc = NULL;
+ struct symlink_cache *sc = NULL;
- symlink_inode_ctx_get (inode, this, VOID(&sc));
+ symlink_inode_ctx_get(inode, this, VOID(&sc));
- if (!sc)
- return 0;
+ if (!sc)
+ return 0;
- if (link && sc->readlink)
- *link = strdup (sc->readlink);
- return 0;
+ if (link && sc->readlink)
+ *link = strdup(sc->readlink);
+ return 0;
}
-
int
-sc_readlink_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int op_ret, int op_errno,
- const char *link, struct iatt *sbuf, dict_t *xdata)
+sc_readlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
+ int op_errno, const char *link, struct iatt *sbuf,
+ dict_t *xdata)
{
- if (op_ret > 0)
- sc_cache_update (this, frame->local, link);
+ if (op_ret > 0)
+ sc_cache_update(this, frame->local, link);
- inode_unref (frame->local);
- frame->local = NULL;
+ inode_unref(frame->local);
+ frame->local = NULL;
- STACK_UNWIND_STRICT (readlink, frame, op_ret, op_errno, link, sbuf,
- xdata);
- return 0;
+ STACK_UNWIND_STRICT(readlink, frame, op_ret, op_errno, link, sbuf, xdata);
+ return 0;
}
-
int
-sc_readlink (call_frame_t *frame, xlator_t *this,
- loc_t *loc, size_t size, dict_t *xdata)
+sc_readlink(call_frame_t *frame, xlator_t *this, loc_t *loc, size_t size,
+ dict_t *xdata)
{
- char *link = NULL;
- struct iatt buf = {0, };
-
- sc_cache_get (this, loc->inode, &link);
-
- if (link) {
- /* cache hit */
- gf_msg_debug (this->name, 0,
- "cache hit %s -> %s",
- loc->path, link);
-
- /*
- libglusterfsclient, nfs or any other translators
- using buf in readlink_cbk should be aware that @buf
- is 0 filled
- */
- STACK_UNWIND_STRICT (readlink, frame, strlen (link), 0, link,
- &buf, NULL);
- FREE (link);
- return 0;
- }
-
- frame->local = inode_ref (loc->inode);
-
- STACK_WIND (frame, sc_readlink_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readlink,
- loc, size, xdata);
-
- return 0;
-}
+ char *link = NULL;
+ struct iatt buf = {
+ 0,
+ };
+
+ sc_cache_get(this, loc->inode, &link);
+
+ if (link) {
+ /* cache hit */
+ gf_msg_debug(this->name, 0, "cache hit %s -> %s", loc->path, link);
+
+ /*
+ libglusterfsclient, nfs or any other translators
+ using buf in readlink_cbk should be aware that @buf
+ is 0 filled
+ */
+ STACK_UNWIND_STRICT(readlink, frame, strlen(link), 0, link, &buf, NULL);
+ FREE(link);
+ return 0;
+ }
+
+ frame->local = inode_ref(loc->inode);
+ STACK_WIND(frame, sc_readlink_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readlink, loc, size, xdata);
+
+ return 0;
+}
int
-sc_symlink_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int op_ret, int op_errno,
- inode_t *inode, struct iatt *buf, struct iatt *preparent,
- struct iatt *postparent, dict_t *xdata)
+sc_symlink_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
+ int op_errno, inode_t *inode, struct iatt *buf,
+ struct iatt *preparent, struct iatt *postparent, dict_t *xdata)
{
- if (op_ret == 0) {
- if (frame->local) {
- sc_cache_set (this, inode, buf, frame->local);
- }
- }
-
- STACK_UNWIND_STRICT (symlink, frame, op_ret, op_errno, inode, buf,
- preparent, postparent, xdata);
- return 0;
-}
+ if (op_ret == 0) {
+ if (frame->local) {
+ sc_cache_set(this, inode, buf, frame->local);
+ }
+ }
+ STACK_UNWIND_STRICT(symlink, frame, op_ret, op_errno, inode, buf, preparent,
+ postparent, xdata);
+ return 0;
+}
int
-sc_symlink (call_frame_t *frame, xlator_t *this,
- const char *dst, loc_t *src, mode_t umask, dict_t *xdata)
+sc_symlink(call_frame_t *frame, xlator_t *this, const char *dst, loc_t *src,
+ mode_t umask, dict_t *xdata)
{
- frame->local = strdup (dst);
+ frame->local = strdup(dst);
- STACK_WIND (frame, sc_symlink_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->symlink,
- dst, src, umask, xdata);
+ STACK_WIND(frame, sc_symlink_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->symlink, dst, src, umask, xdata);
- return 0;
+ return 0;
}
-
int
-sc_lookup_cbk (call_frame_t *frame, void *cookie,
- xlator_t *this, int op_ret, int op_errno,
- inode_t *inode, struct iatt *buf, dict_t *xdata,
- struct iatt *postparent)
+sc_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int op_ret,
+ int op_errno, inode_t *inode, struct iatt *buf, dict_t *xdata,
+ struct iatt *postparent)
{
- if (op_ret == 0)
- sc_cache_validate (this, inode, buf);
- else
- sc_cache_flush (this, inode);
-
- STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, buf,
- xdata, postparent);
- return 0;
+ if (op_ret == 0)
+ sc_cache_validate(this, inode, buf);
+ else
+ sc_cache_flush(this, inode);
+
+ STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, buf, xdata,
+ postparent);
+ return 0;
}
-
int
-sc_lookup (call_frame_t *frame, xlator_t *this,
- loc_t *loc, dict_t *xdata)
+sc_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- STACK_WIND (frame, sc_lookup_cbk,
- FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->lookup,
- loc, xdata);
+ STACK_WIND(frame, sc_lookup_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, loc, xdata);
- return 0;
+ return 0;
}
-
int
-sc_forget (xlator_t *this,
- inode_t *inode)
+sc_forget(xlator_t *this, inode_t *inode)
{
- sc_cache_flush (this, inode);
+ sc_cache_flush(this, inode);
- return 0;
+ return 0;
}
-
int32_t
-init (xlator_t *this)
+init(xlator_t *this)
{
- if (!this->children || this->children->next)
- {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- SYMLINK_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED,
- "FATAL: volume (%s) not configured with exactly one "
- "child", this->name);
- return -1;
- }
-
- if (!this->parents) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- SYMLINK_CACHE_MSG_VOL_MISCONFIGURED,
- "dangling volume. check volfile ");
- }
-
- return 0;
+ if (!this->children || this->children->next) {
+ gf_msg(this->name, GF_LOG_ERROR, 0,
+ SYMLINK_CACHE_MSG_XLATOR_CHILD_MISCONFIGURED,
+ "FATAL: volume (%s) not configured with exactly one "
+ "child",
+ this->name);
+ return -1;
+ }
+
+ if (!this->parents) {
+ gf_msg(this->name, GF_LOG_WARNING, 0,
+ SYMLINK_CACHE_MSG_VOL_MISCONFIGURED,
+ "dangling volume. check volfile ");
+ }
+
+ return 0;
}
-
void
-fini (xlator_t *this)
+fini(xlator_t *this)
{
- return;
+ return;
}
-
struct xlator_fops fops = {
- .lookup = sc_lookup,
- .symlink = sc_symlink,
- .readlink = sc_readlink,
+ .lookup = sc_lookup,
+ .symlink = sc_symlink,
+ .readlink = sc_readlink,
};
-
struct xlator_cbks cbks = {
- .forget = sc_forget,
+ .forget = sc_forget,
};
struct volume_options options[] = {
- { .key = {NULL} },
+ {.key = {NULL}},
};
diff --git a/xlators/performance/write-behind/src/write-behind.c b/xlators/performance/write-behind/src/write-behind.c
index bd62d2e2c8c..c4f53e425bc 100644
--- a/xlators/performance/write-behind/src/write-behind.c
+++ b/xlators/performance/write-behind/src/write-behind.c
@@ -8,7 +8,6 @@
cases as published by the Free Software Foundation.
*/
-
#include "glusterfs.h"
#include "logging.h"
#include "dict.h"
@@ -23,252 +22,244 @@
#include "write-behind-mem-types.h"
#include "write-behind-messages.h"
-#define MAX_VECTOR_COUNT 8
-#define WB_AGGREGATE_SIZE 131072 /* 128 KB */
-#define WB_WINDOW_SIZE 1048576 /* 1MB */
+#define MAX_VECTOR_COUNT 8
+#define WB_AGGREGATE_SIZE 131072 /* 128 KB */
+#define WB_WINDOW_SIZE 1048576 /* 1MB */
typedef struct list_head list_head_t;
struct wb_conf;
struct wb_inode;
typedef struct wb_inode {
- ssize_t window_conf;
- ssize_t window_current;
- ssize_t transit; /* size of data stack_wound, and yet
- to be fulfilled (wb_fulfill_cbk).
- used for trickling_writes
- */
-
- list_head_t all; /* All requests, from enqueue() till destroy().
- Used only for resetting generation
- number when empty.
- */
- list_head_t todo; /* Work to do (i.e, STACK_WIND to server).
- Once we STACK_WIND, the entry is taken
- off the list. If it is non-sync write,
- then we continue to track it via @liability
- or @temptation depending on the status
- of its writeback.
- */
- list_head_t liability; /* Non-sync writes which are lied
- (STACK_UNWIND'ed to caller) but ack
- from server not yet complete. This
- is the "liability" which we hold, and
- must guarantee that dependent operations
- which arrive later (which overlap, etc.)
- are issued only after their dependencies
- in this list are "fulfilled".
-
- Server acks for entries in this list
- shrinks the window.
-
- The sum total of all req->write_size
- of entries in this list must be kept less
- than the permitted window size.
- */
- list_head_t temptation; /* Operations for which we are tempted
- to 'lie' (write-behind), but temporarily
- holding off (because of insufficient
- window capacity, etc.)
-
- This is the list to look at to grow
- the window (in __wb_pick_unwinds()).
-
- Entries typically get chosen from
- write-behind from this list, and therefore
- get "upgraded" to the "liability" list.
- */
- list_head_t wip; /* List of write calls in progress, SYNC or non-SYNC
- which are currently STACK_WIND'ed towards the server.
- This is for guaranteeing that no two overlapping
- writes are in progress at the same time. Modules
- like eager-lock in AFR depend on this behavior.
- */
- list_head_t invalidate_list; /* list of wb_inodes that were marked for
- * iatt invalidation due to requests in
- * liability queue fulfilled while there
- * was a readdirp session on parent
- * directory. For a directory inode, this
- * list points to list of children.
- */
- uint64_t gen; /* Liability generation number. Represents
- the current 'state' of liability. Every
- new addition to the liability list bumps
- the generation number.
-
- a newly arrived request is only required
- to perform causal checks against the entries
- in the liability list which were present
- at the time of its addition. the generation
- number at the time of its addition is stored
- in the request and used during checks.
-
- the liability list can grow while the request
- waits in the todo list waiting for its
- dependent operations to complete. however
- it is not of the request's concern to depend
- itself on those new entries which arrived
- after it arrived (i.e, those that have a
- liability generation higher than itself)
- */
- size_t size; /* Size of the file to catch write after EOF. */
- gf_lock_t lock;
- xlator_t *this;
- inode_t *inode;
- int dontsync; /* If positive, don't pick lies for
- * winding. This is needed to break infinite
- * recursion during invocation of
- * wb_process_queue from
- * wb_fulfill_cbk in case of an
- * error during fulfill.
- */
- gf_atomic_int32_t readdirps;
- gf_atomic_int8_t invalidate;
+ ssize_t window_conf;
+ ssize_t window_current;
+ ssize_t transit; /* size of data stack_wound, and yet
+ to be fulfilled (wb_fulfill_cbk).
+ used for trickling_writes
+ */
+
+ list_head_t all; /* All requests, from enqueue() till destroy().
+ Used only for resetting generation
+ number when empty.
+ */
+ list_head_t todo; /* Work to do (i.e, STACK_WIND to server).
+ Once we STACK_WIND, the entry is taken
+ off the list. If it is non-sync write,
+ then we continue to track it via @liability
+ or @temptation depending on the status
+ of its writeback.
+ */
+ list_head_t liability; /* Non-sync writes which are lied
+ (STACK_UNWIND'ed to caller) but ack
+ from server not yet complete. This
+ is the "liability" which we hold, and
+ must guarantee that dependent operations
+ which arrive later (which overlap, etc.)
+ are issued only after their dependencies
+ in this list are "fulfilled".
+
+ Server acks for entries in this list
+ shrinks the window.
+
+ The sum total of all req->write_size
+ of entries in this list must be kept less
+ than the permitted window size.
+ */
+ list_head_t temptation; /* Operations for which we are tempted
+ to 'lie' (write-behind), but temporarily
+ holding off (because of insufficient
+ window capacity, etc.)
+
+ This is the list to look at to grow
+ the window (in __wb_pick_unwinds()).
+
+ Entries typically get chosen from
+ write-behind from this list, and therefore
+ get "upgraded" to the "liability" list.
+ */
+ list_head_t wip; /* List of write calls in progress, SYNC or non-SYNC
+ which are currently STACK_WIND'ed towards the server.
+ This is for guaranteeing that no two overlapping
+ writes are in progress at the same time. Modules
+ like eager-lock in AFR depend on this behavior.
+ */
+ list_head_t invalidate_list; /* list of wb_inodes that were marked for
+ * iatt invalidation due to requests in
+ * liability queue fulfilled while there
+ * was a readdirp session on parent
+ * directory. For a directory inode, this
+ * list points to list of children.
+ */
+ uint64_t gen; /* Liability generation number. Represents
+ the current 'state' of liability. Every
+ new addition to the liability list bumps
+ the generation number.
+
+ a newly arrived request is only required
+ to perform causal checks against the entries
+ in the liability list which were present
+ at the time of its addition. the generation
+ number at the time of its addition is stored
+ in the request and used during checks.
+
+ the liability list can grow while the request
+ waits in the todo list waiting for its
+ dependent operations to complete. however
+ it is not of the request's concern to depend
+ itself on those new entries which arrived
+ after it arrived (i.e, those that have a
+ liability generation higher than itself)
+ */
+ size_t size; /* Size of the file to catch write after EOF. */
+ gf_lock_t lock;
+ xlator_t *this;
+ inode_t *inode;
+ int dontsync; /* If positive, don't pick lies for
+ * winding. This is needed to break infinite
+ * recursion during invocation of
+ * wb_process_queue from
+ * wb_fulfill_cbk in case of an
+ * error during fulfill.
+ */
+ gf_atomic_int32_t readdirps;
+ gf_atomic_int8_t invalidate;
} wb_inode_t;
-
typedef struct wb_request {
- list_head_t all;
- list_head_t todo;
- list_head_t lie; /* either in @liability or @temptation */
- list_head_t winds;
- list_head_t unwinds;
- list_head_t wip;
-
- call_stub_t *stub;
-
- ssize_t write_size; /* currently held size
- (after collapsing) */
- size_t orig_size; /* size which arrived with the request.
- This is the size by which we grow
- the window when unwinding the frame.
- */
- size_t total_size; /* valid only in @head in wb_fulfill().
- This is the size with which we perform
- STACK_WIND to server and therefore the
- amount by which we shrink the window.
- */
-
- int op_ret;
- int op_errno;
-
- int32_t refcount;
- wb_inode_t *wb_inode;
- glusterfs_fop_t fop;
- gf_lkowner_t lk_owner;
- pid_t client_pid;
- struct iobref *iobref;
- uint64_t gen; /* inode liability state at the time of
- request arrival */
-
- fd_t *fd;
- int wind_count; /* number of sync-attempts. Only
- for debug purposes */
- struct {
- size_t size; /* 0 size == till infinity */
- off_t off;
- int append:1; /* offset is invalid. only one
- outstanding append at a time */
- int tempted:1; /* true only for non-sync writes */
- int lied:1; /* sin committed */
- int fulfilled:1; /* got server acknowledgement */
- int go:1; /* enough aggregating, good to go */
- } ordering;
-
- /* for debug purposes. A request might outlive the fop it is
- * representing. So, preserve essential info for logging.
- */
- uint64_t unique;
- uuid_t gfid;
+ list_head_t all;
+ list_head_t todo;
+ list_head_t lie; /* either in @liability or @temptation */
+ list_head_t winds;
+ list_head_t unwinds;
+ list_head_t wip;
+
+ call_stub_t *stub;
+
+ ssize_t write_size; /* currently held size
+ (after collapsing) */
+ size_t orig_size; /* size which arrived with the request.
+ This is the size by which we grow
+ the window when unwinding the frame.
+ */
+ size_t total_size; /* valid only in @head in wb_fulfill().
+ This is the size with which we perform
+ STACK_WIND to server and therefore the
+ amount by which we shrink the window.
+ */
+
+ int op_ret;
+ int op_errno;
+
+ int32_t refcount;
+ wb_inode_t *wb_inode;
+ glusterfs_fop_t fop;
+ gf_lkowner_t lk_owner;
+ pid_t client_pid;
+ struct iobref *iobref;
+ uint64_t gen; /* inode liability state at the time of
+ request arrival */
+
+ fd_t *fd;
+ int wind_count; /* number of sync-attempts. Only
+ for debug purposes */
+ struct {
+ size_t size; /* 0 size == till infinity */
+ off_t off;
+ int append : 1; /* offset is invalid. only one
+ outstanding append at a time */
+ int tempted : 1; /* true only for non-sync writes */
+ int lied : 1; /* sin committed */
+ int fulfilled : 1; /* got server acknowledgement */
+ int go : 1; /* enough aggregating, good to go */
+ } ordering;
+
+ /* for debug purposes. A request might outlive the fop it is
+ * representing. So, preserve essential info for logging.
+ */
+ uint64_t unique;
+ uuid_t gfid;
} wb_request_t;
-
typedef struct wb_conf {
- uint64_t aggregate_size;
- uint64_t page_size;
- uint64_t window_size;
- gf_boolean_t flush_behind;
- gf_boolean_t trickling_writes;
- gf_boolean_t strict_write_ordering;
- gf_boolean_t strict_O_DIRECT;
- gf_boolean_t resync_after_fsync;
+ uint64_t aggregate_size;
+ uint64_t page_size;
+ uint64_t window_size;
+ gf_boolean_t flush_behind;
+ gf_boolean_t trickling_writes;
+ gf_boolean_t strict_write_ordering;
+ gf_boolean_t strict_O_DIRECT;
+ gf_boolean_t resync_after_fsync;
} wb_conf_t;
-
-
wb_inode_t *
-__wb_inode_ctx_get (xlator_t *this, inode_t *inode)
+__wb_inode_ctx_get(xlator_t *this, inode_t *inode)
{
- uint64_t value = 0;
- wb_inode_t *wb_inode = NULL;
- int ret = 0;
+ uint64_t value = 0;
+ wb_inode_t *wb_inode = NULL;
+ int ret = 0;
- ret = __inode_ctx_get (inode, this, &value);
- if (ret)
- return NULL;
+ ret = __inode_ctx_get(inode, this, &value);
+ if (ret)
+ return NULL;
- wb_inode = (wb_inode_t *)(unsigned long) value;
+ wb_inode = (wb_inode_t *)(unsigned long)value;
- return wb_inode;
+ return wb_inode;
}
-
wb_inode_t *
-wb_inode_ctx_get (xlator_t *this, inode_t *inode)
+wb_inode_ctx_get(xlator_t *this, inode_t *inode)
{
- wb_inode_t *wb_inode = NULL;
+ wb_inode_t *wb_inode = NULL;
- GF_VALIDATE_OR_GOTO ("write-behind", this, out);
- GF_VALIDATE_OR_GOTO (this->name, inode, out);
+ GF_VALIDATE_OR_GOTO("write-behind", this, out);
+ GF_VALIDATE_OR_GOTO(this->name, inode, out);
- LOCK (&inode->lock);
- {
- wb_inode = __wb_inode_ctx_get (this, inode);
- }
- UNLOCK (&inode->lock);
+ LOCK(&inode->lock);
+ {
+ wb_inode = __wb_inode_ctx_get(this, inode);
+ }
+ UNLOCK(&inode->lock);
out:
- return wb_inode;
+ return wb_inode;
}
-
static void
-wb_set_invalidate (wb_inode_t *wb_inode, int set)
-{
- int readdirps = 0;
- inode_t *parent_inode = NULL;
- wb_inode_t *wb_parent_inode = NULL;
-
- parent_inode = inode_parent (wb_inode->inode, NULL, NULL);
- if (parent_inode)
- wb_parent_inode = wb_inode_ctx_get (wb_inode->this,
- parent_inode);
-
- if (wb_parent_inode) {
- LOCK (&wb_parent_inode->lock);
- {
- readdirps = GF_ATOMIC_GET (wb_parent_inode->readdirps);
- if (readdirps && set) {
- GF_ATOMIC_SWAP (wb_inode->invalidate, 1);
- list_del_init (&wb_inode->invalidate_list);
- list_add (&wb_inode->invalidate_list,
- &wb_parent_inode->invalidate_list);
- } else if (readdirps == 0) {
- GF_ATOMIC_SWAP (wb_inode->invalidate, 0);
- list_del_init (&wb_inode->invalidate_list);
- }
- }
- UNLOCK (&wb_parent_inode->lock);
- } else {
- GF_ATOMIC_SWAP (wb_inode->invalidate, 0);
+wb_set_invalidate(wb_inode_t *wb_inode, int set)
+{
+ int readdirps = 0;
+ inode_t *parent_inode = NULL;
+ wb_inode_t *wb_parent_inode = NULL;
+
+ parent_inode = inode_parent(wb_inode->inode, NULL, NULL);
+ if (parent_inode)
+ wb_parent_inode = wb_inode_ctx_get(wb_inode->this, parent_inode);
+
+ if (wb_parent_inode) {
+ LOCK(&wb_parent_inode->lock);
+ {
+ readdirps = GF_ATOMIC_GET(wb_parent_inode->readdirps);
+ if (readdirps && set) {
+ GF_ATOMIC_SWAP(wb_inode->invalidate, 1);
+ list_del_init(&wb_inode->invalidate_list);
+ list_add(&wb_inode->invalidate_list,
+ &wb_parent_inode->invalidate_list);
+ } else if (readdirps == 0) {
+ GF_ATOMIC_SWAP(wb_inode->invalidate, 0);
+ list_del_init(&wb_inode->invalidate_list);
+ }
}
+ UNLOCK(&wb_parent_inode->lock);
+ } else {
+ GF_ATOMIC_SWAP(wb_inode->invalidate, 0);
+ }
- return;
+ return;
}
void
-wb_process_queue (wb_inode_t *wb_inode);
-
+wb_process_queue(wb_inode_t *wb_inode);
/*
Below is a succinct explanation of the code deciding whether two regions
@@ -295,3020 +286,2947 @@ wb_process_queue (wb_inode_t *wb_inode);
*/
gf_boolean_t
-wb_requests_overlap (wb_request_t *req1, wb_request_t *req2)
+wb_requests_overlap(wb_request_t *req1, wb_request_t *req2)
{
- uint64_t r1_start = 0;
- uint64_t r1_end = 0;
- uint64_t r2_start = 0;
- uint64_t r2_end = 0;
- gf_boolean_t do_overlap = _gf_false;
+ uint64_t r1_start = 0;
+ uint64_t r1_end = 0;
+ uint64_t r2_start = 0;
+ uint64_t r2_end = 0;
+ gf_boolean_t do_overlap = _gf_false;
- r1_start = req1->ordering.off;
- if (req1->ordering.size)
- r1_end = r1_start + req1->ordering.size - 1;
- else
- r1_end = ULLONG_MAX;
+ r1_start = req1->ordering.off;
+ if (req1->ordering.size)
+ r1_end = r1_start + req1->ordering.size - 1;
+ else
+ r1_end = ULLONG_MAX;
- r2_start = req2->ordering.off;
- if (req2->ordering.size)
- r2_end = r2_start + req2->ordering.size - 1;
- else
- r2_end = ULLONG_MAX;
+ r2_start = req2->ordering.off;
+ if (req2->ordering.size)
+ r2_end = r2_start + req2->ordering.size - 1;
+ else
+ r2_end = ULLONG_MAX;
- do_overlap = ((r1_end >= r2_start) && (r2_end >= r1_start));
+ do_overlap = ((r1_end >= r2_start) && (r2_end >= r1_start));
- return do_overlap;
+ return do_overlap;
}
-
gf_boolean_t
-wb_requests_conflict (wb_request_t *lie, wb_request_t *req)
+wb_requests_conflict(wb_request_t *lie, wb_request_t *req)
{
- wb_conf_t *conf = NULL;
+ wb_conf_t *conf = NULL;
- conf = req->wb_inode->this->private;
+ conf = req->wb_inode->this->private;
- if (lie == req)
- /* request cannot conflict with itself */
- return _gf_false;
+ if (lie == req)
+ /* request cannot conflict with itself */
+ return _gf_false;
- if (lie->gen >= req->gen)
- /* this liability entry was behind
- us in the todo list */
- return _gf_false;
+ if (lie->gen >= req->gen)
+ /* this liability entry was behind
+ us in the todo list */
+ return _gf_false;
- if (lie->ordering.append)
- /* all modifications wait for the completion
- of outstanding append */
- return _gf_true;
+ if (lie->ordering.append)
+ /* all modifications wait for the completion
+ of outstanding append */
+ return _gf_true;
- if (conf->strict_write_ordering)
- /* We are sure (lie->gen < req->gen) by now. So
- skip overlap check if strict write ordering is
- requested and always return "conflict" against a
- lower generation lie. */
- return _gf_true;
+ if (conf->strict_write_ordering)
+ /* We are sure (lie->gen < req->gen) by now. So
+ skip overlap check if strict write ordering is
+ requested and always return "conflict" against a
+ lower generation lie. */
+ return _gf_true;
- return wb_requests_overlap (lie, req);
+ return wb_requests_overlap(lie, req);
}
-
wb_request_t *
-wb_liability_has_conflict (wb_inode_t *wb_inode, wb_request_t *req)
+wb_liability_has_conflict(wb_inode_t *wb_inode, wb_request_t *req)
{
- wb_request_t *each = NULL;
+ wb_request_t *each = NULL;
- list_for_each_entry (each, &wb_inode->liability, lie) {
- if (wb_requests_conflict (each, req)
- && (!each->ordering.fulfilled))
- /* A fulfilled request shouldn't block another
- * request (even a dependent one) from winding.
- */
- return each;
- }
+ list_for_each_entry(each, &wb_inode->liability, lie)
+ {
+ if (wb_requests_conflict(each, req) && (!each->ordering.fulfilled))
+ /* A fulfilled request shouldn't block another
+ * request (even a dependent one) from winding.
+ */
+ return each;
+ }
- return NULL;
+ return NULL;
}
-
wb_request_t *
-wb_wip_has_conflict (wb_inode_t *wb_inode, wb_request_t *req)
+wb_wip_has_conflict(wb_inode_t *wb_inode, wb_request_t *req)
{
- wb_request_t *each = NULL;
+ wb_request_t *each = NULL;
- if (req->stub->fop != GF_FOP_WRITE)
- /* non-writes fundamentally never conflict with WIP requests */
- return NULL;
+ if (req->stub->fop != GF_FOP_WRITE)
+ /* non-writes fundamentally never conflict with WIP requests */
+ return NULL;
- list_for_each_entry (each, &wb_inode->wip, wip) {
- if (each == req)
- /* request never conflicts with itself,
- though this condition should never occur.
- */
- continue;
+ list_for_each_entry(each, &wb_inode->wip, wip)
+ {
+ if (each == req)
+ /* request never conflicts with itself,
+ though this condition should never occur.
+ */
+ continue;
- if (wb_requests_overlap (each, req))
- return each;
- }
+ if (wb_requests_overlap(each, req))
+ return each;
+ }
- return NULL;
+ return NULL;
}
-
static int
-__wb_request_unref (wb_request_t *req)
-{
- int ret = -1;
- wb_inode_t *wb_inode = NULL;
- char gfid[64] = {0, };
-
- wb_inode = req->wb_inode;
+__wb_request_unref(wb_request_t *req)
+{
+ int ret = -1;
+ wb_inode_t *wb_inode = NULL;
+ char gfid[64] = {
+ 0,
+ };
+
+ wb_inode = req->wb_inode;
+
+ if (req->refcount <= 0) {
+ uuid_utoa_r(req->gfid, gfid);
+
+ gf_msg(
+ "wb-request", GF_LOG_WARNING, 0, WRITE_BEHIND_MSG_RES_UNAVAILABLE,
+ "(unique=%" PRIu64 ", fop=%s, gfid=%s, gen=%" PRIu64
+ "): "
+ "refcount(%d) is <= 0 ",
+ req->unique, gf_fop_list[req->fop], gfid, req->gen, req->refcount);
+ goto out;
+ }
+
+ ret = --req->refcount;
+ if (req->refcount == 0) {
+ uuid_utoa_r(req->gfid, gfid);
+
+ gf_log_callingfn(wb_inode->this->name, GF_LOG_DEBUG,
+ "(unique = %" PRIu64
+ ", fop=%s, gfid=%s, "
+ "gen=%" PRIu64
+ "): destroying request, "
+ "removing from all queues",
+ req->unique, gf_fop_list[req->fop], gfid, req->gen);
+
+ list_del_init(&req->todo);
+ list_del_init(&req->lie);
+ list_del_init(&req->wip);
+
+ list_del_init(&req->all);
+ if (list_empty(&wb_inode->all)) {
+ wb_inode->gen = 0;
+ /* in case of accounting errors? */
+ wb_inode->window_current = 0;
+ }
- if (req->refcount <= 0) {
- uuid_utoa_r (req->gfid, gfid);
+ list_del_init(&req->winds);
+ list_del_init(&req->unwinds);
- gf_msg ("wb-request", GF_LOG_WARNING,
- 0, WRITE_BEHIND_MSG_RES_UNAVAILABLE,
- "(unique=%"PRIu64", fop=%s, gfid=%s, gen=%"PRIu64"): "
- "refcount(%d) is <= 0 ",
- req->unique, gf_fop_list[req->fop], gfid, req->gen,
- req->refcount);
- goto out;
+ if (req->stub) {
+ call_stub_destroy(req->stub);
+ req->stub = NULL;
}
- ret = --req->refcount;
- if (req->refcount == 0) {
- uuid_utoa_r (req->gfid, gfid);
-
- gf_log_callingfn (wb_inode->this->name, GF_LOG_DEBUG,
- "(unique = %"PRIu64", fop=%s, gfid=%s, "
- "gen=%"PRIu64"): destroying request, "
- "removing from all queues", req->unique,
- gf_fop_list[req->fop], gfid, req->gen);
-
- list_del_init (&req->todo);
- list_del_init (&req->lie);
- list_del_init (&req->wip);
-
- list_del_init (&req->all);
- if (list_empty (&wb_inode->all)) {
- wb_inode->gen = 0;
- /* in case of accounting errors? */
- wb_inode->window_current = 0;
- }
-
- list_del_init (&req->winds);
- list_del_init (&req->unwinds);
-
- if (req->stub) {
- call_stub_destroy (req->stub);
- req->stub = NULL;
- }
-
- if (req->iobref)
- iobref_unref (req->iobref);
+ if (req->iobref)
+ iobref_unref(req->iobref);
- if (req->fd)
- fd_unref (req->fd);
+ if (req->fd)
+ fd_unref(req->fd);
- GF_FREE (req);
- }
+ GF_FREE(req);
+ }
out:
- return ret;
+ return ret;
}
-
static int
-wb_request_unref (wb_request_t *req)
+wb_request_unref(wb_request_t *req)
{
- wb_inode_t *wb_inode = NULL;
- int ret = -1;
+ wb_inode_t *wb_inode = NULL;
+ int ret = -1;
- GF_VALIDATE_OR_GOTO ("write-behind", req, out);
+ GF_VALIDATE_OR_GOTO("write-behind", req, out);
- wb_inode = req->wb_inode;
+ wb_inode = req->wb_inode;
- LOCK (&wb_inode->lock);
- {
- ret = __wb_request_unref (req);
- }
- UNLOCK (&wb_inode->lock);
+ LOCK(&wb_inode->lock);
+ {
+ ret = __wb_request_unref(req);
+ }
+ UNLOCK(&wb_inode->lock);
out:
- return ret;
+ return ret;
}
-
static wb_request_t *
-__wb_request_ref (wb_request_t *req)
+__wb_request_ref(wb_request_t *req)
{
- GF_VALIDATE_OR_GOTO ("write-behind", req, out);
+ GF_VALIDATE_OR_GOTO("write-behind", req, out);
- if (req->refcount < 0) {
- gf_msg ("wb-request", GF_LOG_WARNING, 0,
- WRITE_BEHIND_MSG_RES_UNAVAILABLE,
- "refcount(%d) is < 0", req->refcount);
- req = NULL;
- goto out;
- }
+ if (req->refcount < 0) {
+ gf_msg("wb-request", GF_LOG_WARNING, 0,
+ WRITE_BEHIND_MSG_RES_UNAVAILABLE, "refcount(%d) is < 0",
+ req->refcount);
+ req = NULL;
+ goto out;
+ }
- req->refcount++;
+ req->refcount++;
out:
- return req;
+ return req;
}
-
wb_request_t *
-wb_request_ref (wb_request_t *req)
+wb_request_ref(wb_request_t *req)
{
- wb_inode_t *wb_inode = NULL;
+ wb_inode_t *wb_inode = NULL;
- GF_VALIDATE_OR_GOTO ("write-behind", req, out);
+ GF_VALIDATE_OR_GOTO("write-behind", req, out);
- wb_inode = req->wb_inode;
- LOCK (&wb_inode->lock);
- {
- req = __wb_request_ref (req);
- }
- UNLOCK (&wb_inode->lock);
+ wb_inode = req->wb_inode;
+ LOCK(&wb_inode->lock);
+ {
+ req = __wb_request_ref(req);
+ }
+ UNLOCK(&wb_inode->lock);
out:
- return req;
+ return req;
}
-
gf_boolean_t
-wb_enqueue_common (wb_inode_t *wb_inode, call_stub_t *stub, int tempted)
-{
- wb_request_t *req = NULL;
- inode_t *inode = NULL;
-
- GF_VALIDATE_OR_GOTO ("write-behind", wb_inode, out);
- GF_VALIDATE_OR_GOTO (wb_inode->this->name, stub, out);
-
- req = GF_CALLOC (1, sizeof (*req), gf_wb_mt_wb_request_t);
- if (!req)
- goto out;
-
- INIT_LIST_HEAD (&req->all);
- INIT_LIST_HEAD (&req->todo);
- INIT_LIST_HEAD (&req->lie);
- INIT_LIST_HEAD (&req->winds);
- INIT_LIST_HEAD (&req->unwinds);
- INIT_LIST_HEAD (&req->wip);
-
- req->stub = stub;
- req->wb_inode = wb_inode;
- req->fop = stub->fop;
- req->ordering.tempted = tempted;
- req->unique = stub->frame->root->unique;
-
- inode = ((stub->args.fd != NULL) ? stub->args.fd->inode
- : stub->args.loc.inode);
-
- if (inode)
- gf_uuid_copy (req->gfid, inode->gfid);
-
- if (stub->fop == GF_FOP_WRITE) {
- req->write_size = iov_length (stub->args.vector,
- stub->args.count);
-
- /* req->write_size can change as we collapse
- small writes. But the window needs to grow
- only by how much we acknowledge the app. so
- copy the original size in orig_size for the
- purpose of accounting.
- */
- req->orig_size = req->write_size;
-
- /* Let's be optimistic that we can
- lie about it
- */
- req->op_ret = req->write_size;
- req->op_errno = 0;
-
- if (stub->args.fd && (stub->args.fd->flags & O_APPEND))
- req->ordering.append = 1;
- }
+wb_enqueue_common(wb_inode_t *wb_inode, call_stub_t *stub, int tempted)
+{
+ wb_request_t *req = NULL;
+ inode_t *inode = NULL;
- req->lk_owner = stub->frame->root->lk_owner;
- req->client_pid = stub->frame->root->pid;
-
- switch (stub->fop) {
- case GF_FOP_WRITE:
- LOCK (&wb_inode->lock);
- {
- if (wb_inode->size < stub->args.offset) {
- req->ordering.off = wb_inode->size;
- req->ordering.size = stub->args.offset
- + req->write_size
- - wb_inode->size;
- } else {
- req->ordering.off = stub->args.offset;
- req->ordering.size = req->write_size;
- }
-
- if (wb_inode->size < stub->args.offset + req->write_size)
- wb_inode->size = stub->args.offset
- + req->write_size;
- }
- UNLOCK (&wb_inode->lock);
-
- req->fd = fd_ref (stub->args.fd);
-
- break;
- case GF_FOP_READ:
- req->ordering.off = stub->args.offset;
- req->ordering.size = stub->args.size;
-
- req->fd = fd_ref (stub->args.fd);
-
- break;
- case GF_FOP_TRUNCATE:
- req->ordering.off = stub->args.offset;
- req->ordering.size = 0; /* till infinity */
- LOCK (&wb_inode->lock);
- {
- wb_inode->size = req->ordering.off;
- }
- UNLOCK (&wb_inode->lock);
- break;
- case GF_FOP_FTRUNCATE:
- req->ordering.off = stub->args.offset;
- req->ordering.size = 0; /* till infinity */
- LOCK (&wb_inode->lock);
- {
- wb_inode->size = req->ordering.off;
- }
- UNLOCK (&wb_inode->lock);
-
- req->fd = fd_ref (stub->args.fd);
-
- break;
- default:
- if (stub && stub->args.fd)
- req->fd = fd_ref (stub->args.fd);
-
- break;
- }
-
- LOCK (&wb_inode->lock);
- {
- list_add_tail (&req->all, &wb_inode->all);
+ GF_VALIDATE_OR_GOTO("write-behind", wb_inode, out);
+ GF_VALIDATE_OR_GOTO(wb_inode->this->name, stub, out);
+
+ req = GF_CALLOC(1, sizeof(*req), gf_wb_mt_wb_request_t);
+ if (!req)
+ goto out;
+
+ INIT_LIST_HEAD(&req->all);
+ INIT_LIST_HEAD(&req->todo);
+ INIT_LIST_HEAD(&req->lie);
+ INIT_LIST_HEAD(&req->winds);
+ INIT_LIST_HEAD(&req->unwinds);
+ INIT_LIST_HEAD(&req->wip);
+
+ req->stub = stub;
+ req->wb_inode = wb_inode;
+ req->fop = stub->fop;
+ req->ordering.tempted = tempted;
+ req->unique = stub->frame->root->unique;
+
+ inode = ((stub->args.fd != NULL) ? stub->args.fd->inode
+ : stub->args.loc.inode);
+
+ if (inode)
+ gf_uuid_copy(req->gfid, inode->gfid);
+
+ if (stub->fop == GF_FOP_WRITE) {
+ req->write_size = iov_length(stub->args.vector, stub->args.count);
- req->gen = wb_inode->gen;
+ /* req->write_size can change as we collapse
+ small writes. But the window needs to grow
+ only by how much we acknowledge the app. so
+ copy the original size in orig_size for the
+ purpose of accounting.
+ */
+ req->orig_size = req->write_size;
- list_add_tail (&req->todo, &wb_inode->todo);
- __wb_request_ref (req); /* for wind */
+ /* Let's be optimistic that we can
+ lie about it
+ */
+ req->op_ret = req->write_size;
+ req->op_errno = 0;
+
+ if (stub->args.fd && (stub->args.fd->flags & O_APPEND))
+ req->ordering.append = 1;
+ }
+
+ req->lk_owner = stub->frame->root->lk_owner;
+ req->client_pid = stub->frame->root->pid;
+
+ switch (stub->fop) {
+ case GF_FOP_WRITE:
+ LOCK(&wb_inode->lock);
+ {
+ if (wb_inode->size < stub->args.offset) {
+ req->ordering.off = wb_inode->size;
+ req->ordering.size = stub->args.offset + req->write_size -
+ wb_inode->size;
+ } else {
+ req->ordering.off = stub->args.offset;
+ req->ordering.size = req->write_size;
+ }
- if (req->ordering.tempted) {
- list_add_tail (&req->lie, &wb_inode->temptation);
- __wb_request_ref (req); /* for unwind */
- }
+ if (wb_inode->size < stub->args.offset + req->write_size)
+ wb_inode->size = stub->args.offset + req->write_size;
+ }
+ UNLOCK(&wb_inode->lock);
+
+ req->fd = fd_ref(stub->args.fd);
+
+ break;
+ case GF_FOP_READ:
+ req->ordering.off = stub->args.offset;
+ req->ordering.size = stub->args.size;
+
+ req->fd = fd_ref(stub->args.fd);
+
+ break;
+ case GF_FOP_TRUNCATE:
+ req->ordering.off = stub->args.offset;
+ req->ordering.size = 0; /* till infinity */
+ LOCK(&wb_inode->lock);
+ {
+ wb_inode->size = req->ordering.off;
+ }
+ UNLOCK(&wb_inode->lock);
+ break;
+ case GF_FOP_FTRUNCATE:
+ req->ordering.off = stub->args.offset;
+ req->ordering.size = 0; /* till infinity */
+ LOCK(&wb_inode->lock);
+ {
+ wb_inode->size = req->ordering.off;
+ }
+ UNLOCK(&wb_inode->lock);
+
+ req->fd = fd_ref(stub->args.fd);
+
+ break;
+ default:
+ if (stub && stub->args.fd)
+ req->fd = fd_ref(stub->args.fd);
+
+ break;
+ }
+
+ LOCK(&wb_inode->lock);
+ {
+ list_add_tail(&req->all, &wb_inode->all);
+
+ req->gen = wb_inode->gen;
+
+ list_add_tail(&req->todo, &wb_inode->todo);
+ __wb_request_ref(req); /* for wind */
+
+ if (req->ordering.tempted) {
+ list_add_tail(&req->lie, &wb_inode->temptation);
+ __wb_request_ref(req); /* for unwind */
}
- UNLOCK (&wb_inode->lock);
+ }
+ UNLOCK(&wb_inode->lock);
out:
- if (!req)
- return _gf_false;
+ if (!req)
+ return _gf_false;
- return _gf_true;
+ return _gf_true;
}
-
gf_boolean_t
-wb_enqueue (wb_inode_t *wb_inode, call_stub_t *stub)
+wb_enqueue(wb_inode_t *wb_inode, call_stub_t *stub)
{
- return wb_enqueue_common (wb_inode, stub, 0);
+ return wb_enqueue_common(wb_inode, stub, 0);
}
-
gf_boolean_t
-wb_enqueue_tempted (wb_inode_t *wb_inode, call_stub_t *stub)
+wb_enqueue_tempted(wb_inode_t *wb_inode, call_stub_t *stub)
{
- return wb_enqueue_common (wb_inode, stub, 1);
+ return wb_enqueue_common(wb_inode, stub, 1);
}
-
wb_inode_t *
-__wb_inode_create (xlator_t *this, inode_t *inode)
+__wb_inode_create(xlator_t *this, inode_t *inode)
{
- wb_inode_t *wb_inode = NULL;
- wb_conf_t *conf = NULL;
- int ret = 0;
+ wb_inode_t *wb_inode = NULL;
+ wb_conf_t *conf = NULL;
+ int ret = 0;
- GF_VALIDATE_OR_GOTO (this->name, inode, out);
+ GF_VALIDATE_OR_GOTO(this->name, inode, out);
- conf = this->private;
+ conf = this->private;
- wb_inode = GF_CALLOC (1, sizeof (*wb_inode), gf_wb_mt_wb_inode_t);
- if (!wb_inode)
- goto out;
+ wb_inode = GF_CALLOC(1, sizeof(*wb_inode), gf_wb_mt_wb_inode_t);
+ if (!wb_inode)
+ goto out;
- INIT_LIST_HEAD (&wb_inode->all);
- INIT_LIST_HEAD (&wb_inode->todo);
- INIT_LIST_HEAD (&wb_inode->liability);
- INIT_LIST_HEAD (&wb_inode->temptation);
- INIT_LIST_HEAD (&wb_inode->wip);
- INIT_LIST_HEAD (&wb_inode->invalidate_list);
+ INIT_LIST_HEAD(&wb_inode->all);
+ INIT_LIST_HEAD(&wb_inode->todo);
+ INIT_LIST_HEAD(&wb_inode->liability);
+ INIT_LIST_HEAD(&wb_inode->temptation);
+ INIT_LIST_HEAD(&wb_inode->wip);
+ INIT_LIST_HEAD(&wb_inode->invalidate_list);
- wb_inode->this = this;
+ wb_inode->this = this;
- wb_inode->window_conf = conf->window_size;
- wb_inode->inode = inode;
+ wb_inode->window_conf = conf->window_size;
+ wb_inode->inode = inode;
- LOCK_INIT (&wb_inode->lock);
- GF_ATOMIC_INIT (wb_inode->invalidate, 0);
- GF_ATOMIC_INIT (wb_inode->readdirps, 0);
+ LOCK_INIT(&wb_inode->lock);
+ GF_ATOMIC_INIT(wb_inode->invalidate, 0);
+ GF_ATOMIC_INIT(wb_inode->readdirps, 0);
- ret = __inode_ctx_put (inode, this, (uint64_t)(unsigned long)wb_inode);
- if (ret) {
- GF_FREE (wb_inode);
- wb_inode = NULL;
- }
+ ret = __inode_ctx_put(inode, this, (uint64_t)(unsigned long)wb_inode);
+ if (ret) {
+ GF_FREE(wb_inode);
+ wb_inode = NULL;
+ }
out:
- return wb_inode;
+ return wb_inode;
}
-
wb_inode_t *
-wb_inode_create (xlator_t *this, inode_t *inode)
+wb_inode_create(xlator_t *this, inode_t *inode)
{
- wb_inode_t *wb_inode = NULL;
+ wb_inode_t *wb_inode = NULL;
- GF_VALIDATE_OR_GOTO (this->name, inode, out);
+ GF_VALIDATE_OR_GOTO(this->name, inode, out);
- LOCK (&inode->lock);
- {
- wb_inode = __wb_inode_ctx_get (this, inode);
- if (!wb_inode)
- wb_inode = __wb_inode_create (this, inode);
- }
- UNLOCK (&inode->lock);
+ LOCK(&inode->lock);
+ {
+ wb_inode = __wb_inode_ctx_get(this, inode);
+ if (!wb_inode)
+ wb_inode = __wb_inode_create(this, inode);
+ }
+ UNLOCK(&inode->lock);
out:
- return wb_inode;
+ return wb_inode;
}
-
void
-wb_inode_destroy (wb_inode_t *wb_inode)
+wb_inode_destroy(wb_inode_t *wb_inode)
{
- GF_VALIDATE_OR_GOTO ("write-behind", wb_inode, out);
+ GF_VALIDATE_OR_GOTO("write-behind", wb_inode, out);
- LOCK_DESTROY (&wb_inode->lock);
- GF_FREE (wb_inode);
+ LOCK_DESTROY(&wb_inode->lock);
+ GF_FREE(wb_inode);
out:
- return;
+ return;
}
-
void
-__wb_fulfill_request (wb_request_t *req)
-{
- wb_inode_t *wb_inode = NULL;
- char gfid[64] = {0, };
-
- wb_inode = req->wb_inode;
-
- req->ordering.fulfilled = 1;
- wb_inode->window_current -= req->total_size;
- wb_inode->transit -= req->total_size;
-
- uuid_utoa_r (req->gfid, gfid);
-
- gf_log_callingfn (wb_inode->this->name, GF_LOG_DEBUG,
- "(unique=%"PRIu64", fop=%s, gfid=%s, "
- "gen=%"PRIu64"): request fulfilled. "
- "removing the request from liability queue? = %s",
- req->unique, gf_fop_list[req->fop], gfid, req->gen,
- req->ordering.lied ? "yes" : "no");
-
- if (req->ordering.lied) {
- /* 1. If yes, request is in liability queue and hence can be
- safely removed from list.
- 2. If no, request is in temptation queue and hence should be
- left in the queue so that wb_pick_unwinds picks it up
- */
- list_del_init (&req->lie);
- } else {
- /* TODO: fail the req->frame with error if
- necessary
- */
- }
+__wb_fulfill_request(wb_request_t *req)
+{
+ wb_inode_t *wb_inode = NULL;
+ char gfid[64] = {
+ 0,
+ };
+
+ wb_inode = req->wb_inode;
+
+ req->ordering.fulfilled = 1;
+ wb_inode->window_current -= req->total_size;
+ wb_inode->transit -= req->total_size;
+
+ uuid_utoa_r(req->gfid, gfid);
+
+ gf_log_callingfn(wb_inode->this->name, GF_LOG_DEBUG,
+ "(unique=%" PRIu64
+ ", fop=%s, gfid=%s, "
+ "gen=%" PRIu64
+ "): request fulfilled. "
+ "removing the request from liability queue? = %s",
+ req->unique, gf_fop_list[req->fop], gfid, req->gen,
+ req->ordering.lied ? "yes" : "no");
+
+ if (req->ordering.lied) {
+ /* 1. If yes, request is in liability queue and hence can be
+ safely removed from list.
+ 2. If no, request is in temptation queue and hence should be
+ left in the queue so that wb_pick_unwinds picks it up
+ */
+ list_del_init(&req->lie);
+ } else {
+ /* TODO: fail the req->frame with error if
+ necessary
+ */
+ }
- list_del_init (&req->wip);
- __wb_request_unref (req);
+ list_del_init(&req->wip);
+ __wb_request_unref(req);
}
-
/* get a flush/fsync waiting on req */
wb_request_t *
-__wb_request_waiting_on (wb_request_t *req)
+__wb_request_waiting_on(wb_request_t *req)
{
- wb_inode_t *wb_inode = NULL;
- wb_request_t *trav = NULL;
+ wb_inode_t *wb_inode = NULL;
+ wb_request_t *trav = NULL;
- wb_inode = req->wb_inode;
+ wb_inode = req->wb_inode;
- list_for_each_entry (trav, &wb_inode->todo, todo) {
- if (((trav->stub->fop == GF_FOP_FLUSH) || (trav->stub->fop
- == GF_FOP_FSYNC))
- && (trav->gen >= req->gen))
- return trav;
- }
+ list_for_each_entry(trav, &wb_inode->todo, todo)
+ {
+ if (((trav->stub->fop == GF_FOP_FLUSH) ||
+ (trav->stub->fop == GF_FOP_FSYNC)) &&
+ (trav->gen >= req->gen))
+ return trav;
+ }
- return NULL;
+ return NULL;
}
-
void
-__wb_add_request_for_retry (wb_request_t *req)
+__wb_add_request_for_retry(wb_request_t *req)
{
- wb_inode_t *wb_inode = NULL;
+ wb_inode_t *wb_inode = NULL;
- if (!req)
- goto out;
+ if (!req)
+ goto out;
- wb_inode = req->wb_inode;
+ wb_inode = req->wb_inode;
- /* response was unwound and no waiter waiting on this request, retry
- till a flush or fsync (subject to conf->resync_after_fsync).
- */
- wb_inode->transit -= req->total_size;
+ /* response was unwound and no waiter waiting on this request, retry
+ till a flush or fsync (subject to conf->resync_after_fsync).
+ */
+ wb_inode->transit -= req->total_size;
- req->total_size = 0;
+ req->total_size = 0;
- list_del_init (&req->winds);
- list_del_init (&req->todo);
- list_del_init (&req->wip);
+ list_del_init(&req->winds);
+ list_del_init(&req->todo);
+ list_del_init(&req->wip);
- /* sanitize ordering flags to retry */
- req->ordering.go = 0;
+ /* sanitize ordering flags to retry */
+ req->ordering.go = 0;
- /* Add back to todo list to retry */
- list_add (&req->todo, &wb_inode->todo);
+ /* Add back to todo list to retry */
+ list_add(&req->todo, &wb_inode->todo);
out:
- return;
+ return;
}
void
-__wb_add_head_for_retry (wb_request_t *head)
+__wb_add_head_for_retry(wb_request_t *head)
{
- wb_request_t *req = NULL, *tmp = NULL;
+ wb_request_t *req = NULL, *tmp = NULL;
- if (!head)
- goto out;
+ if (!head)
+ goto out;
- list_for_each_entry_safe_reverse (req, tmp, &head->winds,
- winds) {
- __wb_add_request_for_retry (req);
- }
+ list_for_each_entry_safe_reverse(req, tmp, &head->winds, winds)
+ {
+ __wb_add_request_for_retry(req);
+ }
- __wb_add_request_for_retry (head);
+ __wb_add_request_for_retry(head);
out:
- return;
+ return;
}
-
void
-wb_add_head_for_retry (wb_request_t *head)
+wb_add_head_for_retry(wb_request_t *head)
{
- if (!head)
- goto out;
+ if (!head)
+ goto out;
- LOCK (&head->wb_inode->lock);
- {
- __wb_add_head_for_retry (head);
- }
- UNLOCK (&head->wb_inode->lock);
+ LOCK(&head->wb_inode->lock);
+ {
+ __wb_add_head_for_retry(head);
+ }
+ UNLOCK(&head->wb_inode->lock);
out:
- return;
+ return;
}
-
void
-__wb_fulfill_request_err (wb_request_t *req, int32_t op_errno)
+__wb_fulfill_request_err(wb_request_t *req, int32_t op_errno)
{
- wb_inode_t *wb_inode = NULL;
- wb_request_t *waiter = NULL;
- wb_conf_t *conf = NULL;
+ wb_inode_t *wb_inode = NULL;
+ wb_request_t *waiter = NULL;
+ wb_conf_t *conf = NULL;
- wb_inode = req->wb_inode;
+ wb_inode = req->wb_inode;
- conf = wb_inode->this->private;
+ conf = wb_inode->this->private;
- req->op_ret = -1;
- req->op_errno = op_errno;
+ req->op_ret = -1;
+ req->op_errno = op_errno;
- if (req->ordering.lied)
- waiter = __wb_request_waiting_on (req);
+ if (req->ordering.lied)
+ waiter = __wb_request_waiting_on(req);
- if (!req->ordering.lied || waiter) {
- if (!req->ordering.lied) {
- /* response to app is still pending, send failure in
- * response.
- */
- } else {
- /* response was sent, store the error in a
- * waiter (either an fsync or flush).
- */
- waiter->op_ret = -1;
- waiter->op_errno = op_errno;
- }
+ if (!req->ordering.lied || waiter) {
+ if (!req->ordering.lied) {
+ /* response to app is still pending, send failure in
+ * response.
+ */
+ } else {
+ /* response was sent, store the error in a
+ * waiter (either an fsync or flush).
+ */
+ waiter->op_ret = -1;
+ waiter->op_errno = op_errno;
+ }
- if (!req->ordering.lied
- || (waiter->stub->fop == GF_FOP_FLUSH)
- || ((waiter->stub->fop == GF_FOP_FSYNC)
- && !conf->resync_after_fsync)) {
- /* No retry needed, forget the request */
- __wb_fulfill_request (req);
- return;
- }
+ if (!req->ordering.lied || (waiter->stub->fop == GF_FOP_FLUSH) ||
+ ((waiter->stub->fop == GF_FOP_FSYNC) &&
+ !conf->resync_after_fsync)) {
+ /* No retry needed, forget the request */
+ __wb_fulfill_request(req);
+ return;
}
+ }
- __wb_add_request_for_retry (req);
+ __wb_add_request_for_retry(req);
- return;
+ return;
}
-
void
-wb_head_done (wb_request_t *head)
+wb_head_done(wb_request_t *head)
{
- wb_request_t *req = NULL;
- wb_request_t *tmp = NULL;
- wb_inode_t *wb_inode = NULL;
+ wb_request_t *req = NULL;
+ wb_request_t *tmp = NULL;
+ wb_inode_t *wb_inode = NULL;
- wb_inode = head->wb_inode;
+ wb_inode = head->wb_inode;
- LOCK (&wb_inode->lock);
- {
- list_for_each_entry_safe (req, tmp, &head->winds, winds) {
- __wb_fulfill_request (req);
- }
+ LOCK(&wb_inode->lock);
+ {
+ list_for_each_entry_safe(req, tmp, &head->winds, winds)
+ {
+ __wb_fulfill_request(req);
+ }
- __wb_fulfill_request (head);
- }
- UNLOCK (&wb_inode->lock);
+ __wb_fulfill_request(head);
+ }
+ UNLOCK(&wb_inode->lock);
}
-
void
-__wb_fulfill_err (wb_request_t *head, int op_errno)
+__wb_fulfill_err(wb_request_t *head, int op_errno)
{
- wb_request_t *req = NULL, *tmp = NULL;
+ wb_request_t *req = NULL, *tmp = NULL;
- if (!head)
- goto out;
+ if (!head)
+ goto out;
- head->wb_inode->dontsync++;
+ head->wb_inode->dontsync++;
- list_for_each_entry_safe_reverse (req, tmp, &head->winds,
- winds) {
- __wb_fulfill_request_err (req, op_errno);
- }
+ list_for_each_entry_safe_reverse(req, tmp, &head->winds, winds)
+ {
+ __wb_fulfill_request_err(req, op_errno);
+ }
- __wb_fulfill_request_err (head, op_errno);
+ __wb_fulfill_request_err(head, op_errno);
out:
- return;
+ return;
}
-
void
-wb_fulfill_err (wb_request_t *head, int op_errno)
+wb_fulfill_err(wb_request_t *head, int op_errno)
{
- wb_inode_t *wb_inode = NULL;
-
- wb_inode = head->wb_inode;
+ wb_inode_t *wb_inode = NULL;
- LOCK (&wb_inode->lock);
- {
- __wb_fulfill_err (head, op_errno);
+ wb_inode = head->wb_inode;
- }
- UNLOCK (&wb_inode->lock);
+ LOCK(&wb_inode->lock);
+ {
+ __wb_fulfill_err(head, op_errno);
+ }
+ UNLOCK(&wb_inode->lock);
}
-
void
-__wb_modify_write_request (wb_request_t *req, int synced_size)
+__wb_modify_write_request(wb_request_t *req, int synced_size)
{
- struct iovec *vector = NULL;
- int count = 0;
+ struct iovec *vector = NULL;
+ int count = 0;
- if (!req || synced_size == 0)
- goto out;
+ if (!req || synced_size == 0)
+ goto out;
- req->write_size -= synced_size;
- req->stub->args.offset += synced_size;
+ req->write_size -= synced_size;
+ req->stub->args.offset += synced_size;
- vector = req->stub->args.vector;
- count = req->stub->args.count;
+ vector = req->stub->args.vector;
+ count = req->stub->args.count;
- req->stub->args.count = iov_subset (vector, count, synced_size,
- iov_length (vector, count), vector);
+ req->stub->args.count = iov_subset(vector, count, synced_size,
+ iov_length(vector, count), vector);
out:
- return;
+ return;
}
int
-__wb_fulfill_short_write (wb_request_t *req, int size, gf_boolean_t *fulfilled)
+__wb_fulfill_short_write(wb_request_t *req, int size, gf_boolean_t *fulfilled)
{
- int accounted_size = 0;
+ int accounted_size = 0;
- if (req == NULL)
- goto out;
+ if (req == NULL)
+ goto out;
- if (req->write_size <= size) {
- accounted_size = req->write_size;
- __wb_fulfill_request (req);
- *fulfilled = 1;
- } else {
- accounted_size = size;
- __wb_modify_write_request (req, size);
- *fulfilled = 0;
- }
+ if (req->write_size <= size) {
+ accounted_size = req->write_size;
+ __wb_fulfill_request(req);
+ *fulfilled = 1;
+ } else {
+ accounted_size = size;
+ __wb_modify_write_request(req, size);
+ *fulfilled = 0;
+ }
out:
- return accounted_size;
+ return accounted_size;
}
void
-wb_fulfill_short_write (wb_request_t *head, int size)
+wb_fulfill_short_write(wb_request_t *head, int size)
{
- wb_inode_t *wb_inode = NULL;
- wb_request_t *req = NULL, *next = NULL;
- int accounted_size = 0;
- gf_boolean_t fulfilled = _gf_false;
-
- if (!head)
- goto out;
+ wb_inode_t *wb_inode = NULL;
+ wb_request_t *req = NULL, *next = NULL;
+ int accounted_size = 0;
+ gf_boolean_t fulfilled = _gf_false;
- wb_inode = head->wb_inode;
+ if (!head)
+ goto out;
- req = head;
-
- LOCK (&wb_inode->lock);
- {
- /* hold a reference to head so that __wb_fulfill_short_write
- * won't free it. We need head for a cleaner list traversal as
- * list_for_each_entry_safe doesn't iterate over "head" member.
- * So, if we pass "next->winds" as head to list_for_each_entry,
- * "next" is skipped. For a simpler logic we need to traverse
- * the list in the order. So, we start traversal from
- * "head->winds" and hence we want head to be alive.
- */
- __wb_request_ref (head);
+ wb_inode = head->wb_inode;
- next = list_entry (head->winds.next, wb_request_t, winds);
+ req = head;
- accounted_size = __wb_fulfill_short_write (head, size,
- &fulfilled);
+ LOCK(&wb_inode->lock);
+ {
+ /* hold a reference to head so that __wb_fulfill_short_write
+ * won't free it. We need head for a cleaner list traversal as
+ * list_for_each_entry_safe doesn't iterate over "head" member.
+ * So, if we pass "next->winds" as head to list_for_each_entry,
+ * "next" is skipped. For a simpler logic we need to traverse
+ * the list in the order. So, we start traversal from
+ * "head->winds" and hence we want head to be alive.
+ */
+ __wb_request_ref(head);
- size -= accounted_size;
+ next = list_entry(head->winds.next, wb_request_t, winds);
- if (size == 0) {
- if (fulfilled && (next != head))
- req = next;
+ accounted_size = __wb_fulfill_short_write(head, size, &fulfilled);
- goto done;
- }
+ size -= accounted_size;
- list_for_each_entry_safe (req, next, &head->winds, winds) {
- accounted_size = __wb_fulfill_short_write (req, size,
- &fulfilled);
- size -= accounted_size;
+ if (size == 0) {
+ if (fulfilled && (next != head))
+ req = next;
- if (size == 0) {
- if (fulfilled && (next != head))
- req = next;
- break;
- }
+ goto done;
+ }
- }
-done:
- __wb_request_unref (head);
+ list_for_each_entry_safe(req, next, &head->winds, winds)
+ {
+ accounted_size = __wb_fulfill_short_write(req, size, &fulfilled);
+ size -= accounted_size;
+
+ if (size == 0) {
+ if (fulfilled && (next != head))
+ req = next;
+ break;
+ }
}
- UNLOCK (&wb_inode->lock);
+ done:
+ __wb_request_unref(head);
+ }
+ UNLOCK(&wb_inode->lock);
- wb_add_head_for_retry (req);
+ wb_add_head_for_retry(req);
out:
- return;
+ return;
}
int
-wb_fulfill_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
-{
- wb_inode_t *wb_inode = NULL;
- wb_request_t *head = NULL;
-
- head = frame->local;
- frame->local = NULL;
-
- wb_inode = head->wb_inode;
-
- /* There could be a readdirp session in progress. Since wb_fulfill_cbk
- * can potentially remove a request from liability queue,
- * wb_readdirp_cbk will miss writes on this inode (as it invalidates
- * stats only if liability queue is not empty) and hence mark inode
- * for invalidation of stats in readdirp response. Specifically this
- * code fixes the following race mentioned in wb_readdirp_cbk:
- */
-
- /* <removed comment from wb_readdirp_cbk>
- * We cannot guarantee integrity of entry->d_stat as there are cached
- * writes. The stat is most likely stale as it doesn't account the
- * cached writes. However, checking for non-empty liability list here is
- * not a fool-proof solution as there can be races like,
- * 1. readdirp is successful on posix
- * 2. sync of cached write is successful on posix
- * 3. write-behind received sync response and removed the request from
- * liability queue
- * 4. readdirp response is processed at write-behind
- *
- * In the above scenario, stat for the file is sent back in readdirp
- * response but it is stale.
- * </comment> */
- wb_set_invalidate (wb_inode, 1);
-
- if (op_ret == -1) {
- wb_fulfill_err (head, op_errno);
- } else if (op_ret < head->total_size) {
- wb_fulfill_short_write (head, op_ret);
- } else {
- wb_head_done (head);
- }
-
- wb_process_queue (wb_inode);
-
- STACK_DESTROY (frame->root);
-
- return 0;
-}
-
-
-#define WB_IOV_LOAD(vec, cnt, req, head) do { \
- memcpy (&vec[cnt], req->stub->args.vector, \
- (req->stub->args.count * sizeof(vec[0]))); \
- cnt += req->stub->args.count; \
- head->total_size += req->write_size; \
- } while (0)
+wb_fulfill_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
+{
+ wb_inode_t *wb_inode = NULL;
+ wb_request_t *head = NULL;
+
+ head = frame->local;
+ frame->local = NULL;
+
+ wb_inode = head->wb_inode;
+
+ /* There could be a readdirp session in progress. Since wb_fulfill_cbk
+ * can potentially remove a request from liability queue,
+ * wb_readdirp_cbk will miss writes on this inode (as it invalidates
+ * stats only if liability queue is not empty) and hence mark inode
+ * for invalidation of stats in readdirp response. Specifically this
+ * code fixes the following race mentioned in wb_readdirp_cbk:
+ */
+
+ /* <removed comment from wb_readdirp_cbk>
+ * We cannot guarantee integrity of entry->d_stat as there are cached
+ * writes. The stat is most likely stale as it doesn't account the
+ * cached writes. However, checking for non-empty liability list here is
+ * not a fool-proof solution as there can be races like,
+ * 1. readdirp is successful on posix
+ * 2. sync of cached write is successful on posix
+ * 3. write-behind received sync response and removed the request from
+ * liability queue
+ * 4. readdirp response is processed at write-behind
+ *
+ * In the above scenario, stat for the file is sent back in readdirp
+ * response but it is stale.
+ * </comment> */
+ wb_set_invalidate(wb_inode, 1);
+
+ if (op_ret == -1) {
+ wb_fulfill_err(head, op_errno);
+ } else if (op_ret < head->total_size) {
+ wb_fulfill_short_write(head, op_ret);
+ } else {
+ wb_head_done(head);
+ }
+
+ wb_process_queue(wb_inode);
+
+ STACK_DESTROY(frame->root);
+
+ return 0;
+}
+
+#define WB_IOV_LOAD(vec, cnt, req, head) \
+ do { \
+ memcpy(&vec[cnt], req->stub->args.vector, \
+ (req->stub->args.count * sizeof(vec[0]))); \
+ cnt += req->stub->args.count; \
+ head->total_size += req->write_size; \
+ } while (0)
int
-wb_fulfill_head (wb_inode_t *wb_inode, wb_request_t *head)
+wb_fulfill_head(wb_inode_t *wb_inode, wb_request_t *head)
{
- struct iovec vector[MAX_VECTOR_COUNT];
- int count = 0;
- wb_request_t *req = NULL;
- call_frame_t *frame = NULL;
+ struct iovec vector[MAX_VECTOR_COUNT];
+ int count = 0;
+ wb_request_t *req = NULL;
+ call_frame_t *frame = NULL;
- /* make sure head->total_size is updated before we run into any
- * errors
- */
+ /* make sure head->total_size is updated before we run into any
+ * errors
+ */
- WB_IOV_LOAD (vector, count, head, head);
+ WB_IOV_LOAD(vector, count, head, head);
- list_for_each_entry (req, &head->winds, winds) {
- WB_IOV_LOAD (vector, count, req, head);
+ list_for_each_entry(req, &head->winds, winds)
+ {
+ WB_IOV_LOAD(vector, count, req, head);
- if (iobref_merge (head->stub->args.iobref,
- req->stub->args.iobref))
- goto err;
- }
+ if (iobref_merge(head->stub->args.iobref, req->stub->args.iobref))
+ goto err;
+ }
- frame = create_frame (wb_inode->this, wb_inode->this->ctx->pool);
- if (!frame)
- goto err;
+ frame = create_frame(wb_inode->this, wb_inode->this->ctx->pool);
+ if (!frame)
+ goto err;
- frame->root->lk_owner = head->lk_owner;
- frame->root->pid = head->client_pid;
- frame->local = head;
+ frame->root->lk_owner = head->lk_owner;
+ frame->root->pid = head->client_pid;
+ frame->local = head;
- LOCK (&wb_inode->lock);
- {
- wb_inode->transit += head->total_size;
- }
- UNLOCK (&wb_inode->lock);
+ LOCK(&wb_inode->lock);
+ {
+ wb_inode->transit += head->total_size;
+ }
+ UNLOCK(&wb_inode->lock);
- STACK_WIND (frame, wb_fulfill_cbk, FIRST_CHILD (frame->this),
- FIRST_CHILD (frame->this)->fops->writev,
- head->fd, vector, count,
- head->stub->args.offset,
- head->stub->args.flags,
- head->stub->args.iobref, NULL);
+ STACK_WIND(frame, wb_fulfill_cbk, FIRST_CHILD(frame->this),
+ FIRST_CHILD(frame->this)->fops->writev, head->fd, vector, count,
+ head->stub->args.offset, head->stub->args.flags,
+ head->stub->args.iobref, NULL);
- return 0;
+ return 0;
err:
- /* frame creation failure */
- wb_fulfill_err (head, ENOMEM);
+ /* frame creation failure */
+ wb_fulfill_err(head, ENOMEM);
- return ENOMEM;
+ return ENOMEM;
}
-
-#define NEXT_HEAD(head, req) do { \
- if (head) \
- ret |= wb_fulfill_head (wb_inode, head); \
- head = req; \
- expected_offset = req->stub->args.offset + \
- req->write_size; \
- curr_aggregate = 0; \
- vector_count = 0; \
- } while (0)
-
+#define NEXT_HEAD(head, req) \
+ do { \
+ if (head) \
+ ret |= wb_fulfill_head(wb_inode, head); \
+ head = req; \
+ expected_offset = req->stub->args.offset + req->write_size; \
+ curr_aggregate = 0; \
+ vector_count = 0; \
+ } while (0)
int
-wb_fulfill (wb_inode_t *wb_inode, list_head_t *liabilities)
-{
- wb_request_t *req = NULL;
- wb_request_t *head = NULL;
- wb_request_t *tmp = NULL;
- wb_conf_t *conf = NULL;
- off_t expected_offset = 0;
- size_t curr_aggregate = 0;
- size_t vector_count = 0;
- int ret = 0;
-
- conf = wb_inode->this->private;
-
- list_for_each_entry_safe (req, tmp, liabilities, winds) {
- list_del_init (&req->winds);
-
- if (!head) {
- NEXT_HEAD (head, req);
- continue;
- }
+wb_fulfill(wb_inode_t *wb_inode, list_head_t *liabilities)
+{
+ wb_request_t *req = NULL;
+ wb_request_t *head = NULL;
+ wb_request_t *tmp = NULL;
+ wb_conf_t *conf = NULL;
+ off_t expected_offset = 0;
+ size_t curr_aggregate = 0;
+ size_t vector_count = 0;
+ int ret = 0;
+
+ conf = wb_inode->this->private;
+
+ list_for_each_entry_safe(req, tmp, liabilities, winds)
+ {
+ list_del_init(&req->winds);
+
+ if (!head) {
+ NEXT_HEAD(head, req);
+ continue;
+ }
- if (req->fd != head->fd) {
- NEXT_HEAD (head, req);
- continue;
- }
+ if (req->fd != head->fd) {
+ NEXT_HEAD(head, req);
+ continue;
+ }
- if (!is_same_lkowner (&req->lk_owner, &head->lk_owner)) {
- NEXT_HEAD (head, req);
- continue;
- }
+ if (!is_same_lkowner(&req->lk_owner, &head->lk_owner)) {
+ NEXT_HEAD(head, req);
+ continue;
+ }
- if (expected_offset != req->stub->args.offset) {
- NEXT_HEAD (head, req);
- continue;
- }
+ if (expected_offset != req->stub->args.offset) {
+ NEXT_HEAD(head, req);
+ continue;
+ }
- if ((curr_aggregate + req->write_size) > conf->aggregate_size) {
- NEXT_HEAD (head, req);
- continue;
- }
+ if ((curr_aggregate + req->write_size) > conf->aggregate_size) {
+ NEXT_HEAD(head, req);
+ continue;
+ }
- if (vector_count + req->stub->args.count >
- MAX_VECTOR_COUNT) {
- NEXT_HEAD (head, req);
- continue;
- }
+ if (vector_count + req->stub->args.count > MAX_VECTOR_COUNT) {
+ NEXT_HEAD(head, req);
+ continue;
+ }
- list_add_tail (&req->winds, &head->winds);
- curr_aggregate += req->write_size;
- vector_count += req->stub->args.count;
- }
+ list_add_tail(&req->winds, &head->winds);
+ curr_aggregate += req->write_size;
+ vector_count += req->stub->args.count;
+ }
- if (head)
- ret |= wb_fulfill_head (wb_inode, head);
+ if (head)
+ ret |= wb_fulfill_head(wb_inode, head);
- return ret;
+ return ret;
}
-
void
-wb_do_unwinds (wb_inode_t *wb_inode, list_head_t *lies)
+wb_do_unwinds(wb_inode_t *wb_inode, list_head_t *lies)
{
- wb_request_t *req = NULL;
- wb_request_t *tmp = NULL;
- call_frame_t *frame = NULL;
- struct iatt buf = {0, };
+ wb_request_t *req = NULL;
+ wb_request_t *tmp = NULL;
+ call_frame_t *frame = NULL;
+ struct iatt buf = {
+ 0,
+ };
- list_for_each_entry_safe (req, tmp, lies, unwinds) {
- frame = req->stub->frame;
+ list_for_each_entry_safe(req, tmp, lies, unwinds)
+ {
+ frame = req->stub->frame;
- STACK_UNWIND_STRICT (writev, frame, req->op_ret, req->op_errno,
- &buf, &buf, NULL); /* :O */
- req->stub->frame = NULL;
+ STACK_UNWIND_STRICT(writev, frame, req->op_ret, req->op_errno, &buf,
+ &buf, NULL); /* :O */
+ req->stub->frame = NULL;
- list_del_init (&req->unwinds);
- wb_request_unref (req);
- }
+ list_del_init(&req->unwinds);
+ wb_request_unref(req);
+ }
- return;
+ return;
}
-
void
-__wb_pick_unwinds (wb_inode_t *wb_inode, list_head_t *lies)
-{
- wb_request_t *req = NULL;
- wb_request_t *tmp = NULL;
- char gfid[64] = {0,};
-
- list_for_each_entry_safe (req, tmp, &wb_inode->temptation, lie) {
- if (!req->ordering.fulfilled &&
- wb_inode->window_current > wb_inode->window_conf)
- continue;
-
- list_del_init (&req->lie);
- list_move_tail (&req->unwinds, lies);
-
- wb_inode->window_current += req->orig_size;
-
- if (!req->ordering.fulfilled) {
- /* burden increased */
- list_add_tail (&req->lie, &wb_inode->liability);
-
- req->ordering.lied = 1;
-
- wb_inode->gen++;
-
- uuid_utoa_r (req->gfid, gfid);
- gf_msg_debug (wb_inode->this->name, 0,
- "(unique=%"PRIu64", fop=%s, gfid=%s, "
- "gen=%"PRIu64"): added req to liability "
- "queue. inode-generation-number=%"PRIu64,
- req->stub->frame->root->unique,
- gf_fop_list[req->fop], gfid, req->gen,
- wb_inode->gen);
- }
- }
+__wb_pick_unwinds(wb_inode_t *wb_inode, list_head_t *lies)
+{
+ wb_request_t *req = NULL;
+ wb_request_t *tmp = NULL;
+ char gfid[64] = {
+ 0,
+ };
+
+ list_for_each_entry_safe(req, tmp, &wb_inode->temptation, lie)
+ {
+ if (!req->ordering.fulfilled &&
+ wb_inode->window_current > wb_inode->window_conf)
+ continue;
+
+ list_del_init(&req->lie);
+ list_move_tail(&req->unwinds, lies);
+
+ wb_inode->window_current += req->orig_size;
+
+ if (!req->ordering.fulfilled) {
+ /* burden increased */
+ list_add_tail(&req->lie, &wb_inode->liability);
+
+ req->ordering.lied = 1;
+
+ wb_inode->gen++;
+
+ uuid_utoa_r(req->gfid, gfid);
+ gf_msg_debug(wb_inode->this->name, 0,
+ "(unique=%" PRIu64
+ ", fop=%s, gfid=%s, "
+ "gen=%" PRIu64
+ "): added req to liability "
+ "queue. inode-generation-number=%" PRIu64,
+ req->stub->frame->root->unique, gf_fop_list[req->fop],
+ gfid, req->gen, wb_inode->gen);
+ }
+ }
- return;
+ return;
}
-
int
-__wb_collapse_small_writes (wb_conf_t *conf, wb_request_t *holder, wb_request_t *req)
-{
- char *ptr = NULL;
- struct iobuf *iobuf = NULL;
- struct iobref *iobref = NULL;
- int ret = -1;
- ssize_t required_size = 0;
- size_t holder_len = 0;
- size_t req_len = 0;
-
- if (!holder->iobref) {
- holder_len = iov_length (holder->stub->args.vector,
- holder->stub->args.count);
- req_len = iov_length (req->stub->args.vector,
- req->stub->args.count);
-
- required_size = max ((conf->page_size),
- (holder_len + req_len));
- iobuf = iobuf_get2 (req->wb_inode->this->ctx->iobuf_pool,
- required_size);
- if (iobuf == NULL) {
- goto out;
- }
+__wb_collapse_small_writes(wb_conf_t *conf, wb_request_t *holder,
+ wb_request_t *req)
+{
+ char *ptr = NULL;
+ struct iobuf *iobuf = NULL;
+ struct iobref *iobref = NULL;
+ int ret = -1;
+ ssize_t required_size = 0;
+ size_t holder_len = 0;
+ size_t req_len = 0;
+
+ if (!holder->iobref) {
+ holder_len = iov_length(holder->stub->args.vector,
+ holder->stub->args.count);
+ req_len = iov_length(req->stub->args.vector, req->stub->args.count);
+
+ required_size = max((conf->page_size), (holder_len + req_len));
+ iobuf = iobuf_get2(req->wb_inode->this->ctx->iobuf_pool, required_size);
+ if (iobuf == NULL) {
+ goto out;
+ }
- iobref = iobref_new ();
- if (iobref == NULL) {
- iobuf_unref (iobuf);
- goto out;
- }
+ iobref = iobref_new();
+ if (iobref == NULL) {
+ iobuf_unref(iobuf);
+ goto out;
+ }
- ret = iobref_add (iobref, iobuf);
- if (ret != 0) {
- gf_msg (req->wb_inode->this->name, GF_LOG_WARNING,
- -ret, WRITE_BEHIND_MSG_INVALID_ARGUMENT,
- "cannot add iobuf (%p) into iobref (%p)",
- iobuf, iobref);
- iobuf_unref (iobuf);
- iobref_unref (iobref);
- goto out;
- }
+ ret = iobref_add(iobref, iobuf);
+ if (ret != 0) {
+ gf_msg(req->wb_inode->this->name, GF_LOG_WARNING, -ret,
+ WRITE_BEHIND_MSG_INVALID_ARGUMENT,
+ "cannot add iobuf (%p) into iobref (%p)", iobuf, iobref);
+ iobuf_unref(iobuf);
+ iobref_unref(iobref);
+ goto out;
+ }
- iov_unload (iobuf->ptr, holder->stub->args.vector,
- holder->stub->args.count);
- holder->stub->args.vector[0].iov_base = iobuf->ptr;
- holder->stub->args.count = 1;
+ iov_unload(iobuf->ptr, holder->stub->args.vector,
+ holder->stub->args.count);
+ holder->stub->args.vector[0].iov_base = iobuf->ptr;
+ holder->stub->args.count = 1;
- iobref_unref (holder->stub->args.iobref);
- holder->stub->args.iobref = iobref;
+ iobref_unref(holder->stub->args.iobref);
+ holder->stub->args.iobref = iobref;
- iobuf_unref (iobuf);
+ iobuf_unref(iobuf);
- holder->iobref = iobref_ref (iobref);
- }
+ holder->iobref = iobref_ref(iobref);
+ }
- ptr = holder->stub->args.vector[0].iov_base + holder->write_size;
+ ptr = holder->stub->args.vector[0].iov_base + holder->write_size;
- iov_unload (ptr, req->stub->args.vector,
- req->stub->args.count);
+ iov_unload(ptr, req->stub->args.vector, req->stub->args.count);
- holder->stub->args.vector[0].iov_len += req->write_size;
- holder->write_size += req->write_size;
- holder->ordering.size += req->write_size;
+ holder->stub->args.vector[0].iov_len += req->write_size;
+ holder->write_size += req->write_size;
+ holder->ordering.size += req->write_size;
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
void
-__wb_preprocess_winds (wb_inode_t *wb_inode)
-{
- off_t offset_expected = 0;
- ssize_t space_left = 0;
- wb_request_t *req = NULL;
- wb_request_t *tmp = NULL;
- wb_request_t *holder = NULL;
- wb_conf_t *conf = NULL;
- int ret = 0;
- ssize_t page_size = 0;
- char gfid[64] = {0, };
-
- /* With asynchronous IO from a VM guest (as a file), there
- can be two sequential writes happening in two regions
- of the file. But individual (broken down) IO requests
- can arrive interleaved.
-
- TODO: cycle for each such sequence sifting
- through the interleaved ops
- */
-
- conf = wb_inode->this->private;
- page_size = conf->page_size;
-
- list_for_each_entry_safe (req, tmp, &wb_inode->todo, todo) {
- if (wb_inode->dontsync && req->ordering.lied) {
- /* sync has failed. Don't pick lies _again_ for winding
- * as winding these lies again will trigger an infinite
- * recursion of wb_process_queue being called from a
- * failed fulfill. However, pick non-lied requests for
- * winding so that application won't block indefinitely
- * waiting for write result.
- */
-
- uuid_utoa_r (req->gfid, gfid);
- gf_msg_debug (wb_inode->this->name, 0,
- "(unique=%"PRIu64", fop=%s, gfid=%s, "
- "gen=%"PRIu64"): not setting ordering.go"
- "as dontsync is set", req->unique,
- gf_fop_list[req->fop], gfid, req->gen);
-
- continue;
- }
-
- if (!req->ordering.tempted) {
- if (holder) {
- if (wb_requests_conflict (holder, req))
- /* do not hold on write if a
- dependent write is in queue */
- holder->ordering.go = 1;
- }
- /* collapse only non-sync writes */
- continue;
- } else if (!holder) {
- /* holder is always a non-sync write */
- holder = req;
- continue;
- }
-
- offset_expected = holder->stub->args.offset
- + holder->write_size;
-
- if (req->stub->args.offset != offset_expected) {
- holder->ordering.go = 1;
- holder = req;
- continue;
- }
-
- if (!is_same_lkowner (&req->lk_owner, &holder->lk_owner)) {
- holder->ordering.go = 1;
- holder = req;
- continue;
- }
-
- if (req->fd != holder->fd) {
- holder->ordering.go = 1;
- holder = req;
- continue;
- }
+__wb_preprocess_winds(wb_inode_t *wb_inode)
+{
+ off_t offset_expected = 0;
+ ssize_t space_left = 0;
+ wb_request_t *req = NULL;
+ wb_request_t *tmp = NULL;
+ wb_request_t *holder = NULL;
+ wb_conf_t *conf = NULL;
+ int ret = 0;
+ ssize_t page_size = 0;
+ char gfid[64] = {
+ 0,
+ };
+
+ /* With asynchronous IO from a VM guest (as a file), there
+ can be two sequential writes happening in two regions
+ of the file. But individual (broken down) IO requests
+ can arrive interleaved.
+
+ TODO: cycle for each such sequence sifting
+ through the interleaved ops
+ */
+
+ conf = wb_inode->this->private;
+ page_size = conf->page_size;
+
+ list_for_each_entry_safe(req, tmp, &wb_inode->todo, todo)
+ {
+ if (wb_inode->dontsync && req->ordering.lied) {
+ /* sync has failed. Don't pick lies _again_ for winding
+ * as winding these lies again will trigger an infinite
+ * recursion of wb_process_queue being called from a
+ * failed fulfill. However, pick non-lied requests for
+ * winding so that application won't block indefinitely
+ * waiting for write result.
+ */
+
+ uuid_utoa_r(req->gfid, gfid);
+ gf_msg_debug(wb_inode->this->name, 0,
+ "(unique=%" PRIu64
+ ", fop=%s, gfid=%s, "
+ "gen=%" PRIu64
+ "): not setting ordering.go"
+ "as dontsync is set",
+ req->unique, gf_fop_list[req->fop], gfid, req->gen);
+
+ continue;
+ }
- space_left = page_size - holder->write_size;
+ if (!req->ordering.tempted) {
+ if (holder) {
+ if (wb_requests_conflict(holder, req))
+ /* do not hold on write if a
+ dependent write is in queue */
+ holder->ordering.go = 1;
+ }
+ /* collapse only non-sync writes */
+ continue;
+ } else if (!holder) {
+ /* holder is always a non-sync write */
+ holder = req;
+ continue;
+ }
- if (space_left < req->write_size) {
- holder->ordering.go = 1;
- holder = req;
- continue;
- }
+ offset_expected = holder->stub->args.offset + holder->write_size;
- ret = __wb_collapse_small_writes (conf, holder, req);
- if (ret)
- continue;
+ if (req->stub->args.offset != offset_expected) {
+ holder->ordering.go = 1;
+ holder = req;
+ continue;
+ }
- /* collapsed request is as good as wound
- (from its p.o.v)
- */
- list_del_init (&req->todo);
- __wb_fulfill_request (req);
+ if (!is_same_lkowner(&req->lk_owner, &holder->lk_owner)) {
+ holder->ordering.go = 1;
+ holder = req;
+ continue;
+ }
- /* Only the last @holder in queue which
+ if (req->fd != holder->fd) {
+ holder->ordering.go = 1;
+ holder = req;
+ continue;
+ }
- - does not have any non-buffered-writes following it
- - has not yet filled its capacity
+ space_left = page_size - holder->write_size;
- does not get its 'go' set, in anticipation of the arrival
- of consecutive smaller writes.
- */
+ if (space_left < req->write_size) {
+ holder->ordering.go = 1;
+ holder = req;
+ continue;
}
- /* but if trickling writes are enabled, then do not hold back
- writes if there are no outstanding requests
- */
+ ret = __wb_collapse_small_writes(conf, holder, req);
+ if (ret)
+ continue;
- if (conf->trickling_writes && !wb_inode->transit && holder)
- holder->ordering.go = 1;
+ /* collapsed request is as good as wound
+ (from its p.o.v)
+ */
+ list_del_init(&req->todo);
+ __wb_fulfill_request(req);
+
+ /* Only the last @holder in queue which
- if (wb_inode->dontsync > 0)
- wb_inode->dontsync--;
+ - does not have any non-buffered-writes following it
+ - has not yet filled its capacity
- return;
+ does not get its 'go' set, in anticipation of the arrival
+ of consecutive smaller writes.
+ */
+ }
+
+ /* but if trickling writes are enabled, then do not hold back
+ writes if there are no outstanding requests
+ */
+
+ if (conf->trickling_writes && !wb_inode->transit && holder)
+ holder->ordering.go = 1;
+
+ if (wb_inode->dontsync > 0)
+ wb_inode->dontsync--;
+
+ return;
}
int
-__wb_handle_failed_conflict (wb_request_t *req, wb_request_t *conflict,
- list_head_t *tasks)
-{
- wb_conf_t *conf = NULL;
- char gfid[64] = {0, };
-
- conf = req->wb_inode->this->private;
-
- uuid_utoa_r (req->gfid, gfid);
-
- if ((req->stub->fop != GF_FOP_FLUSH)
- && ((req->stub->fop != GF_FOP_FSYNC) || conf->resync_after_fsync)) {
- if (!req->ordering.lied && list_empty (&conflict->wip)) {
- /* If request itself is in liability queue,
- * 1. We cannot unwind as the response has already been
- * sent.
- * 2. We cannot wind till conflict clears up.
- * 3. So, skip the request for now.
- * 4. Otherwise, resume (unwind) it with error.
- */
- req->op_ret = -1;
- req->op_errno = conflict->op_errno;
-
- list_del_init (&req->todo);
- list_add_tail (&req->winds, tasks);
-
- gf_msg_debug (req->wb_inode->this->name, 0,
- "(unique=%"PRIu64", fop=%s, gfid=%s, "
- "gen=%"PRIu64"): A conflicting write "
- "request in liability queue has failed "
- "to sync (error = \"%s\"), "
- "unwinding this request as a failure",
- req->unique, gf_fop_list[req->fop], gfid,
- req->gen, strerror (req->op_errno));
-
- if (req->ordering.tempted) {
- /* make sure that it won't be unwound in
- * wb_do_unwinds too. Otherwise there'll be
- * a double wind.
- */
- list_del_init (&req->lie);
-
- gf_msg_debug (req->wb_inode->this->name, 0,
- "(unique=%"PRIu64", fop=%s, "
- "gfid=%s, gen=%"PRIu64"): "
- "removed from liability queue",
- req->unique,
- gf_fop_list[req->fop], gfid,
- req->gen);
-
- __wb_fulfill_request (req);
- }
- }
- } else {
- gf_msg_debug (req->wb_inode->this->name, 0,
- "(unique=%"PRIu64", fop=%s, gfid=%s, "
- "gen=%"PRIu64"): A conflicting write request "
- "in liability queue has failed to sync "
- "(error = \"%s\"). This is an "
- "FSYNC/FLUSH and we need to maintain ordering "
- "guarantees with other writes in TODO queue. "
- "Hence doing nothing now", req->unique,
- gf_fop_list[req->fop], gfid, req->gen,
- strerror (conflict->op_errno));
-
- /* flush and fsync (without conf->resync_after_fsync) act as
- barriers. We cannot unwind them out of
- order, when there are earlier generation writes just because
- there is a conflicting liability with an error. So, wait for
- our turn till there are no conflicting liabilities.
-
- This situation can arise when there liabilities spread across
- multiple generations. For eg., consider two writes with
- following characterstics:
-
- 1. they belong to different generations gen1, gen2 and
- (gen1 > gen2).
- 2. they overlap.
- 3. both are liabilities.
- 4. gen1 write was attempted to sync, but the attempt failed.
- 5. there was no attempt to sync gen2 write yet.
- 6. A flush (as part of close) is issued and gets a gen no
- gen3.
-
- In the above scenario, if flush is unwound without waiting
- for gen1 and gen2 writes either to be successfully synced or
- purged, we end up with these two writes in wb_inode->todo
- list forever as there will be no attempt to process the queue
- as flush is the last operation.
- */
+__wb_handle_failed_conflict(wb_request_t *req, wb_request_t *conflict,
+ list_head_t *tasks)
+{
+ wb_conf_t *conf = NULL;
+ char gfid[64] = {
+ 0,
+ };
+
+ conf = req->wb_inode->this->private;
+
+ uuid_utoa_r(req->gfid, gfid);
+
+ if ((req->stub->fop != GF_FOP_FLUSH) &&
+ ((req->stub->fop != GF_FOP_FSYNC) || conf->resync_after_fsync)) {
+ if (!req->ordering.lied && list_empty(&conflict->wip)) {
+ /* If request itself is in liability queue,
+ * 1. We cannot unwind as the response has already been
+ * sent.
+ * 2. We cannot wind till conflict clears up.
+ * 3. So, skip the request for now.
+ * 4. Otherwise, resume (unwind) it with error.
+ */
+ req->op_ret = -1;
+ req->op_errno = conflict->op_errno;
+
+ list_del_init(&req->todo);
+ list_add_tail(&req->winds, tasks);
+
+ gf_msg_debug(req->wb_inode->this->name, 0,
+ "(unique=%" PRIu64
+ ", fop=%s, gfid=%s, "
+ "gen=%" PRIu64
+ "): A conflicting write "
+ "request in liability queue has failed "
+ "to sync (error = \"%s\"), "
+ "unwinding this request as a failure",
+ req->unique, gf_fop_list[req->fop], gfid, req->gen,
+ strerror(req->op_errno));
+
+ if (req->ordering.tempted) {
+ /* make sure that it won't be unwound in
+ * wb_do_unwinds too. Otherwise there'll be
+ * a double wind.
+ */
+ list_del_init(&req->lie);
+
+ gf_msg_debug(req->wb_inode->this->name, 0,
+ "(unique=%" PRIu64
+ ", fop=%s, "
+ "gfid=%s, gen=%" PRIu64
+ "): "
+ "removed from liability queue",
+ req->unique, gf_fop_list[req->fop], gfid,
+ req->gen);
+
+ __wb_fulfill_request(req);
+ }
}
+ } else {
+ gf_msg_debug(req->wb_inode->this->name, 0,
+ "(unique=%" PRIu64
+ ", fop=%s, gfid=%s, "
+ "gen=%" PRIu64
+ "): A conflicting write request "
+ "in liability queue has failed to sync "
+ "(error = \"%s\"). This is an "
+ "FSYNC/FLUSH and we need to maintain ordering "
+ "guarantees with other writes in TODO queue. "
+ "Hence doing nothing now",
+ req->unique, gf_fop_list[req->fop], gfid, req->gen,
+ strerror(conflict->op_errno));
+
+ /* flush and fsync (without conf->resync_after_fsync) act as
+ barriers. We cannot unwind them out of
+ order, when there are earlier generation writes just because
+ there is a conflicting liability with an error. So, wait for
+ our turn till there are no conflicting liabilities.
+
+ This situation can arise when there liabilities spread across
+ multiple generations. For eg., consider two writes with
+ following characterstics:
+
+ 1. they belong to different generations gen1, gen2 and
+ (gen1 > gen2).
+ 2. they overlap.
+ 3. both are liabilities.
+ 4. gen1 write was attempted to sync, but the attempt failed.
+ 5. there was no attempt to sync gen2 write yet.
+ 6. A flush (as part of close) is issued and gets a gen no
+ gen3.
+
+ In the above scenario, if flush is unwound without waiting
+ for gen1 and gen2 writes either to be successfully synced or
+ purged, we end up with these two writes in wb_inode->todo
+ list forever as there will be no attempt to process the queue
+ as flush is the last operation.
+ */
+ }
- return 0;
+ return 0;
}
-
int
-__wb_pick_winds (wb_inode_t *wb_inode, list_head_t *tasks,
- list_head_t *liabilities)
-{
- wb_request_t *req = NULL;
- wb_request_t *tmp = NULL;
- wb_request_t *conflict = NULL;
- char req_gfid[64] = {0, }, conflict_gfid[64] = {0, };
-
- list_for_each_entry_safe (req, tmp, &wb_inode->todo, todo) {
- uuid_utoa_r (req->gfid, req_gfid);
-
- conflict = wb_liability_has_conflict (wb_inode, req);
- if (conflict) {
- uuid_utoa_r (conflict->gfid, conflict_gfid);
-
- gf_msg_debug (wb_inode->this->name, 0,
- "Not winding request due to a "
- "conflicting write in liability queue. "
- "REQ: unique=%"PRIu64", fop=%s, "
- "gen=%"PRIu64", gfid=%s. "
- "CONFLICT: unique=%"PRIu64", fop=%s, "
- "gen=%"PRIu64", gfid=%s, "
- "conflicts-sync-failed?=%s, "
- "conflicts-error=%s",
- req->unique, gf_fop_list[req->fop],
- req->gen, req_gfid,
- conflict->unique,
- gf_fop_list[conflict->fop], conflict->gen,
- conflict_gfid,
- (conflict->op_ret == 1) ? "yes" : "no",
- strerror (conflict->op_errno));
-
- if (conflict->op_ret == -1) {
- /* There is a conflicting liability which failed
- * to sync in previous attempts, resume the req
- * and fail, unless its an fsync/flush.
- */
-
- __wb_handle_failed_conflict (req, conflict,
- tasks);
- } else {
- /* There is a conflicting liability which was
- * not attempted to sync even once. Wait till
- * at least one attempt to sync is made.
- */
- }
-
- continue;
- }
+__wb_pick_winds(wb_inode_t *wb_inode, list_head_t *tasks,
+ list_head_t *liabilities)
+{
+ wb_request_t *req = NULL;
+ wb_request_t *tmp = NULL;
+ wb_request_t *conflict = NULL;
+ char req_gfid[64] =
+ {
+ 0,
+ },
+ conflict_gfid[64] = {
+ 0,
+ };
+
+ list_for_each_entry_safe(req, tmp, &wb_inode->todo, todo)
+ {
+ uuid_utoa_r(req->gfid, req_gfid);
+
+ conflict = wb_liability_has_conflict(wb_inode, req);
+ if (conflict) {
+ uuid_utoa_r(conflict->gfid, conflict_gfid);
+
+ gf_msg_debug(wb_inode->this->name, 0,
+ "Not winding request due to a "
+ "conflicting write in liability queue. "
+ "REQ: unique=%" PRIu64
+ ", fop=%s, "
+ "gen=%" PRIu64
+ ", gfid=%s. "
+ "CONFLICT: unique=%" PRIu64
+ ", fop=%s, "
+ "gen=%" PRIu64
+ ", gfid=%s, "
+ "conflicts-sync-failed?=%s, "
+ "conflicts-error=%s",
+ req->unique, gf_fop_list[req->fop], req->gen, req_gfid,
+ conflict->unique, gf_fop_list[conflict->fop],
+ conflict->gen, conflict_gfid,
+ (conflict->op_ret == 1) ? "yes" : "no",
+ strerror(conflict->op_errno));
+
+ if (conflict->op_ret == -1) {
+ /* There is a conflicting liability which failed
+ * to sync in previous attempts, resume the req
+ * and fail, unless its an fsync/flush.
+ */
- if (req->ordering.tempted && !req->ordering.go) {
- /* wait some more */
- gf_msg_debug (wb_inode->this->name, 0,
- "(unique=%"PRIu64", fop=%s, gen=%"PRIu64
- ", gfid=%s): ordering.go is not set, "
- "hence not winding", req->unique,
- gf_fop_list[req->fop], req->gen,
- req_gfid);
- continue;
- }
+ __wb_handle_failed_conflict(req, conflict, tasks);
+ } else {
+ /* There is a conflicting liability which was
+ * not attempted to sync even once. Wait till
+ * at least one attempt to sync is made.
+ */
+ }
- if (req->stub->fop == GF_FOP_WRITE) {
- conflict = wb_wip_has_conflict (wb_inode, req);
-
- if (conflict) {
- uuid_utoa_r (conflict->gfid, conflict_gfid);
-
- gf_msg_debug (wb_inode->this->name, 0,
- "Not winding write request as "
- "a conflicting write is being "
- "synced to backend. "
- "REQ: unique=%"PRIu64" fop=%s,"
- " gen=%"PRIu64", gfid=%s. "
- "CONFLICT: unique=%"PRIu64" "
- "fop=%s, gen=%"PRIu64", "
- "gfid=%s",
- req->unique,
- gf_fop_list[req->fop],
- req->gen, req_gfid,
- conflict->unique,
- gf_fop_list[conflict->fop],
- conflict->gen, conflict_gfid);
- continue;
- }
-
- list_add_tail (&req->wip, &wb_inode->wip);
- req->wind_count++;
-
- if (!req->ordering.tempted)
- /* unrefed in wb_writev_cbk */
- req->stub->frame->local =
- __wb_request_ref (req);
- }
-
- gf_msg_debug (wb_inode->this->name, 0,
- "(unique=%"PRIu64", fop=%s, gfid=%s, "
- "gen=%"PRIu64"): picking the request for "
- "winding", req->unique, gf_fop_list[req->fop],
- req_gfid, req->gen);
-
- list_del_init (&req->todo);
-
- if (req->ordering.tempted) {
- list_add_tail (&req->winds, liabilities);
- } else {
- list_add_tail (&req->winds, tasks);
- }
- }
+ continue;
+ }
- return 0;
-}
+ if (req->ordering.tempted && !req->ordering.go) {
+ /* wait some more */
+ gf_msg_debug(wb_inode->this->name, 0,
+ "(unique=%" PRIu64 ", fop=%s, gen=%" PRIu64
+ ", gfid=%s): ordering.go is not set, "
+ "hence not winding",
+ req->unique, gf_fop_list[req->fop], req->gen,
+ req_gfid);
+ continue;
+ }
+ if (req->stub->fop == GF_FOP_WRITE) {
+ conflict = wb_wip_has_conflict(wb_inode, req);
+
+ if (conflict) {
+ uuid_utoa_r(conflict->gfid, conflict_gfid);
+
+ gf_msg_debug(wb_inode->this->name, 0,
+ "Not winding write request as "
+ "a conflicting write is being "
+ "synced to backend. "
+ "REQ: unique=%" PRIu64
+ " fop=%s,"
+ " gen=%" PRIu64
+ ", gfid=%s. "
+ "CONFLICT: unique=%" PRIu64
+ " "
+ "fop=%s, gen=%" PRIu64
+ ", "
+ "gfid=%s",
+ req->unique, gf_fop_list[req->fop], req->gen,
+ req_gfid, conflict->unique,
+ gf_fop_list[conflict->fop], conflict->gen,
+ conflict_gfid);
+ continue;
+ }
+
+ list_add_tail(&req->wip, &wb_inode->wip);
+ req->wind_count++;
+
+ if (!req->ordering.tempted)
+ /* unrefed in wb_writev_cbk */
+ req->stub->frame->local = __wb_request_ref(req);
+ }
-void
-wb_do_winds (wb_inode_t *wb_inode, list_head_t *tasks)
-{
- wb_request_t *req = NULL;
- wb_request_t *tmp = NULL;
+ gf_msg_debug(wb_inode->this->name, 0,
+ "(unique=%" PRIu64
+ ", fop=%s, gfid=%s, "
+ "gen=%" PRIu64
+ "): picking the request for "
+ "winding",
+ req->unique, gf_fop_list[req->fop], req_gfid, req->gen);
- list_for_each_entry_safe (req, tmp, tasks, winds) {
- list_del_init (&req->winds);
+ list_del_init(&req->todo);
- if (req->op_ret == -1) {
- call_unwind_error_keep_stub (req->stub, req->op_ret,
- req->op_errno);
- } else {
- call_resume_keep_stub (req->stub);
- }
+ if (req->ordering.tempted) {
+ list_add_tail(&req->winds, liabilities);
+ } else {
+ list_add_tail(&req->winds, tasks);
+ }
+ }
- wb_request_unref (req);
- }
+ return 0;
}
-
void
-wb_process_queue (wb_inode_t *wb_inode)
+wb_do_winds(wb_inode_t *wb_inode, list_head_t *tasks)
{
- list_head_t tasks = {0, };
- list_head_t lies = {0, };
- list_head_t liabilities = {0, };
- int wind_failure = 0;
+ wb_request_t *req = NULL;
+ wb_request_t *tmp = NULL;
- INIT_LIST_HEAD (&tasks);
- INIT_LIST_HEAD (&lies);
- INIT_LIST_HEAD (&liabilities);
+ list_for_each_entry_safe(req, tmp, tasks, winds)
+ {
+ list_del_init(&req->winds);
- do {
- gf_log_callingfn (wb_inode->this->name, GF_LOG_DEBUG,
- "processing queues");
+ if (req->op_ret == -1) {
+ call_unwind_error_keep_stub(req->stub, req->op_ret, req->op_errno);
+ } else {
+ call_resume_keep_stub(req->stub);
+ }
- LOCK (&wb_inode->lock);
- {
- __wb_preprocess_winds (wb_inode);
+ wb_request_unref(req);
+ }
+}
- __wb_pick_winds (wb_inode, &tasks, &liabilities);
+void
+wb_process_queue(wb_inode_t *wb_inode)
+{
+ list_head_t tasks = {
+ 0,
+ };
+ list_head_t lies = {
+ 0,
+ };
+ list_head_t liabilities = {
+ 0,
+ };
+ int wind_failure = 0;
+
+ INIT_LIST_HEAD(&tasks);
+ INIT_LIST_HEAD(&lies);
+ INIT_LIST_HEAD(&liabilities);
+
+ do {
+ gf_log_callingfn(wb_inode->this->name, GF_LOG_DEBUG,
+ "processing queues");
+
+ LOCK(&wb_inode->lock);
+ {
+ __wb_preprocess_winds(wb_inode);
- __wb_pick_unwinds (wb_inode, &lies);
+ __wb_pick_winds(wb_inode, &tasks, &liabilities);
- }
- UNLOCK (&wb_inode->lock);
+ __wb_pick_unwinds(wb_inode, &lies);
+ }
+ UNLOCK(&wb_inode->lock);
- wb_do_unwinds (wb_inode, &lies);
+ wb_do_unwinds(wb_inode, &lies);
- wb_do_winds (wb_inode, &tasks);
+ wb_do_winds(wb_inode, &tasks);
- /* If there is an error in wb_fulfill before winding write
- * requests, we would miss invocation of wb_process_queue
- * from wb_fulfill_cbk. So, retry processing again.
- */
- wind_failure = wb_fulfill (wb_inode, &liabilities);
- } while (wind_failure);
+ /* If there is an error in wb_fulfill before winding write
+ * requests, we would miss invocation of wb_process_queue
+ * from wb_fulfill_cbk. So, retry processing again.
+ */
+ wind_failure = wb_fulfill(wb_inode, &liabilities);
+ } while (wind_failure);
- return;
+ return;
}
-
void
wb_set_inode_size(wb_inode_t *wb_inode, struct iatt *postbuf)
{
- GF_ASSERT (wb_inode);
- GF_ASSERT (postbuf);
+ GF_ASSERT(wb_inode);
+ GF_ASSERT(postbuf);
- LOCK (&wb_inode->lock);
- {
- wb_inode->size = postbuf->ia_size;
- }
- UNLOCK (&wb_inode->lock);
+ LOCK(&wb_inode->lock);
+ {
+ wb_inode->size = postbuf->ia_size;
+ }
+ UNLOCK(&wb_inode->lock);
}
-
int
-wb_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, dict_t *xdata)
+wb_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,
+ dict_t *xdata)
{
- wb_request_t *req = NULL;
- wb_inode_t *wb_inode;
+ wb_request_t *req = NULL;
+ wb_inode_t *wb_inode;
- req = frame->local;
- frame->local = NULL;
- wb_inode = req->wb_inode;
+ req = frame->local;
+ frame->local = NULL;
+ wb_inode = req->wb_inode;
- wb_request_unref (req);
+ wb_request_unref(req);
- /* requests could be pending while this was in progress */
- wb_process_queue(wb_inode);
+ /* requests could be pending while this was in progress */
+ wb_process_queue(wb_inode);
- STACK_UNWIND_STRICT (writev, frame, op_ret, op_errno, prebuf, postbuf,
- xdata);
- return 0;
+ STACK_UNWIND_STRICT(writev, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
-
int
-wb_writev_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iovec *vector, int32_t count, off_t offset,
- uint32_t flags, struct iobref *iobref, dict_t *xdata)
+wb_writev_helper(call_frame_t *frame, xlator_t *this, fd_t *fd,
+ struct iovec *vector, int32_t count, off_t offset,
+ uint32_t flags, struct iobref *iobref, dict_t *xdata)
{
- STACK_WIND (frame, wb_writev_cbk,
- FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev,
- fd, vector, count, offset, flags, iobref, xdata);
- return 0;
+ STACK_WIND(frame, wb_writev_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->writev, fd, vector, count, offset,
+ flags, iobref, xdata);
+ return 0;
}
-
int
-wb_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
- int32_t count, off_t offset, uint32_t flags, struct iobref *iobref,
- dict_t *xdata)
-{
- wb_inode_t *wb_inode = NULL;
- wb_conf_t *conf = NULL;
- gf_boolean_t wb_disabled = 0;
- call_stub_t *stub = NULL;
- int ret = -1;
- int32_t op_errno = EINVAL;
- int o_direct = O_DIRECT;
-
- conf = this->private;
-
- wb_inode = wb_inode_create (this, fd->inode);
- if (!wb_inode) {
- op_errno = ENOMEM;
- goto unwind;
- }
-
- if (!conf->strict_O_DIRECT)
- o_direct = 0;
-
- if (fd->flags & (O_SYNC|O_DSYNC|o_direct))
- wb_disabled = 1;
-
- if (flags & (O_SYNC|O_DSYNC|o_direct))
- wb_disabled = 1;
-
- if (wb_disabled)
- stub = fop_writev_stub (frame, wb_writev_helper, fd, vector,
- count, offset, flags, iobref, xdata);
- else
- stub = fop_writev_stub (frame, NULL, fd, vector, count, offset,
- flags, iobref, xdata);
- if (!stub) {
- op_errno = ENOMEM;
- goto unwind;
- }
+wb_writev(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iovec *vector,
+ int32_t count, off_t offset, uint32_t flags, struct iobref *iobref,
+ dict_t *xdata)
+{
+ wb_inode_t *wb_inode = NULL;
+ wb_conf_t *conf = NULL;
+ gf_boolean_t wb_disabled = 0;
+ call_stub_t *stub = NULL;
+ int ret = -1;
+ int32_t op_errno = EINVAL;
+ int o_direct = O_DIRECT;
- if (wb_disabled)
- ret = wb_enqueue (wb_inode, stub);
- else
- ret = wb_enqueue_tempted (wb_inode, stub);
+ conf = this->private;
- if (!ret) {
- op_errno = ENOMEM;
- goto unwind;
- }
+ wb_inode = wb_inode_create(this, fd->inode);
+ if (!wb_inode) {
+ op_errno = ENOMEM;
+ goto unwind;
+ }
- wb_process_queue (wb_inode);
+ if (!conf->strict_O_DIRECT)
+ o_direct = 0;
- return 0;
+ if (fd->flags & (O_SYNC | O_DSYNC | o_direct))
+ wb_disabled = 1;
+
+ if (flags & (O_SYNC | O_DSYNC | o_direct))
+ wb_disabled = 1;
+
+ if (wb_disabled)
+ stub = fop_writev_stub(frame, wb_writev_helper, fd, vector, count,
+ offset, flags, iobref, xdata);
+ else
+ stub = fop_writev_stub(frame, NULL, fd, vector, count, offset, flags,
+ iobref, xdata);
+ if (!stub) {
+ op_errno = ENOMEM;
+ goto unwind;
+ }
+
+ if (wb_disabled)
+ ret = wb_enqueue(wb_inode, stub);
+ else
+ ret = wb_enqueue_tempted(wb_inode, stub);
+
+ if (!ret) {
+ op_errno = ENOMEM;
+ goto unwind;
+ }
+
+ wb_process_queue(wb_inode);
+
+ return 0;
unwind:
- STACK_UNWIND_STRICT (writev, frame, -1, op_errno, NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(writev, frame, -1, op_errno, NULL, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
+ if (stub)
+ call_stub_destroy(stub);
- return 0;
+ return 0;
}
-
int
-wb_readv_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, uint32_t flags, dict_t *xdata)
+wb_readv_helper(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, uint32_t flags, dict_t *xdata)
{
- STACK_WIND (frame, default_readv_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readv, fd, size, offset, flags,
- xdata);
- return 0;
+ STACK_WIND(frame, default_readv_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv, fd, size, offset, flags, xdata);
+ return 0;
}
-
int
-wb_readv (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t offset, uint32_t flags, dict_t *xdata)
+wb_readv(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset, uint32_t flags, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, fd->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, fd->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_readv_stub (frame, wb_readv_helper, fd, size,
- offset, flags, xdata);
- if (!stub)
- goto unwind;
+ stub = fop_readv_stub(frame, wb_readv_helper, fd, size, offset, flags,
+ xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (readv, frame, -1, ENOMEM, NULL, 0, NULL, NULL,
- NULL);
- return 0;
+ STACK_UNWIND_STRICT(readv, frame, -1, ENOMEM, NULL, 0, NULL, NULL, NULL);
+ return 0;
noqueue:
- STACK_WIND (frame, default_readv_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readv, fd, size, offset, flags,
- xdata);
- return 0;
+ STACK_WIND(frame, default_readv_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readv, fd, size, offset, flags, xdata);
+ return 0;
}
-
int
-wb_flush_bg_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, dict_t *xdata)
+wb_flush_bg_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, dict_t *xdata)
{
- STACK_DESTROY (frame->root);
- return 0;
+ STACK_DESTROY(frame->root);
+ return 0;
}
-
int
-wb_flush_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+wb_flush_helper(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- wb_conf_t *conf = NULL;
- wb_inode_t *wb_inode = NULL;
- call_frame_t *bg_frame = NULL;
- int32_t op_errno = 0;
- int op_ret = 0;
+ wb_conf_t *conf = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_frame_t *bg_frame = NULL;
+ int32_t op_errno = 0;
+ int op_ret = 0;
- conf = this->private;
+ conf = this->private;
- wb_inode = wb_inode_ctx_get (this, fd->inode);
- if (!wb_inode) {
- op_ret = -1;
- op_errno = EINVAL;
- goto unwind;
- }
+ wb_inode = wb_inode_ctx_get(this, fd->inode);
+ if (!wb_inode) {
+ op_ret = -1;
+ op_errno = EINVAL;
+ goto unwind;
+ }
+ if (conf->flush_behind)
+ goto flushbehind;
- if (conf->flush_behind)
- goto flushbehind;
-
- STACK_WIND (frame, default_flush_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->flush, fd, xdata);
- return 0;
+ STACK_WIND(frame, default_flush_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->flush, fd, xdata);
+ return 0;
flushbehind:
- bg_frame = copy_frame (frame);
- if (!bg_frame) {
- op_ret = -1;
- op_errno = ENOMEM;
- goto unwind;
- }
-
- STACK_WIND (bg_frame, wb_flush_bg_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->flush, fd, xdata);
- /* fall through */
+ bg_frame = copy_frame(frame);
+ if (!bg_frame) {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto unwind;
+ }
+
+ STACK_WIND(bg_frame, wb_flush_bg_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->flush, fd, xdata);
+ /* fall through */
unwind:
- STACK_UNWIND_STRICT (flush, frame, op_ret, op_errno, NULL);
+ STACK_UNWIND_STRICT(flush, frame, op_ret, op_errno, NULL);
- return 0;
+ return 0;
}
-
int
-wb_flush (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+wb_flush(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, fd->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, fd->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_flush_stub (frame, wb_flush_helper, fd, xdata);
- if (!stub)
- goto unwind;
+ stub = fop_flush_stub(frame, wb_flush_helper, fd, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (flush, frame, -1, ENOMEM, NULL);
+ STACK_UNWIND_STRICT(flush, frame, -1, ENOMEM, NULL);
- return 0;
+ return 0;
noqueue:
- STACK_WIND (frame, default_flush_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->flush, fd, xdata);
- return 0;
+ STACK_WIND(frame, default_flush_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->flush, fd, xdata);
+ return 0;
}
-
-
int
-wb_fsync_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
- int32_t datasync, dict_t *xdata)
+wb_fsync_helper(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync,
+ dict_t *xdata)
{
- STACK_WIND (frame, default_fsync_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsync, fd, datasync, xdata);
- return 0;
+ STACK_WIND(frame, default_fsync_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsync, fd, datasync, xdata);
+ return 0;
}
-
int
-wb_fsync (call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync,
- dict_t *xdata)
+wb_fsync(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t datasync,
+ dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
- int32_t op_errno = EINVAL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
+ int32_t op_errno = EINVAL;
- wb_inode = wb_inode_ctx_get (this, fd->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, fd->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_fsync_stub (frame, wb_fsync_helper, fd, datasync, xdata);
- if (!stub)
- goto unwind;
+ stub = fop_fsync_stub(frame, wb_fsync_helper, fd, datasync, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (fsync, frame, -1, op_errno, NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(fsync, frame, -1, op_errno, NULL, NULL, NULL);
- return 0;
+ return 0;
noqueue:
- STACK_WIND (frame, default_fsync_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsync, fd, datasync, xdata);
- return 0;
+ STACK_WIND(frame, default_fsync_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsync, fd, datasync, xdata);
+ return 0;
}
-
int
-wb_stat_helper (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+wb_stat_helper(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- STACK_WIND (frame, default_stat_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->stat, loc, xdata);
- return 0;
+ STACK_WIND(frame, default_stat_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->stat, loc, xdata);
+ return 0;
}
-
int
-wb_stat (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
+wb_stat(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
-
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, loc->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, loc->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_stat_stub (frame, wb_stat_helper, loc, xdata);
- if (!stub)
- goto unwind;
+ stub = fop_stat_stub(frame, wb_stat_helper, loc, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (stat, frame, -1, ENOMEM, NULL, NULL);
+ STACK_UNWIND_STRICT(stat, frame, -1, ENOMEM, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
- return 0;
+ if (stub)
+ call_stub_destroy(stub);
+ return 0;
noqueue:
- STACK_WIND (frame, default_stat_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->stat, loc, xdata);
- return 0;
+ STACK_WIND(frame, default_stat_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->stat, loc, xdata);
+ return 0;
}
-
int
-wb_fstat_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+wb_fstat_helper(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- STACK_WIND (frame, default_fstat_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fstat, fd, xdata);
- return 0;
+ STACK_WIND(frame, default_fstat_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fstat, fd, xdata);
+ return 0;
}
-
int
-wb_fstat (call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
+wb_fstat(call_frame_t *frame, xlator_t *this, fd_t *fd, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
+ wb_inode = wb_inode_ctx_get(this, fd->inode);
+ if (!wb_inode)
+ goto noqueue;
- wb_inode = wb_inode_ctx_get (this, fd->inode);
- if (!wb_inode)
- goto noqueue;
+ stub = fop_fstat_stub(frame, wb_fstat_helper, fd, xdata);
+ if (!stub)
+ goto unwind;
- stub = fop_fstat_stub (frame, wb_fstat_helper, fd, xdata);
- if (!stub)
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ wb_process_queue(wb_inode);
- wb_process_queue (wb_inode);
-
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (fstat, frame, -1, ENOMEM, NULL, NULL);
+ STACK_UNWIND_STRICT(fstat, frame, -1, ENOMEM, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
- return 0;
+ if (stub)
+ call_stub_destroy(stub);
+ return 0;
noqueue:
- STACK_WIND (frame, default_fstat_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fstat, fd, xdata);
- return 0;
+ STACK_WIND(frame, default_fstat_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fstat, fd, xdata);
+ return 0;
}
-
int32_t
-wb_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+wb_truncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- GF_ASSERT (frame->local);
+ GF_ASSERT(frame->local);
- if (op_ret == 0)
- wb_set_inode_size (frame->local, postbuf);
+ if (op_ret == 0)
+ wb_set_inode_size(frame->local, postbuf);
- frame->local = NULL;
+ frame->local = NULL;
- STACK_UNWIND_STRICT (truncate, frame, op_ret, op_errno, prebuf,
- postbuf, xdata);
- return 0;
+ STACK_UNWIND_STRICT(truncate, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
-
int
-wb_truncate_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
- off_t offset, dict_t *xdata)
+wb_truncate_helper(call_frame_t *frame, xlator_t *this, loc_t *loc,
+ off_t offset, dict_t *xdata)
{
- STACK_WIND (frame, wb_truncate_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
- return 0;
+ STACK_WIND(frame, wb_truncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->truncate, loc, offset, xdata);
+ return 0;
}
-
int
-wb_truncate (call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
- dict_t *xdata)
+wb_truncate(call_frame_t *frame, xlator_t *this, loc_t *loc, off_t offset,
+ dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_create (this, loc->inode);
- if (!wb_inode)
- goto unwind;
+ wb_inode = wb_inode_create(this, loc->inode);
+ if (!wb_inode)
+ goto unwind;
- frame->local = wb_inode;
+ frame->local = wb_inode;
- stub = fop_truncate_stub (frame, wb_truncate_helper, loc,
- offset, xdata);
- if (!stub)
- goto unwind;
+ stub = fop_truncate_stub(frame, wb_truncate_helper, loc, offset, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (truncate, frame, -1, ENOMEM, NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(truncate, frame, -1, ENOMEM, NULL, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
+ if (stub)
+ call_stub_destroy(stub);
- return 0;
+ return 0;
}
-
int32_t
-wb_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
- struct iatt *postbuf, dict_t *xdata)
+wb_ftruncate_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, struct iatt *prebuf,
+ struct iatt *postbuf, dict_t *xdata)
{
- GF_ASSERT (frame->local);
+ GF_ASSERT(frame->local);
- if (op_ret == 0)
- wb_set_inode_size (frame->local, postbuf);
+ if (op_ret == 0)
+ wb_set_inode_size(frame->local, postbuf);
- frame->local = NULL;
+ frame->local = NULL;
- STACK_UNWIND_STRICT (ftruncate, frame, op_ret, op_errno, prebuf,
- postbuf, xdata);
- return 0;
+ STACK_UNWIND_STRICT(ftruncate, frame, op_ret, op_errno, prebuf, postbuf,
+ xdata);
+ return 0;
}
-
int
-wb_ftruncate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
- off_t offset, dict_t *xdata)
+wb_ftruncate_helper(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ dict_t *xdata)
{
- STACK_WIND (frame, wb_ftruncate_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata);
- return 0;
+ STACK_WIND(frame, wb_ftruncate_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->ftruncate, fd, offset, xdata);
+ return 0;
}
-
int
-wb_ftruncate (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- dict_t *xdata)
+wb_ftruncate(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
- int32_t op_errno = 0;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
+ int32_t op_errno = 0;
- wb_inode = wb_inode_create (this, fd->inode);
- if (!wb_inode) {
- op_errno = ENOMEM;
- goto unwind;
- }
+ wb_inode = wb_inode_create(this, fd->inode);
+ if (!wb_inode) {
+ op_errno = ENOMEM;
+ goto unwind;
+ }
- frame->local = wb_inode;
+ frame->local = wb_inode;
- stub = fop_ftruncate_stub (frame, wb_ftruncate_helper, fd,
- offset, xdata);
- if (!stub) {
- op_errno = ENOMEM;
- goto unwind;
- }
+ stub = fop_ftruncate_stub(frame, wb_ftruncate_helper, fd, offset, xdata);
+ if (!stub) {
+ op_errno = ENOMEM;
+ goto unwind;
+ }
- if (!wb_enqueue (wb_inode, stub)) {
- op_errno = ENOMEM;
- goto unwind;
- }
+ if (!wb_enqueue(wb_inode, stub)) {
+ op_errno = ENOMEM;
+ goto unwind;
+ }
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- frame->local = NULL;
+ frame->local = NULL;
- STACK_UNWIND_STRICT (ftruncate, frame, -1, op_errno, NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(ftruncate, frame, -1, op_errno, NULL, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
- return 0;
+ if (stub)
+ call_stub_destroy(stub);
+ return 0;
}
-
int
-wb_setattr_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
- struct iatt *stbuf, int32_t valid, dict_t *xdata)
+wb_setattr_helper(call_frame_t *frame, xlator_t *this, loc_t *loc,
+ struct iatt *stbuf, int32_t valid, dict_t *xdata)
{
- STACK_WIND (frame, default_setattr_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->setattr, loc, stbuf, valid, xdata);
- return 0;
+ STACK_WIND(frame, default_setattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setattr, loc, stbuf, valid, xdata);
+ return 0;
}
-
int
-wb_setattr (call_frame_t *frame, xlator_t *this, loc_t *loc,
- struct iatt *stbuf, int32_t valid, dict_t *xdata)
+wb_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc, struct iatt *stbuf,
+ int32_t valid, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, loc->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, loc->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_setattr_stub (frame, wb_setattr_helper, loc, stbuf,
- valid, xdata);
- if (!stub)
- goto unwind;
+ stub = fop_setattr_stub(frame, wb_setattr_helper, loc, stbuf, valid, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (setattr, frame, -1, ENOMEM, NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(setattr, frame, -1, ENOMEM, NULL, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
- return 0;
+ if (stub)
+ call_stub_destroy(stub);
+ return 0;
noqueue:
- STACK_WIND (frame, default_setattr_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->setattr, loc, stbuf, valid, xdata);
- return 0;
+ STACK_WIND(frame, default_setattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->setattr, loc, stbuf, valid, xdata);
+ return 0;
}
-
int
-wb_fsetattr_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iatt *stbuf, int32_t valid, dict_t *xdata)
+wb_fsetattr_helper(call_frame_t *frame, xlator_t *this, fd_t *fd,
+ struct iatt *stbuf, int32_t valid, dict_t *xdata)
{
- STACK_WIND (frame, default_fsetattr_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsetattr, fd, stbuf, valid, xdata);
- return 0;
+ STACK_WIND(frame, default_fsetattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsetattr, fd, stbuf, valid, xdata);
+ return 0;
}
-
int
-wb_fsetattr (call_frame_t *frame, xlator_t *this, fd_t *fd,
- struct iatt *stbuf, int32_t valid, dict_t *xdata)
+wb_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd, struct iatt *stbuf,
+ int32_t valid, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, fd->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, fd->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_fsetattr_stub (frame, wb_fsetattr_helper, fd, stbuf,
- valid, xdata);
- if (!stub)
- goto unwind;
+ stub = fop_fsetattr_stub(frame, wb_fsetattr_helper, fd, stbuf, valid,
+ xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (fsetattr, frame, -1, ENOMEM, NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(fsetattr, frame, -1, ENOMEM, NULL, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
- return 0;
+ if (stub)
+ call_stub_destroy(stub);
+ return 0;
noqueue:
- STACK_WIND (frame, default_fsetattr_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fsetattr, fd, stbuf, valid, xdata);
- return 0;
+ STACK_WIND(frame, default_fsetattr_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fsetattr, fd, stbuf, valid, xdata);
+ return 0;
}
-
int32_t
-wb_create (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
+wb_create(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ mode_t mode, mode_t umask, fd_t *fd, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
+ wb_inode_t *wb_inode = NULL;
- wb_inode = wb_inode_create (this, fd->inode);
- if (!wb_inode)
- goto unwind;
+ wb_inode = wb_inode_create(this, fd->inode);
+ if (!wb_inode)
+ goto unwind;
- if (((flags & O_RDWR) || (flags & O_WRONLY)) && (flags & O_TRUNC))
- wb_inode->size = 0;
+ if (((flags & O_RDWR) || (flags & O_WRONLY)) && (flags & O_TRUNC))
+ wb_inode->size = 0;
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->create, loc, flags, mode,
- umask, fd, xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this), FIRST_CHILD(this)->fops->create,
+ loc, flags, mode, umask, fd, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT (create, frame, -1, ENOMEM, NULL, NULL, NULL, NULL,
- NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(create, frame, -1, ENOMEM, NULL, NULL, NULL, NULL, NULL,
+ NULL);
+ return 0;
}
-
int32_t
-wb_open (call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
- fd_t *fd, dict_t *xdata)
+wb_open(call_frame_t *frame, xlator_t *this, loc_t *loc, int32_t flags,
+ fd_t *fd, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
+ wb_inode_t *wb_inode = NULL;
- wb_inode = wb_inode_create (this, fd->inode);
- if (!wb_inode)
- goto unwind;
+ wb_inode = wb_inode_create(this, fd->inode);
+ if (!wb_inode)
+ goto unwind;
- if (((flags & O_RDWR) || (flags & O_WRONLY)) && (flags & O_TRUNC))
- wb_inode->size = 0;
+ if (((flags & O_RDWR) || (flags & O_WRONLY)) && (flags & O_TRUNC))
+ wb_inode->size = 0;
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->open, loc, flags, fd, xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this), FIRST_CHILD(this)->fops->open,
+ loc, flags, fd, xdata);
+ return 0;
unwind:
- STACK_UNWIND_STRICT (open, frame, -1, ENOMEM, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(open, frame, -1, ENOMEM, NULL, NULL);
+ return 0;
}
-
int32_t
-wb_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, inode_t *inode,
- struct iatt *buf, dict_t *xdata, struct iatt *postparent)
-{
- if (op_ret == 0) {
- wb_inode_t *wb_inode = wb_inode_ctx_get (this, inode);
- if (wb_inode)
- wb_set_inode_size (wb_inode, buf);
- }
+wb_lookup_cbk(call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
+ int32_t op_errno, inode_t *inode, struct iatt *buf, dict_t *xdata,
+ struct iatt *postparent)
+{
+ if (op_ret == 0) {
+ wb_inode_t *wb_inode = wb_inode_ctx_get(this, inode);
+ if (wb_inode)
+ wb_set_inode_size(wb_inode, buf);
+ }
- STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, buf,
- xdata, postparent);
- return 0;
+ STACK_UNWIND_STRICT(lookup, frame, op_ret, op_errno, inode, buf, xdata,
+ postparent);
+ return 0;
}
-
int
-wb_lookup_helper (call_frame_t *frame, xlator_t *this, loc_t *loc,
- dict_t *xdata)
+wb_lookup_helper(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- STACK_WIND (frame, wb_lookup_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->lookup, loc, xdata);
- return 0;
+ STACK_WIND(frame, wb_lookup_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, loc, xdata);
+ return 0;
}
-
int32_t
-wb_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
- dict_t *xdata)
+wb_lookup(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, loc->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, loc->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_lookup_stub (frame, wb_lookup_helper, loc, xdata);
- if (!stub)
- goto unwind;
+ stub = fop_lookup_stub(frame, wb_lookup_helper, loc, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- if (stub)
- call_stub_destroy (stub);
+ if (stub)
+ call_stub_destroy(stub);
- STACK_UNWIND_STRICT (lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL);
- return 0;
+ STACK_UNWIND_STRICT(lookup, frame, -1, ENOMEM, NULL, NULL, NULL, NULL);
+ return 0;
noqueue:
- STACK_WIND (frame, wb_lookup_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->lookup, loc, xdata);
- return 0;
+ STACK_WIND(frame, wb_lookup_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->lookup, loc, xdata);
+ return 0;
}
static void
-wb_mark_readdirp_start (xlator_t *this, inode_t *directory)
+wb_mark_readdirp_start(xlator_t *this, inode_t *directory)
{
- wb_inode_t *wb_directory_inode = NULL;
+ wb_inode_t *wb_directory_inode = NULL;
- wb_directory_inode = wb_inode_create (this, directory);
+ wb_directory_inode = wb_inode_create(this, directory);
- LOCK (&wb_directory_inode->lock);
- {
- GF_ATOMIC_INC (wb_directory_inode->readdirps);
- }
- UNLOCK (&wb_directory_inode->lock);
+ LOCK(&wb_directory_inode->lock);
+ {
+ GF_ATOMIC_INC(wb_directory_inode->readdirps);
+ }
+ UNLOCK(&wb_directory_inode->lock);
- return;
+ return;
}
static void
-wb_mark_readdirp_end (xlator_t *this, inode_t *directory)
+wb_mark_readdirp_end(xlator_t *this, inode_t *directory)
{
- wb_inode_t *wb_directory_inode = NULL, *wb_inode = NULL, *tmp = NULL;
- int readdirps = 0;
+ wb_inode_t *wb_directory_inode = NULL, *wb_inode = NULL, *tmp = NULL;
+ int readdirps = 0;
+
+ wb_directory_inode = wb_inode_ctx_get(this, directory);
- wb_directory_inode = wb_inode_ctx_get (this, directory);
+ LOCK(&wb_directory_inode->lock);
+ {
+ readdirps = GF_ATOMIC_DEC(wb_directory_inode->readdirps);
+ if (readdirps)
+ goto unlock;
- LOCK (&wb_directory_inode->lock);
+ list_for_each_entry_safe(wb_inode, tmp,
+ &wb_directory_inode->invalidate_list,
+ invalidate_list)
{
- readdirps = GF_ATOMIC_DEC (wb_directory_inode->readdirps);
- if (readdirps)
- goto unlock;
-
- list_for_each_entry_safe (wb_inode, tmp,
- &wb_directory_inode->invalidate_list,
- invalidate_list) {
- list_del_init (&wb_inode->invalidate_list);
- GF_ATOMIC_SWAP (wb_inode->invalidate, 0);
- }
+ list_del_init(&wb_inode->invalidate_list);
+ GF_ATOMIC_SWAP(wb_inode->invalidate, 0);
}
+ }
unlock:
- UNLOCK (&wb_directory_inode->lock);
+ UNLOCK(&wb_directory_inode->lock);
- return;
+ return;
}
int32_t
-wb_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
- int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
- dict_t *xdata)
+wb_readdirp_cbk(call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, gf_dirent_t *entries,
+ dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- gf_dirent_t *entry = NULL;
- inode_t *inode = NULL;
- fd_t *fd = NULL;
+ wb_inode_t *wb_inode = NULL;
+ gf_dirent_t *entry = NULL;
+ inode_t *inode = NULL;
+ fd_t *fd = NULL;
- fd = frame->local;
- frame->local = NULL;
+ fd = frame->local;
+ frame->local = NULL;
- if (op_ret <= 0)
- goto unwind;
+ if (op_ret <= 0)
+ goto unwind;
- list_for_each_entry (entry, &entries->list, list) {
- if (!entry->inode || !IA_ISREG (entry->d_stat.ia_type))
- continue;
+ list_for_each_entry(entry, &entries->list, list)
+ {
+ if (!entry->inode || !IA_ISREG(entry->d_stat.ia_type))
+ continue;
- wb_inode = wb_inode_ctx_get (this, entry->inode);
- if (!wb_inode)
- continue;
+ wb_inode = wb_inode_ctx_get(this, entry->inode);
+ if (!wb_inode)
+ continue;
- LOCK (&wb_inode->lock);
- {
- if (!list_empty (&wb_inode->liability) ||
- GF_ATOMIC_GET (wb_inode->invalidate)) {
- inode = entry->inode;
+ LOCK(&wb_inode->lock);
+ {
+ if (!list_empty(&wb_inode->liability) ||
+ GF_ATOMIC_GET(wb_inode->invalidate)) {
+ inode = entry->inode;
- entry->inode = NULL;
- memset (&entry->d_stat, 0,
- sizeof (entry->d_stat));
+ entry->inode = NULL;
+ memset(&entry->d_stat, 0, sizeof(entry->d_stat));
- inode_unref (inode);
- }
- }
- UNLOCK (&wb_inode->lock);
+ inode_unref(inode);
+ }
}
+ UNLOCK(&wb_inode->lock);
+ }
- wb_mark_readdirp_end (this, fd->inode);
+ wb_mark_readdirp_end(this, fd->inode);
unwind:
- frame->local = NULL;
- STACK_UNWIND_STRICT (readdirp, frame, op_ret, op_errno, entries, xdata);
- return 0;
+ frame->local = NULL;
+ STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, entries, xdata);
+ return 0;
}
-
int32_t
-wb_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
- off_t off, dict_t *xdata)
+wb_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t off, dict_t *xdata)
{
- wb_mark_readdirp_start (this, fd->inode);
+ wb_mark_readdirp_start(this, fd->inode);
- frame->local = fd;
+ frame->local = fd;
- STACK_WIND (frame, wb_readdirp_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdirp,
- fd, size, off, xdata);
+ STACK_WIND(frame, wb_readdirp_cbk, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->readdirp, fd, size, off, xdata);
- return 0;
+ return 0;
}
-
int32_t
-wb_link_helper (call_frame_t *frame, xlator_t *this, loc_t *oldloc,
- loc_t *newloc, dict_t *xdata)
+wb_link_helper(call_frame_t *frame, xlator_t *this, loc_t *oldloc,
+ loc_t *newloc, dict_t *xdata)
{
- STACK_WIND_TAIL (frame,
- FIRST_CHILD(this), FIRST_CHILD(this)->fops->link,
- oldloc, newloc, xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this), FIRST_CHILD(this)->fops->link,
+ oldloc, newloc, xdata);
+ return 0;
}
-
int32_t
-wb_link (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
- dict_t *xdata)
+wb_link(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
+ wb_inode = wb_inode_ctx_get(this, oldloc->inode);
+ if (!wb_inode)
+ goto noqueue;
- wb_inode = wb_inode_ctx_get (this, oldloc->inode);
- if (!wb_inode)
- goto noqueue;
+ stub = fop_link_stub(frame, wb_link_helper, oldloc, newloc, xdata);
+ if (!stub)
+ goto unwind;
- stub = fop_link_stub (frame, wb_link_helper, oldloc, newloc, xdata);
- if (!stub)
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ wb_process_queue(wb_inode);
- wb_process_queue (wb_inode);
-
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (link, frame, -1, ENOMEM, NULL, NULL, NULL, NULL,
- NULL);
+ STACK_UNWIND_STRICT(link, frame, -1, ENOMEM, NULL, NULL, NULL, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
+ if (stub)
+ call_stub_destroy(stub);
- return 0;
+ return 0;
noqueue:
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->link,
- oldloc, newloc, xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this), FIRST_CHILD(this)->fops->link,
+ oldloc, newloc, xdata);
+ return 0;
}
-
int32_t
-wb_fallocate_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
- int32_t keep_size, off_t offset, size_t len, dict_t *xdata)
+wb_fallocate_helper(call_frame_t *frame, xlator_t *this, fd_t *fd,
+ int32_t keep_size, off_t offset, size_t len, dict_t *xdata)
{
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fallocate, fd, keep_size,
- offset, len, xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fallocate, fd, keep_size, offset,
+ len, xdata);
+ return 0;
}
-
int32_t
-wb_fallocate (call_frame_t *frame, xlator_t *this, fd_t *fd,
- int32_t keep_size, off_t offset, size_t len, dict_t *xdata)
+wb_fallocate(call_frame_t *frame, xlator_t *this, fd_t *fd, int32_t keep_size,
+ off_t offset, size_t len, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
-
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, fd->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, fd->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_fallocate_stub (frame, wb_fallocate_helper, fd, keep_size,
- offset, len, xdata);
- if (!stub)
- goto unwind;
+ stub = fop_fallocate_stub(frame, wb_fallocate_helper, fd, keep_size, offset,
+ len, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (fallocate, frame, -1, ENOMEM, NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(fallocate, frame, -1, ENOMEM, NULL, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
+ if (stub)
+ call_stub_destroy(stub);
- return 0;
+ return 0;
noqueue:
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->fallocate, fd, keep_size,
- offset, len, xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this),
+ FIRST_CHILD(this)->fops->fallocate, fd, keep_size, offset,
+ len, xdata);
+ return 0;
}
-
int32_t
-wb_discard_helper (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- size_t len, dict_t *xdata)
+wb_discard_helper(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ size_t len, dict_t *xdata)
{
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->discard,
- fd, offset, len, xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this), FIRST_CHILD(this)->fops->discard,
+ fd, offset, len, xdata);
+ return 0;
}
-
int32_t
-wb_discard (call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
- size_t len, dict_t *xdata)
+wb_discard(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ size_t len, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, fd->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, fd->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_discard_stub (frame, wb_discard_helper, fd, offset, len,
- xdata);
- if (!stub)
- goto unwind;
+ stub = fop_discard_stub(frame, wb_discard_helper, fd, offset, len, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (discard, frame, -1, ENOMEM, NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(discard, frame, -1, ENOMEM, NULL, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
- return 0;
+ if (stub)
+ call_stub_destroy(stub);
+ return 0;
noqueue:
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->discard,
- fd, offset, len, xdata);
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this), FIRST_CHILD(this)->fops->discard,
+ fd, offset, len, xdata);
- return 0;
+ return 0;
}
-
int32_t
-wb_zerofill_helper (call_frame_t *frame, xlator_t *this, fd_t *fd,
- off_t offset, off_t len, dict_t *xdata)
+wb_zerofill_helper(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ off_t len, dict_t *xdata)
{
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->zerofill,
- fd, offset, len, xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this), FIRST_CHILD(this)->fops->zerofill,
+ fd, offset, len, xdata);
+ return 0;
}
int32_t
-wb_zerofill (call_frame_t *frame, xlator_t *this, fd_t *fd,
- off_t offset, off_t len, dict_t *xdata)
+wb_zerofill(call_frame_t *frame, xlator_t *this, fd_t *fd, off_t offset,
+ off_t len, dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, fd->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, fd->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_zerofill_stub (frame, wb_zerofill_helper, fd, offset, len,
- xdata);
- if (!stub)
- goto unwind;
+ stub = fop_zerofill_stub(frame, wb_zerofill_helper, fd, offset, len, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- STACK_UNWIND_STRICT (zerofill, frame, -1, ENOMEM, NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(zerofill, frame, -1, ENOMEM, NULL, NULL, NULL);
- if (stub)
- call_stub_destroy (stub);
+ if (stub)
+ call_stub_destroy(stub);
noqueue:
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->zerofill,
- fd, offset, len, xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this), FIRST_CHILD(this)->fops->zerofill,
+ fd, offset, len, xdata);
+ return 0;
}
int32_t
-wb_rename (call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
- dict_t *xdata)
+wb_rename(call_frame_t *frame, xlator_t *this, loc_t *oldloc, loc_t *newloc,
+ dict_t *xdata)
{
- wb_inode_t *wb_inode = NULL;
- call_stub_t *stub = NULL;
+ wb_inode_t *wb_inode = NULL;
+ call_stub_t *stub = NULL;
- wb_inode = wb_inode_ctx_get (this, oldloc->inode);
- if (!wb_inode)
- goto noqueue;
+ wb_inode = wb_inode_ctx_get(this, oldloc->inode);
+ if (!wb_inode)
+ goto noqueue;
- stub = fop_rename_stub (frame, default_rename_resume, oldloc, newloc,
- xdata);
- if (!stub)
- goto unwind;
+ stub = fop_rename_stub(frame, default_rename_resume, oldloc, newloc, xdata);
+ if (!stub)
+ goto unwind;
- if (!wb_enqueue (wb_inode, stub))
- goto unwind;
+ if (!wb_enqueue(wb_inode, stub))
+ goto unwind;
- wb_process_queue (wb_inode);
+ wb_process_queue(wb_inode);
- return 0;
+ return 0;
unwind:
- if (stub)
- call_stub_destroy (stub);
+ if (stub)
+ call_stub_destroy(stub);
- STACK_UNWIND_STRICT (rename, frame, -1, ENOMEM, NULL, NULL, NULL,
- NULL, NULL, NULL);
+ STACK_UNWIND_STRICT(rename, frame, -1, ENOMEM, NULL, NULL, NULL, NULL, NULL,
+ NULL);
- return 0;
+ return 0;
noqueue:
- STACK_WIND_TAIL (frame, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->rename, oldloc, newloc,
- xdata);
- return 0;
+ STACK_WIND_TAIL(frame, FIRST_CHILD(this), FIRST_CHILD(this)->fops->rename,
+ oldloc, newloc, xdata);
+ return 0;
}
-
int
-wb_forget (xlator_t *this, inode_t *inode)
+wb_forget(xlator_t *this, inode_t *inode)
{
- uint64_t tmp = 0;
- wb_inode_t *wb_inode = NULL;
+ uint64_t tmp = 0;
+ wb_inode_t *wb_inode = NULL;
- inode_ctx_del (inode, this, &tmp);
+ inode_ctx_del(inode, this, &tmp);
- wb_inode = (wb_inode_t *)(long)tmp;
+ wb_inode = (wb_inode_t *)(long)tmp;
- if (!wb_inode)
- return 0;
+ if (!wb_inode)
+ return 0;
- GF_ASSERT (list_empty (&wb_inode->todo));
- GF_ASSERT (list_empty (&wb_inode->liability));
- GF_ASSERT (list_empty (&wb_inode->temptation));
+ GF_ASSERT(list_empty(&wb_inode->todo));
+ GF_ASSERT(list_empty(&wb_inode->liability));
+ GF_ASSERT(list_empty(&wb_inode->temptation));
- GF_FREE (wb_inode);
+ GF_FREE(wb_inode);
- return 0;
+ return 0;
}
-
int
-wb_release (xlator_t *this, fd_t *fd)
+wb_release(xlator_t *this, fd_t *fd)
{
- uint64_t tmp = 0;
+ uint64_t tmp = 0;
- (void) fd_ctx_del (fd, this, &tmp);
+ (void)fd_ctx_del(fd, this, &tmp);
- return 0;
+ return 0;
}
-
int
-wb_priv_dump (xlator_t *this)
+wb_priv_dump(xlator_t *this)
{
- wb_conf_t *conf = NULL;
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
- int ret = -1;
+ wb_conf_t *conf = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ int ret = -1;
- GF_VALIDATE_OR_GOTO ("write-behind", this, out);
+ GF_VALIDATE_OR_GOTO("write-behind", this, out);
- conf = this->private;
- GF_VALIDATE_OR_GOTO (this->name, conf, out);
+ conf = this->private;
+ GF_VALIDATE_OR_GOTO(this->name, conf, out);
- gf_proc_dump_build_key (key_prefix, "xlator.performance.write-behind",
- "priv");
+ gf_proc_dump_build_key(key_prefix, "xlator.performance.write-behind",
+ "priv");
- gf_proc_dump_add_section (key_prefix);
+ gf_proc_dump_add_section(key_prefix);
- gf_proc_dump_write ("aggregate_size", "%d", conf->aggregate_size);
- gf_proc_dump_write ("window_size", "%d", conf->window_size);
- gf_proc_dump_write ("flush_behind", "%d", conf->flush_behind);
- gf_proc_dump_write ("trickling_writes", "%d", conf->trickling_writes);
+ gf_proc_dump_write("aggregate_size", "%d", conf->aggregate_size);
+ gf_proc_dump_write("window_size", "%d", conf->window_size);
+ gf_proc_dump_write("flush_behind", "%d", conf->flush_behind);
+ gf_proc_dump_write("trickling_writes", "%d", conf->trickling_writes);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
void
-__wb_dump_requests (struct list_head *head, char *prefix)
+__wb_dump_requests(struct list_head *head, char *prefix)
{
- char key[GF_DUMP_MAX_BUF_LEN] = {0, };
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, }, flag = 0;
- wb_request_t *req = NULL;
-
- list_for_each_entry (req, head, all) {
- gf_proc_dump_build_key (key_prefix, key, "%s",
- (char *)gf_fop_list[req->fop]);
+ char key[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] =
+ {
+ 0,
+ },
+ flag = 0;
+ wb_request_t *req = NULL;
- gf_proc_dump_add_section(key_prefix);
+ list_for_each_entry(req, head, all)
+ {
+ gf_proc_dump_build_key(key_prefix, key, "%s",
+ (char *)gf_fop_list[req->fop]);
- gf_proc_dump_write ("unique", "%"PRIu64, req->unique);
+ gf_proc_dump_add_section(key_prefix);
- gf_proc_dump_write ("refcount", "%d", req->refcount);
+ gf_proc_dump_write("unique", "%" PRIu64, req->unique);
- if (list_empty (&req->todo))
- gf_proc_dump_write ("wound", "yes");
- else
- gf_proc_dump_write ("wound", "no");
+ gf_proc_dump_write("refcount", "%d", req->refcount);
- gf_proc_dump_write ("generation-number", "%d", req->gen);
+ if (list_empty(&req->todo))
+ gf_proc_dump_write("wound", "yes");
+ else
+ gf_proc_dump_write("wound", "no");
- gf_proc_dump_write ("req->op_ret", "%d", req->op_ret);
- gf_proc_dump_write ("req->op_errno", "%d", req->op_errno);
- gf_proc_dump_write ("sync-attempts", "%d", req->wind_count);
+ gf_proc_dump_write("generation-number", "%d", req->gen);
- if (req->fop == GF_FOP_WRITE) {
- if (list_empty (&req->wip))
- gf_proc_dump_write ("sync-in-progress", "no");
- else
- gf_proc_dump_write ("sync-in-progress", "yes");
+ gf_proc_dump_write("req->op_ret", "%d", req->op_ret);
+ gf_proc_dump_write("req->op_errno", "%d", req->op_errno);
+ gf_proc_dump_write("sync-attempts", "%d", req->wind_count);
- gf_proc_dump_write ("size", "%"GF_PRI_SIZET,
- req->write_size);
+ if (req->fop == GF_FOP_WRITE) {
+ if (list_empty(&req->wip))
+ gf_proc_dump_write("sync-in-progress", "no");
+ else
+ gf_proc_dump_write("sync-in-progress", "yes");
- if (req->stub)
- gf_proc_dump_write ("offset", "%"PRId64,
- req->stub->args.offset);
+ gf_proc_dump_write("size", "%" GF_PRI_SIZET, req->write_size);
- flag = req->ordering.lied;
- gf_proc_dump_write ("lied", "%d", flag);
+ if (req->stub)
+ gf_proc_dump_write("offset", "%" PRId64,
+ req->stub->args.offset);
- flag = req->ordering.append;
- gf_proc_dump_write ("append", "%d", flag);
+ flag = req->ordering.lied;
+ gf_proc_dump_write("lied", "%d", flag);
- flag = req->ordering.fulfilled;
- gf_proc_dump_write ("fulfilled", "%d", flag);
+ flag = req->ordering.append;
+ gf_proc_dump_write("append", "%d", flag);
- flag = req->ordering.go;
- gf_proc_dump_write ("go", "%d", flag);
+ flag = req->ordering.fulfilled;
+ gf_proc_dump_write("fulfilled", "%d", flag);
- }
+ flag = req->ordering.go;
+ gf_proc_dump_write("go", "%d", flag);
}
+ }
}
-
int
-wb_inode_dump (xlator_t *this, inode_t *inode)
-{
- wb_inode_t *wb_inode = NULL;
- int32_t ret = -1;
- char *path = NULL;
- char key_prefix[GF_DUMP_MAX_BUF_LEN] = {0, };
- char uuid_str[64] = {0,};
-
- if ((inode == NULL) || (this == NULL)) {
- ret = 0;
- goto out;
- }
-
- wb_inode = wb_inode_ctx_get (this, inode);
- if (wb_inode == NULL) {
- ret = 0;
- goto out;
- }
+wb_inode_dump(xlator_t *this, inode_t *inode)
+{
+ wb_inode_t *wb_inode = NULL;
+ int32_t ret = -1;
+ char *path = NULL;
+ char key_prefix[GF_DUMP_MAX_BUF_LEN] = {
+ 0,
+ };
+ char uuid_str[64] = {
+ 0,
+ };
+
+ if ((inode == NULL) || (this == NULL)) {
+ ret = 0;
+ goto out;
+ }
- uuid_utoa_r (inode->gfid, uuid_str);
+ wb_inode = wb_inode_ctx_get(this, inode);
+ if (wb_inode == NULL) {
+ ret = 0;
+ goto out;
+ }
- gf_proc_dump_build_key (key_prefix, "xlator.performance.write-behind",
- "wb_inode");
+ uuid_utoa_r(inode->gfid, uuid_str);
- gf_proc_dump_add_section (key_prefix);
+ gf_proc_dump_build_key(key_prefix, "xlator.performance.write-behind",
+ "wb_inode");
- __inode_path (inode, NULL, &path);
- if (path != NULL) {
- gf_proc_dump_write ("path", "%s", path);
- GF_FREE (path);
- }
+ gf_proc_dump_add_section(key_prefix);
- gf_proc_dump_write ("inode", "%p", inode);
+ __inode_path(inode, NULL, &path);
+ if (path != NULL) {
+ gf_proc_dump_write("path", "%s", path);
+ GF_FREE(path);
+ }
- gf_proc_dump_write ("gfid", "%s", uuid_str);
+ gf_proc_dump_write("inode", "%p", inode);
- gf_proc_dump_write ("window_conf", "%"GF_PRI_SIZET,
- wb_inode->window_conf);
+ gf_proc_dump_write("gfid", "%s", uuid_str);
- gf_proc_dump_write ("window_current", "%"GF_PRI_SIZET,
- wb_inode->window_current);
+ gf_proc_dump_write("window_conf", "%" GF_PRI_SIZET, wb_inode->window_conf);
+ gf_proc_dump_write("window_current", "%" GF_PRI_SIZET,
+ wb_inode->window_current);
- gf_proc_dump_write ("transit-size", "%"GF_PRI_SIZET,
- wb_inode->transit);
+ gf_proc_dump_write("transit-size", "%" GF_PRI_SIZET, wb_inode->transit);
- gf_proc_dump_write ("dontsync", "%d", wb_inode->dontsync);
+ gf_proc_dump_write("dontsync", "%d", wb_inode->dontsync);
- ret = TRY_LOCK (&wb_inode->lock);
- if (!ret)
- {
- if (!list_empty (&wb_inode->all)) {
- __wb_dump_requests (&wb_inode->all, key_prefix);
- }
- UNLOCK (&wb_inode->lock);
+ ret = TRY_LOCK(&wb_inode->lock);
+ if (!ret) {
+ if (!list_empty(&wb_inode->all)) {
+ __wb_dump_requests(&wb_inode->all, key_prefix);
}
+ UNLOCK(&wb_inode->lock);
+ }
- if (ret && wb_inode)
- gf_proc_dump_write ("Unable to dump the inode information",
- "(Lock acquisition failed) %p (gfid: %s)",
- wb_inode, uuid_str);
+ if (ret && wb_inode)
+ gf_proc_dump_write("Unable to dump the inode information",
+ "(Lock acquisition failed) %p (gfid: %s)", wb_inode,
+ uuid_str);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
int
-mem_acct_init (xlator_t *this)
+mem_acct_init(xlator_t *this)
{
- int ret = -1;
+ int ret = -1;
- if (!this) {
- goto out;
- }
+ if (!this) {
+ goto out;
+ }
- ret = xlator_mem_acct_init (this, gf_wb_mt_end + 1);
+ ret = xlator_mem_acct_init(this, gf_wb_mt_end + 1);
- if (ret != 0) {
- gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
- WRITE_BEHIND_MSG_NO_MEMORY,
- "Memory accounting init"
- "failed");
- }
+ if (ret != 0) {
+ gf_msg(this->name, GF_LOG_ERROR, ENOMEM, WRITE_BEHIND_MSG_NO_MEMORY,
+ "Memory accounting init"
+ "failed");
+ }
out:
- return ret;
+ return ret;
}
-
int
-reconfigure (xlator_t *this, dict_t *options)
+reconfigure(xlator_t *this, dict_t *options)
{
- wb_conf_t *conf = NULL;
- int ret = -1;
+ wb_conf_t *conf = NULL;
+ int ret = -1;
- conf = this->private;
+ conf = this->private;
- GF_OPTION_RECONF ("cache-size", conf->window_size, options, size_uint64,
- out);
+ GF_OPTION_RECONF("cache-size", conf->window_size, options, size_uint64,
+ out);
- GF_OPTION_RECONF ("flush-behind", conf->flush_behind, options, bool,
- out);
+ GF_OPTION_RECONF("flush-behind", conf->flush_behind, options, bool, out);
- GF_OPTION_RECONF ("trickling-writes", conf->trickling_writes, options,
- bool, out);
+ GF_OPTION_RECONF("trickling-writes", conf->trickling_writes, options, bool,
+ out);
- GF_OPTION_RECONF ("strict-O_DIRECT", conf->strict_O_DIRECT, options,
- bool, out);
+ GF_OPTION_RECONF("strict-O_DIRECT", conf->strict_O_DIRECT, options, bool,
+ out);
- GF_OPTION_RECONF ("strict-write-ordering", conf->strict_write_ordering,
- options, bool, out);
- GF_OPTION_RECONF ("resync-failed-syncs-after-fsync",
- conf->resync_after_fsync, options, bool, out);
+ GF_OPTION_RECONF("strict-write-ordering", conf->strict_write_ordering,
+ options, bool, out);
+ GF_OPTION_RECONF("resync-failed-syncs-after-fsync",
+ conf->resync_after_fsync, options, bool, out);
- ret = 0;
+ ret = 0;
out:
- return ret;
+ return ret;
}
-
int32_t
-init (xlator_t *this)
-{
- wb_conf_t *conf = NULL;
- int32_t ret = -1;
-
- if ((this->children == NULL)
- || this->children->next) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- WRITE_BEHIND_MSG_INIT_FAILED,
- "FATAL: write-behind (%s) not configured with exactly "
- "one child", this->name);
- goto out;
- }
-
- if (this->parents == NULL) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- WRITE_BEHIND_MSG_VOL_MISCONFIGURED,
- "dangling volume. check volfilex");
- }
-
- conf = GF_CALLOC (1, sizeof (*conf), gf_wb_mt_wb_conf_t);
- if (conf == NULL) {
- goto out;
- }
-
- /* configure 'options aggregate-size <size>' */
- GF_OPTION_INIT ("aggregate-size", conf->aggregate_size, size_uint64, out);
- conf->page_size = conf->aggregate_size;
-
- /* configure 'option window-size <size>' */
- GF_OPTION_INIT ("cache-size", conf->window_size, size_uint64, out);
-
- if (!conf->window_size && conf->aggregate_size) {
- gf_msg (this->name, GF_LOG_WARNING, 0,
- WRITE_BEHIND_MSG_SIZE_NOT_SET,
- "setting window-size to be equal to "
- "aggregate-size(%"PRIu64")",
- conf->aggregate_size);
- conf->window_size = conf->aggregate_size;
- }
-
- if (conf->window_size < conf->aggregate_size) {
- gf_msg (this->name, GF_LOG_ERROR, 0,
- WRITE_BEHIND_MSG_EXCEEDED_MAX_SIZE,
- "aggregate-size(%"PRIu64") cannot be more than "
- "window-size(%"PRIu64")", conf->aggregate_size,
- conf->window_size);
- goto out;
- }
-
- /* configure 'option flush-behind <on/off>' */
- GF_OPTION_INIT ("flush-behind", conf->flush_behind, bool, out);
-
- GF_OPTION_INIT ("trickling-writes", conf->trickling_writes, bool, out);
-
- GF_OPTION_INIT ("strict-O_DIRECT", conf->strict_O_DIRECT, bool, out);
-
- GF_OPTION_INIT ("strict-write-ordering", conf->strict_write_ordering,
- bool, out);
-
- GF_OPTION_INIT ("resync-failed-syncs-after-fsync",
- conf->resync_after_fsync, bool, out);
-
- this->private = conf;
- ret = 0;
+init(xlator_t *this)
+{
+ wb_conf_t *conf = NULL;
+ int32_t ret = -1;
+
+ if ((this->children == NULL) || this->children->next) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, WRITE_BEHIND_MSG_INIT_FAILED,
+ "FATAL: write-behind (%s) not configured with exactly "
+ "one child",
+ this->name);
+ goto out;
+ }
+
+ if (this->parents == NULL) {
+ gf_msg(this->name, GF_LOG_WARNING, 0,
+ WRITE_BEHIND_MSG_VOL_MISCONFIGURED,
+ "dangling volume. check volfilex");
+ }
+
+ conf = GF_CALLOC(1, sizeof(*conf), gf_wb_mt_wb_conf_t);
+ if (conf == NULL) {
+ goto out;
+ }
+
+ /* configure 'options aggregate-size <size>' */
+ GF_OPTION_INIT("aggregate-size", conf->aggregate_size, size_uint64, out);
+ conf->page_size = conf->aggregate_size;
+
+ /* configure 'option window-size <size>' */
+ GF_OPTION_INIT("cache-size", conf->window_size, size_uint64, out);
+
+ if (!conf->window_size && conf->aggregate_size) {
+ gf_msg(this->name, GF_LOG_WARNING, 0, WRITE_BEHIND_MSG_SIZE_NOT_SET,
+ "setting window-size to be equal to "
+ "aggregate-size(%" PRIu64 ")",
+ conf->aggregate_size);
+ conf->window_size = conf->aggregate_size;
+ }
+
+ if (conf->window_size < conf->aggregate_size) {
+ gf_msg(this->name, GF_LOG_ERROR, 0, WRITE_BEHIND_MSG_EXCEEDED_MAX_SIZE,
+ "aggregate-size(%" PRIu64
+ ") cannot be more than "
+ "window-size(%" PRIu64 ")",
+ conf->aggregate_size, conf->window_size);
+ goto out;
+ }
+
+ /* configure 'option flush-behind <on/off>' */
+ GF_OPTION_INIT("flush-behind", conf->flush_behind, bool, out);
+
+ GF_OPTION_INIT("trickling-writes", conf->trickling_writes, bool, out);
+
+ GF_OPTION_INIT("strict-O_DIRECT", conf->strict_O_DIRECT, bool, out);
+
+ GF_OPTION_INIT("strict-write-ordering", conf->strict_write_ordering, bool,
+ out);
+
+ GF_OPTION_INIT("resync-failed-syncs-after-fsync", conf->resync_after_fsync,
+ bool, out);
+
+ this->private = conf;
+ ret = 0;
out:
- if (ret) {
- GF_FREE (conf);
- }
- return ret;
+ if (ret) {
+ GF_FREE(conf);
+ }
+ return ret;
}
-
void
-fini (xlator_t *this)
+fini(xlator_t *this)
{
- wb_conf_t *conf = NULL;
+ wb_conf_t *conf = NULL;
- GF_VALIDATE_OR_GOTO ("write-behind", this, out);
+ GF_VALIDATE_OR_GOTO("write-behind", this, out);
- conf = this->private;
- if (!conf) {
- goto out;
- }
+ conf = this->private;
+ if (!conf) {
+ goto out;
+ }
- this->private = NULL;
- GF_FREE (conf);
+ this->private = NULL;
+ GF_FREE(conf);
out:
- return;
+ return;
}
-
struct xlator_fops fops = {
- .writev = wb_writev,
- .readv = wb_readv,
- .flush = wb_flush,
- .fsync = wb_fsync,
- .stat = wb_stat,
- .fstat = wb_fstat,
- .truncate = wb_truncate,
- .ftruncate = wb_ftruncate,
- .setattr = wb_setattr,
- .fsetattr = wb_fsetattr,
- .lookup = wb_lookup,
- .readdirp = wb_readdirp,
- .link = wb_link,
- .fallocate = wb_fallocate,
- .discard = wb_discard,
- .zerofill = wb_zerofill,
- .rename = wb_rename,
-};
-
-
-struct xlator_cbks cbks = {
- .forget = wb_forget,
- .release = wb_release
+ .writev = wb_writev,
+ .readv = wb_readv,
+ .flush = wb_flush,
+ .fsync = wb_fsync,
+ .stat = wb_stat,
+ .fstat = wb_fstat,
+ .truncate = wb_truncate,
+ .ftruncate = wb_ftruncate,
+ .setattr = wb_setattr,
+ .fsetattr = wb_fsetattr,
+ .lookup = wb_lookup,
+ .readdirp = wb_readdirp,
+ .link = wb_link,
+ .fallocate = wb_fallocate,
+ .discard = wb_discard,
+ .zerofill = wb_zerofill,
+ .rename = wb_rename,
};
+struct xlator_cbks cbks = {.forget = wb_forget, .release = wb_release};
struct xlator_dumpops dumpops = {
- .priv = wb_priv_dump,
- .inodectx = wb_inode_dump,
+ .priv = wb_priv_dump,
+ .inodectx = wb_inode_dump,
};
-
struct volume_options options[] = {
- { .key = {"flush-behind"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "on",
- .op_version = {1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"write-behind"},
- .description = "If this option is set ON, instructs write-behind "
- "translator to perform flush in background, by "
- "returning success (or any errors, if any of "
- "previous writes were failed) to application even "
- "before flush FOP is sent to backend filesystem. "
- },
- { .key = {"cache-size", "window-size"},
- .type = GF_OPTION_TYPE_SIZET,
- .min = 512 * GF_UNIT_KB,
- .max = 1 * GF_UNIT_GB,
- .default_value = "1MB",
- .op_version = {1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"write-behind"},
- .description = "Size of the write-behind buffer for a single file "
- "(inode)."
- },
- { .key = {"trickling-writes"},
- .type = GF_OPTION_TYPE_BOOL,
- .op_version = {GD_OP_VERSION_3_13_1},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"write-behind"},
- .default_value = "on",
- },
- { .key = {"strict-O_DIRECT"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "off",
- .op_version = {2},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"write-behind"},
- .description = "This option when set to off, ignores the "
- "O_DIRECT flag."
- },
- { .key = {"strict-write-ordering"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "off",
- .op_version = {2},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"write-behind"},
- .description = "Do not let later writes overtake earlier writes even "
- "if they do not overlap",
- },
- { .key = {"resync-failed-syncs-after-fsync"},
- .type = GF_OPTION_TYPE_BOOL,
- .default_value = "off",
- .op_version = {GD_OP_VERSION_3_7_7},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .tags = {"write-behind"},
- .description = "If sync of \"cached-writes issued before fsync\" "
- "(to backend) fails, this option configures whether "
- "to retry syncing them after fsync or forget them. "
- "If set to on, cached-writes are retried "
- "till a \"flush\" fop (or a successful sync) on sync "
- "failures. "
- "fsync itself is failed irrespective of the value of "
- "this option. ",
- },
- { .key = {"aggregate-size"},
- .type = GF_OPTION_TYPE_SIZET,
- .default_value = "128KB",
- .op_version = {GD_OP_VERSION_4_1_0},
- .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
- .description = "Will aggregate writes until data of specified "
- "size is fully filled for a single file provided "
- "there are no dependent fops on cached writes. This "
- "option just sets the aggregate size. Note that "
- "aggregation won't happen if performance.write-behind-trickling-writes"
- " is turned on. Hence turn off performance.write-behind.trickling-writes"
- " so that writes are aggregated till a max of "
- "\"aggregate-size\" bytes",
- },
- { .key = {NULL} },
+ {.key = {"flush-behind"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "on",
+ .op_version = {1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"write-behind"},
+ .description = "If this option is set ON, instructs write-behind "
+ "translator to perform flush in background, by "
+ "returning success (or any errors, if any of "
+ "previous writes were failed) to application even "
+ "before flush FOP is sent to backend filesystem. "},
+ {.key = {"cache-size", "window-size"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .min = 512 * GF_UNIT_KB,
+ .max = 1 * GF_UNIT_GB,
+ .default_value = "1MB",
+ .op_version = {1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"write-behind"},
+ .description = "Size of the write-behind buffer for a single file "
+ "(inode)."},
+ {
+ .key = {"trickling-writes"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .op_version = {GD_OP_VERSION_3_13_1},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"write-behind"},
+ .default_value = "on",
+ },
+ {.key = {"strict-O_DIRECT"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .op_version = {2},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"write-behind"},
+ .description = "This option when set to off, ignores the "
+ "O_DIRECT flag."},
+ {
+ .key = {"strict-write-ordering"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .op_version = {2},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"write-behind"},
+ .description = "Do not let later writes overtake earlier writes even "
+ "if they do not overlap",
+ },
+ {
+ .key = {"resync-failed-syncs-after-fsync"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .op_version = {GD_OP_VERSION_3_7_7},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .tags = {"write-behind"},
+ .description = "If sync of \"cached-writes issued before fsync\" "
+ "(to backend) fails, this option configures whether "
+ "to retry syncing them after fsync or forget them. "
+ "If set to on, cached-writes are retried "
+ "till a \"flush\" fop (or a successful sync) on sync "
+ "failures. "
+ "fsync itself is failed irrespective of the value of "
+ "this option. ",
+ },
+ {
+ .key = {"aggregate-size"},
+ .type = GF_OPTION_TYPE_SIZET,
+ .default_value = "128KB",
+ .op_version = {GD_OP_VERSION_4_1_0},
+ .flags = OPT_FLAG_SETTABLE | OPT_FLAG_DOC | OPT_FLAG_CLIENT_OPT,
+ .description = "Will aggregate writes until data of specified "
+ "size is fully filled for a single file provided "
+ "there are no dependent fops on cached writes. This "
+ "option just sets the aggregate size. Note that "
+ "aggregation won't happen if "
+ "performance.write-behind-trickling-writes"
+ " is turned on. Hence turn off "
+ "performance.write-behind.trickling-writes"
+ " so that writes are aggregated till a max of "
+ "\"aggregate-size\" bytes",
+ },
+ {.key = {NULL}},
};