summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Avati <avati@redhat.com>2012-05-27 16:52:21 -0700
committerAnand Avati <avati@redhat.com>2012-05-29 23:03:52 -0700
commit1b798491193add9cb296ce6817a6cbc2fdb9db34 (patch)
treea71c4313a0bcbcf83e4fab39cfd563385415253b
parent493ef71222e780cb542c7edc5dfb7d0e3097c55a (diff)
storage/posix: readdirp enhancementsv3.3.0
- avoid multiple calls to posix_istat(). use cheaper posix_pstat() - code re-org Change-Id: I4a2e32626ade49b7d18158952849c6fe7bd6875c BUG: 816140 Reviewed-on: http://review.gluster.com/3488 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-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 f9805628689..62c36d79426 100644
--- a/xlators/storage/posix/src/posix.c
+++ b/xlators/storage/posix/src/posix.c
@@ -3610,6 +3610,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)
@@ -3621,13 +3679,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);
@@ -3650,7 +3702,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);
@@ -3661,43 +3713,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);