Whamcloud - gitweb
LU-9679 osc: convert a while loop to for 06/37606/2
authorNeilBrown <neilb@suse.com>
Thu, 13 Dec 2018 00:00:38 +0000 (11:00 +1100)
committerOleg Drokin <green@whamcloud.com>
Sun, 1 Mar 2020 05:35:12 +0000 (05:35 +0000)
This loop uses 'continue' in several places,
and each one is proceeded by
   ext = next_extent(ext)
which also appears at the end.
This is exactly the pattern that a 'for' loop
simplifies.  So change to a for loop.

Linux-Commit 9083b739197b ("lustre: osc: convert a while loop to for")

Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Mr NeilBrown <neilb@suse.com>
Change-Id: Ie622690134f9b3ee829255bcf997d06289abd6e6
Reviewed-on: https://review.whamcloud.com/37606
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osc/osc_cache.c

index 38a64d1..917ed96 100644 (file)
@@ -692,11 +692,11 @@ static struct osc_extent *osc_extent_find(const struct lu_env *env,
 restart:
        osc_object_lock(obj);
        ext = osc_extent_search(obj, cur->oe_start);
-       if (ext == NULL)
+       if (!ext)
                ext = first_extent(obj);
-       while (ext != NULL) {
+       for (; ext; ext = next_extent(ext)) {
                pgoff_t ext_chk_start = ext->oe_start >> ppc_bits;
-               pgoff_t ext_chk_end   = ext->oe_end   >> ppc_bits;
+               pgoff_t ext_chk_end = ext->oe_end >> ppc_bits;
 
                LASSERT(sanity_check_nolock(ext) == 0);
                if (chunk > ext_chk_end + 1 || chunk < ext_chk_start)
@@ -707,15 +707,12 @@ restart:
                        EASSERTF(!overlapped(ext, cur), ext,
                                 EXTSTR"\n", EXTPARA(cur));
 
-                       ext = next_extent(ext);
                        continue;
                }
 
                /* discontiguous chunks? */
-               if (chunk + 1 < ext_chk_start) {
-                       ext = next_extent(ext);
+               if (chunk + 1 < ext_chk_start)
                        continue;
-               }
 
                /* ok, from now on, ext and cur have these attrs:
                 * 1. covered by the same lock
@@ -740,30 +737,24 @@ restart:
                }
 
                /* non-overlapped extent */
-               if (ext->oe_state != OES_CACHE || ext->oe_fsync_wait) {
+               if (ext->oe_state != OES_CACHE || ext->oe_fsync_wait)
                        /* we can't do anything for a non OES_CACHE extent, or
                         * if there is someone waiting for this extent to be
                         * flushed, try next one. */
-                       ext = next_extent(ext);
                        continue;
-               }
 
                /* check if they belong to the same rpc slot before trying to
                 * merge. the extents are not overlapped and contiguous at
                 * chunk level to get here. */
-               if (ext->oe_max_end != max_end) {
+               if (ext->oe_max_end != max_end)
                        /* if they don't belong to the same RPC slot or
                         * max_pages_per_rpc has ever changed, do not merge. */
-                       ext = next_extent(ext);
                        continue;
-               }
 
                /* check whether maximum extent size will be hit */
                if ((ext_chk_end - ext_chk_start + 1 + 1) << ppc_bits >
-                   cli->cl_max_extent_pages) {
-                       ext = next_extent(ext);
+                   cli->cl_max_extent_pages)
                        continue;
-               }
 
                /* it's required that an extent must be contiguous at chunk
                 * level so that we know the whole extent is covered by grant
@@ -800,8 +791,6 @@ restart:
                }
                if (found != NULL)
                        break;
-
-               ext = next_extent(ext);
        }
 
        osc_extent_tree_dump(D_CACHE, obj);