diff mbox series

btrfs: use SECTOR_SHIFT to convert phy to lba

Message ID 703d830a41f97b60e2cd2c59e3b15432a01220fa.1681551217.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs: use SECTOR_SHIFT to convert phy to lba | expand

Commit Message

Anand Jain April 15, 2023, 9:51 a.m. UTC
Use SECTOR_SHIFT while converting a physical address to an LBA, makes
it more readable.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
Dave,
 I found some more places where we can use SECTOR_SHIFT.
 Can you please fold this into the patch sent earlier? Thanks.

 fs/btrfs/check-integrity.c | 2 +-
 fs/btrfs/compression.c     | 3 ++-
 fs/btrfs/inode.c           | 2 +-
 fs/btrfs/raid56.c          | 2 +-
 4 files changed, 5 insertions(+), 4 deletions(-)

Comments

David Sterba May 2, 2023, 4 p.m. UTC | #1
On Sat, Apr 15, 2023 at 05:51:23PM +0800, Anand Jain wrote:
> Use SECTOR_SHIFT while converting a physical address to an LBA, makes
> it more readable.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> Dave,
>  I found some more places where we can use SECTOR_SHIFT.
>  Can you please fold this into the patch sent earlier? Thanks.

Folded and added to misc-next, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c
index 82e49d985019..b4408037b823 100644
--- a/fs/btrfs/check-integrity.c
+++ b/fs/btrfs/check-integrity.c
@@ -1565,7 +1565,7 @@  static int btrfsic_read_block(struct btrfsic_state *state,
 
 		bio = bio_alloc(block_ctx->dev->bdev, num_pages - i,
 				REQ_OP_READ, GFP_NOFS);
-		bio->bi_iter.bi_sector = dev_bytenr >> 9;
+		bio->bi_iter.bi_sector = dev_bytenr >> SECTOR_SHIFT;
 
 		for (j = i; j < num_pages; j++) {
 			ret = bio_add_page(bio, block_ctx->pagev[j],
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 2d0493f0a184..1a982dac9f81 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -421,7 +421,8 @@  static noinline int add_ra_bio_pages(struct inode *inode,
 		 */
 		if (!em || cur < em->start ||
 		    (cur + fs_info->sectorsize > extent_map_end(em)) ||
-		    (em->block_start >> 9) != orig_bio->bi_iter.bi_sector) {
+		    (em->block_start >> SECTOR_SHIFT) !=
+		     orig_bio->bi_iter.bi_sector) {
 			free_extent_map(em);
 			unlock_extent(tree, cur, page_end, NULL);
 			unlock_page(page);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 57d070025c7a..b9f88309bd4c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8630,7 +8630,7 @@  static int btrfs_getattr(struct mnt_idmap *idmap,
 	inode_bytes = inode_get_bytes(inode);
 	spin_unlock(&BTRFS_I(inode)->lock);
 	stat->blocks = (ALIGN(inode_bytes, blocksize) +
-			ALIGN(delalloc_bytes, blocksize)) >> 9;
+			ALIGN(delalloc_bytes, blocksize)) >> SECTOR_SHIFT;
 	return 0;
 }
 
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index ed6343f566d4..734c65ad281e 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -1099,7 +1099,7 @@  static int rbio_add_io_sector(struct btrfs_raid_bio *rbio,
 	bio = bio_alloc(stripe->dev->bdev,
 			max(BTRFS_STRIPE_LEN >> PAGE_SHIFT, 1),
 			op, GFP_NOFS);
-	bio->bi_iter.bi_sector = disk_start >> 9;
+	bio->bi_iter.bi_sector = disk_start >> SECTOR_SHIFT;
 	bio->bi_private = rbio;
 
 	__bio_add_page(bio, sector->page, sectorsize, sector->pgoff);