]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove XFS_IFEXTENTS
authorChristoph Hellwig <hch@lst.de>
Wed, 30 Jun 2021 22:38:58 +0000 (18:38 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 30 Jun 2021 22:38:58 +0000 (18:38 -0400)
Source kernel commit: b2197a36c0ef5b35a0ed83de744610a462da1ad3

The in-memory XFS_IFEXTENTS is now only used to check if an inode with
extents still needs the extents to be read into memory before doing
operations that need the extent map.  Add a new xfs_need_iread_extents
helper that returns true for btree format forks that do not have any
entries in the in-memory extent btree, and use that instead of checking
the XFS_IFEXTENTS flag.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/namei.c
libxfs/util.c
libxfs/xfs_attr_leaf.c
libxfs/xfs_bmap.c
libxfs/xfs_dir2_sf.c
libxfs/xfs_inode_fork.c
libxfs/xfs_inode_fork.h
repair/phase6.c
repair/quotacheck.c

index 02c774437a96e2c6ee8edad5e5f2a02c986aed34..4e2047b21cea042a29c36a2e071b4c6d174186de 100644 (file)
@@ -384,11 +384,9 @@ list_leafdir(
        int                     error = 0;
 
        /* Read extent map. */
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = -libxfs_iread_extents(NULL, dp, XFS_DATA_FORK);
-               if (error)
-                       return error;
-       }
+       error = -libxfs_iread_extents(NULL, dp, XFS_DATA_FORK);
+       if (error)
+               return error;
 
        while (dabno < geo->leafblk) {
                unsigned int    offset;
index d227a29089b6a32ccd0739421f09a55764f654fc..f8ea3d2ae345eb49af8a9e2b9d5428ec330f3290 100644 (file)
@@ -310,7 +310,6 @@ libxfs_init_new_inode(
                /* FALLTHROUGH */
        case S_IFLNK:
                ip->i_df.if_format = XFS_DINODE_FMT_EXTENTS;
-               ip->i_df.if_flags = XFS_IFEXTENTS;
                ip->i_df.if_bytes = 0;
                ip->i_df.if_u1.if_root = NULL;
                break;
index bb8833c5298cdfe5422cd924b7e8a1faa6101d93..e13e83e0c13796b46eba93c4b87ae6b13c23c167 100644 (file)
@@ -648,10 +648,8 @@ xfs_attr_shortform_create(
        trace_xfs_attr_sf_create(args);
 
        ASSERT(ifp->if_bytes == 0);
-       if (ifp->if_format == XFS_DINODE_FMT_EXTENTS) {
-               ifp->if_flags &= ~XFS_IFEXTENTS;        /* just in case */
+       if (ifp->if_format == XFS_DINODE_FMT_EXTENTS)
                ifp->if_format = XFS_DINODE_FMT_LOCAL;
-       }
        xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
        hdr = (struct xfs_attr_sf_hdr *)ifp->if_u1.if_data;
        memset(hdr, 0, sizeof(*hdr));
index 9dbfdca8f3a59f138684605a12fd1758c56266a6..ba385cd02c706180f554e105650388fc2d187cdb 100644 (file)
@@ -598,7 +598,7 @@ xfs_bmap_btree_to_extents(
 
        ASSERT(cur);
        ASSERT(whichfork != XFS_COW_FORK);
-       ASSERT(ifp->if_flags & XFS_IFEXTENTS);
+       ASSERT(!xfs_need_iread_extents(ifp));
        ASSERT(ifp->if_format == XFS_DINODE_FMT_BTREE);
        ASSERT(be16_to_cpu(rblock->bb_level) == 1);
        ASSERT(be16_to_cpu(rblock->bb_numrecs) == 1);
@@ -798,7 +798,6 @@ xfs_bmap_local_to_extents_empty(
        ASSERT(ifp->if_nextents == 0);
 
        xfs_bmap_forkoff_reset(ip, whichfork);
-       ifp->if_flags |= XFS_IFEXTENTS;
        ifp->if_u1.if_root = NULL;
        ifp->if_height = 0;
        ifp->if_format = XFS_DINODE_FMT_EXTENTS;
@@ -842,7 +841,6 @@ xfs_bmap_local_to_extents(
 
        flags = 0;
        error = 0;
-       ASSERT(!(ifp->if_flags & XFS_IFEXTENTS));
        memset(&args, 0, sizeof(args));
        args.tp = tp;
        args.mp = ip->i_mount;
@@ -1091,7 +1089,6 @@ xfs_bmap_add_attrfork(
        ASSERT(ip->i_afp == NULL);
 
        ip->i_afp = xfs_ifork_alloc(XFS_DINODE_FMT_EXTENTS, 0);
-       ip->i_afp->if_flags = XFS_IFEXTENTS;
        logflags = 0;
        switch (ip->i_df.if_format) {
        case XFS_DINODE_FMT_LOCAL:
@@ -1217,16 +1214,11 @@ xfs_iread_extents(
        struct xfs_btree_cur    *cur;
        int                     error;
 
-       if (ifp->if_flags & XFS_IFEXTENTS)
+       if (!xfs_need_iread_extents(ifp))
                return 0;
 
        ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
 
-       if (XFS_IS_CORRUPT(mp, ifp->if_format != XFS_DINODE_FMT_BTREE)) {
-               error = -EFSCORRUPTED;
-               goto out;
-       }
-
        ir.loaded = 0;
        xfs_iext_first(ifp, &ir.icur);
        cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
@@ -1241,8 +1233,6 @@ xfs_iread_extents(
                goto out;
        }
        ASSERT(ir.loaded == xfs_iext_count(ifp));
-
-       ifp->if_flags |= XFS_IFEXTENTS;
        return 0;
 out:
        xfs_iext_destroy(ifp);
index 4c0093b25c2545de6fff6ac1af89d6b6fd4592f6..c1cc2e711e7cc240dfc8c2902a2d4a3c758836ab 100644 (file)
@@ -827,7 +827,6 @@ xfs_dir2_sf_create(
         * convert it to local format.
         */
        if (dp->i_df.if_format == XFS_DINODE_FMT_EXTENTS) {
-               dp->i_df.if_flags &= ~XFS_IFEXTENTS;    /* just in case */
                dp->i_df.if_format = XFS_DINODE_FMT_LOCAL;
                xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE);
        }
index f39ac7db80cd67ed8f9be8285f636c1568edf945..1a49c41f3a46e55d9be91d097d66f06686f3332f 100644 (file)
@@ -58,7 +58,6 @@ xfs_init_local_fork(
        }
 
        ifp->if_bytes = size;
-       ifp->if_flags &= ~XFS_IFEXTENTS;
 }
 
 /*
@@ -148,7 +147,6 @@ xfs_iformat_extents(
                        xfs_iext_next(ifp, &icur);
                }
        }
-       ifp->if_flags |= XFS_IFEXTENTS;
        return 0;
 }
 
@@ -210,7 +208,6 @@ xfs_iformat_btree(
         */
        xfs_bmdr_to_bmbt(ip, dfp, XFS_DFORK_SIZE(dip, ip->i_mount, whichfork),
                         ifp->if_broot, size);
-       ifp->if_flags &= ~XFS_IFEXTENTS;
 
        ifp->if_bytes = 0;
        ifp->if_u1.if_root = NULL;
@@ -620,8 +617,6 @@ xfs_iflush_fork(
                break;
 
        case XFS_DINODE_FMT_EXTENTS:
-               ASSERT((ifp->if_flags & XFS_IFEXTENTS) ||
-                      !(iip->ili_fields & extflag[whichfork]));
                if ((iip->ili_fields & extflag[whichfork]) &&
                    (ifp->if_bytes > 0)) {
                        ASSERT(ifp->if_nextents > 0);
@@ -681,7 +676,6 @@ xfs_ifork_init_cow(
 
        ip->i_cowfp = kmem_cache_zalloc(xfs_ifork_zone,
                                       GFP_NOFS | __GFP_NOFAIL);
-       ip->i_cowfp->if_flags = XFS_IFEXTENTS;
        ip->i_cowfp->if_format = XFS_DINODE_FMT_EXTENTS;
 }
 
index ac8b2182ce8c57b8d3f458e0c7201610c2d1efbd..a6f7897b6887b1f83a0f8b162a64c778ecb89a31 100644 (file)
@@ -22,16 +22,10 @@ struct xfs_ifork {
                char            *if_data;       /* inline file data */
        } if_u1;
        short                   if_broot_bytes; /* bytes allocated for root */
-       unsigned char           if_flags;       /* per-fork flags */
        int8_t                  if_format;      /* format of this fork */
        xfs_extnum_t            if_nextents;    /* # of extents in this fork */
 };
 
-/*
- * Per-fork incore inode flags.
- */
-#define        XFS_IFEXTENTS   0x02    /* All extent pointers are read in */
-
 /*
  * Worst-case increase in the fork extent count when we're adding a single
  * extent to a fork and there's no possibility of splitting an existing mapping.
@@ -236,4 +230,10 @@ int xfs_ifork_verify_local_attr(struct xfs_inode *ip);
 int xfs_iext_count_may_overflow(struct xfs_inode *ip, int whichfork,
                int nr_to_add);
 
+/* returns true if the fork has extents but they are not read in yet. */
+static inline bool xfs_need_iread_extents(struct xfs_ifork *ifp)
+{
+       return ifp->if_format == XFS_DINODE_FMT_BTREE && ifp->if_height == 0;
+}
+
 #endif /* __XFS_INODE_FORK_H__ */
index 9ada8f2bc3bcc5155779d711323293be897fcbe2..0929dcdfcd96e4f731c21074223205f3b59320a6 100644 (file)
@@ -413,11 +413,10 @@ bmap_next_offset(
                return EIO;
        }
 
-       if (!(ip->i_df.if_flags & XFS_IFEXTENTS)) {
-               error = -libxfs_iread_extents(NULL, ip, XFS_DATA_FORK);
-               if (error)
-                       return error;
-       }
+        /* Read extent map. */
+       error = -libxfs_iread_extents(NULL, ip, XFS_DATA_FORK);
+       if (error)
+               return error;
 
        bno = *bnop + 1;
        if (!libxfs_iext_lookup_extent(ip, &ip->i_df, bno, &icur, &got))
@@ -501,7 +500,6 @@ mk_rbmino(xfs_mount_t *mp)
        /*
         * now the ifork
         */
-       ip->i_df.if_flags = XFS_IFEXTENTS;
        ip->i_df.if_bytes = 0;
        ip->i_df.if_u1.if_root = NULL;
 
@@ -742,7 +740,6 @@ mk_rsumino(xfs_mount_t *mp)
        /*
         * now the ifork
         */
-       ip->i_df.if_flags = XFS_IFEXTENTS;
        ip->i_df.if_bytes = 0;
        ip->i_df.if_u1.if_root = NULL;
 
@@ -844,7 +841,6 @@ mk_root_dir(xfs_mount_t *mp)
        /*
         * now the ifork
         */
-       ip->i_df.if_flags = XFS_IFEXTENTS;
        ip->i_df.if_bytes = 0;
        ip->i_df.if_u1.if_root = NULL;
 
index 817474ffd2dcd98d7bdc01071ff375a308dbf748..5e007a180c57fff5e50e5e60d48da68f8858ea3a 100644 (file)
@@ -165,15 +165,13 @@ qc_count_rtblocks(
        struct xfs_ifork        *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
        int                     error;
 
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = -libxfs_iread_extents(NULL, ip, XFS_DATA_FORK);
-               if (error) {
-                       do_warn(
+       error = -libxfs_iread_extents(NULL, ip, XFS_DATA_FORK);
+       if (error) {
+               do_warn(
 _("could not read ino %"PRIu64" extents, err=%d\n"),
-                               ip->i_ino, error);
-                       chkd_flags = 0;
-                       return 0;
-               }
+                       ip->i_ino, error);
+               chkd_flags = 0;
+               return 0;
        }
 
        for_each_xfs_iext(ifp, &icur, &got)
@@ -438,15 +436,13 @@ quotacheck_verify(
        }
 
        ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
-       if (!(ifp->if_flags & XFS_IFEXTENTS)) {
-               error = -libxfs_iread_extents(NULL, ip, XFS_DATA_FORK);
-               if (error) {
-                       do_warn(
+       error = -libxfs_iread_extents(NULL, ip, XFS_DATA_FORK);
+       if (error) {
+               do_warn(
        _("could not read %s inode %"PRIu64" extents, err=%d\n"),
-                               qflags_typestr(type), ip->i_ino, error);
-                       chkd_flags = 0;
-                       goto err;
-               }
+                       qflags_typestr(type), ip->i_ino, error);
+               chkd_flags = 0;
+               goto err;
        }
 
        /* Walk each extent of the quota inode and compare counters. */