Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v5 0/4] btrfs: simplify the stripe buffer handling
Date: Sun,  5 Jul 2026 21:17:53 +0930	[thread overview]
Message-ID: <cover.1783251701.git.wqu@suse.com> (raw)

[CHANGELOG]
v5:
- Use a simpler and faster way to implement calc_sector_number()
  Commit 81cea6cd7041 ("btrfs: remove btrfs_bio::fs_info by extracting
  it from btrfs_bio::inode") uses logical bytenr as the file_offset for
  scrub bbios, so we have a very reliable way to determine the bytenr,
  without the need to iterate through all the blocks.

  This removes the only the caller that iterates through the scrub block
  addresses, and should also completely shut sashiko up on the impossible
  unaligned address returned by kvmalloc(64K).

v4:
- Add a patch to extract the common handling of scrub read endios
  This is to reduce duplication and allow a single
  invalidate_kernel_vmap_range() call to be added with proper comments.

- Add a comment on why we need to call invalidate_kernel_vmap_range()
  for vmallocated memory
  It's mostly copied from dma-api doc.

v3:
- Add a patch to remove a unused macro

- Add new ASSERT()s to make sure the kvmallocated memory is page aligned
  The size is 64K, which is page aligned and power of 2, thus the
  resulted memory should at least be page aligned.

  Furthermore, we have several call sites using (BTRFS_STRIPE_LEN /
  PAGE_SIZE) or (BTRFS_STRIPE_LEN >> PAGE_SHIFT), add an build time
  assert to make sure our PAGE_SIZE is not larger than BTRFS_STRIPE_LEN.

v2:
- Fix a potential double-free during release_scrub_stripe()
  Reported by sashiko.

- Enlarge the scrub bbio to be able to contain the full buffer
  Since the buffer is allocated by kvmalloc(), it's possible that not
  all pages are physically contiguous.

  In that case we have to enlarge the bbio to contain
  (BTRFS_STRIPE_LEN >> PAGE_SHIFT) bvecs.

This is to use kvmalloc() to allocate a buffer for scrub, so that we do
not need to bother page-switching, and simplify the scrub progress.


Qu Wenruo (4):
  btrfs: remove SCRUB_MAX_SECTORS_PER_BLOCK
  btrfs: extract the common scrub read endio into a helper
  btrfs: scrub: implement calc_sector_number() in a faster way
  btrfs: use kvmalloc() for stripe buffer of scrub_stripe

 fs/btrfs/raid56.c |  18 +---
 fs/btrfs/raid56.h |   2 +-
 fs/btrfs/scrub.c  | 241 ++++++++++++++++++++--------------------------
 3 files changed, 110 insertions(+), 151 deletions(-)

-- 
2.54.0


             reply	other threads:[~2026-07-05 11:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-05 11:47 Qu Wenruo [this message]
2026-07-05 11:47 ` [PATCH v5 1/4] btrfs: remove SCRUB_MAX_SECTORS_PER_BLOCK Qu Wenruo
2026-07-05 11:47 ` [PATCH v5 2/4] btrfs: extract the common scrub read endio into a helper Qu Wenruo
2026-07-05 11:47 ` [PATCH v5 3/4] btrfs: scrub: implement calc_sector_number() in a faster way Qu Wenruo
2026-07-05 11:47 ` [PATCH v5 4/4] btrfs: use kvmalloc() for stripe buffer of scrub_stripe Qu Wenruo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cover.1783251701.git.wqu@suse.com \
    --to=wqu@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox