gfs2: Stop using GFS2_BASIC_BLOCK and GFS2_BASIC_BLOCK_SHIFT
authorAndreas Gruenbacher <agruenba@redhat.com>
Sat, 21 Oct 2023 19:59:03 +0000 (21:59 +0200)
committerAndreas Gruenbacher <agruenba@redhat.com>
Mon, 23 Oct 2023 09:47:13 +0000 (11:47 +0200)
Header gfs2_ondisk.h defines GFS2_BASIC_BLOCK and GFS2_BASIC_BLOCK_SHIFT
in a misguided attempt to abstract away the fact that sectors on block
devices are 512 or (1 << 9) bytes in size.  Stop using those definitions.

I would be inclinded to remove those definitions altogether, but the
gfs2 user-space tools are using them.

In addition, instead of GFS2_SB(inode)->sd_sb.sb_bsize_shift, simply use
inode->i_blkbits.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Cc: Andrew Price <anprice@redhat.com>
fs/gfs2/inode.h
fs/gfs2/ops_fstype.c

index c8c5814e7295d9dd83b1c6c6693a6660a478e14b..908c739220b83160653f2f69e90e1a79449fc47f 100644 (file)
@@ -44,19 +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 <<
-               (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
+       inode->i_blocks = blocks << (inode->i_blkbits - 9);
 }
 
 static inline u64 gfs2_get_inode_blocks(const struct inode *inode)
 {
-       return inode->i_blocks >>
-               (GFS2_SB(inode)->sd_sb.sb_bsize_shift - GFS2_BASIC_BLOCK_SHIFT);
+       return inode->i_blocks >> (inode->i_blkbits - 9);
 }
 
 static inline void gfs2_add_inode_blocks(struct inode *inode, s64 change)
 {
-       change <<= inode->i_blkbits - GFS2_BASIC_BLOCK_SHIFT;
+       change <<= inode->i_blkbits - 9;
        gfs2_assert(GFS2_SB(inode), (change >= 0 || inode->i_blocks >= -change));
        inode->i_blocks += change;
 }
index 33ca04733e933e25d6fb1ce88d4f137eef191a9d..ecca978419e87e32526c190e70ef4f2419f5c436 100644 (file)
@@ -292,8 +292,7 @@ static int gfs2_read_sb(struct gfs2_sbd *sdp, int silent)
                return error;
        }
 
-       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift -
-                              GFS2_BASIC_BLOCK_SHIFT;
+       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9;
        sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
        sdp->sd_diptrs = (sdp->sd_sb.sb_bsize -
                          sizeof(struct gfs2_dinode)) / sizeof(u64);
@@ -1190,10 +1189,9 @@ 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, GFS2_BASIC_BLOCK);
+       sdp->sd_sb.sb_bsize = sb_min_blocksize(sb, 512);
        sdp->sd_sb.sb_bsize_shift = sb->s_blocksize_bits;
-       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift -
-                               GFS2_BASIC_BLOCK_SHIFT;
+       sdp->sd_fsb2bb_shift = sdp->sd_sb.sb_bsize_shift - 9;
        sdp->sd_fsb2bb = BIT(sdp->sd_fsb2bb_shift);
 
        sdp->sd_tune.gt_logd_secs = sdp->sd_args.ar_commit;