[PATCH V3 11/16] xfsprogs: Extend per-inode extent counter widths
From: Chandan Babu R <hidden>
Date: 2021-09-16 10:09:21
Subsystem:
the rest · Maintainer:
Linus Torvalds
This commit adds a new 64-bit per-inode data extent counter. However the maximum number of extents that a data fork can hold is limited to 2^48 extents. This feature is available only when XFS_SB_FEAT_INCOMPAT_EXTCOUNT_64BIT feature bit is enabled on the filesystem. Also, enabling this feature bit causes attr fork extent counter to use the 32-bit extent counter that was previously used to hold the data fork extent counter. This implies that the attr fork can now occupy a maximum of 2^32 extents. Signed-off-by: Chandan Babu R <redacted> --- db/field.c | 4 -- db/field.h | 2 - db/inode.c | 44 +++++++++++++++++-- include/libxlog.h | 6 ++- include/xfs_inode.h | 5 +++ include/xfs_mount.h | 4 +- libxfs/xfs_bmap.c | 8 ++-- libxfs/xfs_format.h | 87 ++++++++++++++++++++++++++------------ libxfs/xfs_fs.h | 1 + libxfs/xfs_ialloc.c | 2 + libxfs/xfs_inode_buf.c | 25 ++++++++++- libxfs/xfs_inode_fork.h | 18 ++++++-- libxfs/xfs_log_format.h | 3 +- libxfs/xfs_sb.c | 3 ++ libxfs/xfs_trans_inode.c | 5 +++ logprint/log_misc.c | 23 +++++++--- logprint/log_print_all.c | 31 +++++++++++--- logprint/log_print_trans.c | 2 +- repair/bmap_repair.c | 10 ++++- repair/dinode.c | 15 +++++-- 20 files changed, 229 insertions(+), 69 deletions(-)
diff --git a/db/field.c b/db/field.c
index 51268938..1e274ffc 100644
--- a/db/field.c
+++ b/db/field.c@@ -25,8 +25,6 @@ #include "symlink.h" const ftattr_t ftattrtab[] = { - { FLDT_AEXTNUM, "aextnum", fp_num, "%d", SI(bitsz(xfs_aextnum_t)), - FTARG_SIGNED, NULL, NULL }, { FLDT_AGBLOCK, "agblock", fp_num, "%u", SI(bitsz(xfs_agblock_t)), FTARG_DONULL, fa_agblock, NULL }, { FLDT_AGBLOCKNZ, "agblocknz", fp_num, "%u", SI(bitsz(xfs_agblock_t)),
@@ -300,8 +298,6 @@ const ftattr_t ftattrtab[] = { FTARG_DONULL, fa_drtbno, NULL }, { FLDT_EXTLEN, "extlen", fp_num, "%u", SI(bitsz(xfs_extlen_t)), 0, NULL, NULL }, - { FLDT_EXTNUM, "extnum", fp_num, "%d", SI(bitsz(xfs_extnum_t)), - FTARG_SIGNED, NULL, NULL }, { FLDT_FSIZE, "fsize", fp_num, "%lld", SI(bitsz(xfs_fsize_t)), FTARG_SIGNED, NULL, NULL }, { FLDT_INO, "ino", fp_num, "%llu", SI(bitsz(xfs_ino_t)), FTARG_DONULL,
diff --git a/db/field.h b/db/field.h
index 387c189e..614fd0ab 100644
--- a/db/field.h
+++ b/db/field.h@@ -5,7 +5,6 @@ */ typedef enum fldt { - FLDT_AEXTNUM, FLDT_AGBLOCK, FLDT_AGBLOCKNZ, FLDT_AGF,
@@ -143,7 +142,6 @@ typedef enum fldt { FLDT_DRFSBNO, FLDT_DRTBNO, FLDT_EXTLEN, - FLDT_EXTNUM, FLDT_FSIZE, FLDT_INO, FLDT_INOBT,
diff --git a/db/inode.c b/db/inode.c
index 33dfffd0..ab825fc3 100644
--- a/db/inode.c
+++ b/db/inode.c@@ -37,6 +37,8 @@ static int inode_u_muuid_count(void *obj, int startoff); static int inode_u_sfdir2_count(void *obj, int startoff); static int inode_u_sfdir3_count(void *obj, int startoff); static int inode_u_symlink_count(void *obj, int startoff); +static int inode_v3_64bitext_count(void *obj, int startoff); +static int inode_v3_pad2_count(void *obj, int startoff); static const cmdinfo_t inode_cmd = { "inode", NULL, inode_f, 0, 1, 1, "[inode#]",
@@ -100,8 +102,8 @@ const field_t inode_core_flds[] = { { "size", FLDT_FSIZE, OI(COFF(size)), C1, 0, TYP_NONE }, { "nblocks", FLDT_DRFSBNO, OI(COFF(nblocks)), C1, 0, TYP_NONE }, { "extsize", FLDT_EXTLEN, OI(COFF(extsize)), C1, 0, TYP_NONE }, - { "nextents32", FLDT_EXTNUM, OI(COFF(nextents32)), C1, 0, TYP_NONE }, - { "nextents16", FLDT_AEXTNUM, OI(COFF(nextents16)), C1, 0, TYP_NONE }, + { "nextents32", FLDT_UINT32D, OI(COFF(nextents32)), C1, 0, TYP_NONE }, + { "nextents16", FLDT_UINT16D, OI(COFF(nextents16)), C1, 0, TYP_NONE }, { "forkoff", FLDT_UINT8D, OI(COFF(forkoff)), C1, 0, TYP_NONE }, { "aformat", FLDT_DINODE_FMT, OI(COFF(aformat)), C1, 0, TYP_NONE }, { "dmevmask", FLDT_UINT32X, OI(COFF(dmevmask)), C1, 0, TYP_NONE },
@@ -162,7 +164,10 @@ const field_t inode_v3_flds[] = { { "lsn", FLDT_UINT64X, OI(COFF(lsn)), C1, 0, TYP_NONE }, { "flags2", FLDT_UINT64X, OI(COFF(flags2)), C1, 0, TYP_NONE }, { "cowextsize", FLDT_EXTLEN, OI(COFF(cowextsize)), C1, 0, TYP_NONE }, - { "pad2", FLDT_UINT8X, OI(OFF(pad2)), CI(12), FLD_ARRAY|FLD_SKIPALL, TYP_NONE }, + { "nextents64", FLDT_UINT64D, OI(COFF(nextents64)), + inode_v3_64bitext_count, FLD_COUNT, TYP_NONE }, + { "pad2", FLDT_UINT8X, OI(OFF(pad2)), inode_v3_pad2_count, + FLD_ARRAY|FLD_COUNT|FLD_SKIPALL, TYP_NONE }, { "crtime", FLDT_TIMESTAMP, OI(COFF(crtime)), C1, 0, TYP_NONE }, { "inumber", FLDT_INO, OI(COFF(ino)), C1, 0, TYP_NONE }, { "uuid", FLDT_UUID, OI(COFF(uuid)), C1, 0, TYP_NONE },
@@ -181,6 +186,9 @@ const field_t inode_v3_flds[] = { { "metadata", FLDT_UINT1, OI(COFF(flags2) + bitsz(uint64_t) - XFS_DIFLAG2_METADATA_BIT-1), C1, 0, TYP_NONE }, + { "nrext64", FLDT_UINT1, + OI(COFF(flags2) + bitsz(uint64_t) - XFS_DIFLAG2_NREXT64_BIT-1), C1, + 0, TYP_NONE }, { NULL } };
@@ -409,6 +417,36 @@ inode_core_projid_count( return dic->di_version >= 2; } +static int +inode_v3_64bitext_count( + void *obj, + int startoff) +{ + struct xfs_dinode *dic; + + ASSERT(startoff == 0); + ASSERT(obj == iocur_top->data); + dic = obj; + return !!(be64_to_cpu(dic->di_flags2) & XFS_DIFLAG2_NREXT64); +} + +static int +inode_v3_pad2_count( + void *obj, + int startoff) +{ + struct xfs_dinode *dic; + + ASSERT(startoff == 0); + ASSERT(obj == iocur_top->data); + dic = obj; + + if (be64_to_cpu(dic->di_flags2) & XFS_DIFLAG2_NREXT64) + return 4; + else + return 12; +} + static int inode_f( int argc,
diff --git a/include/libxlog.h b/include/libxlog.h
index adaa9963..fe30481c 100644
--- a/include/libxlog.h
+++ b/include/libxlog.h@@ -89,13 +89,15 @@ extern int xlog_find_tail(struct xlog *log, xfs_daddr_t *head_blk, extern int xlog_recover(struct xlog *log, int readonly); extern void xlog_recover_print_data(char *p, int len); -extern void xlog_recover_print_logitem(struct xlog_recover_item *item); +extern void xlog_recover_print_logitem(struct xlog *log, + struct xlog_recover_item *item); extern void xlog_recover_print_trans_head(struct xlog_recover *tr); extern int xlog_print_find_oldest(struct xlog *log, xfs_daddr_t *last_blk); /* for transactional view */ extern void xlog_recover_print_trans_head(struct xlog_recover *tr); -extern void xlog_recover_print_trans(struct xlog_recover *trans, +extern void xlog_recover_print_trans(struct xlog *log, + struct xlog_recover *trans, struct list_head *itemq, int print); extern int xlog_do_recovery_pass(struct xlog *log, xfs_daddr_t head_blk, xfs_daddr_t tail_blk, int pass);
diff --git a/include/xfs_inode.h b/include/xfs_inode.h
index bf8e68e1..450ea8ff 100644
--- a/include/xfs_inode.h
+++ b/include/xfs_inode.h@@ -211,6 +211,11 @@ static inline bool xfs_inode_has_bigrtextents(struct xfs_inode *ip) return XFS_IS_REALTIME_INODE(ip) && ip->i_mount->m_sb.sb_rextsize > 1; } +static inline bool xfs_inode_has_nrext64(struct xfs_inode *ip) +{ + return ip->i_diflags2 & XFS_DIFLAG2_NREXT64; +} + static inline bool xfs_is_always_cow_inode(struct xfs_inode *ip) { return false;
diff --git a/include/xfs_mount.h b/include/xfs_mount.h
index 2ee93e37..c8385d16 100644
--- a/include/xfs_mount.h
+++ b/include/xfs_mount.h@@ -153,8 +153,9 @@ typedef struct xfs_mount { #define XFS_FEAT_NEEDSREPAIR (1ULL << 25) /* needs xfs_repair */ #define XFS_FEAT_ATOMIC_SWAP (1ULL << 26) /* extent swap log items */ #define XFS_FEAT_METADIR (1ULL << 27) /* metadata directory tree */ +#define XFS_FEAT_NREXT64 (1ULL << 28) /* 64-bit inode extent counters */ -#define __XFS_HAS_FEAT(name, NAME) \ +#define __XFS_HAS_FEAT(name, NAME) \ static inline bool xfs_has_ ## name (struct xfs_mount *mp) \ { \ return mp->m_features & XFS_FEAT_ ## NAME; \
@@ -198,6 +199,7 @@ __XFS_HAS_FEAT(bigtime, BIGTIME) __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) __XFS_HAS_FEAT(atomicswap, ATOMIC_SWAP) __XFS_HAS_FEAT(metadir, METADIR) +__XFS_HAS_FEAT(nrext64, NREXT64) /* * Decide if this filesystem can use log-assisted ("atomic") extent swapping.
diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c
index 3c23ea30..8a1b94bb 100644
--- a/libxfs/xfs_bmap.c
+++ b/libxfs/xfs_bmap.c@@ -48,18 +48,16 @@ xfs_bmap_compute_maxlevels( int whichfork) /* data or attr fork */ { xfs_extnum_t maxleafents; /* max leaf entries possible */ + xfs_rfsblock_t maxblocks; /* max blocks at this level */ int level; /* btree level */ - uint maxblocks; /* max blocks at this level */ int maxrootrecs; /* max records in root block */ int minleafrecs; /* min records in leaf block */ int minnoderecs; /* min records in node block */ int sz; /* root block size */ /* - * The maximum number of extents in a file, hence the maximum number of - * leaf entries, is controlled by the size of the on-disk extent count, - * either a signed 32-bit number for the data fork, or a signed 16-bit - * number for the attr fork. + * The maximum number of extents in a fork, hence the maximum number of + * leaf entries, is controlled by the size of the on-disk extent count. * * Note that we can no longer assume that if we are in ATTR1 that the * fork offset of all the inodes will be
diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
index 36c382e7..9971300a 100644
--- a/libxfs/xfs_format.h
+++ b/libxfs/xfs_format.h@@ -388,6 +388,7 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_BIGTIME (1 << 3) /* large timestamps */ #define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */ #define XFS_SB_FEAT_INCOMPAT_METADIR (1 << 5) /* metadata dir tree */ +#define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 6) /* 64-bit data fork extent counter */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \
@@ -802,6 +803,15 @@ typedef struct xfs_dinode { __be64 di_size; /* number of bytes in file */ __be64 di_nblocks; /* # of direct & btree blocks used */ __be32 di_extsize; /* basic/minimum extent size for file */ + /* + * On a extcnt64bit filesystem, di_nextents64 holds the data fork + * extent count, di_nextents32 holds the attr fork extent count, + * and di_nextents16 must be zero. + * + * Otherwise, di_nextents32 holds the data fork extent count, + * di_nextents16 holds the attr fork extent count, and di_nextents64 + * must be zero. + */ __be32 di_nextents32; /* 32-bit extent counter */ __be16 di_nextents16; /* 16-bit extent counter */ __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */
@@ -820,7 +830,8 @@ typedef struct xfs_dinode { __be64 di_lsn; /* flush sequence */ __be64 di_flags2; /* more random flags */ __be32 di_cowextsize; /* basic cow extent size for file */ - __u8 di_pad2[12]; /* more padding for future expansion */ + __u8 di_pad2[4]; /* more padding for future expansion */ + __be64 di_nextents64; /* 64-bit extent counter */ /* fields only written to during inode creation */ xfs_timestamp_t di_crtime; /* time created */
@@ -875,10 +886,14 @@ enum xfs_dinode_fmt { /* * Max values for extlen, disk inode's extent counters. */ + #define MAXEXTLEN ((xfs_extlen_t)0x1fffff) /* 21 bits */ +#define XFS_IFORK_EXTCNT_MAXU48 ((xfs_extnum_t)0xffffffffffff) /* Unsigned 48-bits */ +#define XFS_IFORK_EXTCNT_MAXU32 ((xfs_aextnum_t)0xffffffff) /* Unsigned 32-bits */ #define XFS_IFORK_EXTCNT_MAXS32 ((xfs_extnum_t)0x7fffffff) /* Signed 32-bits */ #define XFS_IFORK_EXTCNT_MAXS16 ((xfs_aextnum_t)0x7fff) /* Signed 16-bits */ + /* * Inode minimum and maximum sizes. */
@@ -930,32 +945,6 @@ enum xfs_dinode_fmt { (dip)->di_format : \ (dip)->di_aformat) -static inline int -xfs_dfork_nextents( - struct xfs_dinode *dip, - int whichfork, - xfs_extnum_t *nextents) -{ - int error = 0; - - switch (whichfork) { - case XFS_DATA_FORK: - *nextents = be32_to_cpu(dip->di_nextents32); - break; - - case XFS_ATTR_FORK: - *nextents = be16_to_cpu(dip->di_nextents16); - break; - - default: - ASSERT(0); - error = -EFSCORRUPTED; - break; - } - - return error; -} - /* * For block and character special files the 32bit dev_t is stored at the * beginning of the data fork.
@@ -1022,6 +1011,7 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) #define XFS_DIFLAG2_COWEXTSIZE_BIT 2 /* copy on write extent size hint */ #define XFS_DIFLAG2_BIGTIME_BIT 3 /* big timestamps */ #define XFS_DIFLAG2_METADATA_BIT 4 /* filesystem metadata */ +#define XFS_DIFLAG2_NREXT64_BIT 5 /* 64-bit extent counter enabled */ #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT) #define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT)
@@ -1052,10 +1042,11 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) * - Metadata directory entries must have correct ftype. */ #define XFS_DIFLAG2_METADATA (1 << XFS_DIFLAG2_METADATA_BIT) +#define XFS_DIFLAG2_NREXT64 (1 << XFS_DIFLAG2_NREXT64_BIT) #define XFS_DIFLAG2_ANY \ (XFS_DIFLAG2_DAX | XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE | \ - XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_METADATA) + XFS_DIFLAG2_BIGTIME | XFS_DIFLAG2_METADATA | XFS_DIFLAG2_NREXT64) static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) {
@@ -1063,6 +1054,46 @@ static inline bool xfs_dinode_has_bigtime(const struct xfs_dinode *dip) (dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_BIGTIME)); } +static inline bool xfs_dinode_has_nrext64(const struct xfs_dinode *dip) +{ + return dip->di_version >= 3 && + (dip->di_flags2 & cpu_to_be64(XFS_DIFLAG2_NREXT64)); +} + +static inline int +xfs_dfork_nextents( + struct xfs_dinode *dip, + int whichfork, + xfs_extnum_t *nextents) +{ + int error = 0; + bool inode_has_nrext64; + + inode_has_nrext64 = xfs_dinode_has_nrext64(dip); + + if (inode_has_nrext64 && dip->di_nextents16 != 0) + return -EFSCORRUPTED; + + switch (whichfork) { + case XFS_DATA_FORK: + *nextents = inode_has_nrext64 ? be64_to_cpu(dip->di_nextents64) : + be32_to_cpu(dip->di_nextents32); + break; + + case XFS_ATTR_FORK: + *nextents = inode_has_nrext64 ? be32_to_cpu(dip->di_nextents32) : + be16_to_cpu(dip->di_nextents16); + break; + + default: + ASSERT(0); + error = -EFSCORRUPTED; + break; + } + + return error; +} + /* * Inode number format: * low inopblog bits - offset in block
diff --git a/libxfs/xfs_fs.h b/libxfs/xfs_fs.h
index b7690691..3d0b679d 100644
--- a/libxfs/xfs_fs.h
+++ b/libxfs/xfs_fs.h@@ -254,6 +254,7 @@ typedef struct xfs_fsop_resblks { #define XFS_FSOP_GEOM_FLAGS_INOBTCNT (1 << 22) /* inobt btree counter */ #define XFS_FSOP_GEOM_FLAGS_ATOMIC_SWAP (1 << 23) /* atomic swapext */ #define XFS_FSOP_GEOM_FLAGS_METADIR (1 << 24) /* metadata directories */ +#define XFS_FSOP_GEOM_FLAGS_NREXT64 (1 << 25) /* 64-bit extent counter */ /* * Minimum and maximum sizes need for growth checks.
diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index 67dd9060..7fac2c34 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c@@ -2831,6 +2831,8 @@ xfs_ialloc_setup_geometry( igeo->new_diflags2 = 0; if (xfs_has_bigtime(mp)) igeo->new_diflags2 |= XFS_DIFLAG2_BIGTIME; + if (xfs_has_nrext64(mp)) + igeo->new_diflags2 |= XFS_DIFLAG2_NREXT64; /* Compute inode btree geometry. */ igeo->agino_log = sbp->sb_inopblog + sbp->sb_agblklog;
diff --git a/libxfs/xfs_inode_buf.c b/libxfs/xfs_inode_buf.c
index 5909bc26..15690f7f 100644
--- a/libxfs/xfs_inode_buf.c
+++ b/libxfs/xfs_inode_buf.c@@ -282,6 +282,27 @@ xfs_inode_to_disk_ts( return ts; } +static inline void +xfs_inode_to_disk_iext_counters( + struct xfs_inode *ip, + struct xfs_dinode *to) +{ + if (xfs_inode_has_nrext64(ip)) { + to->di_nextents64 = cpu_to_be64(xfs_ifork_nextents(&ip->i_df)); + to->di_nextents32 = cpu_to_be32(xfs_ifork_nextents(ip->i_afp)); + /* + * We might be upgrading the inode to use wider extent counters + * than was previously used. Hence zero the unused field. + */ + to->di_nextents16 = cpu_to_be16(0); + } else { + if (xfs_has_v3inodes(ip->i_mount)) + to->di_nextents64 = 0; + to->di_nextents32 = cpu_to_be32(xfs_ifork_nextents(&ip->i_df)); + to->di_nextents16 = cpu_to_be16(xfs_ifork_nextents(ip->i_afp)); + } +} + void xfs_inode_to_disk( struct xfs_inode *ip,
@@ -310,8 +331,6 @@ xfs_inode_to_disk( to->di_size = cpu_to_be64(ip->i_disk_size); to->di_nblocks = cpu_to_be64(ip->i_nblocks); to->di_extsize = cpu_to_be32(ip->i_extsize); - to->di_nextents32 = cpu_to_be32(xfs_ifork_nextents(&ip->i_df)); - to->di_nextents16 = cpu_to_be16(xfs_ifork_nextents(ip->i_afp)); to->di_forkoff = ip->i_forkoff; to->di_aformat = xfs_ifork_format(ip->i_afp); to->di_flags = cpu_to_be16(ip->i_diflags);
@@ -331,6 +350,8 @@ xfs_inode_to_disk( to->di_version = 2; to->di_flushiter = cpu_to_be16(ip->i_flushiter); } + + xfs_inode_to_disk_iext_counters(ip, to); } static xfs_failaddr_t
diff --git a/libxfs/xfs_inode_fork.h b/libxfs/xfs_inode_fork.h
index 4b9df10e..f8a85ba6 100644
--- a/libxfs/xfs_inode_fork.h
+++ b/libxfs/xfs_inode_fork.h@@ -136,10 +136,22 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp) static inline xfs_extnum_t xfs_iext_max_nextents(struct xfs_mount *mp, int whichfork) { - if (whichfork == XFS_DATA_FORK || whichfork == XFS_COW_FORK) - return XFS_IFORK_EXTCNT_MAXS32; + bool has_64bit_extcnt = xfs_has_nrext64(mp); - return XFS_IFORK_EXTCNT_MAXS16; + switch (whichfork) { + case XFS_DATA_FORK: + case XFS_COW_FORK: + return has_64bit_extcnt ? XFS_IFORK_EXTCNT_MAXU48 + : XFS_IFORK_EXTCNT_MAXS32; + + case XFS_ATTR_FORK: + return has_64bit_extcnt ? XFS_IFORK_EXTCNT_MAXU32 + : XFS_IFORK_EXTCNT_MAXS16; + + default: + ASSERT(0); + return 0; + } } struct xfs_ifork *xfs_ifork_alloc(enum xfs_dinode_fmt format,
diff --git a/libxfs/xfs_log_format.h b/libxfs/xfs_log_format.h
index 9f352ff4..de4bcb94 100644
--- a/libxfs/xfs_log_format.h
+++ b/libxfs/xfs_log_format.h@@ -429,7 +429,8 @@ struct xfs_log_dinode { uint64_t di_flags2; /* more random flags */ uint32_t di_cowextsize; /* basic cow extent size for file */ - uint8_t di_pad2[12]; /* more padding for future expansion */ + uint8_t di_pad2[4]; /* more padding for future expansion */ + uint64_t di_nextents64; /* higher part of data fork extent count */ /* fields only written to during inode creation */ xfs_log_timestamp_t di_crtime; /* time created */
diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c
index ae336f0a..2489f619 100644
--- a/libxfs/xfs_sb.c
+++ b/libxfs/xfs_sb.c@@ -1173,6 +1173,9 @@ xfs_fs_geometry( geo->flags |= XFS_FSOP_GEOM_FLAGS_ATOMIC_SWAP; if (xfs_has_metadir(mp)) geo->flags |= XFS_FSOP_GEOM_FLAGS_METADIR; + if (xfs_has_nrext64(mp)) + geo->flags |= XFS_FSOP_GEOM_FLAGS_NREXT64; + geo->rtsectsize = sbp->sb_blocksize; geo->dirblocksize = xfs_dir2_dirblock_bytes(sbp);
diff --git a/libxfs/xfs_trans_inode.c b/libxfs/xfs_trans_inode.c
index 6fc7a65d..fb069c02 100644
--- a/libxfs/xfs_trans_inode.c
+++ b/libxfs/xfs_trans_inode.c@@ -141,6 +141,11 @@ xfs_trans_log_inode( flags |= XFS_ILOG_CORE; } + if ((flags & XFS_ILOG_CORE) && + xfs_has_nrext64(ip->i_mount) && + !xfs_inode_has_nrext64(ip)) + ip->i_diflags2 |= XFS_DIFLAG2_NREXT64; + /* * Inode verifiers do not check that the extent size hint is an integer * multiple of the rt extent size on a directory with both rtinherit
diff --git a/logprint/log_misc.c b/logprint/log_misc.c
index 4e8760c4..56b373f9 100644
--- a/logprint/log_misc.c
+++ b/logprint/log_misc.c@@ -438,8 +438,11 @@ xlog_print_trans_qoff(char **ptr, uint len) static void xlog_print_trans_inode_core( + struct xfs_mount *mp, struct xfs_log_dinode *ip) { + xfs_extnum_t nextents; + printf(_("INODE CORE\n")); printf(_("magic 0x%hx mode 0%ho version %d format %d\n"), ip->di_magic, ip->di_mode, (int)ip->di_version,
@@ -450,11 +453,21 @@ xlog_print_trans_inode_core( xlog_extract_dinode_ts(ip->di_atime), xlog_extract_dinode_ts(ip->di_mtime), xlog_extract_dinode_ts(ip->di_ctime)); - printf(_("size 0x%llx nblocks 0x%llx extsize 0x%x nextents 0x%x\n"), + + if (ip->di_flags2 & XFS_DIFLAG2_NREXT64) + nextents = ip->di_nextents64; + else + nextents = ip->di_nextents32; + printf(_("size 0x%llx nblocks 0x%llx extsize 0x%x nextents 0x%lx\n"), (unsigned long long)ip->di_size, (unsigned long long)ip->di_nblocks, - ip->di_extsize, ip->di_nextents32); - printf(_("naextents 0x%x forkoff %d dmevmask 0x%x dmstate 0x%hx\n"), - ip->di_nextents16, (int)ip->di_forkoff, ip->di_dmevmask, + ip->di_extsize, nextents); + + if (ip->di_flags2 & XFS_DIFLAG2_NREXT64) + nextents = ip->di_nextents32; + else + nextents = ip->di_nextents16; + printf(_("naextents 0x%lx forkoff %d dmevmask 0x%x dmstate 0x%hx\n"), + nextents, (int)ip->di_forkoff, ip->di_dmevmask, ip->di_dmstate); printf(_("flags 0x%x gen 0x%x\n"), ip->di_flags, ip->di_gen);
@@ -564,7 +577,7 @@ xlog_print_trans_inode( memmove(&dino, *ptr, sizeof(dino)); mode = dino.di_mode & S_IFMT; size = (int)dino.di_size; - xlog_print_trans_inode_core(&dino); + xlog_print_trans_inode_core(log->l_mp, &dino); *ptr += xfs_log_dinode_size(log->l_mp); skip_count--;
diff --git a/logprint/log_print_all.c b/logprint/log_print_all.c
index 403c5637..adc7c79c 100644
--- a/logprint/log_print_all.c
+++ b/logprint/log_print_all.c@@ -238,9 +238,13 @@ xlog_recover_print_dquot( STATIC void xlog_recover_print_inode_core( + struct xlog *log, struct xfs_log_dinode *di) { - printf(_(" CORE inode:\n")); + xfs_extnum_t nextents; + xfs_aextnum_t anextents; + + printf(_(" CORE inode:\n")); if (!print_inode) return; printf(_(" magic:%c%c mode:0x%x ver:%d format:%d\n"),
@@ -254,10 +258,19 @@ xlog_recover_print_inode_core( xlog_extract_dinode_ts(di->di_mtime), xlog_extract_dinode_ts(di->di_ctime)); printf(_(" flushiter:%d\n"), di->di_flushiter); + + if (di->di_flags2 & XFS_DIFLAG2_NREXT64) { + nextents = di->di_nextents64; + anextents = di->di_nextents32; + } else { + nextents = di->di_nextents32; + anextents = di->di_nextents16; + } + printf(_(" size:0x%llx nblks:0x%llx exsize:%d " - "nextents:%d anextents:%d\n"), (unsigned long long) + "nextents:%lu anextents:%u\n"), (unsigned long long) di->di_size, (unsigned long long)di->di_nblocks, - di->di_extsize, di->di_nextents32, (int)di->di_nextents16); + di->di_extsize, nextents, anextents); printf(_(" forkoff:%d dmevmask:0x%x dmstate:%d flags:0x%x " "gen:%u\n"), (int)di->di_forkoff, di->di_dmevmask, (int)di->di_dmstate,
@@ -270,6 +283,7 @@ xlog_recover_print_inode_core( STATIC void xlog_recover_print_inode( + struct xlog *log, struct xlog_recover_item *item) { struct xfs_inode_log_format f_buf;
@@ -291,7 +305,7 @@ xlog_recover_print_inode( ASSERT(item->ri_buf[1].i_len == offsetof(struct xfs_log_dinode, di_next_unlinked) || item->ri_buf[1].i_len == sizeof(struct xfs_log_dinode)); - xlog_recover_print_inode_core((struct xfs_log_dinode *) + xlog_recover_print_inode_core(log, (struct xfs_log_dinode *) item->ri_buf[1].i_addr); hasdata = (f->ilf_fields & XFS_ILOG_DFORK) != 0;
@@ -386,6 +400,7 @@ xlog_recover_print_icreate( void xlog_recover_print_logitem( + struct xlog *log, struct xlog_recover_item *item) { switch (ITEM_TYPE(item)) {
@@ -396,7 +411,7 @@ xlog_recover_print_logitem( xlog_recover_print_icreate(item); break; case XFS_LI_INODE: - xlog_recover_print_inode(item); + xlog_recover_print_inode(log, item); break; case XFS_LI_EFD: xlog_recover_print_efd(item);
@@ -442,6 +457,7 @@ xlog_recover_print_logitem( static void xlog_recover_print_item( + struct xlog *log, struct xlog_recover_item *item) { int i;
@@ -507,11 +523,12 @@ xlog_recover_print_item( (long)item->ri_buf[i].i_addr, item->ri_buf[i].i_len); } printf("\n"); - xlog_recover_print_logitem(item); + xlog_recover_print_logitem(log, item); } void xlog_recover_print_trans( + struct xlog *log, struct xlog_recover *trans, struct list_head *itemq, int print)
@@ -524,5 +541,5 @@ xlog_recover_print_trans( print_xlog_record_line(); xlog_recover_print_trans_head(trans); list_for_each_entry(item, itemq, ri_list) - xlog_recover_print_item(item); + xlog_recover_print_item(log, item); }
diff --git a/logprint/log_print_trans.c b/logprint/log_print_trans.c
index 2004b5a0..c6386fb0 100644
--- a/logprint/log_print_trans.c
+++ b/logprint/log_print_trans.c@@ -24,7 +24,7 @@ xlog_recover_do_trans( struct xlog_recover *trans, int pass) { - xlog_recover_print_trans(trans, &trans->r_itemq, 3); + xlog_recover_print_trans(log, trans, &trans->r_itemq, 3); return 0; }
diff --git a/repair/bmap_repair.c b/repair/bmap_repair.c
index 847538b1..7d3bb330 100644
--- a/repair/bmap_repair.c
+++ b/repair/bmap_repair.c@@ -579,7 +579,10 @@ rebuild_bmap( if (nextents == 0) return 0; (*dinop)->di_format = XFS_DINODE_FMT_EXTENTS; - (*dinop)->di_nextents32 = 0; + if (be64_to_cpu((*dinop)->di_flags2) & XFS_DIFLAG2_NREXT64) + (*dinop)->di_nextents64 = 0; + else + (*dinop)->di_nextents32 = 0; libxfs_dinode_calc_crc(mp, *dinop); *dirty = 1; break;
@@ -590,7 +593,10 @@ rebuild_bmap( if (nextents == 0) return 0; (*dinop)->di_aformat = XFS_DINODE_FMT_EXTENTS; - (*dinop)->di_nextents16 = 0; + if (be64_to_cpu((*dinop)->di_flags2) & XFS_DIFLAG2_NREXT64) + (*dinop)->di_nextents32 = 0; + else + (*dinop)->di_nextents16 = 0; libxfs_dinode_calc_crc(mp, *dinop); *dirty = 1; break;
diff --git a/repair/dinode.c b/repair/dinode.c
index c995a524..01674443 100644
--- a/repair/dinode.c
+++ b/repair/dinode.c@@ -78,7 +78,10 @@ _("would have cleared inode %" PRIu64 " attributes\n"), ino_num); if (anextents != 0) { if (no_modify) return(1); - dino->di_nextents16 = cpu_to_be16(0); + if (xfs_dinode_has_nrext64(dino)) + dino->di_nextents32 = 0; + else + dino->di_nextents16 = 0; } if (dino->di_aformat != XFS_DINODE_FMT_EXTENTS) {
@@ -1872,7 +1875,10 @@ _("too many data fork extents (%" PRIu64 ") in inode %" PRIu64 "\n"), do_warn( _("correcting nextents for inode %" PRIu64 ", was %lu - counted %" PRIu64 "\n"), lino, dnextents, nextents); - dino->di_nextents32 = cpu_to_be32(nextents); + if (xfs_dinode_has_nrext64(dino)) + dino->di_nextents64 = cpu_to_be64(nextents); + else + dino->di_nextents32 = cpu_to_be32(nextents); *dirty = 1; } else { do_warn(
@@ -1896,7 +1902,10 @@ _("too many attr fork extents (%" PRIu64 ") in inode %" PRIu64 "\n"), do_warn( _("correcting anextents for inode %" PRIu64 ", was %lu - counted %" PRIu64 "\n"), lino, dnextents, anextents); - dino->di_nextents16 = cpu_to_be16(anextents); + if (xfs_dinode_has_nrext64(dino)) + dino->di_nextents32 = cpu_to_be32(anextents); + else + dino->di_nextents16 = cpu_to_be16(anextents); *dirty = 1; } else { do_warn(
--
2.30.2