]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: remove suport for filesystems without unwritten extent flag
authorChristoph Hellwig <hch@lst.de>
Fri, 9 Nov 2018 22:59:17 +0000 (16:59 -0600)
committerEric Sandeen <sandeen@redhat.com>
Fri, 9 Nov 2018 22:59:17 +0000 (16:59 -0600)
Source kernel commit: daa79baefc47293c753fed191d722f7ef605a303

The option to enable unwritten extents was made default in 2003,
removed from mkfs in 2007, and cannot be disabled in v5.  We also
rely on it for a lot of common functionality, so filesystems without
it will run a completely untested and buggy code path.  Enabling the
support also is a simple bit flip using xfs_db, so legacy file
systems can still be brought forward.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
db/sb.c
libxfs/xfs_bmap.c
libxfs/xfs_format.h
libxfs/xfs_sb.c
repair/dinode.c
repair/sb.c
repair/versions.c

diff --git a/db/sb.c b/db/sb.c
index f676eea3c8ac5982ae200d86e3586889e6c1eea1..5059b261ceff7fd5297bbf3abae5fc029fed35f9 100644 (file)
--- a/db/sb.c
+++ b/db/sb.c
@@ -658,7 +658,8 @@ version_string(
                strcat(s, ",DALIGN");
        if (xfs_sb_version_haslogv2(sbp))
                strcat(s, ",LOGV2");
-       if (xfs_sb_version_hasextflgbit(sbp))
+       /* This feature is required now as well */
+       if (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT)
                strcat(s, ",EXTFLG");
        if (xfs_sb_version_hassector(sbp))
                strcat(s, ",SECTOR");
@@ -725,7 +726,8 @@ version_f(
                                version = 0x0034 | XFS_SB_VERSION_EXTFLGBIT;
                                break;
                        case XFS_SB_VERSION_4:
-                               if (xfs_sb_version_hasextflgbit(&mp->m_sb))
+                               if (mp->m_sb.sb_versionnum &
+                                               XFS_SB_VERSION_EXTFLGBIT)
                                        dbprintf(
                _("unwritten extents flag is already enabled\n"));
                                else
index cf4e9637d78276466da438696d0ba28855da290b..c17d3515cf936728e0c96660d86c94fcd55a77f6 100644 (file)
@@ -4072,8 +4072,7 @@ xfs_bmapi_allocate(
         * extents to real extents when we're about to write the data.
         */
        if ((!bma->wasdel || (bma->flags & XFS_BMAPI_COWFORK)) &&
-           (bma->flags & XFS_BMAPI_PREALLOC) &&
-           xfs_sb_version_hasextflgbit(&mp->m_sb))
+           (bma->flags & XFS_BMAPI_PREALLOC))
                bma->got.br_state = XFS_EXT_UNWRITTEN;
 
        if (bma->wasdel)
@@ -5236,8 +5235,7 @@ __xfs_bunmapi(
                         * unmapping part of it.  But we can't really
                         * get rid of part of a realtime extent.
                         */
-                       if (del.br_state == XFS_EXT_UNWRITTEN ||
-                           !xfs_sb_version_hasextflgbit(&mp->m_sb)) {
+                       if (del.br_state == XFS_EXT_UNWRITTEN) {
                                /*
                                 * This piece is unwritten, or we're not
                                 * using unwritten extents.  Skip over it.
@@ -5287,10 +5285,9 @@ __xfs_bunmapi(
                                del.br_blockcount -= mod;
                                del.br_startoff += mod;
                                del.br_startblock += mod;
-                       } else if ((del.br_startoff == start &&
-                                   (del.br_state == XFS_EXT_UNWRITTEN ||
-                                    tp->t_blk_res == 0)) ||
-                                  !xfs_sb_version_hasextflgbit(&mp->m_sb)) {
+                       } else if (del.br_startoff == start &&
+                                  (del.br_state == XFS_EXT_UNWRITTEN ||
+                                   tp->t_blk_res == 0)) {
                                /*
                                 * Can't make it unwritten.  There isn't
                                 * a full extent here so just skip it.
@@ -6105,11 +6102,7 @@ xfs_bmap_validate_extent(
                    XFS_FSB_TO_AGNO(mp, endfsb))
                        return __this_address;
        }
-       if (irec->br_state != XFS_EXT_NORM) {
-               if (whichfork != XFS_DATA_FORK)
-                       return __this_address;
-               if (!xfs_sb_version_hasextflgbit(&mp->m_sb))
-                       return __this_address;
-       }
+       if (irec->br_state != XFS_EXT_NORM && whichfork != XFS_DATA_FORK)
+               return __this_address;
        return NULL;
 }
index da87afa7e7008438472712ddf923dec7576fd2cf..0d34221676edc0b900d39d90e548c0b010bb8fbd 100644 (file)
@@ -287,6 +287,8 @@ static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp)
 {
        if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT))
                return false;
+       if (!(sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT))
+               return false;
 
        /* check for unknown features in the fs */
        if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) ||
@@ -357,12 +359,6 @@ static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp)
               (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT);
 }
 
-static inline bool xfs_sb_version_hasextflgbit(struct xfs_sb *sbp)
-{
-       return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 ||
-              (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT);
-}
-
 static inline bool xfs_sb_version_hassector(struct xfs_sb *sbp)
 {
        return (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT);
index 93584fac2a210f2174cc71c0c40e56813c182998..cee77a67f7490a6ae96ae502808af1dba5ac4833 100644 (file)
@@ -1092,7 +1092,8 @@ xfs_fs_geometry(
 
        geo->version = XFS_FSOP_GEOM_VERSION;
        geo->flags = XFS_FSOP_GEOM_FLAGS_NLINK |
-                    XFS_FSOP_GEOM_FLAGS_DIRV2;
+                    XFS_FSOP_GEOM_FLAGS_DIRV2 |
+                    XFS_FSOP_GEOM_FLAGS_EXTFLG;
        if (xfs_sb_version_hasattr(sbp))
                geo->flags |= XFS_FSOP_GEOM_FLAGS_ATTR;
        if (xfs_sb_version_hasquota(sbp))
@@ -1101,8 +1102,6 @@ xfs_fs_geometry(
                geo->flags |= XFS_FSOP_GEOM_FLAGS_IALIGN;
        if (xfs_sb_version_hasdalign(sbp))
                geo->flags |= XFS_FSOP_GEOM_FLAGS_DALIGN;
-       if (xfs_sb_version_hasextflgbit(sbp))
-               geo->flags |= XFS_FSOP_GEOM_FLAGS_EXTFLG;
        if (xfs_sb_version_hassector(sbp))
                geo->flags |= XFS_FSOP_GEOM_FLAGS_SECTOR;
        if (xfs_sb_version_hasasciici(sbp))
index f466e7784206b7e19ea62b742cb169bfe0ec5fdb..f670bf87c50d86c9003640950492d9d4e549a02b 100644 (file)
@@ -338,21 +338,6 @@ _("inode %" PRIu64 " - bad rt extent overflows - start %" PRIu64 ", "
                return 1;
        }
 
-       /*
-        * verify that the blocks listed in the record
-        * are multiples of an extent
-        */
-       if (xfs_sb_version_hasextflgbit(&mp->m_sb) == 0 &&
-                       (irec->br_startblock % mp->m_sb.sb_rextsize != 0 ||
-                        irec->br_blockcount % mp->m_sb.sb_rextsize != 0)) {
-               do_warn(
-_("malformed rt inode extent [%" PRIu64 " %" PRIu64 "] (fs rtext size = %u)\n"),
-                       irec->br_startblock,
-                       irec->br_blockcount,
-                       mp->m_sb.sb_rextsize);
-               return 1;
-       }
-
        /*
         * set the appropriate number of extents
         * this iterates block by block, this can be optimised using extents
@@ -360,8 +345,7 @@ _("malformed rt inode extent [%" PRIu64 " %" PRIu64 "] (fs rtext size = %u)\n"),
        for (b = irec->br_startblock; b < irec->br_startblock +
                        irec->br_blockcount; b += mp->m_sb.sb_rextsize)  {
                ext = (xfs_rtblock_t) b / mp->m_sb.sb_rextsize;
-               pwe = xfs_sb_version_hasextflgbit(&mp->m_sb) &&
-                               irec->br_state == XFS_EXT_UNWRITTEN &&
+               pwe = irec->br_state == XFS_EXT_UNWRITTEN &&
                                (b % mp->m_sb.sb_rextsize != 0);
 
                if (check_dups == 1)  {
index 059422c56328fd21c93ff4fddab27ef21c2c9bfd..119bf2190b13f6b0c9548d8e1592b44c0a0c6b99 100644 (file)
@@ -57,8 +57,7 @@ copy_sb(xfs_sb_t *source, xfs_sb_t *dest)
         */
        if (xfs_sb_version_hasdalign(source))
                dest->sb_versionnum |= XFS_SB_VERSION_DALIGNBIT;
-       if (xfs_sb_version_hasextflgbit(source))
-               dest->sb_versionnum |= XFS_SB_VERSION_EXTFLGBIT;
+       dest->sb_versionnum |= XFS_SB_VERSION_EXTFLGBIT;
 
        /*
         * these are all supposed to be zero or will get reset anyway
@@ -683,9 +682,7 @@ get_sb_geometry(fs_geometry_t *geo, xfs_sb_t *sbp)
        if (xfs_sb_version_hasdalign(sbp))
                geo->sb_salignbit = 1;
 
-       if (xfs_sb_version_hasextflgbit(sbp))
-               geo->sb_extflgbit = 1;
-
+       geo->sb_extflgbit = 1;
        geo->sb_fully_zeroed = 1;
 }
 
index 8fad41fa3c98e71ec78d70b190c9787cdf9ff880..4c44b4e79c9514d0a00760a0ce43df24c73fcfee 100644 (file)
@@ -102,7 +102,7 @@ parse_sb_version(xfs_sb_t *sb)
        fs_aligned_inodes = 0;
        fs_sb_feature_bits = 0;
        fs_ino_alignment = 0;
-       fs_has_extflgbit = 0;
+       fs_has_extflgbit = 1;
        have_uquotino = 0;
        have_gquotino = 0;
        have_pquotino = 0;
@@ -116,9 +116,6 @@ parse_sb_version(xfs_sb_t *sb)
         * ok, check to make sure that the sb isn't newer
         * than we are
         */
-       if (xfs_sb_version_hasextflgbit(sb))
-               fs_has_extflgbit = 1;
-
        if (!xfs_sb_good_version(sb))  {
                do_warn(_("WARNING:  unknown superblock version %d\n"),
                        XFS_SB_VERSION_NUM(sb));