mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-30 04:15:06 +01:00
vdev_disk: simplify alignment checks for linear ABDs
A linear ABD is a single contiguous range, so only its first page can carry an offset and only its last one can be short. That leaves the alignment of the buffer as the only thing to check, and no reason to look up the pages. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Rob Norris <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Closes #19102
This commit is contained in:
1 parent
04424a5c34
commit
78f49e1ddb
1 file changed
+12
-2
@@ -982,8 +982,7 @@ vdev_disk_check_alignment_cb(struct page *page, size_t off, size_t len,
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we can submit the pages in this ABD to the kernel as-is. Returns
|
||||
* the number of pages, or 0 if it can't be submitted like this.
|
||||
* Check if we can submit the pages in this ABD to the kernel as-is.
|
||||
*/
|
||||
static boolean_t
|
||||
vdev_disk_check_alignment(abd_t *abd, uint64_t size, struct block_device *bdev)
|
||||
@@ -992,6 +991,17 @@ vdev_disk_check_alignment(abd_t *abd, uint64_t size, struct block_device *bdev)
|
||||
.blocksize = bdev_logical_block_size(bdev),
|
||||
};
|
||||
|
||||
/*
|
||||
* A linear ABD is a single contiguous range, so only its first page
|
||||
* can carry an offset and only its last one can be short. That leaves
|
||||
* the alignment of the buffer as the only thing to check, and no
|
||||
* reason to look up the pages.
|
||||
*/
|
||||
if (abd_is_linear(abd)) {
|
||||
ASSERT(IS_P2ALIGNED(size, s.blocksize));
|
||||
return (IS_P2ALIGNED(abd_to_buf(abd), s.blocksize));
|
||||
}
|
||||
|
||||
if (abd_iterate_page_func(abd, 0, size,
|
||||
vdev_disk_check_alignment_cb, &s))
|
||||
return (B_FALSE);
|
||||
|
||||
Reference in new issue
Block a user