Remove useless "while" loop. If the condition ci.sector_count && !error is
true, we go to a branch that ends with "break". If this condition is
false, the "while" loop will not be executed again. So, the loop can't be
executed more than once.

Signed-off-by: Mikulas Patocka <[email protected]>

---
 drivers/md/dm.c |   57 ++++++++++++++++++++++++++------------------------------
 1 file changed, 27 insertions(+), 30 deletions(-)

Index: linux-2.6/drivers/md/dm.c
===================================================================
--- linux-2.6.orig/drivers/md/dm.c      2021-02-23 17:18:54.000000000 +0100
+++ linux-2.6/drivers/md/dm.c   2021-02-26 19:10:31.000000000 +0100
@@ -1584,38 +1584,35 @@ static blk_qc_t __split_and_process_bio(
        } else {
                ci.bio = bio;
                ci.sector_count = bio_sectors(bio);
-               while (ci.sector_count && !error) {
-                       error = __split_and_process_non_flush(&ci);
-                       if (ci.sector_count && !error) {
-                               /*
-                                * Remainder must be passed to 
submit_bio_noacct()
-                                * so that it gets handled *after* bios already 
submitted
-                                * have been completely processed.
-                                * We take a clone of the original to store in
-                                * ci.io->orig_bio to be used by end_io_acct() 
and
-                                * for dec_pending to use for completion 
handling.
-                                */
-                               struct bio *b = bio_split(bio, bio_sectors(bio) 
- ci.sector_count,
-                                                         GFP_NOIO, 
&md->queue->bio_split);
-                               ci.io->orig_bio = b;
+               error = __split_and_process_non_flush(&ci);
+               if (ci.sector_count && !error) {
+                       /*
+                        * Remainder must be passed to submit_bio_noacct()
+                        * so that it gets handled *after* bios already 
submitted
+                        * have been completely processed.
+                        * We take a clone of the original to store in
+                        * ci.io->orig_bio to be used by end_io_acct() and
+                        * for dec_pending to use for completion handling.
+                        */
+                       struct bio *b = bio_split(bio, bio_sectors(bio) - 
ci.sector_count,
+                                                 GFP_NOIO, 
&md->queue->bio_split);
+                       ci.io->orig_bio = b;
 
-                               /*
-                                * Adjust IO stats for each split, otherwise 
upon queue
-                                * reentry there will be redundant IO 
accounting.
-                                * NOTE: this is a stop-gap fix, a proper fix 
involves
-                                * significant refactoring of DM core's bio 
splitting
-                                * (by eliminating DM's splitting and just 
using bio_split)
-                                */
-                               part_stat_lock();
-                               __dm_part_stat_sub(dm_disk(md)->part0,
-                                                  
sectors[op_stat_group(bio_op(bio))], ci.sector_count);
-                               part_stat_unlock();
+                       /*
+                        * Adjust IO stats for each split, otherwise upon queue
+                        * reentry there will be redundant IO accounting.
+                        * NOTE: this is a stop-gap fix, a proper fix involves
+                        * significant refactoring of DM core's bio splitting
+                        * (by eliminating DM's splitting and just using 
bio_split)
+                        */
+                       part_stat_lock();
+                       __dm_part_stat_sub(dm_disk(md)->part0,
+                                          sectors[op_stat_group(bio_op(bio))], 
ci.sector_count);
+                       part_stat_unlock();
 
-                               bio_chain(b, bio);
-                               trace_block_split(b, bio->bi_iter.bi_sector);
-                               ret = submit_bio_noacct(bio);
-                               break;
-                       }
+                       bio_chain(b, bio);
+                       trace_block_split(b, bio->bi_iter.bi_sector);
+                       ret = submit_bio_noacct(bio);
                }
        }
 

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

Reply via email to