]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
gfs2: Use SECTOR_SIZE and SECTOR_SHIFT
authorAndreas Gruenbacher <agruenba@redhat.com>
Thu, 24 Apr 2025 15:33:53 +0000 (17:33 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Wed, 9 Jul 2025 17:40:07 +0000 (19:40 +0200)
Use the SECTOR_SIZE and SECTOR_SHIFT constants where appropriate instead
of hardcoding their values.

Reported-by: Damien Le Moal <dlemoal@kernel.org>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/inode.h
fs/gfs2/meta_io.c
fs/gfs2/ops_fstype.c

index eafe123617e6980ab1494e2bfc9e7fc0fe941249..811a0bd3792cd52c2a392983ab016ed27f5173cc 100644 (file)
@@ -44,17 +44,17 @@ static inline int gfs2_is_dir(const struct gfs2_inode *ip)
 
 static inline void gfs2_set_inode_blocks(struct inode *inode, u64 blocks)
 {
-       inode->i_blocks = blocks << (inode->i_blkbits - 9);
+       inode->i_blocks = blocks << (inode->i_blkbits - SECTOR_SHIFT);
 }
 
 static inline u64 gfs2_get_inode_blocks(const struct inode *inode)
 {
-       return inode->i_blocks >> (inode->i_blkbits - 9);
+       return inode->i_blocks >> (inode->i_blkbits - SECTOR_SHIFT);
 }
 
 static inline void gfs2_add_inode_blocks(struct inode *inode, s64 change)
 {
-       change <<= inode->i_blkbits - 9;
+       change <<= inode->i_blkbits - SECTOR_SHIFT;
        gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks >= -change));
        inode->i_blocks += change;
 }
index 9dc8885c95d072de9e3c76dd6cad0d5c59b533b7..72c730582451ac55e9dd03f3b88a0340e1790cdb 100644 (file)
@@ -228,7 +228,7 @@ static void gfs2_submit_bhs(blk_opf_t opf, struct buffer_head *bhs[], int num)
                struct bio *bio;
 
                bio = bio_alloc(bh->b_bdev, num, opf, GFP_NOIO);
-               bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9);
+               bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> SECTOR_SHIFT);
                while (num > 0) {
                        bh = *bhs;
                        if (!bio_add_folio(bio, bh->b_folio, bh->b_size, bh_offset(bh))) {
index 85c491fcf1a3669d71d71837e2f38cbeca033f91..a19d7e431c8ea24b0727f763049a43265be6aed0 100644 (file)
@@ -163,7 +163,7 @@ static int gfs2_check_sb(struct gfs2_sbd *sdp, int silent)
                return -EINVAL;
        }
 
-       if (sb->sb_bsize < 512 || sb->sb_bsize > PAGE_SIZE ||
+       if (sb->sb_bsize < SECTOR_SIZE || sb->sb_bsize > PAGE_SIZE ||
            (sb->sb_bsize & (sb->sb_bsize - 1))) {
                pr_warn("Invalid block size\n");
                return -EINVAL;
@@ -224,8 +224,8 @@ static int gfs2_read_super(struct gfs2_sbd *sdp, sector_t sector, int silent)
        if (unlikely(!sb))
                return -ENOMEM;
        err = bdev_rw_virt(sdp->sd_vfs->s_bdev,
-                       sector * (sdp->sd_vfs->s_blocksize >> 9), sb, PAGE_SIZE,
-                       REQ_OP_READ | REQ_META);
+                          sector << (sdp->sd_vfs->s_blocksize_bits - SECTOR_SHIFT),
+                          sb, PAGE_SIZE, REQ_OP_READ | REQ_META);
        if (err) {
                pr_warn("error %d reading superblock\n", err);
                kfree(sb);
@@ -257,7 +257,7 @@ static int gfs2_read_sb(struct gfs2_sbd *sdp, int silent)
                return error;
        }
 
-       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9;
+       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - SECTOR_SHIFT;
        sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
        sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
                          sizeof(struct gfs2_dinode)) / sizeof(u64);
@@ -1155,12 +1155,12 @@ static int gfs2_fill_super(struct super_block *sb, struct fs_context *fc)
 
        /* Set up the buffer cache and fill in some fake block size values
           to allow us to read-in the on-disk superblock. */
-       sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, 512);
+       sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, SECTOR_SIZE);
        error = -EINVAL;
        if (!sdp->sd_sb.sb_bsize)
                goto fail_free;
        sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits;
-       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9;
+       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - SECTOR_SHIFT;
        sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
 
        sdp->sd_tune.gt_logd_secs = sdp->sd_args.ar_commit;