diff options
author | Amar Tumballi <amar@gluster.com> | 2012-01-18 18:06:44 +0530 |
---|---|---|
committer | Anand Avati <avati@gluster.com> | 2012-01-25 02:03:44 -0800 |
commit | cf8486cbef329ef66868f658fa35f470f97db462 (patch) | |
tree | 18cf37bd7cf65ac820d435fb1ee43dc205a2917b /xlators/storage | |
parent | b02afc6d008f9959db28244eb2b9dd3b9ef92393 (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 'xlators/storage')
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 2 | ||||
-rw-r--r-- | xlators/storage/posix/src/posix.c | 80 |
2 files changed, 57 insertions, 25 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 31a4e667d17..346e6a7a640 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -170,7 +170,7 @@ _posix_xattr_get_set (dict_t *xattr_req, } } else if (!strcmp (key, GLUSTERFS_OPEN_FD_COUNT)) { loc = filler->loc; - if (!list_empty (&loc->inode->fd_list)) { + if (loc && !list_empty (&loc->inode->fd_list)) { ret = dict_set_uint32 (filler->xattr, key, 1); if (ret < 0) gf_log (filler->this->name, GF_LOG_WARNING, diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 7f82431e88b..f895aec2b06 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -3386,10 +3386,27 @@ out: return count; } +dict_t * +posix_entry_xattr_fill (xlator_t *this, inode_t *inode, + fd_t *fd, char *name, dict_t *dict, + struct iatt *stbuf) +{ + loc_t tmp_loc = {0,}; + char *entry_path = NULL; + + /* if we don't send the 'loc', open-fd-count be a problem. */ + tmp_loc.inode = inode; + + MAKE_HANDLE_PATH (entry_path, this, fd->inode->gfid, name); + + return posix_lookup_xattr_fill (this, entry_path, + &tmp_loc, dict, stbuf); + +} int32_t posix_do_readdir (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t off, int whichop) + fd_t *fd, size_t size, off_t off, int whichop, dict_t *dict) { struct posix_fd *pfd = NULL; DIR *dir = NULL; @@ -3400,6 +3417,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this, gf_dirent_t entries; struct iatt stbuf = {0, }; gf_dirent_t *tmp_entry = NULL; + inode_table_t *itable = NULL; #ifdef IGNORE_READDIRP_ATTRS uuid_t gfid; ia_type_t entry_type = 0; @@ -3432,33 +3450,47 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this, /* pick ENOENT to indicate EOF */ op_errno = errno; + op_ret = count; + + if (whichop != GF_FOP_READDIRP) + goto out; - if (whichop == GF_FOP_READDIRP) { - list_for_each_entry (tmp_entry, &entries.list, list) { + itable = fd->inode->table; + + list_for_each_entry (tmp_entry, &entries.list, list) { #ifdef IGNORE_READDIRP_ATTRS - ret = inode_grep_for_gfid (fd->inode->table, fd->inode, - tmp_entry->d_name, gfid, - &entry_type); - if (ret == 0) { - memset (&stbuf, 0, sizeof (stbuf)); - uuid_copy (stbuf.ia_gfid, gfid); - posix_fill_ino_from_gfid (this, &stbuf); - stbuf.ia_type = entry_type; - } else { - posix_istat (this, fd->inode->gfid, - tmp_entry->d_name, &stbuf); - } -#else + ret = inode_grep_for_gfid (fd->inode->table, fd->inode, + tmp_entry->d_name, gfid, + &entry_type); + if (ret == 0) { + memset (&stbuf, 0, sizeof (stbuf)); + uuid_copy (stbuf.ia_gfid, gfid); + posix_fill_ino_from_gfid (this, &stbuf); + stbuf.ia_type = entry_type; + } else { posix_istat (this, fd->inode->gfid, tmp_entry->d_name, &stbuf); + } +#else + posix_istat (this, fd->inode->gfid, + tmp_entry->d_name, &stbuf); #endif - if (stbuf.ia_ino) - tmp_entry->d_ino = stbuf.ia_ino; - tmp_entry->d_stat = stbuf; + if (stbuf.ia_ino) + tmp_entry->d_ino = stbuf.ia_ino; + + if (dict) { + tmp_entry->inode = inode_find (itable, stbuf.ia_gfid); + if (!tmp_entry->inode) + tmp_entry->inode = inode_new (itable); + + tmp_entry->dict = + posix_entry_xattr_fill (this, tmp_entry->inode, + fd, tmp_entry->d_name, + dict, &stbuf); } - } - op_ret = count; + tmp_entry->d_stat = stbuf; + } out: STACK_UNWIND_STRICT (readdir, frame, op_ret, op_errno, &entries); @@ -3473,16 +3505,16 @@ int32_t posix_readdir (call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size, off_t off) { - posix_do_readdir (frame, this, fd, size, off, GF_FOP_READDIR); + posix_do_readdir (frame, this, fd, size, off, GF_FOP_READDIR, NULL); return 0; } int32_t posix_readdirp (call_frame_t *frame, xlator_t *this, - fd_t *fd, size_t size, off_t off) + fd_t *fd, size_t size, off_t off, dict_t *dict) { - posix_do_readdir (frame, this, fd, size, off, GF_FOP_READDIRP); + posix_do_readdir (frame, this, fd, size, off, GF_FOP_READDIRP, dict); return 0; } |