summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr
diff options
context:
space:
mode:
authorShehjar Tikoo <shehjart@gluster.com>2009-10-02 03:07:55 +0000
committerAnand V. Avati <avati@dev.gluster.com>2009-10-06 06:34:53 -0700
commit02bced30690a5d298f262dce459bfecd001da2fe (patch)
treeb8b243be98e46fbea57536f9e7659feb8696fa55 /xlators/cluster/afr
parent6b5a8b8536a943bd7f3241e1a08de934f7566169 (diff)
afr: Support readdirp fop
Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 292 (Separate readdirp functionality from readdir fop) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=292
Diffstat (limited to 'xlators/cluster/afr')
-rw-r--r--xlators/cluster/afr/src/afr-dir-read.c82
-rw-r--r--xlators/cluster/afr/src/afr-dir-read.h4
-rw-r--r--xlators/cluster/afr/src/afr.c1
3 files changed, 77 insertions, 10 deletions
diff --git a/xlators/cluster/afr/src/afr-dir-read.c b/xlators/cluster/afr/src/afr-dir-read.c
index f1638c740..e259f624b 100644
--- a/xlators/cluster/afr/src/afr-dir-read.c
+++ b/xlators/cluster/afr/src/afr-dir-read.c
@@ -180,8 +180,45 @@ afr_readdir_cbk (call_frame_t *frame, void *cookie,
int32_t
-afr_readdir (call_frame_t *frame, xlator_t *this,
- fd_t *fd, size_t size, off_t offset)
+afr_readdirp_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
+ int32_t op_ret, int32_t op_errno, gf_dirent_t *entries)
+{
+ afr_private_t * priv = NULL;
+ afr_local_t * local = NULL;
+ xlator_t ** children = NULL;
+ ino_t inum = 0;
+
+ gf_dirent_t * entry = NULL;
+
+ int child_index = -1;
+
+ priv = this->private;
+ children = priv->children;
+
+ local = frame->local;
+
+ child_index = (long) cookie;
+
+ if (op_ret != -1) {
+ list_for_each_entry (entry, &entries->list, list) {
+ inum = afr_itransform (entry->d_ino, priv->child_count,
+ child_index);
+ entry->d_ino = inum;
+ inum = afr_itransform (entry->d_stat.st_ino,
+ priv->child_count, child_index);
+ entry->d_stat.st_ino = inum;
+ }
+ }
+
+ AFR_STACK_UNWIND (frame, op_ret, op_errno, entries);
+
+ return 0;
+}
+
+
+int32_t
+afr_do_readdir (call_frame_t *frame, xlator_t *this,
+ fd_t *fd, size_t size, off_t offset, int whichop)
{
afr_private_t * priv = NULL;
xlator_t ** children = NULL;
@@ -217,14 +254,22 @@ afr_readdir (call_frame_t *frame, xlator_t *this,
goto out;
}
- local->fd = fd_ref (fd);
- local->cont.readdir.size = size;
- local->cont.readdir.offset = offset;
-
- STACK_WIND_COOKIE (frame, afr_readdir_cbk, (void *) (long) call_child,
- children[call_child],
- children[call_child]->fops->readdir,
- fd, size, offset);
+ local->fd = fd_ref (fd);
+ local->cont.readdir.size = size;
+ local->cont.readdir.offset = offset;
+
+ if (whichop == GF_FOP_READDIR)
+ STACK_WIND_COOKIE (frame, afr_readdir_cbk,
+ (void *) (long) call_child,
+ children[call_child],
+ children[call_child]->fops->readdir, fd,
+ size, offset);
+ else
+ STACK_WIND_COOKIE (frame, afr_readdirp_cbk,
+ (void *) (long) call_child,
+ children[call_child],
+ children[call_child]->fops->readdirp, fd,
+ size, offset);
op_ret = 0;
out:
@@ -236,6 +281,23 @@ out:
int32_t
+afr_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset)
+{
+ afr_do_readdir (frame, this, fd, size, offset, GF_FOP_READDIR);
+ return 0;
+}
+
+
+int32_t
+afr_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
+ off_t offset)
+{
+ afr_do_readdir (frame, this, fd, size, offset, GF_FOP_READDIRP);
+ return 0;
+}
+
+int32_t
afr_getdents_cbk (call_frame_t *frame, void *cookie,
xlator_t *this, int32_t op_ret, int32_t op_errno,
dir_entry_t *entry, int32_t count)
diff --git a/xlators/cluster/afr/src/afr-dir-read.h b/xlators/cluster/afr/src/afr-dir-read.h
index 6d981fdfd..8749c35ff 100644
--- a/xlators/cluster/afr/src/afr-dir-read.h
+++ b/xlators/cluster/afr/src/afr-dir-read.h
@@ -35,6 +35,10 @@ afr_readdir (call_frame_t *frame, xlator_t *this,
int32_t
+afr_readdirp (call_frame_t *frame, xlator_t *this,
+ fd_t *fd, size_t size, off_t offset);
+
+int32_t
afr_getdents (call_frame_t *frame, xlator_t *this,
fd_t *fd, size_t size, off_t offset, int32_t flag);
diff --git a/xlators/cluster/afr/src/afr.c b/xlators/cluster/afr/src/afr.c
index befc182b6..babcbae8c 100644
--- a/xlators/cluster/afr/src/afr.c
+++ b/xlators/cluster/afr/src/afr.c
@@ -2612,6 +2612,7 @@ struct xlator_fops fops = {
/* dir read */
.opendir = afr_opendir,
.readdir = afr_readdir,
+ .readdir = afr_readdirp,
.getdents = afr_getdents,
/* dir write */