]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: remove im_len field in struct xfs_imap
authorChristoph Hellwig <hch@lst.de>
Mon, 1 Jun 2026 12:43:48 +0000 (14:43 +0200)
committerCarlos Maiolino <cem@kernel.org>
Tue, 9 Jun 2026 07:14:42 +0000 (09:14 +0200)
im_len is always set to the same value for a given file system,
which makes it redundant.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_inode_buf.c
fs/xfs/libxfs/xfs_inode_buf.h
fs/xfs/scrub/ialloc.c
fs/xfs/scrub/ialloc_repair.c
fs/xfs/scrub/inode_repair.c
fs/xfs/xfs_inode_item.c

index a3fe4e5b1cdd5d4696bf0b2f952bd0b402b21b4d..6ea7e96a07b4e626e8854f7c57a9343a03d22020 100644 (file)
@@ -2552,7 +2552,6 @@ out_map:
                XFS_INO_TO_OFFSET(mp, ino);
 out:
        imap->im_blkno = xfs_agbno_to_daddr(pag, cluster_agbno);
-       imap->im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
        imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog);
 
        /*
@@ -2561,12 +2560,13 @@ out:
         * read_buf and panicing when we get an error from the
         * driver.
         */
-       if ((imap->im_blkno + imap->im_len) >
+       if (imap->im_blkno +
+           XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster) >
            XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks)) {
                xfs_alert(mp,
-       "%s: (im_blkno (0x%llx) + im_len (0x%llx)) > sb_dblocks (0x%llx)",
-                       __func__, (unsigned long long) imap->im_blkno,
-                       (unsigned long long) imap->im_len,
+       "%s: (im_blkno (0x%llx) + len (0x%x)) > sb_dblocks (0x%llx)",
+                       __func__, imap->im_blkno,
+                       XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster),
                        XFS_FSB_TO_BB(mp, mp->m_sb.sb_dblocks));
                return -EINVAL;
        }
index 88e27d567df3ce8e9055ba4d5ec1c9a1eac575ab..ecc50daa67ba21e3bf5f77db2f6ed3137d505fac 100644 (file)
@@ -137,7 +137,8 @@ xfs_imap_to_bp(
        int                     error;
 
        error = xfs_trans_read_buf(mp, tp, mp->m_ddev_targp, imap->im_blkno,
-                       imap->im_len, 0, bpp, &xfs_inode_buf_ops);
+                       XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster),
+                       0, bpp, &xfs_inode_buf_ops);
        if (xfs_metadata_is_sick(error))
                xfs_agno_mark_sick(mp, xfs_daddr_to_agno(mp, imap->im_blkno),
                                XFS_SICK_AG_INODES);
index 8d43d2641c73280301a6827a076f9363eafe2c01..54870796da419aca959cd1e35e1e02e1d7f6eb18 100644 (file)
@@ -15,7 +15,6 @@ struct xfs_dinode;
  */
 struct xfs_imap {
        xfs_daddr_t     im_blkno;       /* starting BB of inode chunk */
-       unsigned short  im_len;         /* length in BBs of inode chunk */
        unsigned short  im_boffset;     /* inode offset in block in bytes */
 };
 
index 911dc0f9a79d8230b399e7b0dc19d89137c898fa..a7192ba29262a15142c39e19f98a96161a3ec0d6 100644 (file)
@@ -395,7 +395,6 @@ xchk_iallocbt_check_cluster(
         */
        ir_holemask = (irec->ir_holemask & cluster_mask);
        imap.im_blkno = xfs_agbno_to_daddr(to_perag(bs->cur->bc_group), agbno);
-       imap.im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
        imap.im_boffset = XFS_INO_TO_OFFSET(mp, irec->ir_startino) <<
                        mp->m_sb.sb_inodelog;
 
@@ -406,7 +405,8 @@ xchk_iallocbt_check_cluster(
        }
 
        trace_xchk_iallocbt_check_cluster(to_perag(bs->cur->bc_group),
-                       irec->ir_startino, imap.im_blkno, imap.im_len,
+                       irec->ir_startino, imap.im_blkno,
+                       XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster),
                        cluster_base, nr_inodes, cluster_mask, ir_holemask,
                        XFS_INO_TO_OFFSET(mp, irec->ir_startino +
                                          cluster_base));
