diff options
author | Youling Tang <tangyouling@kylinos.cn> | 2025-06-05 10:06:38 +0800 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-07-01 12:44:44 -0400 |
commit | d1391dc6220837d6ac9d6738d5d5fb716eb6cd9c (patch) | |
tree | f77219d3436a308cbcfd59bc3be0041e6efabc6b | |
parent | 44ccc43fd18de4258ec9533c57925061136faa1a (diff) |
bcachefs: Simplify bch2_bio_map()
For the part of directly mapping the kernel virtual address, there is no
need to increase to bio page-by-page. It can be directly replaced by
bio_add_virt_nofail().
For the address part of the vmalloc region, its physical address is
discontinuous and needs to be increased page-by-page to bio. The helper
function bio_add_vmalloc() can be used to simplify the implementation of
bch2_bio_map().
Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/util.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index df9a6071fe18..05b40debf211 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -617,17 +617,10 @@ void bch2_pd_controller_debug_to_text(struct printbuf *out, struct bch_pd_contro void bch2_bio_map(struct bio *bio, void *base, size_t size) { - while (size) { - struct page *page = is_vmalloc_addr(base) - ? vmalloc_to_page(base) - : virt_to_page(base); - unsigned offset = offset_in_page(base); - unsigned len = min_t(size_t, PAGE_SIZE - offset, size); - - BUG_ON(!bio_add_page(bio, page, len, offset)); - size -= len; - base += len; - } + if (is_vmalloc_addr(base)) + bio_add_vmalloc(bio, base, size); + else + bio_add_virt_nofail(bio, base, size); } int bch2_bio_alloc_pages(struct bio *bio, size_t size, gfp_t gfp_mask) |