gluster / glusterfs

Gluster Filesystem : Build your distributed storage in minutes
https://www.gluster.org
GNU General Public License v2.0
4.51k stars 1.07k forks source link

small improvement around readdir(p) #4346

Open mykaul opened 2 weeks ago

mykaul commented 2 weeks ago

Updates: #1000

mykaul commented 2 weeks ago

CC @jkroonza - this is a patch I've found somewhere in my archives and is an example of a (micro) optimization. HTH. I believe I've had one that improves some inode (link?) code paths that might be useful too.

gluster-ant commented 2 weeks ago

CLANG-FORMAT FAILURE: Before merging the patch, this diff needs to be considered for passing clang-format

index ade8773fd..329f1e55c 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -5891,7 +5891,8 @@ posix_readdirp_fill(xlator_t *this, fd_t *fd, gf_dirent_t *entries,
             ret = posix_pstat(this, inode, inode->gfid, hpath, &stbuf,
                               _gf_false, _gf_true);
         else
-            ret = posix_pstat(this, inode, zero_gfid, hpath, &stbuf, _gf_false, _gf_true);
+            ret = posix_pstat(this, inode, zero_gfid, hpath, &stbuf, _gf_false,
+                              _gf_true);

         if (ret == -1) {
             if (inode)
@@ -6033,10 +6034,7 @@ posix_readdirp(call_frame_t *frame, xlator_t *this, fd_t *fd, size_t size,
         if (op_ret >= 0) {
             op_ret = 0;

-            list_for_each_entry(entry, &entries.list, list)
-            {
-                op_ret++;
-            }
+            list_for_each_entry(entry, &entries.list, list) { op_ret++; }
         }

         STACK_UNWIND_STRICT(readdirp, frame, op_ret, op_errno, &entries, NULL);