index 608c7022ac151a1dbcdfe52e341c9f8bb72bb6dd..2d7b9ce968dc41053f1785f987c389c23b80d38b 100644 (file)
@@ -306,7 +306,6 @@ xrep_ibt_process_cluster(
         * either inode btree.
         */
        imap.im_blkno = xfs_agbno_to_daddr(sc->sa.pag, cluster_bno);
-       imap.im_len = XFS_FSB_TO_BB(mp, igeo->blocks_per_cluster);
        imap.im_boffset = 0;
        error = xfs_imap_to_bp(mp, sc->tp, &imap, &cluster_bp);
        if (error)
index c84657add97ae0495dffa1a8a66600e17f0261cc..8d180673b76bd3e9bfcaf924ba69f2051d70280a 100644 (file)
@@ -1547,6 +1547,7 @@ xrep_dinode_core(
        struct xrep_inode       *ri)
 {
        struct xfs_scrub        *sc = ri->sc;
+       struct xfs_mount        *mp = sc->mp;
        struct xfs_buf          *bp;
        struct xfs_dinode       *dip;
        xfs_ino_t               ino = sc->sm->sm_ino;
@@ -1559,8 +1560,10 @@ xrep_dinode_core(
                return error;
 
        /* Read the inode cluster buffer. */
-       error = xfs_trans_read_buf(sc->mp, sc->tp, sc->mp->m_ddev_targp,
-                       ri->imap.im_blkno, ri->imap.im_len, 0, &bp, NULL);
+       error = xfs_trans_read_buf(mp, sc->tp, mp->m_ddev_targp,
+                       ri->imap.im_blkno,
+                       XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster),
+                       0, &bp, NULL);
        if (error)
                return error;
 
@@ -1583,10 +1586,10 @@ xrep_dinode_core(
 write:
        /* Write out the inode. */
        trace_xrep_dinode_fixed(sc, dip);
-       xfs_dinode_calc_crc(sc->mp, dip);
+       xfs_dinode_calc_crc(mp, dip);
        xfs_trans_buf_set_type(sc->tp, bp, XFS_BLFT_DINO_BUF);
        xfs_trans_log_buf(sc->tp, bp, ri->imap.im_boffset,
-                       ri->imap.im_boffset + sc->mp->m_sb.sb_inodesize - 1);
+                       ri->imap.im_boffset + mp->m_sb.sb_inodesize - 1);
 
        /*
         * In theory, we've fixed the ondisk inode record enough that we should
index 2307ce96f75375b658391611c9240000744aacdb..3256495202cf75e642497ae55659e7a7ec50b304 100644 (file)
@@ -647,13 +647,14 @@ xfs_inode_item_format(
 {
        struct xfs_inode_log_item *iip = INODE_ITEM(lip);
        struct xfs_inode        *ip = iip->ili_inode;
+       struct xfs_mount        *mp = ip->i_mount;
        struct xfs_inode_log_format *ilf;
 
        ilf = xlog_format_start(lfb, XLOG_REG_TYPE_IFORMAT);
        ilf->ilf_type = XFS_LI_INODE;
        ilf->ilf_ino = I_INO(ip);
        ilf->ilf_blkno = ip->i_imap.im_blkno;
-       ilf->ilf_len = ip->i_imap.im_len;
+       ilf->ilf_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
        ilf->ilf_boffset = ip->i_imap.im_boffset;
        ilf->ilf_fields = XFS_ILOG_CORE;
        ilf->ilf_size = 2; /* format + core */