Patch "btrfs: scrub: update last_physical after scrubbing one stripe" has been added to the 6.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    btrfs: scrub: update last_physical after scrubbing one stripe

to the 6.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     btrfs-scrub-update-last_physical-after-scrubbing-one.patch
and it can be found in the queue-6.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 219c05f189b7f160a05fb0699486ae36ed79e0a6
Author: Qu Wenruo <wqu@xxxxxxxx>
Date:   Fri Mar 8 13:40:31 2024 +1030

    btrfs: scrub: update last_physical after scrubbing one stripe
    
    [ Upstream commit 63447b7dd40c6a9ae8d3bb70c11f4c46731823e3 ]
    
    Currently sctx->stat.last_physical only got updated in the following
    cases:
    
    - When the last stripe of a non-RAID56 chunk is scrubbed
      This implies a pitfall, if the last stripe is at the chunk boundary,
      and we finished the scrub of the whole chunk, we won't update
      last_physical at all until the next chunk.
    
    - When a P/Q stripe of a RAID56 chunk is scrubbed
    
    This leads the following two problems:
    
    - sctx->stat.last_physical is not updated for a almost full chunk
      This is especially bad, affecting scrub resume, as the resume would
      start from last_physical, causing unnecessary re-scrub.
    
    - "btrfs scrub status" will not report any progress for a long time
    
    Fix the problem by properly updating @last_physical after each stripe is
    scrubbed.
    
    And since we're here, for the sake of consistency, use spin lock to
    protect the update of @last_physical, just like all the remaining
    call sites touching sctx->stat.
    
    Reported-by: Michel Palleau <michel.palleau@xxxxxxxxx>
    Link: https://lore.kernel.org/linux-btrfs/CAMFk-+igFTv2E8svg=cQ6o3e6CrR5QwgQ3Ok9EyRaEvvthpqCQ@xxxxxxxxxxxxxx/
    Reviewed-by: Johannes Thumshirn <johannes.thumshirn@xxxxxxx>
    Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
    Reviewed-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: David Sterba <dsterba@xxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index 9712169593980..731d7d562db1a 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -1875,6 +1875,9 @@ static int flush_scrub_stripes(struct scrub_ctx *sctx)
 		stripe = &sctx->stripes[i];
 
 		wait_scrub_stripe_io(stripe);
+		spin_lock(&sctx->stat_lock);
+		sctx->stat.last_physical = stripe->physical + stripe_length(stripe);
+		spin_unlock(&sctx->stat_lock);
 		scrub_reset_stripe(stripe);
 	}
 out:
@@ -2143,7 +2146,9 @@ static int scrub_simple_mirror(struct scrub_ctx *sctx,
 					 cur_physical, &found_logical);
 		if (ret > 0) {
 			/* No more extent, just update the accounting */
+			spin_lock(&sctx->stat_lock);
 			sctx->stat.last_physical = physical + logical_length;
+			spin_unlock(&sctx->stat_lock);
 			ret = 0;
 			break;
 		}
@@ -2340,6 +2345,10 @@ static noinline_for_stack int scrub_stripe(struct scrub_ctx *sctx,
 			stripe_logical += chunk_logical;
 			ret = scrub_raid56_parity_stripe(sctx, scrub_dev, bg,
 							 map, stripe_logical);
+			spin_lock(&sctx->stat_lock);
+			sctx->stat.last_physical = min(physical + BTRFS_STRIPE_LEN,
+						       physical_end);
+			spin_unlock(&sctx->stat_lock);
 			if (ret)
 				goto out;
 			goto next;




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux