diff mbox series

btrfs: remove unused raid56 functions which were dedicated for scrub

Message ID db16bb361ef4fb39c71c236dd3985ed88b85ecd0.1681282065.git.wqu@suse.com (mailing list archive)
State New, archived
Headers show
Series btrfs: remove unused raid56 functions which were dedicated for scrub | expand

Commit Message

Qu Wenruo April 12, 2023, 6:47 a.m. UTC
Since the scrub rework, the following raid56 functions are no longer
called:

- raid56_add_scrub_pages()
- raid56_alloc_missing_rbio()
- raid56_submit_missing_rbio()

Those functions are all utilized by scrub to handle missing device cases
for RAID56.

However the new scrub code handle them in a completely different method:

- If it's data stripes, go recovery path through btrfs_submit_bio()
- If it's P/Q stripes, it would be handled through
  raid56_parity_submit_scrub_rbio()
  And that function would handle dev-replace and repair properly.

Thus we can safely remove those functions.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/raid56.c | 47 -----------------------------------------------
 fs/btrfs/raid56.h |  7 -------
 2 files changed, 54 deletions(-)

Comments

Neal Gompa April 12, 2023, 12:52 p.m. UTC | #1
On Wed, Apr 12, 2023 at 3:16 AM Qu Wenruo <wqu@suse.com> wrote:
>
> Since the scrub rework, the following raid56 functions are no longer
> called:
>
> - raid56_add_scrub_pages()
> - raid56_alloc_missing_rbio()
> - raid56_submit_missing_rbio()
>
> Those functions are all utilized by scrub to handle missing device cases
> for RAID56.
>
> However the new scrub code handle them in a completely different method:
>
> - If it's data stripes, go recovery path through btrfs_submit_bio()
> - If it's P/Q stripes, it would be handled through
>   raid56_parity_submit_scrub_rbio()
>   And that function would handle dev-replace and repair properly.
>
> Thus we can safely remove those functions.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  fs/btrfs/raid56.c | 47 -----------------------------------------------
>  fs/btrfs/raid56.h |  7 -------
>  2 files changed, 54 deletions(-)
>
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index ed6343f566d4..2fab37f062de 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -2376,23 +2376,6 @@ struct btrfs_raid_bio *raid56_parity_alloc_scrub_rbio(struct bio *bio,
>         return rbio;
>  }
>
> -/* Used for both parity scrub and missing. */
> -void raid56_add_scrub_pages(struct btrfs_raid_bio *rbio, struct page *page,
> -                           unsigned int pgoff, u64 logical)
> -{
> -       const u32 sectorsize = rbio->bioc->fs_info->sectorsize;
> -       int stripe_offset;
> -       int index;
> -
> -       ASSERT(logical >= rbio->bioc->full_stripe_logical);
> -       ASSERT(logical + sectorsize <= rbio->bioc->full_stripe_logical +
> -                                      BTRFS_STRIPE_LEN * rbio->nr_data);
> -       stripe_offset = (int)(logical - rbio->bioc->full_stripe_logical);
> -       index = stripe_offset / sectorsize;
> -       rbio->bio_sectors[index].page = page;
> -       rbio->bio_sectors[index].pgoff = pgoff;
> -}
> -
>  /*
>   * We just scrub the parity that we have correct data on the same horizontal,
>   * so we needn't allocate all pages for all the stripes.
> @@ -2764,33 +2747,3 @@ void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio)
>         if (!lock_stripe_add(rbio))
>                 start_async_work(rbio, scrub_rbio_work_locked);
>  }
> -
> -/* The following code is used for dev replace of a missing RAID 5/6 device. */
> -
> -struct btrfs_raid_bio *
> -raid56_alloc_missing_rbio(struct bio *bio, struct btrfs_io_context *bioc)
> -{
> -       struct btrfs_fs_info *fs_info = bioc->fs_info;
> -       struct btrfs_raid_bio *rbio;
> -
> -       rbio = alloc_rbio(fs_info, bioc);
> -       if (IS_ERR(rbio))
> -               return NULL;
> -
> -       rbio->operation = BTRFS_RBIO_REBUILD_MISSING;
> -       bio_list_add(&rbio->bio_list, bio);
> -       /*
> -        * This is a special bio which is used to hold the completion handler
> -        * and make the scrub rbio is similar to the other types
> -        */
> -       ASSERT(!bio->bi_iter.bi_size);
> -
> -       set_rbio_range_error(rbio, bio);
> -
> -       return rbio;
> -}
> -
> -void raid56_submit_missing_rbio(struct btrfs_raid_bio *rbio)
> -{
> -       start_async_work(rbio, recover_rbio_work);
> -}
> diff --git a/fs/btrfs/raid56.h b/fs/btrfs/raid56.h
> index 6583c225b1bd..0f7f31c8cb98 100644
> --- a/fs/btrfs/raid56.h
> +++ b/fs/btrfs/raid56.h
> @@ -187,19 +187,12 @@ void raid56_parity_recover(struct bio *bio, struct btrfs_io_context *bioc,
>                            int mirror_num);
>  void raid56_parity_write(struct bio *bio, struct btrfs_io_context *bioc);
>
> -void raid56_add_scrub_pages(struct btrfs_raid_bio *rbio, struct page *page,
> -                           unsigned int pgoff, u64 logical);
> -
>  struct btrfs_raid_bio *raid56_parity_alloc_scrub_rbio(struct bio *bio,
>                                 struct btrfs_io_context *bioc,
>                                 struct btrfs_device *scrub_dev,
>                                 unsigned long *dbitmap, int stripe_nsectors);
>  void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio);
>
> -struct btrfs_raid_bio *
> -raid56_alloc_missing_rbio(struct bio *bio, struct btrfs_io_context *bioc);
> -void raid56_submit_missing_rbio(struct btrfs_raid_bio *rbio);
> -
>  int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info);
>  void btrfs_free_stripe_hash_table(struct btrfs_fs_info *info);
>
> --
> 2.39.2
>

LGTM.

Reviewed-by: Neal Gompa <neal@gompa.dev>



--
真実はいつも一つ!/ Always, there's only one truth!
David Sterba April 17, 2023, 5:49 p.m. UTC | #2
On Wed, Apr 12, 2023 at 02:47:50PM +0800, Qu Wenruo wrote:
> Since the scrub rework, the following raid56 functions are no longer
> called:
> 
> - raid56_add_scrub_pages()
> - raid56_alloc_missing_rbio()
> - raid56_submit_missing_rbio()
> 
> Those functions are all utilized by scrub to handle missing device cases
> for RAID56.
> 
> However the new scrub code handle them in a completely different method:
> 
> - If it's data stripes, go recovery path through btrfs_submit_bio()
> - If it's P/Q stripes, it would be handled through
>   raid56_parity_submit_scrub_rbio()
>   And that function would handle dev-replace and repair properly.
> 
> Thus we can safely remove those functions.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Added to the rest of the scrub rework patches, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index ed6343f566d4..2fab37f062de 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -2376,23 +2376,6 @@  struct btrfs_raid_bio *raid56_parity_alloc_scrub_rbio(struct bio *bio,
 	return rbio;
 }
 
-/* Used for both parity scrub and missing. */
-void raid56_add_scrub_pages(struct btrfs_raid_bio *rbio, struct page *page,
-			    unsigned int pgoff, u64 logical)
-{
-	const u32 sectorsize = rbio->bioc->fs_info->sectorsize;
-	int stripe_offset;
-	int index;
-
-	ASSERT(logical >= rbio->bioc->full_stripe_logical);
-	ASSERT(logical + sectorsize <= rbio->bioc->full_stripe_logical +
-				       BTRFS_STRIPE_LEN * rbio->nr_data);
-	stripe_offset = (int)(logical - rbio->bioc->full_stripe_logical);
-	index = stripe_offset / sectorsize;
-	rbio->bio_sectors[index].page = page;
-	rbio->bio_sectors[index].pgoff = pgoff;
-}
-
 /*
  * We just scrub the parity that we have correct data on the same horizontal,
  * so we needn't allocate all pages for all the stripes.
@@ -2764,33 +2747,3 @@  void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio)
 	if (!lock_stripe_add(rbio))
 		start_async_work(rbio, scrub_rbio_work_locked);
 }
-
-/* The following code is used for dev replace of a missing RAID 5/6 device. */
-
-struct btrfs_raid_bio *
-raid56_alloc_missing_rbio(struct bio *bio, struct btrfs_io_context *bioc)
-{
-	struct btrfs_fs_info *fs_info = bioc->fs_info;
-	struct btrfs_raid_bio *rbio;
-
-	rbio = alloc_rbio(fs_info, bioc);
-	if (IS_ERR(rbio))
-		return NULL;
-
-	rbio->operation = BTRFS_RBIO_REBUILD_MISSING;
-	bio_list_add(&rbio->bio_list, bio);
-	/*
-	 * This is a special bio which is used to hold the completion handler
-	 * and make the scrub rbio is similar to the other types
-	 */
-	ASSERT(!bio->bi_iter.bi_size);
-
-	set_rbio_range_error(rbio, bio);
-
-	return rbio;
-}
-
-void raid56_submit_missing_rbio(struct btrfs_raid_bio *rbio)
-{
-	start_async_work(rbio, recover_rbio_work);
-}
diff --git a/fs/btrfs/raid56.h b/fs/btrfs/raid56.h
index 6583c225b1bd..0f7f31c8cb98 100644
--- a/fs/btrfs/raid56.h
+++ b/fs/btrfs/raid56.h
@@ -187,19 +187,12 @@  void raid56_parity_recover(struct bio *bio, struct btrfs_io_context *bioc,
 			   int mirror_num);
 void raid56_parity_write(struct bio *bio, struct btrfs_io_context *bioc);
 
-void raid56_add_scrub_pages(struct btrfs_raid_bio *rbio, struct page *page,
-			    unsigned int pgoff, u64 logical);
-
 struct btrfs_raid_bio *raid56_parity_alloc_scrub_rbio(struct bio *bio,
 				struct btrfs_io_context *bioc,
 				struct btrfs_device *scrub_dev,
 				unsigned long *dbitmap, int stripe_nsectors);
 void raid56_parity_submit_scrub_rbio(struct btrfs_raid_bio *rbio);
 
-struct btrfs_raid_bio *
-raid56_alloc_missing_rbio(struct bio *bio, struct btrfs_io_context *bioc);
-void raid56_submit_missing_rbio(struct btrfs_raid_bio *rbio);
-
 int btrfs_alloc_stripe_hash_table(struct btrfs_fs_info *info);
 void btrfs_free_stripe_hash_table(struct btrfs_fs_info *info);