summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/syncop.c192
-rw-r--r--libglusterfs/src/syncop.h21
-rw-r--r--libglusterfs/src/xlator.h1
3 files changed, 211 insertions, 3 deletions
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index beb5d9db4a1..cfece659171 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -24,6 +24,20 @@
#include "syncop.h"
+call_frame_t *
+syncop_create_frame ()
+{
+ struct synctask *task = NULL;
+ struct call_frame_t *frame = NULL;
+
+ task = synctask_get ();
+
+ if (task) {
+ frame = task->opaque;
+ }
+
+ return (call_frame_t *)frame;
+}
void
synctask_yield (struct synctask *task)
@@ -95,6 +109,8 @@ synctask_wrap (struct synctask *task)
*/
task->complete = 1;
synctask_wake (task);
+
+ synctask_yield (task);
}
@@ -105,7 +121,7 @@ synctask_destroy (struct synctask *task)
return;
if (task->stack)
- FREE (task);
+ FREE (task->stack);
FREE (task);
}
@@ -305,7 +321,181 @@ syncop_lookup (xlator_t *subvol, loc_t *loc, dict_t *xattr_req,
return args.op_ret;
}
+static gf_dirent_t *
+entry_copy (gf_dirent_t *source)
+{
+ gf_dirent_t *sink = NULL;
+
+ sink = gf_dirent_for_name (source->d_name);
+
+ sink->d_off = source->d_off;
+ sink->d_ino = source->d_ino;
+ sink->d_type = source->d_type;
+
+ return sink;
+}
+
+int32_t
+syncop_readdirp_cbk (call_frame_t *frame,
+ void *cookie,
+ xlator_t *this,
+ int32_t op_ret,
+ int32_t op_errno,
+ gf_dirent_t *entries)
+{
+ struct syncargs *args = NULL;
+ gf_dirent_t *entry = NULL;
+ gf_dirent_t *tmp = NULL;
+
+ int count = 0;
+
+ args = cookie;
+
+ INIT_LIST_HEAD (&args->entries.list);
+
+ args->op_ret = op_ret;
+ args->op_errno = op_errno;
+
+ if (op_ret >= 0) {
+ list_for_each_entry (entry, &entries->list, list) {
+ tmp = entry_copy (entry);
+ gf_log (this->name, GF_LOG_TRACE,
+ "adding entry=%s, count=%d",
+ tmp->d_name, count);
+ list_add_tail (&tmp->list, &(args->entries.list));
+ count++;
+ }
+ }
+
+ __wake (args);
+
+ return 0;
+
+}
+
+int
+syncop_readdirp (xlator_t *subvol,
+ fd_t *fd,
+ size_t size,
+ off_t off,
+ gf_dirent_t *entries)
+{
+ struct syncargs args = {0, };
+
+ SYNCOP (subvol, (&args), syncop_readdirp_cbk, subvol->fops->readdirp,
+ fd, size, off);
+
+ if (entries)
+ list_splice_init (&args.entries.list, &entries->list);
+
+ errno = args.op_errno;
+ return args.op_ret;
+
+}
+
+int32_t
+syncop_opendir_cbk (call_frame_t *frame,
+ void *cookie,
+ xlator_t *this,
+ int32_t op_ret,
+ int32_t op_errno,
+ fd_t *fd)
+{
+ struct syncargs *args = NULL;
+
+ args = cookie;
+
+ args->op_ret = op_ret;
+ args->op_errno = op_errno;
+
+ __wake (args);
+
+ return 0;
+}
+
+int
+syncop_opendir (xlator_t *subvol,
+ loc_t *loc,
+ fd_t *fd)
+{
+ struct syncargs args = {0, };
+ SYNCOP (subvol, (&args), syncop_opendir_cbk, subvol->fops->opendir,
+ loc, fd);
+
+ errno = args.op_errno;
+ return args.op_ret;
+
+}
+
+
+int
+syncop_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int op_ret, int op_errno)
+{
+ struct syncargs *args = NULL;
+
+ args = cookie;
+
+ args->op_ret = op_ret;
+ args->op_errno = op_errno;
+
+ __wake (args);
+
+ return 0;
+}
+
+
+int
+syncop_setxattr (xlator_t *subvol, loc_t *loc, dict_t *dict, int32_t flags)
+{
+ struct syncargs args = {0, };
+
+ SYNCOP (subvol, (&args), syncop_setxattr_cbk, subvol->fops->setxattr,
+ loc, dict, flags);
+
+ errno = args.op_errno;
+ return args.op_ret;
+}
+
+int
+syncop_statfs_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno,
+ struct statvfs *buf)
+
+{
+ struct syncargs *args = NULL;
+
+ args = cookie;
+
+ args->op_ret = op_ret;
+ args->op_errno = op_errno;
+
+ if (op_ret == 0) {
+ args->statvfs_buf = *buf;
+ }
+
+ __wake (args);
+
+ return 0;
+}
+
+
+int
+syncop_statfs (xlator_t *subvol, loc_t *loc, struct statvfs *buf)
+
+{
+ struct syncargs args = {0, };
+
+ SYNCOP (subvol, (&args), syncop_statfs_cbk, subvol->fops->statfs,
+ loc);
+
+ if (buf)
+ *buf = args.statvfs_buf;
+
+ errno = args.op_errno;
+ return args.op_ret;
+}
int
syncop_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index ce364b07301..13b07ed31fd 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -76,6 +76,8 @@ struct syncargs {
struct iatt iatt1;
struct iatt iatt2;
dict_t *xattr;
+ gf_dirent_t entries;
+ struct statvfs statvfs_buf;
/* do not touch */
pthread_mutex_t mutex;
@@ -134,10 +136,10 @@ struct syncargs {
#define SYNCOP(subvol, stb, cbk, op, params ...) do { \
call_frame_t *frame = NULL; \
\
- frame = create_frame (THIS, THIS->ctx->pool); \
+ frame = syncop_create_frame (); \
\
__yawn (stb); \
- STACK_WIND_COOKIE (frame, (void *)stb, cbk, subvol, op, params);\
+ STACK_WIND_COOKIE (frame, cbk, (void *)stb, subvol, op, params);\
__yield (stb); \
} while (0)
@@ -157,8 +159,23 @@ int syncop_lookup (xlator_t *subvol, loc_t *loc, dict_t *xattr_req,
/* out */
struct iatt *iatt, dict_t **xattr_rsp, struct iatt *parent);
+int syncop_readdirp (xlator_t *subvol, fd_t *fd, size_t size, off_t off,
+ /* out */
+ gf_dirent_t *entries);
+
+int
+syncop_opendir (xlator_t *subvol,
+ loc_t *loc,
+ fd_t *fd);
+
int syncop_setattr (xlator_t *subvol, loc_t *loc, struct iatt *iatt, int valid,
/* out */
struct iatt *preop, struct iatt *postop);
+int
+syncop_statfs (xlator_t *subvol, loc_t *loc, struct statvfs *buf);
+
+int
+syncop_setxattr (xlator_t *subvol, loc_t *loc, dict_t *dict, int32_t flags);
+
#endif /* _SYNCOP_H */
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index e373cc42400..ef79c354fcc 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -76,6 +76,7 @@ typedef int32_t (*event_notify_fn_t) (xlator_t *this, int32_t event, void *data,
#include "iatt.h"
+
struct _loc {
const char *path;
const char *name;