summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-05-27 16:52:21 -0700
committerAnand Avati <avati@redhat.com>2012-05-28 19:43:30 -0700
commit28afac7af6989953e53b35ed7fbb944a45f691a4 (patch)
tree40d87b922ed70092bdd69da4b5c9ef1e4b89a25d /xlators/storage/posix
parent5d0194e8ed68d587ffbe0531fe634790fd51f698 (diff)
storage/posix: readdirp enhancements
- avoid multiple calls to posix_istat(). use cheaper posix_pstat() - code re-org Change-Id: I4a2e32626ade49b7d18158952849c6fe7bd6875c BUG: 816140 Reviewed-on: http://review.gluster.com/3460 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/storage/posix')
-rw-r--r--xlators/storage/posix/src/posix.c106
1 files changed, 61 insertions, 45 deletions
diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c
index 0b469ec66..7dbd7546c 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3611,6 +3611,64 @@ posix_entry_xattr_fill (xlator_t *this, inode_t *inode,
}
+
+int
+posix_readdirp_fill (xlator_t *this, fd_t *fd, gf_dirent_t *entries, dict_t *dict)
+{
+ gf_dirent_t *entry = NULL;
+ inode_table_t *itable = NULL;
+ inode_t *inode = NULL;
+ char *hpath = NULL;
+ int len = 0;
+ struct iatt stbuf = {0, };
+ uuid_t gfid;
+
+
+ itable = fd->inode->table;
+
+ len = posix_handle_path (this, fd->inode->gfid, NULL, NULL, 0);
+ hpath = alloca (len + 256); /* NAME_MAX */
+ posix_handle_path (this, fd->inode->gfid, NULL, hpath, len);
+ len = strlen (hpath);
+ hpath[len] = '/';
+
+ list_for_each_entry (entry, &entries->list, list) {
+ memset (gfid, 0, 16);
+ inode = inode_grep (fd->inode->table, fd->inode,
+ entry->d_name);
+ if (inode)
+ uuid_copy (gfid, inode->gfid);
+
+ strcpy (&hpath[len+1], entry->d_name);
+
+ posix_pstat (this, gfid, hpath, &stbuf);
+
+ if (!inode)
+ inode = inode_find (itable, stbuf.ia_gfid);
+
+ if (!inode)
+ inode = inode_new (itable);
+
+ entry->inode = inode;
+
+ if (dict) {
+ entry->dict =
+ posix_entry_xattr_fill (this, entry->inode,
+ fd, entry->d_name,
+ dict, &stbuf);
+ dict_ref (entry->dict);
+ }
+
+ entry->d_stat = stbuf;
+ if (stbuf.ia_ino)
+ entry->d_ino = stbuf.ia_ino;
+ inode = NULL;
+ }
+
+ return 0;
+}
+
+
int32_t
posix_do_readdir (call_frame_t *frame, xlator_t *this,
fd_t *fd, size_t size, off_t off, int whichop, dict_t *dict)
@@ -3622,13 +3680,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this,
int32_t op_ret = -1;
int32_t op_errno = 0;
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;
-#endif
+
VALIDATE_OR_GOTO (frame, out);
VALIDATE_OR_GOTO (this, out);
@@ -3651,7 +3703,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this,
"dir is NULL for fd=%p", fd);
op_errno = EINVAL;
goto out;
- }
+ }
count = posix_fill_readdir (fd, dir, off, size, &entries);
@@ -3662,43 +3714,7 @@ posix_do_readdir (call_frame_t *frame, xlator_t *this,
if (whichop != GF_FOP_READDIRP)
goto out;
- 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
- posix_istat (this, fd->inode->gfid,
- tmp_entry->d_name, &stbuf);
-#endif
- 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);
- dict_ref (tmp_entry->dict);
- }
-
- tmp_entry->d_stat = stbuf;
- }
+ posix_readdirp_fill (this, fd, &entries, dict);
out:
STACK_UNWIND_STRICT (readdir, frame, op_ret, op_errno, &entries, NULL);