summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2012-01-18 18:06:44 +0530
committerAnand Avati <avati@gluster.com>2012-01-25 02:03:44 -0800
commitcf8486cbef329ef66868f658fa35f470f97db462 (patch)
tree18cf37bd7cf65ac820d435fb1ee43dc205a2917b /libglusterfs
parentb02afc6d008f9959db28244eb2b9dd3b9ef92393 (diff)
core: get xattrs also as part of readdirp
readdirp_req() call sends a dict_t * as an argument, which contains all the xattr keys for which the entries got in readdirp_rsp() are having xattr value filled dictionary. Change-Id: I8b7e1290740ea3e884e67d19156ce849227167c0 Signed-off-by: Amar Tumballi <amar@gluster.com> BUG: 765785 Reviewed-on: http://review.gluster.com/771 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@gluster.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/call-stub.c7
-rw-r--r--libglusterfs/src/call-stub.h6
-rw-r--r--libglusterfs/src/defaults.c8
-rw-r--r--libglusterfs/src/defaults.h8
-rw-r--r--libglusterfs/src/gf-dirent.c49
-rw-r--r--libglusterfs/src/gf-dirent.h6
-rw-r--r--libglusterfs/src/syncop.c3
-rw-r--r--libglusterfs/src/syncop.h1
-rw-r--r--libglusterfs/src/xlator.h3
9 files changed, 56 insertions, 35 deletions
diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c
index 8761b40a0..8b28dc9be 100644
--- a/libglusterfs/src/call-stub.c
+++ b/libglusterfs/src/call-stub.c
@@ -1810,7 +1810,8 @@ fop_readdirp_stub (call_frame_t *frame,
fop_readdirp_t fn,
fd_t *fd,
size_t size,
- off_t off)
+ off_t off,
+ dict_t *dict)
{
call_stub_t *stub = NULL;
@@ -1821,6 +1822,7 @@ fop_readdirp_stub (call_frame_t *frame,
stub->args.readdirp.fd = fd_ref (fd);
stub->args.readdirp.size = size;
stub->args.readdirp.off = off;
+ stub->args.readdirp.dict = dict;
out:
return stub;
@@ -2438,7 +2440,8 @@ call_resume_wind (call_stub_t *stub)
stub->frame->this,
stub->args.readdirp.fd,
stub->args.readdirp.size,
- stub->args.readdirp.off);
+ stub->args.readdirp.off,
+ stub->args.readdirp.dict);
break;
}
diff --git a/libglusterfs/src/call-stub.h b/libglusterfs/src/call-stub.h
index 01b6cdd1b..4b03dbfe2 100644
--- a/libglusterfs/src/call-stub.h
+++ b/libglusterfs/src/call-stub.h
@@ -502,6 +502,7 @@ typedef struct {
fd_t *fd;
size_t size;
off_t off;
+ dict_t *dict;
} readdirp;
struct {
fop_readdirp_cbk_t fn;
@@ -1022,10 +1023,11 @@ fop_readdir_stub (call_frame_t *frame,
call_stub_t *
fop_readdirp_stub (call_frame_t *frame,
- fop_readdir_t fn,
+ fop_readdirp_t fn,
fd_t *fd,
size_t size,
- off_t off);
+ off_t off,
+ dict_t *dict);
call_stub_t *
fop_readdirp_cbk_stub (call_frame_t *frame,
diff --git a/libglusterfs/src/defaults.c b/libglusterfs/src/defaults.c
index 392819ca9..828f266b3 100644
--- a/libglusterfs/src/defaults.c
+++ b/libglusterfs/src/defaults.c
@@ -750,10 +750,10 @@ default_readdir_resume (call_frame_t *frame, xlator_t *this, fd_t *fd,
int32_t
default_readdirp_resume (call_frame_t *frame, xlator_t *this, fd_t *fd,
- size_t size, off_t off)
+ size_t size, off_t off, dict_t *dict)
{
STACK_WIND (frame, default_readdirp_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdirp, fd, size, off);
+ FIRST_CHILD(this)->fops->readdirp, fd, size, off, dict);
return 0;
}
@@ -1117,10 +1117,10 @@ default_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd,
int32_t
default_readdirp (call_frame_t *frame, xlator_t *this, fd_t *fd,
- size_t size, off_t off)
+ size_t size, off_t off, dict_t *dict)
{
STACK_WIND (frame, default_readdirp_cbk, FIRST_CHILD(this),
- FIRST_CHILD(this)->fops->readdirp, fd, size, off);
+ FIRST_CHILD(this)->fops->readdirp, fd, size, off, dict);
return 0;
}
diff --git a/libglusterfs/src/defaults.h b/libglusterfs/src/defaults.h
index a312901a7..fe04cbf92 100644
--- a/libglusterfs/src/defaults.h
+++ b/libglusterfs/src/defaults.h
@@ -206,7 +206,7 @@ int32_t default_readdir (call_frame_t *frame,
int32_t default_readdirp (call_frame_t *frame,
xlator_t *this,
fd_t *fd,
- size_t size, off_t off);
+ size_t size, off_t off, dict_t *dict);
int32_t default_xattrop (call_frame_t *frame,
xlator_t *this,
@@ -418,9 +418,9 @@ int32_t default_readdir_resume (call_frame_t *frame,
size_t size, off_t off);
int32_t default_readdirp_resume (call_frame_t *frame,
- xlator_t *this,
- fd_t *fd,
- size_t size, off_t off);
+ xlator_t *this,
+ fd_t *fd,
+ size_t size, off_t off, dict_t *dict);
int32_t default_xattrop_resume (call_frame_t *frame,
xlator_t *this,
diff --git a/libglusterfs/src/gf-dirent.c b/libglusterfs/src/gf-dirent.c
index 4c85db3f3..8d15b0405 100644
--- a/libglusterfs/src/gf-dirent.c
+++ b/libglusterfs/src/gf-dirent.c
@@ -31,26 +31,6 @@
#include "xlator.h"
gf_dirent_t *
-gf_dirent_for_namelen (int len)
-{
- gf_dirent_t *gf_dirent = NULL;
-
- /* TODO: use mem-pool */
- gf_dirent = CALLOC (len, sizeof(char));
- if (!gf_dirent)
- return NULL;
-
- INIT_LIST_HEAD (&gf_dirent->list);
-
- gf_dirent->d_off = 0;
- gf_dirent->d_ino = -1;
- gf_dirent->d_type = 0;
-
- return gf_dirent;
-}
-
-
-gf_dirent_t *
gf_dirent_for_name (const char *name)
{
gf_dirent_t *gf_dirent = NULL;
@@ -86,7 +66,36 @@ gf_dirent_free (gf_dirent_t *entries)
return;
list_for_each_entry_safe (entry, tmp, &entries->list, list) {
+ if (entry->dict)
+ dict_unref (entry->dict);
+ if (entry->inode)
+ inode_unref (entry->inode);
+
list_del (&entry->list);
GF_FREE (entry);
}
}
+
+/* TODO: Currently, with this function, we will be breaking the
+ policy of 1-1 mapping of kernel nlookup refs with our inode_t's
+ nlookup count.
+ Need more thoughts before finalizing this function
+*/
+int
+gf_link_inodes_from_dirent (xlator_t *this, inode_t *parent,
+ gf_dirent_t *entries)
+{
+ gf_dirent_t *entry = NULL;
+ inode_t *link_inode = NULL;
+
+ list_for_each_entry (entry, &entries->list, list) {
+ if (entry->inode) {
+ link_inode = inode_link (entry->inode, parent,
+ entry->d_name, &entry->d_stat);
+ inode_lookup (link_inode);
+ inode_unref (link_inode);
+ }
+ }
+
+ return 0;
+}
diff --git a/libglusterfs/src/gf-dirent.h b/libglusterfs/src/gf-dirent.h
index db1dac835..29b4aba80 100644
--- a/libglusterfs/src/gf-dirent.h
+++ b/libglusterfs/src/gf-dirent.h
@@ -27,6 +27,7 @@
#endif
#include "iatt.h"
+#include "inode.h"
#define gf_dirent_size(name) (sizeof (gf_dirent_t) + strlen (name) + 1)
@@ -51,12 +52,15 @@ struct _gf_dirent_t {
uint32_t d_len;
uint32_t d_type;
struct iatt d_stat;
+ dict_t *dict;
+ inode_t *inode;
char d_name[0];
};
gf_dirent_t *gf_dirent_for_name (const char *name);
void gf_dirent_free (gf_dirent_t *entries);
-gf_dirent_t * gf_dirent_for_namelen (int len);
+int gf_link_inodes_from_dirent (xlator_t *this, inode_t *parent,
+ gf_dirent_t *entries);
#endif /* _GF_DIRENT_H */
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index 99956bfb7..2771bdea5 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -394,12 +394,13 @@ syncop_readdirp (xlator_t *subvol,
fd_t *fd,
size_t size,
off_t off,
+ dict_t *dict,
gf_dirent_t *entries)
{
struct syncargs args = {0, };
SYNCOP (subvol, (&args), syncop_readdirp_cbk, subvol->fops->readdirp,
- fd, size, off);
+ fd, size, off, dict);
if (entries)
list_splice_init (&args.entries.list, &entries->list);
diff --git a/libglusterfs/src/syncop.h b/libglusterfs/src/syncop.h
index 9d9c5a9cc..b4cdafd53 100644
--- a/libglusterfs/src/syncop.h
+++ b/libglusterfs/src/syncop.h
@@ -165,6 +165,7 @@ int syncop_lookup (xlator_t *subvol, loc_t *loc, dict_t *xattr_req,
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,
+ dict_t *dict,
/* out */
gf_dirent_t *entries);
diff --git a/libglusterfs/src/xlator.h b/libglusterfs/src/xlator.h
index c86e8718c..fab3b4468 100644
--- a/libglusterfs/src/xlator.h
+++ b/libglusterfs/src/xlator.h
@@ -606,7 +606,8 @@ typedef int32_t (*fop_readdirp_t) (call_frame_t *frame,
xlator_t *this,
fd_t *fd,
size_t size,
- off_t offset);
+ off_t offset,
+ dict_t *dict);
typedef int32_t (*fop_xattrop_t) (call_frame_t *frame,
xlator_t *this,