From cf8486cbef329ef66868f658fa35f470f97db462 Mon Sep 17 00:00:00 2001 From: Amar Tumballi Date: Wed, 18 Jan 2012 18:06:44 +0530 Subject: 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 BUG: 765785 Reviewed-on: http://review.gluster.com/771 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- libglusterfs/src/call-stub.c | 7 +++++-- libglusterfs/src/call-stub.h | 6 ++++-- libglusterfs/src/defaults.c | 8 ++++---- libglusterfs/src/defaults.h | 8 ++++---- libglusterfs/src/gf-dirent.c | 49 ++++++++++++++++++++++++++------------------ libglusterfs/src/gf-dirent.h | 6 +++++- libglusterfs/src/syncop.c | 3 ++- libglusterfs/src/syncop.h | 1 + libglusterfs/src/xlator.h | 3 ++- 9 files changed, 56 insertions(+), 35 deletions(-) (limited to 'libglusterfs') diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index 8761b40a0c6..8b28dc9bec6 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 01b6cdd1b38..4b03dbfe209 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 392819ca9d1..828f266b38e 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 a312901a779..fe04cbf9205 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 4c85db3f3cf..8d15b040553 100644 --- a/libglusterfs/src/gf-dirent.c +++ b/libglusterfs/src/gf-dirent.c @@ -30,26 +30,6 @@ #include "compat.h" #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) { @@ -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 db1dac83566..29b4aba8036 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 99956bfb7ee..2771bdea5b6 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 9d9c5a9ccf7..b4cdafd535c 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 c86e8718cac..fab3b4468d8 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, -- cgit