public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Qu Wenruo <wqu@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: [PATCH 3/8] btrfs: pass a physical address to btrfs_repair_io_failure
Date: Wed,  9 Apr 2025 13:10:37 +0200	[thread overview]
Message-ID: <20250409111055.3640328-4-hch@lst.de> (raw)
In-Reply-To: <20250409111055.3640328-1-hch@lst.de>

This avoid stepping into bvec internals or complicated folio to
page offset calculations.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/btrfs/bio.c     | 9 ++++-----
 fs/btrfs/bio.h     | 3 +--
 fs/btrfs/disk-io.c | 7 ++++---
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c
index 8c2eee1f1878..10f31ee1e8c0 100644
--- a/fs/btrfs/bio.c
+++ b/fs/btrfs/bio.c
@@ -192,7 +192,7 @@ static void btrfs_end_repair_bio(struct btrfs_bio *repair_bbio,
 		btrfs_repair_io_failure(fs_info, btrfs_ino(inode),
 				  repair_bbio->file_offset, fs_info->sectorsize,
 				  repair_bbio->saved_iter.bi_sector << SECTOR_SHIFT,
-				  page_folio(bv->bv_page), bv->bv_offset, mirror);
+				  bvec_phys(bv), mirror);
 	} while (mirror != fbio->bbio->mirror_num);
 
 done:
@@ -803,8 +803,8 @@ void btrfs_submit_bbio(struct btrfs_bio *bbio, int mirror_num)
  * freeing the bio.
  */
 int btrfs_repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
-			    u64 length, u64 logical, struct folio *folio,
-			    unsigned int folio_offset, int mirror_num)
+			    u64 length, u64 logical, phys_addr_t paddr,
+			    int mirror_num)
 {
 	struct btrfs_io_stripe smap = { 0 };
 	struct bio_vec bvec;
@@ -835,8 +835,7 @@ int btrfs_repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
 
 	bio_init(&bio, smap.dev->bdev, &bvec, 1, REQ_OP_WRITE | REQ_SYNC);
 	bio.bi_iter.bi_sector = smap.physical >> SECTOR_SHIFT;
-	ret = bio_add_folio(&bio, folio, length, folio_offset);
-	ASSERT(ret);
+	__bio_add_page(&bio, phys_to_page(paddr), length, offset_in_page(paddr));
 	ret = submit_bio_wait(&bio);
 	if (ret) {
 		/* try to remap that extent elsewhere? */
diff --git a/fs/btrfs/bio.h b/fs/btrfs/bio.h
index e2fe16074ad6..dc2eb43b7097 100644
--- a/fs/btrfs/bio.h
+++ b/fs/btrfs/bio.h
@@ -110,7 +110,6 @@ void btrfs_bio_end_io(struct btrfs_bio *bbio, blk_status_t status);
 void btrfs_submit_bbio(struct btrfs_bio *bbio, int mirror_num);
 void btrfs_submit_repair_write(struct btrfs_bio *bbio, int mirror_num, bool dev_replace);
 int btrfs_repair_io_failure(struct btrfs_fs_info *fs_info, u64 ino, u64 start,
-			    u64 length, u64 logical, struct folio *folio,
-			    unsigned int folio_offset, int mirror_num);
+			    u64 length, u64 logical, phys_addr_t paddr, int mirror_num);
 
 #endif
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 3dd555db3d32..7cd1a7a775ed 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -193,10 +193,11 @@ static int btrfs_repair_eb_io_failure(const struct extent_buffer *eb,
 		u64 end = min_t(u64, eb->start + eb->len,
 				folio_pos(folio) + eb->folio_size);
 		u32 len = end - start;
+		phys_addr_t paddr = PFN_PHYS(folio_pfn(folio)) +
+				    offset_in_folio(folio, start);
 
-		ret = btrfs_repair_io_failure(fs_info, 0, start, len,
-					      start, folio, offset_in_folio(folio, start),
-					      mirror_num);
+		ret = btrfs_repair_io_failure(fs_info, 0, start, len, start,
+					      paddr, mirror_num);
 		if (ret)
 			break;
 	}
-- 
2.47.2


  parent reply	other threads:[~2025-04-09 11:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-09 11:10 RFC: (almost) stop poking into bvec internals in btrfs Christoph Hellwig
2025-04-09 11:10 ` [PATCH 1/8] btrfs: remove the alignment checks in end_bbio_data_read Christoph Hellwig
2025-04-09 22:13   ` Qu Wenruo
2025-04-10  5:30     ` Christoph Hellwig
2025-04-10  5:39       ` Qu Wenruo
2025-04-09 11:10 ` [PATCH 2/8] btrfs: track the next file offset in struct btrfs_bio_ctrl Christoph Hellwig
2025-04-09 22:15   ` Qu Wenruo
2025-04-09 11:10 ` Christoph Hellwig [this message]
2025-04-09 22:19   ` [PATCH 3/8] btrfs: pass a physical address to btrfs_repair_io_failure Qu Wenruo
2025-04-10  5:31     ` Christoph Hellwig
2025-04-10  6:06   ` Johannes Thumshirn
2025-04-10  6:17     ` hch
2025-04-09 11:10 ` [PATCH 4/8] btrfs: move kmapping out of btrfs_check_sector_csum Christoph Hellwig
2025-04-10  6:16   ` Johannes Thumshirn
2025-04-16  4:51   ` Qu Wenruo
2025-04-09 11:10 ` [PATCH 5/8] btrfs: simplify bvec iteration in index_one_bio Christoph Hellwig
2025-04-18  2:09   ` Qu Wenruo
2025-04-09 11:10 ` [PATCH 6/8] btrfs: store a kernel virtual address in struct sector_ptr Christoph Hellwig
2025-04-09 22:34   ` Qu Wenruo
2025-04-10  5:34     ` Christoph Hellwig
2025-04-14  3:04       ` Qu Wenruo
2025-04-17 23:41         ` Qu Wenruo
2025-04-09 11:10 ` [PATCH 7/8] btrfs: refactor getting the address of a stripe sector Christoph Hellwig
2025-04-09 22:38   ` Qu Wenruo
2025-04-19  1:01   ` Qu Wenruo
2025-04-09 11:10 ` [PATCH 8/8] btrfs: use bvec_kmap_local in btrfs_decompress_buf2page Christoph Hellwig

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=20250409111055.3640328-4-hch@lst.de \
    --to=hch@lst.de \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=wqu@suse.com \
    /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