xfsprogs: Extend per-inode extent counters
v4 cover xfsprogs: Extend per-inode extent counters
This patchset implements the changes to userspace programs that are required to support extending inode's data and attr fork extent counter fields. These changes allow programs in xfsprogs to be able to create and work with filesystem instances with 64-bit data fork extent counter and 32-bit attr fork extent counter fields.
The patchset can also be obtained from
https://github.com/chandanr/xfsprogs-dev.git at branch xfs-incompat-extend-extcnt-v4.
Changelog:
V3 -> V4:
1. Rebase patchset on top of Darrick's "xfs: kill XFS_BTREE_MAXLEVELS" patchset.
2. Carve out a 64-bit inode field out of the existing di_pad and di_flushiter fields to hold the 64-bit data fork extent counter.
3. Use the existing 32-bit inode data fork extent counter to hold the attr fork extent counter.
4. Pass XFS_BULK_IREQ_NREXT64 flag to the bulkstat ioctl if the underlying filesystem support for large exent counters is detected by the presence of XFS_FSOP_GEOM_FLAGS_NREXT64 bit.
V2 -> V3:
1. Introduce the ability to upgrade existing filesystems to use 64-bit extent counters if it is feasible to do so.
2. Report presence of 64-bit extent counters via xfs_info.
3. Add XFS_SB_FEAT_INCOMPAT_NREXT64 to XFS_SB_FEAT_INCOMPAT_ALL in a separate patch.
4. Rename mkfs.xfs option from extcnt64bit to nrext64.
V1 -> V2:
1. Rebase patches on top of Darrick's btree-dynamic-depth branch.
2. Add support for using the new bulkstat ioctl version to support 64-bit data fork extent counter field.
Chandan Babu R (19):
xfsprogs: Move extent count limits to xfs_format.h
xfsprogs: Introduce xfs_iext_max_nextents() helper
xfsprogs: Use xfs_extnum_t instead of basic data types
xfsprogs: Introduce xfs_dfork_nextents() helper
xfsprogs: Use basic types to define xfs_log_dinode's di_nextents and
di_anextents
xfsprogs: Promote xfs_extnum_t and xfs_aextnum_t to 64 and 32-bits
respectively
xfsprogs: Introduce XFS_SB_FEAT_INCOMPAT_NREXT64 and associated per-fs
feature bit
xfsprogs: Introduce XFS_FSOP_GEOM_FLAGS_NREXT64
xfsprogs: Introduce XFS_DIFLAG2_NREXT64 and associated helpers
xfsprogs: Use xfs_rfsblock_t to count maximum blocks that can be used
by BMBT
xfsprogs: Introduce macros to represent new maximum extent counts for
data/attr forks
xfsprogs: Introduce per-inode 64-bit extent counters
xfsprogs: Conditionally upgrade existing inodes to use 64-bit extent
counters
xfsprogs: Enable bulkstat ioctl to support 64-bit extent counters
xfsprogs: Add XFS_SB_FEAT_INCOMPAT_NREXT64 to the list of supported
flags
xfsprogs: xfs_info: Report NREXT64 feature status
xfsprogs: Add mkfs option to create filesystem with large extent
counters
xfsprogs: Add support for upgrading to NREXT64 feature
xfsprogs: Define max extent length based on on-disk format definition
Darrick J. Wong (1):
xfsprogs: xfs_repair: allow administrators to add older v5 features
db/bmap.c | 8 +- db/btdump.c | 4 +- db/check.c | 28 +++-- db/field.c | 4 - db/field.h | 2 - db/frag.c | 8 +- db/inode.c | 187 ++++++++++++++++++++++++++-- db/metadump.c | 6 +- fsr/xfs_fsr.c | 4 +- include/libxfs.h | 1 + include/xfs_inode.h | 5 + io/bulkstat.c | 1 + libfrog/bulkstat.c | 29 ++++- libfrog/fsgeom.c | 6 +- libxfs/libxfs_api_defs.h | 3 + libxfs/xfs_bmap.c | 75 ++++++------ libxfs/xfs_format.h | 60 +++++++-- libxfs/xfs_fs.h | 13 +- libxfs/xfs_ialloc.c | 2 + libxfs/xfs_inode_buf.c | 62 +++++++--- libxfs/xfs_inode_fork.c | 13 +- libxfs/xfs_inode_fork.h | 59 ++++++++- libxfs/xfs_log_format.h | 22 +++- libxfs/xfs_sb.c | 3 + libxfs/xfs_trans_resv.c | 10 +- libxfs/xfs_types.h | 11 +- logprint/log_misc.c | 20 ++- logprint/log_print_all.c | 18 ++- man/man8/mkfs.xfs.8 | 7 ++ man/man8/xfs_admin.8 | 30 +++++ mkfs/xfs_mkfs.c | 29 ++++- repair/attr_repair.c | 2 +- repair/dinode.c | 95 +++++++++------ repair/dinode.h | 4 +- repair/globals.c | 4 + repair/globals.h | 4 + repair/phase2.c | 254 +++++++++++++++++++++++++++++++++++++-- repair/phase4.c | 2 +- repair/prefetch.c | 2 +- repair/rmap.c | 4 +- repair/scan.c | 6 +- repair/xfs_repair.c | 44 +++++++ 42 files changed, 944 insertions(+), 207 deletions(-)
Signature · 1 line
2.30.2
PATCH v4 1/20 xfsprogs: xfs_repair: allow administrators to add older v5 features
From: "Darrick J. Wong" <[email protected]>
Add to xfs_db the ability to add certain existing features (finobt, reflink, and rmapbt) to an existing filesystem if it's eligible.
--- include/libxfs.h | 1 + libxfs/libxfs_api_defs.h | 3 + man/man8/xfs_admin.8 | 30 ++++++ repair/globals.c | 3 + repair/globals.h | 3 + repair/phase2.c | 221 +++++++++++++++++++++++++++++++++++++-- repair/rmap.c | 4 +- repair/xfs_repair.c | 33 ++++++ 8 files changed, 286 insertions(+), 12 deletions(-)
include/libxfs.h +1 -0
@@ -77,6 +77,7 @@ struct iomap;#include "xfs_refcount_btree.h" #include "xfs_refcount.h" #include "xfs_btree_staging.h" +#include "xfs_ag_resv.h" #ifndef ARRAY_SIZE #define ARRAY_SIZE (x) (sizeof(x) / sizeof((x)[0]))
libxfs/libxfs_api_defs.h +3 -0
@@ -21,6 +21,8 @@#define xfs_ag_init_headers libxfs_ag_init_headers#define xfs_ag_block_count libxfs_ag_block_count +#define xfs_ag_resv_free libxfs_ag_resv_free +#define xfs_ag_resv_init libxfs_ag_resv_init#define xfs_alloc_ag_max_usable libxfs_alloc_ag_max_usable#define xfs_allocbt_maxrecs libxfs_allocbt_maxrecs
@@ -109,6 +111,7 @@#define xfs_highbit32 libxfs_highbit32#define xfs_highbit64 libxfs_highbit64#define xfs_ialloc_calc_rootino libxfs_ialloc_calc_rootino +#define xfs_ialloc_read_agi libxfs_ialloc_read_agi#define xfs_idata_realloc libxfs_idata_realloc#define xfs_idestroy_fork libxfs_idestroy_fork#define xfs_iext_lookup_extent libxfs_iext_lookup_extent
man/man8/xfs_admin.8 +30 -0
@@ -149,6 +149,36 @@ Upgrade a filesystem to support larger timestamps up to the year 2486. The filesystem cannot be downgraded after this feature is enabled. Once enabled, the filesystem will not be mountable by older kernels. This feature was added to Linux 5.10. +.TP 0.4i +.B finobt +Track free inodes through a separate free inode btree index to speed up inode +allocation on old filesystems. +This upgrade can fail if any AG has less than 1% free space remaining. +The filesystem cannot be downgraded after this feature is enabled. +This feature was added to Linux 3.16. +.TP 0.4i +.B reflink +Enable sharing of file data blocks. +This upgrade can fail if any AG has less than 2% free space remaining. +The filesystem cannot be downgraded after this feature is enabled. +This feature was added to Linux 4.9. +.TP 0.4i +.B rmapbt +Store an index of the owners of on-disk blocks. +This enables much stronger cross-referencing of various metadata structures +and online repairs to space usage metadata. +The filesystem cannot be downgraded after this feature is enabled. +This upgrade can fail if any AG has less than 5% free space remaining. +This feature was added to Linux 4.8. +.TP 0.4i +.B metadir +Create a directory tree of metadata inodes instead of storing them all in the +superblock. +This is required for reverse mapping btrees and reflink support on the realtime +device. +The filesystem cannot be downgraded after this feature is enabled. +This upgrade can fail if any AG has less than 5% free space remaining. +This feature is not upstream yet. .RE .TP .BI \-U " uuid"
repair/globals.c +3 -0
@@ -50,6 +50,9 @@ int convert_lazy_count; /* Convert lazy-count mode on/off */int lazy_count;/* What to set if to if converting */ bool add_inobtcount;/* add inode btree counts to AGI */ bool add_bigtime;/* add support for timestamps up to 2486 */ +bool add_finobt;/* add free inode btrees */ +bool add_reflink;/* add reference count btrees */ +bool add_rmapbt;/* add reverse mapping btrees */ /* misc status variables */
repair/globals.h +3 -0
@@ -91,6 +91,9 @@ extern int convert_lazy_count; /* Convert lazy-count mode on/off */extern int lazy_count;/* What to set if to if converting */ extern bool add_inobtcount;/* add inode btree counts to AGI */ extern bool add_bigtime;/* add support for timestamps up to 2486 */ +extern bool add_finobt;/* add free inode btrees */ +extern bool add_reflink;/* add reference count btrees */ +extern bool add_rmapbt;/* add reverse mapping btrees */ /* misc status variables */
repair/phase2.c +211 -10
256 lines not on this page · raw message
repair/rmap.c +2 -2
@@ -49,8 +49,8 @@ boolrmap_needs_work ( struct xfs_mount *mp) { -return xfs_sb_version_hasreflink (&mp->m_sb) || -xfs_sb_version_hasrmapbt (&mp->m_sb); +return xfs_sb_version_hasreflink (&mp->m_sb) || add_reflink || +xfs_sb_version_hasrmapbt (&mp->m_sb) || add_rmapbt; }/*
repair/xfs_repair.c +33 -0
@@ -67,6 +67,9 @@ enum c_opt_nums {CONVERT_LAZY_COUNT =0 ,CONVERT_INOBTCOUNT ,CONVERT_BIGTIME , +CONVERT_FINOBT , +CONVERT_REFLINK , +CONVERT_RMAPBT , C_MAX_OPTS, };
@@ -74,6 +77,9 @@ static char *c_opts[] = { [CONVERT_LAZY_COUNT] = "lazycount", [CONVERT_INOBTCOUNT] = "inobtcount", [CONVERT_BIGTIME] = "bigtime", + [CONVERT_FINOBT] = "finobt", + [CONVERT_REFLINK] = "reflink", + [CONVERT_RMAPBT] = "rmapbt", [C_MAX_OPTS] = NULL, };
@@ -324,6 +330,33 @@ process_args(int argc, char **argv) _("-c bigtime only supports upgrades\n")); add_bigtime = true;break ; +case CONVERT_FINOBT : +if (!val) +do_abort ( +_ ("-c finobt requires a parameter\n" )); +if (strtol (val,NULL ,0 ) !=1 ) +do_abort ( +_ ("-c finobt only supports upgrades\n" )); + add_finobt = true; +break ; +case CONVERT_REFLINK : +if (!val) +do_abort ( +_ ("-c reflink requires a parameter\n" )); +if (strtol (val,NULL ,0 ) !=1 ) +do_abort ( +_ ("-c reflink only supports upgrades\n" )); + add_reflink = true; +break ; +case CONVERT_RMAPBT : +if (!val) +do_abort ( +_ ("-c rmapbt requires a parameter\n" )); +if (strtol (val,NULL ,0 ) !=1 ) +do_abort ( +_ ("-c rmapbt only supports upgrades\n" )); + add_rmapbt = true; +break ;default :unknown ('c' , val);break ;
Signature · 1 line
2.30.2
PATCH v4 2/20 xfsprogs: Move extent count limits to xfs_format.h
In reply to Chandan Babu RMaximum values associated with extent counters i.e. Maximum extent length, Maximum data extents and Maximum xattr extents are dictated by the on-disk format. Hence move these definitions over to xfs_format.h.
--- libxfs/xfs_format.h | 7 +++++++ libxfs/xfs_types.h | 7 ------- 2 files changed, 7 insertions(+), 7 deletions(-)
libxfs/xfs_format.h +7 -0
@@ -1051,6 +1051,13 @@ enum xfs_dinode_fmt { { XFS_DINODE_FMT_BTREE, "btree" }, \ { XFS_DINODE_FMT_UUID, "uuid" } +/* +* Max values for extlen, extnum, aextnum. +*/ +#define MAXEXTLEN ((xfs_extlen_t)0x001fffff)/* 21 bits */ +#define MAXEXTNUM ((xfs_extnum_t)0x7fffffff)/* signed int */ +#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff)/* signed short */ +/* * Inode minimum and maximum sizes. */
libxfs/xfs_types.h +0 -7
@@ -56,13 +56,6 @@ typedef void * xfs_failaddr_t;#define NULLFSINO ((xfs_ino_t)-1)#define NULLAGINO ((xfs_agino_t)-1) -/* -* Max values for extlen, extnum, aextnum. -*/ -#define MAXEXTLEN ((xfs_extlen_t)0x001fffff)/* 21 bits */ -#define MAXEXTNUM ((xfs_extnum_t)0x7fffffff)/* signed int */ -#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff)/* signed short */ -/* * Minimum and maximum blocksize and sectorsize. * The blocksize upper limit is pretty much arbitrary.
Signature · 1 line
2.30.2
PATCH v4 3/20 xfsprogs: Introduce xfs_iext_max_nextents() helper
In reply to Chandan Babu Rxfs_iext_max_nextents() returns the maximum number of extents possible for one of data, cow or attribute fork. This helper will be extended further in a future commit when maximum extent counts associated with data/attribute forks are increased.
--- libxfs/xfs_bmap.c | 9 ++++----- libxfs/xfs_inode_buf.c | 8 +++----- libxfs/xfs_inode_fork.c | 2 +- libxfs/xfs_inode_fork.h | 8 ++++++++ repair/dinode.c | 4 ++-- 5 files changed, 18 insertions(+), 13 deletions(-)
libxfs/xfs_bmap.c +4 -5
@@ -68,13 +68,12 @@ xfs_bmap_compute_maxlevels(* ATTR2 we have to assume the worst case scenario of a minimum size * available. */ -if (whichfork ==XFS_DATA_FORK ) { - maxleafents =MAXEXTNUM ; + maxleafents =xfs_iext_max_nextents (whichfork); +if (whichfork ==XFS_DATA_FORK ) sz =XFS_BMDR_SPACE_CALC (MINDBTPTRS ); - }else { - maxleafents =MAXAEXTNUM ; +else sz =XFS_BMDR_SPACE_CALC (MINABTPTRS ); - } + maxrootrecs =xfs_bmdr_maxrecs (sz,0 ); minleafrecs = mp->m_bmap_dmnr[0 ]; minnoderecs = mp->m_bmap_dmnr[1 ];
libxfs/xfs_inode_buf.c +3 -5
@@ -334,6 +334,7 @@ xfs_dinode_verify_fork( int whichfork) {uint32_t di_nextents =XFS_DFORK_NEXTENTS (dip, whichfork); +xfs_extnum_t max_extents;switch (XFS_DFORK_FORMAT (dip, whichfork)) {case XFS_DINODE_FMT_LOCAL :
@@ -355,12 +356,9 @@ xfs_dinode_verify_fork(return __this_address;break ;case XFS_DINODE_FMT_BTREE : -if (whichfork ==XFS_ATTR_FORK ) { -if (di_nextents >MAXAEXTNUM ) -return __this_address; - }else if (di_nextents >MAXEXTNUM ) { + max_extents =xfs_iext_max_nextents (whichfork); +if (di_nextents > max_extents)return __this_address; - }break ;default :return __this_address;
libxfs/xfs_inode_fork.c +1 -1
@@ -742,7 +742,7 @@ xfs_iext_count_may_overflow(if (whichfork ==XFS_COW_FORK )return 0 ; - max_exts = (whichfork ==XFS_ATTR_FORK ) ?MAXAEXTNUM :MAXEXTNUM ; + max_exts =xfs_iext_max_nextents (whichfork);if (XFS_TEST_ERROR (false, ip->i_mount,XFS_ERRTAG_REDUCE_MAX_IEXTENTS )) max_exts =10 ;
libxfs/xfs_inode_fork.h +8 -0
@@ -133,6 +133,14 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp)return ifp->if_format; } +static inline xfs_extnum_t xfs_iext_max_nextents (int whichfork) +{ +if (whichfork ==XFS_DATA_FORK || whichfork ==XFS_COW_FORK ) +return MAXEXTNUM ; + +return MAXAEXTNUM ; +} +struct xfs_ifork *xfs_ifork_alloc (enum xfs_dinode_fmt format,xfs_extnum_t nextents);struct xfs_ifork *xfs_iext_state_to_fork (struct xfs_inode *ip,int state);
repair/dinode.c +2 -2
@@ -1796,7 +1796,7 @@ _("bad nblocks %llu for inode %" PRIu64 ", would reset to %" PRIu64 "\n"), } } -if (nextents >MAXEXTNUM ) { +if (nextents >xfs_iext_max_nextents (XFS_DATA_FORK )) {do_warn (_ ("too many data fork extents (%" PRIu64") in inode %" PRIu64"\n" ), nextents, lino);
@@ -1819,7 +1819,7 @@ _("bad nextents %d for inode %" PRIu64 ", would reset to %" PRIu64 "\n"), } } -if (anextents >MAXAEXTNUM ) { +if (anextents >xfs_iext_max_nextents (XFS_ATTR_FORK )) {do_warn (_ ("too many attr fork extents (%" PRIu64") in inode %" PRIu64"\n" ), anextents, lino);
Signature · 1 line
2.30.2
PATCH v4 4/20 xfsprogs: Use xfs_extnum_t instead of basic data types
In reply to Chandan Babu Rxfs_extnum_t is the type to use to declare variables which have values obtained from xfs_dinode->di_[a]nextents. This commit replaces basic types (e.g. uint32_t) with xfs_extnum_t for such variables.
--- db/bmap.c | 2 +- db/frag.c | 2 +- libxfs/xfs_bmap.c | 2 +- libxfs/xfs_inode_buf.c | 2 +- libxfs/xfs_inode_fork.c | 2 +- repair/dinode.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
db/bmap.c +1 -1
@@ -47,7 +47,7 @@ bmap(int n;int nex;xfs_fsblock_t nextbno; -int nextents; +xfs_extnum_t nextents;xfs_bmbt_ptr_t *pp;xfs_bmdr_block_t *rblock;typnm_t typ;
db/frag.c +1 -1
@@ -273,7 +273,7 @@ process_fork( int whichfork) {extmap_t *extmap; -int nex; +xfs_extnum_t nex; nex =XFS_DFORK_NEXTENTS (dip, whichfork);if (!nex)
libxfs/xfs_bmap.c +1 -1
@@ -48,7 +48,7 @@ xfs_bmap_compute_maxlevels( {int level;/* btree level */ uint maxblocks;/* max blocks at this level */ -uint maxleafents;/* max leaf entries possible */ +xfs_extnum_t maxleafents;/* max leaf entries possible */ int maxrootrecs;/* max records in root block */ int minleafrecs;/* min records in leaf block */ int minnoderecs;/* min records in node block */
libxfs/xfs_inode_buf.c +1 -1
@@ -333,7 +333,7 @@ xfs_dinode_verify_fork( struct xfs_mount *mp, int whichfork) { - uint32_t di_nextents = XFS_DFORK_NEXTENTS(dip, whichfork); +xfs_extnum_t di_nextents =XFS_DFORK_NEXTENTS (dip, whichfork);xfs_extnum_t max_extents;switch (XFS_DFORK_FORMAT (dip, whichfork)) {
libxfs/xfs_inode_fork.c +1 -1
@@ -103,7 +103,7 @@ xfs_iformat_extents(struct xfs_mount *mp = ip->i_mount;struct xfs_ifork *ifp =XFS_IFORK_PTR (ip, whichfork);int state =xfs_bmap_fork_to_state (whichfork); -int nex =XFS_DFORK_NEXTENTS (dip, whichfork); +xfs_extnum_t nex =XFS_DFORK_NEXTENTS (dip, whichfork);int size = nex *sizeof (xfs_bmbt_rec_t);struct xfs_iext_cursor icur;struct xfs_bmbt_rec *dp;
repair/dinode.c +1 -1
@@ -932,7 +932,7 @@ process_exinode(xfs_bmbt_rec_t *rp;xfs_fileoff_t first_key;xfs_fileoff_t last_key; -int32_t numrecs; +xfs_extnum_t numrecs;int ret; lino =XFS_AGINO_TO_INO (mp, agno, ino);
Signature · 1 line
2.30.2
PATCH v4 5/20 xfsprogs: Introduce xfs_dfork_nextents() helper
In reply to Chandan Babu RThis commit replaces the macro XFS_DFORK_NEXTENTS() with the helper function xfs_dfork_nextents(). As of this commit, xfs_dfork_nextents() returns the same value as XFS_DFORK_NEXTENTS(). A future commit which extends inode's extent counter fields will add more logic to this helper.
This commit also replaces direct accesses to xfs_dinode->di_[a]nextents with calls to xfs_dfork_nextents().
No functional changes have been made.
--- db/bmap.c | 6 ++--- db/btdump.c | 4 ++-- db/check.c | 28 +++++++++++++--------- db/frag.c | 6 +++-- db/inode.c | 14 ++++++----- db/metadump.c | 4 ++-- libxfs/xfs_format.h | 4 ---- libxfs/xfs_inode_buf.c | 16 +++++++++---- libxfs/xfs_inode_fork.c | 9 +++---- libxfs/xfs_inode_fork.h | 32 +++++++++++++++++++++++++ repair/attr_repair.c | 2 +- repair/dinode.c | 53 +++++++++++++++++++++++------------------ repair/prefetch.c | 2 +- 13 files changed, 116 insertions(+), 64 deletions(-)
db/bmap.c +3 -3
@@ -68,7 +68,7 @@ bmap(ASSERT (fmt ==XFS_DINODE_FMT_LOCAL || fmt ==XFS_DINODE_FMT_EXTENTS || fmt ==XFS_DINODE_FMT_BTREE );if (fmt ==XFS_DINODE_FMT_EXTENTS ) { - nextents =XFS_DFORK_NEXTENTS (dip, whichfork); + nextents =xfs_dfork_nextents (dip, whichfork); xp = (xfs_bmbt_rec_t *)XFS_DFORK_PTR (dip, whichfork);for (ep = xp; ep < &xp[nextents] && n < nex; ep++) {if (!bmap_one_extent (ep, &curoffset, eoffset, &n, bep))
@@ -158,9 +158,9 @@ bmap_f(push_cur ();set_cur_inode (iocur_top->ino); dip = iocur_top->data; -if (be32_to_cpu (dip->di_nextents)) +if (xfs_dfork_data_extents (dip)) dfork =1 ; -if (be16_to_cpu (dip->di_anextents)) +if (xfs_dfork_attr_extents (dip)) afork =1 ;pop_cur (); }
db/btdump.c +2 -2
@@ -166,13 +166,13 @@ dump_inode( dip = iocur_top->data;if (attrfork) { -if (!dip->di_anextents || +if (!xfs_dfork_attr_extents (dip) || dip->di_aformat !=XFS_DINODE_FMT_BTREE ) {dbprintf (_ ("attr fork not in btree format\n" ));return 0 ; } }else { -if (!dip->di_nextents || +if (!xfs_dfork_data_extents (dip) || dip->di_format !=XFS_DINODE_FMT_BTREE ) {dbprintf (_ ("data fork not in btree format\n" ));return 0 ;
db/check.c +17 -11
@@ -2713,7 +2713,7 @@ process_exinode(xfs_bmbt_rec_t *rp; rp = (xfs_bmbt_rec_t *)XFS_DFORK_PTR (dip, whichfork); - *nex =XFS_DFORK_NEXTENTS (dip, whichfork); + *nex =xfs_dfork_nextents (dip, whichfork);if (*nex <0 || *nex >XFS_DFORK_SIZE (dip, mp, whichfork) /sizeof (xfs_bmbt_rec_t)) {if (!sflag || id->ilist)
@@ -2737,12 +2737,14 @@ process_inode(inodata_t *id =NULL ;xfs_ino_t ino;xfs_extnum_t nextents =0 ; +xfs_extnum_t dnextents;int security;xfs_rfsblock_t totblocks;xfs_rfsblock_t totdblocks =0 ;xfs_rfsblock_t totiblocks =0 ;dbm_t type;xfs_extnum_t anextents =0 ; +xfs_extnum_t danextents;xfs_rfsblock_t atotdblocks =0 ;xfs_rfsblock_t atotiblocks =0 ;xfs_qcnt_t bc =0 ;
@@ -2871,14 +2873,17 @@ process_inode( error++;return ; } + + dnextents =xfs_dfork_data_extents (dip); + danextents =xfs_dfork_attr_extents (dip); +if (verbose || (id && id->ilist) ||CHECK_BLIST (bno)) dbprintf(_("inode %lld mode %#o fmt %s " "afmt %s " "nex %d anex %d nblk %lld sz %lld%s%s%s%s%s%s%s\n"), id->ino, mode, fmtnames[(int)dip->di_format], fmtnames[(int)dip->di_aformat], - be32_to_cpu(dip->di_nextents), - be16_to_cpu(dip->di_anextents), + dnextents, danextents, be64_to_cpu(dip->di_nblocks), be64_to_cpu(dip->di_size), diflags & XFS_DIFLAG_REALTIME ? " rt" : "", diflags & XFS_DIFLAG_PREALLOC ? " pre" : "",
@@ -2893,25 +2898,26 @@ process_inode( type =DBM_DIR ;if (dip->di_format ==XFS_DINODE_FMT_LOCAL )break ; - blkmap =blkmap_alloc (be32_to_cpu (dip->di_nextents)); + + blkmap =blkmap_alloc (dnextents);break ;case S_IFREG :if (diflags &XFS_DIFLAG_REALTIME ) type =DBM_RTDATA ;else if (id->ino == mp->m_sb.sb_rbmino) { type =DBM_RTBITMAP ; - blkmap =blkmap_alloc (be32_to_cpu (dip->di_nextents)); + blkmap =blkmap_alloc (dnextents);addlink_inode (id); }else if (id->ino == mp->m_sb.sb_rsumino) { type =DBM_RTSUM ; - blkmap =blkmap_alloc (be32_to_cpu (dip->di_nextents)); + blkmap =blkmap_alloc (dnextents);addlink_inode (id); }else if (id->ino == mp->m_sb.sb_uquotino || id->ino == mp->m_sb.sb_gquotino || id->ino == mp->m_sb.sb_pquotino) { type =DBM_QUOTA ; - blkmap =blkmap_alloc (be32_to_cpu (dip->di_nextents)); + blkmap =blkmap_alloc (dnextents);addlink_inode (id); }else
@@ -2993,17 +2999,17 @@ process_inode( be64_to_cpu(dip->di_nblocks), id->ino, totblocks); error++; } -if (nextents !=be32_to_cpu (dip->di_nextents)) { +if (nextents != dnextents) {if (v)dbprintf (_ ("bad nextents %d for inode %lld, counted %d\n" ), -be32_to_cpu (dip->di_nextents), id->ino, nextents); + dnextents, id->ino, nextents); error++; } -if (anextents !=be16_to_cpu (dip->di_anextents)) { +if (anextents != danextents) {if (v)dbprintf (_ ("bad anextents %d for inode %lld, counted " "%d\n" ), -be16_to_cpu (dip->di_anextents), id->ino, anextents); + danextents, id->ino, anextents); error++; }if (type ==DBM_DIR )
db/frag.c +4 -2
@@ -262,9 +262,11 @@ process_exinode( int whichfork) {xfs_bmbt_rec_t *rp; +xfs_extnum_t nextents; rp = (xfs_bmbt_rec_t *)XFS_DFORK_PTR (dip, whichfork); -process_bmbt_reclist (rp,XFS_DFORK_NEXTENTS (dip, whichfork), extmapp); + nextents =xfs_dfork_nextents (dip, whichfork); +process_bmbt_reclist (rp, nextents, extmapp); } static void
@@ -275,7 +277,7 @@ process_fork(extmap_t *extmap;xfs_extnum_t nex; - nex =XFS_DFORK_NEXTENTS (dip, whichfork); + nex =xfs_dfork_nextents (dip, whichfork);if (!nex)return ; extmap =extmap_alloc (nex);
db/inode.c +8 -6
@@ -275,7 +275,7 @@ inode_a_bmx_count(return 0 ;ASSERT ((char *)XFS_DFORK_APTR (dip) - (char *)dip ==byteize (startoff));return dip->di_aformat ==XFS_DINODE_FMT_EXTENTS ? -be16_to_cpu (dip->di_anextents) :0 ; +xfs_dfork_attr_extents (dip) :0 ; } static int
@@ -329,6 +329,7 @@ inode_a_size( {struct xfs_attr_shortform *asf;xfs_dinode_t *dip; +xfs_extnum_t nextents;ASSERT (startoff ==0 );ASSERT (idx ==0 );
@@ -338,8 +339,8 @@ inode_a_size( asf = (struct xfs_attr_shortform *)XFS_DFORK_APTR (dip);return bitize (be16_to_cpu (asf->hdr.totsize));case XFS_DINODE_FMT_EXTENTS : -return (int )be16_to_cpu (dip->di_anextents) * -bitsz (xfs_bmbt_rec_t); + nextents =xfs_dfork_attr_extents (dip); + return nextents * bitsz(struct xfs_bmbt_rec);case XFS_DINODE_FMT_BTREE :return bitize ((int )XFS_DFORK_ASIZE (dip, mp));default :
@@ -500,7 +501,7 @@ inode_u_bmx_count( dip = obj;ASSERT ((char *)XFS_DFORK_DPTR (dip) - (char *)dip ==byteize (startoff));return dip->di_format ==XFS_DINODE_FMT_EXTENTS ? -be32_to_cpu (dip->di_nextents) :0 ; +xfs_dfork_data_extents (dip) :0 ; } static int
@@ -586,6 +587,7 @@ inode_u_size( int idx) {xfs_dinode_t *dip; +xfs_extnum_t nextents;ASSERT (startoff ==0 );ASSERT (idx ==0 );
@@ -596,8 +598,8 @@ inode_u_size(case XFS_DINODE_FMT_LOCAL :return bitize ((int )be64_to_cpu (dip->di_size));case XFS_DINODE_FMT_EXTENTS : -return (int )be32_to_cpu (dip->di_nextents) * -bitsz (xfs_bmbt_rec_t); + nextents =xfs_dfork_data_extents (dip); + return nextents * bitsz(struct xfs_bmbt_rec);case XFS_DINODE_FMT_BTREE :return bitize ((int )XFS_DFORK_DSIZE (dip, mp));case XFS_DINODE_FMT_UUID :
db/metadump.c +2 -2
@@ -2282,7 +2282,7 @@ process_exinode( whichfork = (itype ==TYP_ATTR ) ?XFS_ATTR_FORK :XFS_DATA_FORK ; - nex =XFS_DFORK_NEXTENTS (dip, whichfork); + nex =xfs_dfork_nextents (dip, whichfork); used = nex *sizeof (xfs_bmbt_rec_t);if (nex <0 || used >XFS_DFORK_SIZE (dip, mp, whichfork)) {if (show_warnings)
@@ -2335,7 +2335,7 @@ static intprocess_dev_inode ( xfs_dinode_t *dip) { -if (XFS_DFORK_NEXTENTS (dip,XFS_DATA_FORK )) { +if (xfs_dfork_data_extents (dip)) {if (show_warnings)print_warning ("inode %llu has unexpected extents" , (unsigned long long )cur_ino);
libxfs/xfs_format.h +0 -4
@@ -1107,10 +1107,6 @@ enum xfs_dinode_fmt { ((w) ==XFS_DATA_FORK ? \ (dip)->di_format : \ (dip)->di_aformat) -#define XFS_DFORK_NEXTENTS (dip,w) \ - ((w) == XFS_DATA_FORK ? \ - be32_to_cpu((dip)->di_nextents) : \ - be16_to_cpu((dip)->di_anextents))/* * For block and character special files the 32bit dev_t is stored at the
libxfs/xfs_inode_buf.c +11 -5
@@ -333,9 +333,11 @@ xfs_dinode_verify_fork( struct xfs_mount *mp, int whichfork) { -xfs_extnum_t di_nextents =XFS_DFORK_NEXTENTS (dip, whichfork); +xfs_extnum_t di_nextents;xfs_extnum_t max_extents; + di_nextents =xfs_dfork_nextents (dip, whichfork); +switch (XFS_DFORK_FORMAT (dip, whichfork)) {case XFS_DINODE_FMT_LOCAL :/*
@@ -402,6 +404,8 @@ xfs_dinode_verify(uint16_t flags;uint64_t flags2;uint64_t di_size; +xfs_rfsblock_t nblocks; +xfs_extnum_t nextents;if (dip->di_magic !=cpu_to_be16 (XFS_DINODE_MAGIC ))return __this_address;
@@ -432,10 +436,12 @@ xfs_dinode_verify(if ((S_ISLNK (mode) ||S_ISDIR (mode)) && di_size ==0 )return __this_address; + nextents =xfs_dfork_data_extents (dip); + nextents +=xfs_dfork_attr_extents (dip); + nblocks =be64_to_cpu (dip->di_nblocks); +/* Fork checks carried over from xfs_iformat_fork */ -if (mode && -be32_to_cpu (dip->di_nextents) +be16_to_cpu (dip->di_anextents) > -be64_to_cpu (dip->di_nblocks)) +if (mode && nextents > nblocks)return __this_address;if (mode &&XFS_DFORK_BOFF (dip) > mp->m_sb.sb_inodesize)
@@ -492,7 +498,7 @@ xfs_dinode_verify(default :return __this_address; } -if (dip->di_anextents) +if (xfs_dfork_attr_extents (dip))return __this_address; }
libxfs/xfs_inode_fork.c +5 -4
@@ -103,7 +103,7 @@ xfs_iformat_extents(struct xfs_mount *mp = ip->i_mount;struct xfs_ifork *ifp =XFS_IFORK_PTR (ip, whichfork);int state =xfs_bmap_fork_to_state (whichfork); -xfs_extnum_t nex =XFS_DFORK_NEXTENTS (dip, whichfork); +xfs_extnum_t nex =xfs_dfork_nextents (dip, whichfork);int size = nex *sizeof (xfs_bmbt_rec_t);struct xfs_iext_cursor icur;struct xfs_bmbt_rec *dp;
@@ -228,7 +228,7 @@ xfs_iformat_data_fork(* depend on it. */ ip->i_df.if_format = dip->di_format; - ip->i_df.if_nextents =be32_to_cpu (dip->di_nextents); + ip->i_df.if_nextents =xfs_dfork_data_extents (dip);switch (inode->i_mode &S_IFMT ) {case S_IFIFO :
@@ -293,14 +293,15 @@ xfs_iformat_attr_fork(struct xfs_inode *ip, struct xfs_dinode *dip) { + xfs_extnum_t naextents;int error =0 ;/* * Initialize the extent count early, as the per-format routines may * depend on it. */ - ip->i_afp =xfs_ifork_alloc (dip->di_aformat, -be16_to_cpu (dip->di_anextents)); + naextents =xfs_dfork_attr_extents (dip); + ip->i_afp =xfs_ifork_alloc (dip->di_aformat, naextents);switch (ip->i_afp->if_format) {case XFS_DINODE_FMT_LOCAL :
libxfs/xfs_inode_fork.h +32 -0
@@ -141,6 +141,38 @@ static inline xfs_extnum_t xfs_iext_max_nextents(int whichfork)return MAXAEXTNUM ; } +static inline xfs_extnum_t +xfs_dfork_data_extents ( +struct xfs_dinode *dip) +{ +return be32_to_cpu (dip->di_nextents); +} + +static inline xfs_extnum_t +xfs_dfork_attr_extents ( +struct xfs_dinode *dip) +{ +return be16_to_cpu (dip->di_anextents); +} + +static inline xfs_extnum_t +xfs_dfork_nextents ( +struct xfs_dinode *dip, +int whichfork) +{ +switch (whichfork) { +case XFS_DATA_FORK : +return xfs_dfork_data_extents (dip); +case XFS_ATTR_FORK : +return xfs_dfork_attr_extents (dip); +default : +ASSERT (0 ); +break ; + } + +return 0 ; +} +struct xfs_ifork *xfs_ifork_alloc (enum xfs_dinode_fmt format,xfs_extnum_t nextents);struct xfs_ifork *xfs_iext_state_to_fork (struct xfs_inode *ip,int state);
repair/attr_repair.c +1 -1
@@ -1083,7 +1083,7 @@ process_longform_attr( bno =blkmap_get (blkmap,0 );if (bno ==NULLFSBLOCK ) {if (dip->di_aformat ==XFS_DINODE_FMT_EXTENTS && -be16_to_cpu (dip->di_anextents) ==0 ) +xfs_dfork_attr_extents (dip) ==0 )return (0 );/* the kernel can handle this state */ do_warn( _("block 0 of inode %" PRIu64 " attribute fork is missing\n"),
repair/dinode.c +30 -23
143 lines not on this page · raw message
repair/prefetch.c +1 -1
@@ -393,7 +393,7 @@ pf_read_exinode( xfs_dinode_t *dino) {pf_read_bmbt_reclist (args, (xfs_bmbt_rec_t *)XFS_DFORK_DPTR (dino), -be32_to_cpu (dino->di_nextents)); +xfs_dfork_data_extents (dino)); } static void
Signature · 1 line
2.30.2
PATCH v4 6/20 xfsprogs: Use basic types to define xfs_log_dinode's di_nextents and di_anextents
In reply to Chandan Babu RA future commit will increase the width of xfs_extnum_t in order to facilitate larger per-inode extent counters. Hence this patch now uses basic types to define xfs_log_dinode->[di_nextents|dianextents].
--- libxfs/xfs_log_format.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
libxfs/xfs_log_format.h +2 -2
@@ -396,8 +396,8 @@ struct xfs_log_dinode {xfs_fsize_t di_size;/* number of bytes in file */ xfs_rfsblock_t di_nblocks;/* # of direct & btree blocks used */ xfs_extlen_t di_extsize;/* basic/minimum extent size for file */ -xfs_extnum_t di_nextents;/* number of extents in data fork */ -xfs_aextnum_t di_anextents;/* number of extents in attribute fork*/ +uint32_t di_nextents;/* number of extents in data fork */ +uint16_t di_anextents;/* number of extents in attribute fork*/ uint8_t di_forkoff;/* attr fork offs, <<3 for 64b align */ int8_t di_aformat;/* format of attr fork's data */ uint32_t di_dmevmask;/* DMIG event mask */
Signature · 1 line
2.30.2
PATCH v4 7/20 xfsprogs: Promote xfs_extnum_t and xfs_aextnum_t to 64 and 32-bits respectively
In reply to Chandan Babu RA future commit will introduce a 64-bit on-disk data extent counter and a 32-bit on-disk attr extent counter. This commit promotes xfs_extnum_t and xfs_aextnum_t to 64 and 32-bits in order to correctly handle in-core versions of these quantities.
--- libxfs/xfs_bmap.c | 4 ++-- libxfs/xfs_inode_fork.c | 2 +- libxfs/xfs_inode_fork.h | 2 +- libxfs/xfs_types.h | 4 ++-- repair/dinode.c | 20 ++++++++++---------- repair/dinode.h | 4 ++-- repair/scan.c | 6 +++--- 7 files changed, 21 insertions(+), 21 deletions(-)
libxfs/xfs_bmap.c +2 -2
@@ -46,9 +46,9 @@ xfs_bmap_compute_maxlevels( xfs_mount_t *mp, /* file system mount structure */ int whichfork) /* data or attr fork */ { +xfs_extnum_t maxleafents;/* max leaf entries possible */ int level;/* btree level */ uint maxblocks;/* max blocks at this level */ -xfs_extnum_t maxleafents;/* max leaf entries possible */ int maxrootrecs;/* max records in root block */ int minleafrecs;/* min records in leaf block */ int minnoderecs;/* min records in node block */
@@ -460,7 +460,7 @@ error0:if (bp_release)xfs_trans_brelse (NULL , bp); error_norelse: -xfs_warn (mp,"%s: BAD after btree leaves for %d extents" , +xfs_warn (mp,"%s: BAD after btree leaves for %llu extents" , __func__, i);xfs_err (mp,"%s: CORRUPTED BTREE OR SOMETHING" , __func__);xfs_force_shutdown (mp,SHUTDOWN_CORRUPT_INCORE );
libxfs/xfs_inode_fork.c +1 -1
@@ -115,7 +115,7 @@ xfs_iformat_extents(* we just bail out rather than crash in kmem_alloc() or memcpy() below. */ if (unlikely (size <0 || size >XFS_DFORK_SIZE (dip, mp, whichfork))) { -xfs_warn (ip->i_mount,"corrupt inode %Lu ((a)extents = %d)." , +xfs_warn (ip->i_mount,"corrupt inode %Lu ((a)extents = %llu)." , (unsigned long long ) ip->i_ino, nex); xfs_inode_verifier_error(ip, -EFSCORRUPTED, "xfs_iformat_extents(1)", dip, sizeof(*dip),
libxfs/xfs_inode_fork.h +1 -1
@@ -21,9 +21,9 @@ struct xfs_ifork {void *if_root;/* extent tree root */ char *if_data;/* inline file data */ } if_u1; +xfs_extnum_t if_nextents;/* # of extents in this fork */ short if_broot_bytes;/* bytes allocated for root */ int8_t if_format;/* format of this fork */ -xfs_extnum_t if_nextents;/* # of extents in this fork */ };/*
libxfs/xfs_types.h +2 -2
@@ -12,8 +12,8 @@ typedef uint32_t xfs_agblock_t; /* blockno in alloc. group */typedef uint32_t xfs_agino_t ;/* inode # within allocation grp */ typedef uint32_t xfs_extlen_t ;/* extent length in blocks */ typedef uint32_t xfs_agnumber_t ;/* allocation group number */ -typedef int32_t xfs_extnum_t ;/* # of extents in a file */ -typedef int16_t xfs_aextnum_t ;/* # extents in an attribute fork */ +typedef uint64_t xfs_extnum_t ;/* # of extents in a file */ +typedef uint32_t xfs_aextnum_t ;/* # extents in an attribute fork */ typedef int64_t xfs_fsize_t ;/* bytes in a file */ typedef uint64_t xfs_ufsize_t ;/* unsigned bytes in a file */
repair/dinode.c +10 -10
@@ -342,7 +342,7 @@ static int process_bmbt_reclist_int( xfs_mount_t *mp, xfs_bmbt_rec_t *rp, - int *numrecs, + xfs_extnum_t *numrecs, int type, xfs_ino_t ino, xfs_rfsblock_t *tot,
@@ -645,7 +645,7 @@ int process_bmbt_reclist( xfs_mount_t *mp, xfs_bmbt_rec_t *rp, - int *numrecs, + xfs_extnum_t *numrecs, int type, xfs_ino_t ino, xfs_rfsblock_t *tot,
@@ -666,7 +666,7 @@ int scan_bmbt_reclist( xfs_mount_t *mp, xfs_bmbt_rec_t *rp, - int *numrecs, + xfs_extnum_t *numrecs, int type, xfs_ino_t ino, xfs_rfsblock_t *tot,
@@ -1045,7 +1045,7 @@ _("mismatch between format (%d) and size (%" PRId64 ") in symlink inode %" PRIu6*/ if (numrecs > max_symlink_blocks) {do_warn ( -_ ("bad number of extents (%d) in symlink %" PRIu64" data fork\n" ), +_ ("bad number of extents (%lu) in symlink %" PRIu64" data fork\n" ), numrecs, lino);return (1 ); }
@@ -1603,7 +1603,7 @@ _("realtime summary inode %" PRIu64 " has bad type 0x%x, "), nextents =xfs_dfork_data_extents (dinoc);if (mp->m_sb.sb_rblocks ==0 && nextents !=0 ) {do_warn ( -_ ("bad # of extents (%d) for realtime summary inode %" PRIu64"\n" ), +_ ("bad # of extents (%lu) for realtime summary inode %" PRIu64"\n" ), nextents, lino);return 1 ; }
@@ -1626,7 +1626,7 @@ _("realtime bitmap inode %" PRIu64 " has bad type 0x%x, "), nextents =xfs_dfork_data_extents (dinoc);if (mp->m_sb.sb_rblocks ==0 && nextents !=0 ) {do_warn ( -_ ("bad # of extents (%d) for realtime bitmap inode %" PRIu64"\n" ), +_ ("bad # of extents (%lu) for realtime bitmap inode %" PRIu64"\n" ), nextents, lino);return 1 ; }
@@ -1815,13 +1815,13 @@ _("too many data fork extents (%" PRIu64 ") in inode %" PRIu64 "\n"),if (nextents != dnextents) {if (!no_modify) {do_warn ( -_ ("correcting nextents for inode %" PRIu64", was %d - counted %" PRIu64"\n" ), +_ ("correcting nextents for inode %" PRIu64", was %lu - counted %" PRIu64"\n" ), lino, dnextents, nextents); dino->di_nextents =cpu_to_be32 (nextents); *dirty =1 ; }else {do_warn ( -_ ("bad nextents %d for inode %" PRIu64", would reset to %" PRIu64"\n" ), +_ ("bad nextents %lu for inode %" PRIu64", would reset to %" PRIu64"\n" ), dnextents, lino, nextents); } }
@@ -1837,13 +1837,13 @@ _("too many attr fork extents (%" PRIu64 ") in inode %" PRIu64 "\n"),if (anextents != dnextents) {if (!no_modify) {do_warn ( -_ ("correcting anextents for inode %" PRIu64", was %d - counted %" PRIu64"\n" ), +_ ("correcting anextents for inode %" PRIu64", was %lu - counted %" PRIu64"\n" ), lino, dnextents, anextents); dino->di_anextents =cpu_to_be16 (anextents); *dirty =1 ; }else {do_warn ( -_ ("bad anextents %d for inode %" PRIu64", would reset to %" PRIu64"\n" ), +_ ("bad anextents %lu for inode %" PRIu64", would reset to %" PRIu64"\n" ), dnextents, lino, anextents); } }
repair/dinode.h +2 -2
@@ -20,7 +20,7 @@ convert_extent( int process_bmbt_reclist(xfs_mount_t *mp, xfs_bmbt_rec_t *rp, - int *numrecs, + xfs_extnum_t *numrecs, int type, xfs_ino_t ino, xfs_rfsblock_t *tot,
@@ -33,7 +33,7 @@ int scan_bmbt_reclist( xfs_mount_t *mp, xfs_bmbt_rec_t *rp, - int *numrecs, + xfs_extnum_t *numrecs, int type, xfs_ino_t ino, xfs_rfsblock_t *tot,
repair/scan.c +3 -3
@@ -220,7 +220,7 @@ scan_bmapbt(xfs_fileoff_t first_key;xfs_fileoff_t last_key;char *forkname =get_forkname (whichfork); -int numrecs; +xfs_extnum_t numrecs;xfs_agnumber_t agno;xfs_agblock_t agbno;int state;
@@ -425,7 +425,7 @@ _("couldn't add inode %"PRIu64" bmbt block %"PRIu64" reverse-mapping data."),if (numrecs > mp->m_bmap_dmxr[0 ] || (isroot ==0 && numrecs < mp->m_bmap_dmnr[0 ])) {do_warn ( -_ ("inode %" PRIu64" bad # of bmap records (%u, min - %u, max - %u)\n" ), +_ ("inode %" PRIu64" bad # of bmap records (%lu, min - %u, max - %u)\n" ), ino, numrecs, mp->m_bmap_dmnr[0 ], mp->m_bmap_dmxr[0 ]);return (1 );
@@ -476,7 +476,7 @@ _("out-of-order bmap key (file offset) in inode %" PRIu64 ", %s fork, fsbno %" Pif (numrecs > mp->m_bmap_dmxr[1 ] || (isroot ==0 && numrecs < mp->m_bmap_dmnr[1 ])) {do_warn ( -_ ("inode %" PRIu64" bad # of bmap records (%u, min - %u, max - %u)\n" ), +_ ("inode %" PRIu64" bad # of bmap records (%lu, min - %u, max - %u)\n" ), ino, numrecs, mp->m_bmap_dmnr[1 ], mp->m_bmap_dmxr[1 ]);return (1 ); }
Signature · 1 line
2.30.2
PATCH v4 8/20 xfsprogs: Introduce XFS_SB_FEAT_INCOMPAT_NREXT64 and associated per-fs feature bit
In reply to Chandan Babu RXFS_SB_FEAT_INCOMPAT_NREXT64 incompat feature bit will be set on filesystems which support large per-inode extent counters. This commit defines the new incompat feature bit and the corresponding per-fs feature bit (along with inline functions to work on it).
--- libxfs/xfs_format.h | 7 +++++++ 1 file changed, 7 insertions(+)
libxfs/xfs_format.h +7 -0
@@ -469,6 +469,7 @@ xfs_sb_has_ro_compat_feature(#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2)/* metadata UUID */ #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_NREXT64 (1 << 5)/* 64-bit data fork extent counter */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE| \ XFS_SB_FEAT_INCOMPAT_SPINODES| \
@@ -575,6 +576,12 @@ static inline bool xfs_sb_version_hasbigtime(struct xfs_sb *sbp) (sbp->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_BIGTIME ); } +static inline bool xfs_sb_version_hasnrext64 (struct xfs_sb *sbp) +{ +return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && + (sbp->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_NREXT64 ); +} +/* * Inode btree block counter. We record the number of inobt and finobt blocks * in the AGI header so that we can skip the finobt walk at mount time when
Signature · 1 line
2.30.2
PATCH v4 9/20 xfsprogs: Introduce XFS_FSOP_GEOM_FLAGS_NREXT64
In reply to Chandan Babu RXFS_FSOP_GEOM_FLAGS_NREXT64 indicates that the current filesystem instance supports 64-bit per-inode extent counters.
--- libxfs/xfs_fs.h | 1 + libxfs/xfs_sb.c | 3 +++ 2 files changed, 4 insertions(+)
libxfs/xfs_fs.h +1 -0
@@ -251,6 +251,7 @@ typedef struct xfs_fsop_resblks {#define XFS_FSOP_GEOM_FLAGS_REFLINK (1 << 20)/* files can share blocks */ #define XFS_FSOP_GEOM_FLAGS_BIGTIME (1 << 21)/* 64-bit nsec timestamps */ #define XFS_FSOP_GEOM_FLAGS_INOBTCNT (1 << 22)/* inobt btree counter */ +#define XFS_FSOP_GEOM_FLAGS_NREXT64 (1 << 23)/* 64-bit extent counter */ /* * Minimum and maximum sizes need for growth checks.
libxfs/xfs_sb.c +3 -0
@@ -1020,6 +1020,9 @@ xfs_fs_geometry( geo->logsectsize = sbp->sb_logsectsize; else geo->logsectsize = BBSIZE; +if (xfs_sb_version_hasnrext64 (sbp)) + geo->flags |=XFS_FSOP_GEOM_FLAGS_NREXT64 ; + geo->rtsectsize = sbp->sb_blocksize; geo->dirblocksize =xfs_dir2_dirblock_bytes (sbp);
Signature · 1 line
2.30.2
PATCH v4 10/20 xfsprogs: Introduce XFS_DIFLAG2_NREXT64 and associated helpers
In reply to Chandan Babu RThis commit adds the new per-inode flag XFS_DIFLAG2_NREXT64 to indicate that an inode supports 64-bit extent counters. This flag is also enabled by default on newly created inodes when the corresponding filesystem has large extent counter feature bit (i.e. XFS_FEAT_NREXT64) set.
--- db/inode.c | 3 +++ include/xfs_inode.h | 5 +++++ libxfs/xfs_format.h | 10 +++++++++- libxfs/xfs_ialloc.c | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-)
db/inode.c +3 -0
@@ -178,6 +178,9 @@ const field_t inode_v3_flds[] = { {"bigtime" ,FLDT_UINT1 ,OI (COFF (flags2) +bitsz (uint64_t) -XFS_DIFLAG2_BIGTIME_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 } };
include/xfs_inode.h +5 -0
@@ -164,6 +164,11 @@ static inline bool xfs_inode_has_bigtime(struct xfs_inode *ip)return ip->i_diflags2 &XFS_DIFLAG2_BIGTIME ; } +static inline bool xfs_inode_has_nrext64 (struct xfs_inode *ip) +{ +return ip->i_diflags2 &XFS_DIFLAG2_NREXT64 ; +} + typedef struct cred { uid_t cr_uid; gid_t cr_gid;
libxfs/xfs_format.h +9 -1
@@ -1180,15 +1180,17 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)#define XFS_DIFLAG2_REFLINK_BIT 1/* file's blocks may be shared */ #define XFS_DIFLAG2_COWEXTSIZE_BIT 2/* copy on write extent size hint */ #define XFS_DIFLAG2_BIGTIME_BIT 3/* big timestamps */ +#define XFS_DIFLAG2_NREXT64_BIT 4/* 64-bit extent counter enabled */ #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT)#define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT)#define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT)#define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_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_BIGTIME | XFS_DIFLAG2_NREXT64)static inline bool xfs_dinode_has_bigtime (const struct xfs_dinode *dip) {
@@ -1196,6 +1198,12 @@ 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 )); +} +/* * Inode number format: * low inopblog bits - offset in block
libxfs/xfs_ialloc.c +2 -0
@@ -2770,6 +2770,8 @@ xfs_ialloc_setup_geometry( igeo->new_diflags2 =0 ;if (xfs_sb_version_hasbigtime (&mp->m_sb)) igeo->new_diflags2 |=XFS_DIFLAG2_BIGTIME ; +if (xfs_sb_version_hasnrext64 (&mp->m_sb)) + igeo->new_diflags2 |=XFS_DIFLAG2_NREXT64 ;/* Compute inode btree geometry. */ igeo->agino_log = sbp->sb_inopblog + sbp->sb_agblklog;
Signature · 1 line
2.30.2
Re: [PATCH V4 10/20] xfsprogs: Introduce XFS_DIFLAG2_NREXT64 and associated helpers
Quoted 18 lines · Chandan Babu R
This commit adds the new per-inode flag
XFS_DIFLAG2_NREXT64to indicate that an inode supports 64-bit extent counters. This flag is also enabled by default on newly created inodes when the corresponding filesystem has large extent counter feature bit (i.e.XFS_FEAT_NREXT64) set.Signed-off-by Chandan Babu R <[email protected]>--- db/inode.c | 3 +++ include/xfs_inode.h | 5 +++++ libxfs/xfs_format.h | 10 +++++++++- libxfs/xfs_ialloc.c | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-)db/inode.c +0
-0
db/inode.c const field_t inode_v3_flds[] = { · line 182
Quoted 5 lines
db/inode.c +2
-0@@ -178,6 +178,9 @@ const field_t inode_v3_flds[] = { {"bigtime" ,FLDT_UINT1 ,OI (COFF (flags2) +bitsz (uint64_t) -XFS_DIFLAG2_BIGTIME_BIT -1 ),C1 , 0, TYP_NONE }, + { "nrext64", FLDT_UINT1, + OI(COFF(flags2) + bitsz(uint64_t) - XFS_DIFLAG2_NREXT64_BIT-1), C1,
Nit: spaces around the '-' operator.
--D
Quoted 72 lines
db/inode.c +1
-0+ 0, TYP_NONE }, { NULL } };include/xfs_inode.h +5
-0@@ -164,6 +164,11 @@ static inline bool xfs_inode_has_bigtime(struct xfs_inode *ip)return ip->i_diflags2 &XFS_DIFLAG2_BIGTIME ; } +static inline bool xfs_inode_has_nrext64 (struct xfs_inode *ip) +{ +return ip->i_diflags2 &XFS_DIFLAG2_NREXT64 ; +} + typedef struct cred { uid_t cr_uid; gid_t cr_gid;libxfs/xfs_format.h +9
-1@@ -1180,15 +1180,17 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)#define XFS_DIFLAG2_REFLINK_BIT 1/* file's blocks may be shared */ #define XFS_DIFLAG2_COWEXTSIZE_BIT 2/* copy on write extent size hint */ #define XFS_DIFLAG2_BIGTIME_BIT 3/* big timestamps */ +#define XFS_DIFLAG2_NREXT64_BIT 4/* 64-bit extent counter enabled */ #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT)#define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT)#define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT)#define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_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_BIGTIME | XFS_DIFLAG2_NREXT64)static inline bool xfs_dinode_has_bigtime (const struct xfs_dinode *dip) {@@ -1196,6 +1198,12 @@ 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 )); +} +/* * Inode number format: * low inopblog bits - offset in block libxfs/xfs_ialloc.c +2
-0@@ -2770,6 +2770,8 @@ xfs_ialloc_setup_geometry( igeo->new_diflags2 =0 ;if (xfs_sb_version_hasbigtime (&mp->m_sb)) igeo->new_diflags2 |=XFS_DIFLAG2_BIGTIME ; +if (xfs_sb_version_hasnrext64 (&mp->m_sb)) + igeo->new_diflags2 |=XFS_DIFLAG2_NREXT64 ;/* Compute inode btree geometry. */ igeo->agino_log = sbp->sb_inopblog + sbp->sb_agblklog;Signature · 1 line
2.30.2
Re: [PATCH V4 10/20] xfsprogs: Introduce XFS_DIFLAG2_NREXT64 and associated helpers
Quoted 14 lines · Darrick J. Wong
Quoted 13 lines · Chandan Babu R
This commit adds the new per-inode flag
XFS_DIFLAG2_NREXT64to indicate that an inode supports 64-bit extent counters. This flag is also enabled by default on newly created inodes when the corresponding filesystem has large extent counter feature bit (i.e.XFS_FEAT_NREXT64) set.Signed-off-by Chandan Babu R <[email protected]>--- db/inode.c | 3 +++ include/xfs_inode.h | 5 +++++ libxfs/xfs_format.h | 10 +++++++++- libxfs/xfs_ialloc.c | 2 ++ 4 files changed, 19 insertions(+), 1 deletion(-)
Quoted 13 lines
db/inode.c const field_t inode_v3_flds[] = { · line 182
Quoted 10 lines
db/inode.c +2
-0@@ -178,6 +178,9 @@ const field_t inode_v3_flds[] = { {"bigtime" ,FLDT_UINT1 ,OI (COFF (flags2) +bitsz (uint64_t) -XFS_DIFLAG2_BIGTIME_BIT -1 ),C1 , 0, TYP_NONE }, + { "nrext64", FLDT_UINT1, + OI(COFF(flags2) + bitsz(uint64_t) - XFS_DIFLAG2_NREXT64_BIT-1), C1,Nit: spaces around the '-' operator.
Ok. I will fix that.
Quoted 74 lines
--D
Quoted 72 lines
db/inode.c +1
-0+ 0, TYP_NONE }, { NULL } };include/xfs_inode.h +5
-0@@ -164,6 +164,11 @@ static inline bool xfs_inode_has_bigtime(struct xfs_inode *ip)return ip->i_diflags2 &XFS_DIFLAG2_BIGTIME ; } +static inline bool xfs_inode_has_nrext64 (struct xfs_inode *ip) +{ +return ip->i_diflags2 &XFS_DIFLAG2_NREXT64 ; +} + typedef struct cred { uid_t cr_uid; gid_t cr_gid;libxfs/xfs_format.h +9
-1@@ -1180,15 +1180,17 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)#define XFS_DIFLAG2_REFLINK_BIT 1/* file's blocks may be shared */ #define XFS_DIFLAG2_COWEXTSIZE_BIT 2/* copy on write extent size hint */ #define XFS_DIFLAG2_BIGTIME_BIT 3/* big timestamps */ +#define XFS_DIFLAG2_NREXT64_BIT 4/* 64-bit extent counter enabled */ #define XFS_DIFLAG2_DAX (1 << XFS_DIFLAG2_DAX_BIT)#define XFS_DIFLAG2_REFLINK (1 << XFS_DIFLAG2_REFLINK_BIT)#define XFS_DIFLAG2_COWEXTSIZE (1 << XFS_DIFLAG2_COWEXTSIZE_BIT)#define XFS_DIFLAG2_BIGTIME (1 << XFS_DIFLAG2_BIGTIME_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_BIGTIME | XFS_DIFLAG2_NREXT64)static inline bool xfs_dinode_has_bigtime (const struct xfs_dinode *dip) {@@ -1196,6 +1198,12 @@ 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 )); +} +/* * Inode number format: * low inopblog bits - offset in block libxfs/xfs_ialloc.c +2
-0@@ -2770,6 +2770,8 @@ xfs_ialloc_setup_geometry( igeo->new_diflags2 =0 ;if (xfs_sb_version_hasbigtime (&mp->m_sb)) igeo->new_diflags2 |=XFS_DIFLAG2_BIGTIME ; +if (xfs_sb_version_hasnrext64 (&mp->m_sb)) + igeo->new_diflags2 |=XFS_DIFLAG2_NREXT64 ;/* Compute inode btree geometry. */ igeo->agino_log = sbp->sb_inopblog + sbp->sb_agblklog;Signature · 1 line
2.30.2
Signature · 1 line
chandan
PATCH v4 11/20 xfsprogs: Use xfs_rfsblock_t to count maximum blocks that can be used by BMBT
In reply to Chandan Babu R--- libxfs/xfs_bmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
libxfs/xfs_bmap.c +1 -1
@@ -47,8 +47,8 @@ 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 */
Signature · 1 line
2.30.2
PATCH v4 12/20 xfsprogs: Introduce macros to represent new maximum extent counts for data/attr forks
In reply to Chandan Babu RThis commit defines new macros to represent maximum extent counts allowed by filesystems which have support for large per-inode extent counters.
--- libxfs/xfs_bmap.c | 9 ++++----- libxfs/xfs_format.h | 8 +++++--- libxfs/xfs_inode_buf.c | 3 ++- libxfs/xfs_inode_fork.c | 2 +- libxfs/xfs_inode_fork.h | 19 +++++++++++++++---- repair/dinode.c | 6 ++++-- 6 files changed, 31 insertions(+), 16 deletions(-)
libxfs/xfs_bmap.c +4 -5
@@ -55,10 +55,8 @@ xfs_bmap_compute_maxlevels(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
@@ -68,7 +66,8 @@ xfs_bmap_compute_maxlevels(* ATTR2 we have to assume the worst case scenario of a minimum size * available. */ - maxleafents =xfs_iext_max_nextents (whichfork); + maxleafents =xfs_iext_max_nextents (xfs_sb_version_hasnrext64 (&mp->m_sb), + whichfork);if (whichfork ==XFS_DATA_FORK ) sz =XFS_BMDR_SPACE_CALC (MINDBTPTRS );else
libxfs/xfs_format.h +5 -3
@@ -1061,9 +1061,11 @@ enum xfs_dinode_fmt {/* * Max values for extlen, extnum, aextnum. */ -#define MAXEXTLEN ((xfs_extlen_t)0x001fffff)/* 21 bits */ -#define MAXEXTNUM ((xfs_extnum_t)0x7fffffff)/* signed int */ -#define MAXAEXTNUM ((xfs_aextnum_t)0x7fff)/* signed short */ +#define MAXEXTLEN ((xfs_extlen_t)0x1fffff)/* 21 bits */ +#define XFS_MAX_EXTCNT_DATA_FORK ((xfs_extnum_t)0xffffffffffff)/* Unsigned 48-bits */ +#define XFS_MAX_EXTCNT_ATTR_FORK ((xfs_aextnum_t)0xffffffff)/* Unsigned 32-bits */ +#define XFS_MAX_EXTCNT_DATA_FORK_OLD ((xfs_extnum_t)0x7fffffff)/* Signed 32-bits */ +#define XFS_MAX_EXTCNT_ATTR_FORK_OLD ((xfs_aextnum_t)0x7fff)/* Signed 16-bits */ /* * Inode minimum and maximum sizes.
libxfs/xfs_inode_buf.c +2 -1
@@ -358,7 +358,8 @@ xfs_dinode_verify_fork(return __this_address;break ;case XFS_DINODE_FMT_BTREE : - max_extents =xfs_iext_max_nextents (whichfork); + max_extents =xfs_iext_max_nextents (xfs_dinode_has_nrext64 (dip), + whichfork);if (di_nextents > max_extents)return __this_address;break ;
libxfs/xfs_inode_fork.c +1 -1
@@ -743,7 +743,7 @@ xfs_iext_count_may_overflow(if (whichfork ==XFS_COW_FORK )return 0 ; - max_exts =xfs_iext_max_nextents (whichfork); + max_exts =xfs_iext_max_nextents (xfs_inode_has_nrext64 (ip), whichfork);if (XFS_TEST_ERROR (false, ip->i_mount,XFS_ERRTAG_REDUCE_MAX_IEXTENTS )) max_exts =10 ;
libxfs/xfs_inode_fork.h +15 -4
@@ -133,12 +133,23 @@ static inline int8_t xfs_ifork_format(struct xfs_ifork *ifp)return ifp->if_format; } -static inline xfs_extnum_t xfs_iext_max_nextents (int whichfork) +static inline xfs_extnum_t xfs_iext_max_nextents (bool has_big_extcnt, +int whichfork) { -if (whichfork ==XFS_DATA_FORK || whichfork ==XFS_COW_FORK ) -return MAXEXTNUM ; +switch (whichfork) { +case XFS_DATA_FORK : +case XFS_COW_FORK : +return has_big_extcnt ?XFS_MAX_EXTCNT_DATA_FORK + :XFS_MAX_EXTCNT_DATA_FORK_OLD ; + +case XFS_ATTR_FORK : +return has_big_extcnt ?XFS_MAX_EXTCNT_ATTR_FORK + :XFS_MAX_EXTCNT_ATTR_FORK_OLD ; -return MAXAEXTNUM ; +default : +ASSERT (0 ); +return 0 ; + } } static inline xfs_extnum_t
repair/dinode.c +4 -2
@@ -1804,7 +1804,8 @@ _("bad nblocks %llu for inode %" PRIu64 ", would reset to %" PRIu64 "\n"), } } -if (nextents >xfs_iext_max_nextents (XFS_DATA_FORK )) { +if (nextents >xfs_iext_max_nextents (xfs_dinode_has_nrext64 (dino), +XFS_DATA_FORK )) {do_warn (_ ("too many data fork extents (%" PRIu64") in inode %" PRIu64"\n" ), nextents, lino);
@@ -1826,7 +1827,8 @@ _("bad nextents %lu for inode %" PRIu64 ", would reset to %" PRIu64 "\n"), } } -if (anextents >xfs_iext_max_nextents (XFS_ATTR_FORK )) { +if (anextents >xfs_iext_max_nextents (xfs_dinode_has_nrext64 (dino), +XFS_ATTR_FORK )) {do_warn (_ ("too many attr fork extents (%" PRIu64") in inode %" PRIu64"\n" ), anextents, lino);
Signature · 1 line
2.30.2
PATCH v4 13/20 xfsprogs: Introduce per-inode 64-bit extent counters
In reply to Chandan Babu RThis commit introduces new fields in the on-disk inode format to support 64-bit data fork extent counters and 32-bit attribute fork extent counters. The new fields will be used only when an inode has XFS_DIFLAG2_NREXT64 flag set. Otherwise we continue to use the regular 32-bit data fork extent counters and 16-bit attribute fork extent counters.
--- db/field.c | 4 - db/field.h | 2 - db/inode.c | 170 ++++++++++++++++++++++++++++++++++++++- libxfs/xfs_format.h | 22 ++++- libxfs/xfs_inode_buf.c | 27 ++++++- libxfs/xfs_inode_fork.h | 10 ++- libxfs/xfs_log_format.h | 22 ++++- logprint/log_misc.c | 20 ++++- logprint/log_print_all.c | 18 ++++- repair/dinode.c | 18 ++++- 10 files changed, 279 insertions(+), 34 deletions(-)
db/field.c +0 -4
@@ -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,
db/field.h +0 -2
@@ -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,
db/inode.c +166 -4
196 lines not on this page · raw message
libxfs/xfs_format.h +18 -4
@@ -980,16 +980,30 @@ typedef struct xfs_dinode {__be32 di_nlink;/* number of links to file */ __be16 di_projid_lo;/* lower part of owner's project id */ __be16 di_projid_hi;/* higher part owner's project id */ -__u8 di_pad[6 ];/* unused, zeroed space */ -__be16 di_flushiter;/* incremented on flush */ +union { +__be64 di_big_dextcnt;/* NREXT64 data extents */ +__u8 di_v3_pad[8 ];/* !NREXT64 V3 inode zeroed space */ +struct { +__u8 di_v2_pad[6 ];/* V2 inode zeroed space */ +__be16 di_flushiter;/* V2 inode incremented on flush */ + }; + };xfs_timestamp_t di_atime;/* time last accessed */ xfs_timestamp_t di_mtime;/* time last modified */ xfs_timestamp_t di_ctime;/* time created/inode modified */ __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 */ -__be32 di_nextents;/* number of extents in data fork */ -__be16 di_anextents;/* number of extents in attribute fork*/ +union { +struct { +__be32 di_big_aextcnt;/* NREXT64 attr extents */ +__be16 di_nrext64_pad;/* NREXT64 unused, zero */ + } __packed; +struct { +__be32 di_nextents;/* !NREXT64 data extents */ +__be16 di_anextents;/* !NREXT64 attr extents */ + } __packed; + };__u8 di_forkoff;/* attr fork offs, <<3 for 64b align */ __s8 di_aformat;/* format of attr fork's data */ __be32 di_dmevmask;/* DMIG event mask */
libxfs/xfs_inode_buf.c +23 -4
@@ -276,6 +276,25 @@ 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_big_dextcnt =cpu_to_be64 (xfs_ifork_nextents (&ip->i_df)); + to->di_big_aextcnt =cpu_to_be32 (xfs_ifork_nextents (ip->i_afp)); +/* +* We might be upgrading the inode to use larger extent counters +* than was previously used. Hence zero the unused field. +*/ + to->di_nrext64_pad =cpu_to_be16 (0 ); + }else { + to->di_nextents =cpu_to_be32 (xfs_ifork_nextents (&ip->i_df)); + to->di_anextents =cpu_to_be16 (xfs_ifork_nextents (ip->i_afp)); + } +} + void xfs_inode_to_disk( struct xfs_inode *ip,
@@ -293,7 +312,6 @@ xfs_inode_to_disk( to->di_projid_lo =cpu_to_be16 (ip->i_projid &0xffff ); to->di_projid_hi =cpu_to_be16 (ip->i_projid >>16 ); -memset (to->di_pad,0 ,sizeof (to->di_pad)); to->di_atime =xfs_inode_to_disk_ts (ip, inode->i_atime); to->di_mtime =xfs_inode_to_disk_ts (ip, inode->i_mtime); to->di_ctime =xfs_inode_to_disk_ts (ip, inode->i_ctime);
@@ -304,8 +322,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_nextents =cpu_to_be32 (xfs_ifork_nextents (&ip->i_df)); - to->di_anextents =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);
@@ -320,11 +336,14 @@ xfs_inode_to_disk( to->di_lsn =cpu_to_be64 (lsn);memset (to->di_pad2,0 ,sizeof (to->di_pad2));uuid_copy (&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid); - to->di_flushiter =0 ; +memset (to->di_v3_pad,0 ,sizeof (to->di_v3_pad)); }else { to->di_version =2 ; to->di_flushiter =cpu_to_be16 (ip->i_flushiter); +memset (to->di_v2_pad,0 ,sizeof (to->di_v2_pad)); } + +xfs_inode_to_disk_iext_counters (ip, to); } static xfs_failaddr_t
libxfs/xfs_inode_fork.h +8 -2
@@ -156,14 +156,20 @@ static inline xfs_extnum_txfs_dfork_data_extents ( struct xfs_dinode *dip) { -return be32_to_cpu (dip->di_nextents); +if (xfs_dinode_has_nrext64 (dip)) +return be64_to_cpu (dip->di_big_dextcnt); +else +return be32_to_cpu (dip->di_nextents); }static inline xfs_extnum_t xfs_dfork_attr_extents (struct xfs_dinode *dip) { -return be16_to_cpu (dip->di_anextents); +if (xfs_dinode_has_nrext64 (dip)) +return be32_to_cpu (dip->di_big_aextcnt); +else +return be16_to_cpu (dip->di_anextents); } static inline xfs_extnum_t
libxfs/xfs_log_format.h +18 -4
@@ -388,16 +388,30 @@ struct xfs_log_dinode {uint32_t di_nlink;/* number of links to file */ uint16_t di_projid_lo;/* lower part of owner's project id */ uint16_t di_projid_hi;/* higher part of owner's project id */ -uint8_t di_pad[6 ];/* unused, zeroed space */ -uint16_t di_flushiter;/* incremented on flush */ +union { +uint64_t di_big_dextcnt;/* NREXT64 data extents */ +uint8_t di_v3_pad[8 ];/* !NREXT64 V3 inode zeroed space */ +struct { +uint8_t di_v2_pad[6 ];/* V2 inode zeroed space */ +uint16_t di_flushiter;/* V2 inode incremented on flush */ + }; + };xfs_log_timestamp_t di_atime;/* time last accessed */ xfs_log_timestamp_t di_mtime;/* time last modified */ xfs_log_timestamp_t di_ctime;/* time created/inode modified */ xfs_fsize_t di_size;/* number of bytes in file */ xfs_rfsblock_t di_nblocks;/* # of direct & btree blocks used */ xfs_extlen_t di_extsize;/* basic/minimum extent size for file */ -uint32_t di_nextents;/* number of extents in data fork */ -uint16_t di_anextents;/* number of extents in attribute fork*/ +union { +struct { +uint32_t di_big_aextcnt;/* NREXT64 attr extents */ +uint16_t di_nrext64_pad;/* NREXT64 unused, zero */ + } __packed; +struct { +uint32_t di_nextents;/* !NREXT64 data extents */ +uint16_t di_anextents;/* !NREXT64 attr extents */ + } __packed; + };uint8_t di_forkoff;/* attr fork offs, <<3 for 64b align */ int8_t di_aformat;/* format of attr fork's data */ uint32_t di_dmevmask;/* DMIG event mask */
logprint/log_misc.c +16 -4
@@ -440,6 +440,8 @@ static voidxlog_print_trans_inode_core ( 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 +452,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_big_dextcnt; +else + nextents = ip->di_nextents; +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_nextents); -printf (_ ("naextents 0x%x forkoff %d dmevmask 0x%x dmstate 0x%hx\n" ), - ip->di_anextents, (int )ip->di_forkoff, ip->di_dmevmask, + ip->di_extsize, nextents); + +if (ip->di_flags2 &XFS_DIFLAG2_NREXT64 ) + nextents = ip->di_big_aextcnt; +else + nextents = ip->di_anextents; +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);
logprint/log_print_all.c +15 -3
@@ -240,7 +240,10 @@ STATIC voidxlog_recover_print_inode_core ( 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 +257,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_big_dextcnt; + anextents = di->di_big_aextcnt; + }else { + nextents = di->di_nextents; + anextents = di->di_anextents; + } +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_nextents, (int )di->di_anextents); + 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,
repair/dinode.c +15 -3
@@ -71,7 +71,12 @@ _("would have cleared inode %" PRIu64 " attributes\n"), ino_num);if (xfs_dfork_attr_extents (dino) !=0 ) {if (no_modify)return (1 ); - dino->di_anextents =cpu_to_be16 (0 ); + +if (xfs_dinode_has_nrext64 (dino)) + dino->di_big_aextcnt =0 ; +else + dino->di_anextents =0 ; + }if (dino->di_aformat !=XFS_DINODE_FMT_EXTENTS ) {
@@ -1818,7 +1823,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_nextents =cpu_to_be32 (nextents); +if (xfs_dinode_has_nrext64 (dino)) + dino->di_big_dextcnt =cpu_to_be64 (nextents); +else + dino->di_nextents =cpu_to_be32 (nextents); *dirty =1 ; }else { do_warn(
@@ -1841,7 +1849,11 @@ _("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_anextents =cpu_to_be16 (anextents); +if (xfs_dinode_has_nrext64 (dino)) + dino->di_big_aextcnt =cpu_to_be32 (anextents); +else + dino->di_anextents =cpu_to_be16 (anextents); + *dirty =1 ; }else { do_warn(
Signature · 1 line
2.30.2
Re: [PATCH V4 13/20] xfsprogs: Introduce per-inode 64-bit extent counters
Quoted 83 lines · Chandan Babu R
This commit introduces new fields in the on-disk inode format to support 64-bit data fork extent counters and 32-bit attribute fork extent counters. The new fields will be used only when an inode has
XFS_DIFLAG2_NREXT64flag set. Otherwise we continue to use the regular 32-bit data fork extent counters and 16-bit attribute fork extent counters.Signed-off-by Chandan Babu R <[email protected]>Suggested-by Dave Chinner <[email protected]>--- db/field.c | 4 - db/field.h | 2 - db/inode.c | 170 ++++++++++++++++++++++++++++++++++++++- libxfs/xfs_format.h | 22 ++++- libxfs/xfs_inode_buf.c | 27 ++++++- libxfs/xfs_inode_fork.h | 10 ++- libxfs/xfs_log_format.h | 22 ++++- logprint/log_misc.c | 20 ++++- logprint/log_print_all.c | 18 ++++- repair/dinode.c | 18 ++++- 10 files changed, 279 insertions(+), 34 deletions(-)db/field.c +0
-4@@ -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,db/field.h +0
-2@@ -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,db/inode.c +8
-0@@ -27,6 +27,14 @@ static int inode_core_nlinkv2_count(void *obj, int startoff);static int inode_core_onlink_count (void *obj,int startoff);static int inode_core_projid_count (void *obj,int startoff);static int inode_core_nlinkv1_count (void *obj,int startoff); +static int inode_core_big_dextcnt_count (void *obj,int startoff); +static int inode_core_v3_pad_count (void *obj,int startoff); +static int inode_core_v2_pad_count (void *obj,int startoff); +static int inode_core_flushiter_count (void *obj,int startoff); +static int inode_core_big_aextcnt_count (void *obj,int startoff); +static int inode_core_nrext64_pad_count (void *obj,int startoff); +static int inode_core_nextents_count (void *obj,int startoff); +static int inode_core_anextents_count (void *obj,int startoff);static int inode_f (int argc,char **argv);static int inode_u_offset (void *obj,int startoff,int idx);static int inode_u_bmbt_count (void *obj,int startoff);
db/inode.c const field_t inode_core_flds[] = { · line 101
Quoted 5 lines
db/inode.c +1
-1@@ -90,18 +98,30 @@ const field_t inode_core_flds[] = { inode_core_projid_count, FLD_COUNT, TYP_NONE }, {"projid_hi" ,FLDT_UINT16D ,OI (COFF (projid_hi)), inode_core_projid_count, FLD_COUNT, TYP_NONE }, - { "pad", FLDT_UINT8X, OI(OFF(pad)), CI(6), FLD_ARRAY|FLD_SKIPALL, TYP_NONE }, + { "big_dextcnt", FLDT_UINT64D, OI(COFF(big_dextcnt)),
Any reason we don't leave the display names as nextents and naextents? I think fstests has a fair amount of hardcoded xfs_db output, right?
Quoted 36 lines
db/inode.c +18
-3+ inode_core_big_dextcnt_count, FLD_COUNT, TYP_NONE }, + {"v3_pad" ,FLDT_UINT8X ,OI (OFF (v3_pad)), + inode_core_v3_pad_count, FLD_ARRAY|FLD_COUNT|FLD_SKIPALL, TYP_NONE }, + { "v2_pad", FLDT_UINT8X, OI(OFF(v2_pad)), + inode_core_v2_pad_count, FLD_ARRAY|FLD_COUNT|FLD_SKIPALL, TYP_NONE }, { "uid", FLDT_UINT32D, OI(COFF(uid)), C1, 0, TYP_NONE }, { "gid", FLDT_UINT32D, OI(COFF(gid)), C1, 0, TYP_NONE }, - { "flushiter", FLDT_UINT16D, OI(COFF(flushiter)), C1, 0, TYP_NONE }, + { "flushiter", FLDT_UINT16D, OI(COFF(flushiter)), + inode_core_flushiter_count, FLD_COUNT, TYP_NONE }, { "atime", FLDT_TIMESTAMP, OI(COFF(atime)), C1, 0, TYP_NONE }, { "mtime", FLDT_TIMESTAMP, OI(COFF(mtime)), C1, 0, TYP_NONE }, { "ctime", FLDT_TIMESTAMP, OI(COFF(ctime)), C1, 0, TYP_NONE }, { "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 }, - { "nextents", FLDT_EXTNUM, OI(COFF(nextents)), C1, 0, TYP_NONE }, - { "naextents", FLDT_AEXTNUM, OI(COFF(anextents)), C1, 0, TYP_NONE }, + { "big_aextcnt", FLDT_UINT32D, OI(COFF(big_aextcnt)), + inode_core_big_aextcnt_count, FLD_COUNT, TYP_NONE }, + { "nrext64_pad", FLDT_UINT16D, OI(COFF(nrext64_pad)), + inode_core_nrext64_pad_count, FLD_COUNT, TYP_NONE }, + { "nextents", FLDT_UINT32D, OI(COFF(nextents)), + inode_core_nextents_count, FLD_COUNT, TYP_NONE }, + { "naextents", FLDT_UINT16D, OI(COFF(anextents)), + inode_core_anextents_count, FLD_COUNT, 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 },@@ -403,6 +423,148 @@ inode_core_projid_count(return dic->di_version >=2 ; } +static int +inode_core_big_dextcnt_count( + void *obj,
db/inode.c inode_core_projid_count( · line 438
Quoted 10 lines
db/inode.c +10
-0+ int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 && + (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 ))
(dic->di_flags2 & cpu_to_be64(XFS_DIFLAG2_NREXT64)) ?
(I forget, does userspace's version of those macros elide constants?)
--D
Quoted 423 lines
db/inode.c +129
-0+return 1 ; + else + return 0; +} + +static int +inode_core_v3_pad_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if ((dic->di_version ==3 ) + && !(be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 8 ; +else +return 0 ; +} + +static int +inode_core_v2_pad_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 ) +return 0 ; +else +return 6 ; +} + +static int +inode_core_flushiter_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 ) +return 0 ; +else +return 1 ; +} + +static int +inode_core_big_aextcnt_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 && + (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 1 ; +else +return 0 ; +} + +static int +inode_core_nrext64_pad_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 && + (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 1 ; +else +return 0 ; +} + +static int +inode_core_nextents_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if ((dic->di_version ==3 ) + && (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 0 ; +else +return 1 ; +} + +static int +inode_core_anextents_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if ((dic->di_version ==3 ) + && (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 0 ; +else +return 1 ; +} + static int inode_f( int argc,libxfs/xfs_format.h +18
-4@@ -980,16 +980,30 @@ typedef struct xfs_dinode {__be32 di_nlink;/* number of links to file */ __be16 di_projid_lo;/* lower part of owner's project id */ __be16 di_projid_hi;/* higher part owner's project id */ -__u8 di_pad[6 ];/* unused, zeroed space */ -__be16 di_flushiter;/* incremented on flush */ +union { +__be64 di_big_dextcnt;/* NREXT64 data extents */ +__u8 di_v3_pad[8 ];/* !NREXT64 V3 inode zeroed space */ +struct { +__u8 di_v2_pad[6 ];/* V2 inode zeroed space */ +__be16 di_flushiter;/* V2 inode incremented on flush */ + }; + };xfs_timestamp_t di_atime;/* time last accessed */ xfs_timestamp_t di_mtime;/* time last modified */ xfs_timestamp_t di_ctime;/* time created/inode modified */ __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 */ -__be32 di_nextents;/* number of extents in data fork */ -__be16 di_anextents;/* number of extents in attribute fork*/ +union { +struct { +__be32 di_big_aextcnt;/* NREXT64 attr extents */ +__be16 di_nrext64_pad;/* NREXT64 unused, zero */ + } __packed; +struct { +__be32 di_nextents;/* !NREXT64 data extents */ +__be16 di_anextents;/* !NREXT64 attr extents */ + } __packed; + };__u8 di_forkoff;/* attr fork offs, <<3 for 64b align */ __s8 di_aformat;/* format of attr fork's data */ __be32 di_dmevmask;/* DMIG event mask */ libxfs/xfs_inode_buf.c +23
-4@@ -276,6 +276,25 @@ 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_big_dextcnt =cpu_to_be64 (xfs_ifork_nextents (&ip->i_df)); + to->di_big_aextcnt =cpu_to_be32 (xfs_ifork_nextents (ip->i_afp)); +/* +* We might be upgrading the inode to use larger extent counters +* than was previously used. Hence zero the unused field. +*/ + to->di_nrext64_pad =cpu_to_be16 (0 ); + }else { + to->di_nextents =cpu_to_be32 (xfs_ifork_nextents (&ip->i_df)); + to->di_anextents =cpu_to_be16 (xfs_ifork_nextents (ip->i_afp)); + } +} + void xfs_inode_to_disk( struct xfs_inode *ip,@@ -293,7 +312,6 @@ xfs_inode_to_disk( to->di_projid_lo =cpu_to_be16 (ip->i_projid &0xffff ); to->di_projid_hi =cpu_to_be16 (ip->i_projid >>16 ); -memset (to->di_pad,0 ,sizeof (to->di_pad)); to->di_atime =xfs_inode_to_disk_ts (ip, inode->i_atime); to->di_mtime =xfs_inode_to_disk_ts (ip, inode->i_mtime); to->di_ctime =xfs_inode_to_disk_ts (ip, inode->i_ctime);@@ -304,8 +322,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_nextents =cpu_to_be32 (xfs_ifork_nextents (&ip->i_df)); - to->di_anextents =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);@@ -320,11 +336,14 @@ xfs_inode_to_disk( to->di_lsn =cpu_to_be64 (lsn);memset (to->di_pad2,0 ,sizeof (to->di_pad2));uuid_copy (&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid); - to->di_flushiter =0 ; +memset (to->di_v3_pad,0 ,sizeof (to->di_v3_pad)); }else { to->di_version =2 ; to->di_flushiter =cpu_to_be16 (ip->i_flushiter); +memset (to->di_v2_pad,0 ,sizeof (to->di_v2_pad)); } + +xfs_inode_to_disk_iext_counters (ip, to); } static xfs_failaddr_tlibxfs/xfs_inode_fork.h +8
-2@@ -156,14 +156,20 @@ static inline xfs_extnum_txfs_dfork_data_extents ( struct xfs_dinode *dip) { -return be32_to_cpu (dip->di_nextents); +if (xfs_dinode_has_nrext64 (dip)) +return be64_to_cpu (dip->di_big_dextcnt); +else +return be32_to_cpu (dip->di_nextents); }static inline xfs_extnum_t xfs_dfork_attr_extents (struct xfs_dinode *dip) { -return be16_to_cpu (dip->di_anextents); +if (xfs_dinode_has_nrext64 (dip)) +return be32_to_cpu (dip->di_big_aextcnt); +else +return be16_to_cpu (dip->di_anextents); } static inline xfs_extnum_tlibxfs/xfs_log_format.h +18
-4@@ -388,16 +388,30 @@ struct xfs_log_dinode {uint32_t di_nlink;/* number of links to file */ uint16_t di_projid_lo;/* lower part of owner's project id */ uint16_t di_projid_hi;/* higher part of owner's project id */ -uint8_t di_pad[6 ];/* unused, zeroed space */ -uint16_t di_flushiter;/* incremented on flush */ +union { +uint64_t di_big_dextcnt;/* NREXT64 data extents */ +uint8_t di_v3_pad[8 ];/* !NREXT64 V3 inode zeroed space */ +struct { +uint8_t di_v2_pad[6 ];/* V2 inode zeroed space */ +uint16_t di_flushiter;/* V2 inode incremented on flush */ + }; + };xfs_log_timestamp_t di_atime;/* time last accessed */ xfs_log_timestamp_t di_mtime;/* time last modified */ xfs_log_timestamp_t di_ctime;/* time created/inode modified */ xfs_fsize_t di_size;/* number of bytes in file */ xfs_rfsblock_t di_nblocks;/* # of direct & btree blocks used */ xfs_extlen_t di_extsize;/* basic/minimum extent size for file */ -uint32_t di_nextents;/* number of extents in data fork */ -uint16_t di_anextents;/* number of extents in attribute fork*/ +union { +struct { +uint32_t di_big_aextcnt;/* NREXT64 attr extents */ +uint16_t di_nrext64_pad;/* NREXT64 unused, zero */ + } __packed; +struct { +uint32_t di_nextents;/* !NREXT64 data extents */ +uint16_t di_anextents;/* !NREXT64 attr extents */ + } __packed; + };uint8_t di_forkoff;/* attr fork offs, <<3 for 64b align */ int8_t di_aformat;/* format of attr fork's data */ uint32_t di_dmevmask;/* DMIG event mask */ logprint/log_misc.c +16
-4@@ -440,6 +440,8 @@ static voidxlog_print_trans_inode_core ( 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 +452,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_big_dextcnt; +else + nextents = ip->di_nextents; +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_nextents); -printf (_ ("naextents 0x%x forkoff %d dmevmask 0x%x dmstate 0x%hx\n" ), - ip->di_anextents, (int )ip->di_forkoff, ip->di_dmevmask, + ip->di_extsize, nextents); + +if (ip->di_flags2 &XFS_DIFLAG2_NREXT64 ) + nextents = ip->di_big_aextcnt; +else + nextents = ip->di_anextents; +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);logprint/log_print_all.c +15
-3@@ -240,7 +240,10 @@ STATIC voidxlog_recover_print_inode_core ( 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 +257,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_big_dextcnt; + anextents = di->di_big_aextcnt; + }else { + nextents = di->di_nextents; + anextents = di->di_anextents; + } +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_nextents, (int )di->di_anextents); + 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,repair/dinode.c +15
-3@@ -71,7 +71,12 @@ _("would have cleared inode %" PRIu64 " attributes\n"), ino_num);if (xfs_dfork_attr_extents (dino) !=0 ) {if (no_modify)return (1 ); - dino->di_anextents =cpu_to_be16 (0 ); + +if (xfs_dinode_has_nrext64 (dino)) + dino->di_big_aextcnt =0 ; +else + dino->di_anextents =0 ; + }if (dino->di_aformat !=XFS_DINODE_FMT_EXTENTS ) {@@ -1818,7 +1823,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_nextents =cpu_to_be32 (nextents); +if (xfs_dinode_has_nrext64 (dino)) + dino->di_big_dextcnt =cpu_to_be64 (nextents); +else + dino->di_nextents =cpu_to_be32 (nextents); *dirty =1 ; }else { do_warn(@@ -1841,7 +1849,11 @@ _("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_anextents =cpu_to_be16 (anextents); +if (xfs_dinode_has_nrext64 (dino)) + dino->di_big_aextcnt =cpu_to_be32 (anextents); +else + dino->di_anextents =cpu_to_be16 (anextents); + *dirty =1 ; }else { do_warn(Signature · 1 line
2.30.2
Re: [PATCH V4 13/20] xfsprogs: Introduce per-inode 64-bit extent counters
Quoted 83 lines · Darrick J. Wong
Quoted 82 lines · Chandan Babu R
This commit introduces new fields in the on-disk inode format to support 64-bit data fork extent counters and 32-bit attribute fork extent counters. The new fields will be used only when an inode has
XFS_DIFLAG2_NREXT64flag set. Otherwise we continue to use the regular 32-bit data fork extent counters and 16-bit attribute fork extent counters.Signed-off-by Chandan Babu R <[email protected]>Suggested-by Dave Chinner <[email protected]>--- db/field.c | 4 - db/field.h | 2 - db/inode.c | 170 ++++++++++++++++++++++++++++++++++++++- libxfs/xfs_format.h | 22 ++++- libxfs/xfs_inode_buf.c | 27 ++++++- libxfs/xfs_inode_fork.h | 10 ++- libxfs/xfs_log_format.h | 22 ++++- logprint/log_misc.c | 20 ++++- logprint/log_print_all.c | 18 ++++- repair/dinode.c | 18 ++++- 10 files changed, 279 insertions(+), 34 deletions(-)db/field.c +0
-4@@ -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,db/field.h +0
-2@@ -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,db/inode.c +8
-0@@ -27,6 +27,14 @@ static int inode_core_nlinkv2_count(void *obj, int startoff);static int inode_core_onlink_count (void *obj,int startoff);static int inode_core_projid_count (void *obj,int startoff);static int inode_core_nlinkv1_count (void *obj,int startoff); +static int inode_core_big_dextcnt_count (void *obj,int startoff); +static int inode_core_v3_pad_count (void *obj,int startoff); +static int inode_core_v2_pad_count (void *obj,int startoff); +static int inode_core_flushiter_count (void *obj,int startoff); +static int inode_core_big_aextcnt_count (void *obj,int startoff); +static int inode_core_nrext64_pad_count (void *obj,int startoff); +static int inode_core_nextents_count (void *obj,int startoff); +static int inode_core_anextents_count (void *obj,int startoff);static int inode_f (int argc,char **argv);static int inode_u_offset (void *obj,int startoff,int idx);static int inode_u_bmbt_count (void *obj,int startoff);
Quoted 8 lines
db/inode.c const field_t inode_core_flds[] = { · line 101
Quoted 6 lines
db/inode.c +1
-1@@ -90,18 +98,30 @@ const field_t inode_core_flds[] = { inode_core_projid_count, FLD_COUNT, TYP_NONE }, {"projid_hi" ,FLDT_UINT16D ,OI (COFF (projid_hi)), inode_core_projid_count, FLD_COUNT, TYP_NONE }, - { "pad", FLDT_UINT8X, OI(OFF(pad)), CI(6), FLD_ARRAY|FLD_SKIPALL, TYP_NONE }, + { "big_dextcnt", FLDT_UINT64D, OI(COFF(big_dextcnt)),Any reason we don't leave the display names as nextents and naextents?
Using existing names to display extent counts would require an xfs_db user to additionally check the status of XFS_DIFLAG2_NREXT64 flag in order to determine the exact source of the extent count (large extent counter vs small extent counter).
This was the reason to print the large extent counters with different field names.
Come to think of it, Most of the times an xfs_db user would generally be interested in the extent counter value rather than the exact field from which the count has been obtained from. Hence in the interest of optimizing for the general case, I will change the code to continue to use nextents/naextents names.
Quoted 2 lines
I think fstests has a fair amount of hardcoded
xfs_dboutput, right?
Actually xfs/298 is the only test which refers to nextents field directly,
_scratch_xfs_db -c "inode $inode" -c "p core.nextents"
Other tests use the helper function _scratch_get_iext_count() to obtain the value of extent counters.
I had extended _scratch_get_iext_count() to obtain the correct data/attr fork extent counters based on whether the per-inode flag XFS_DIFLAG2_NREXT64 is set or not. This won't be required when xfs_db uses the same names to print the extent counters.
Quoted 478 lines
Quoted 36 lines
db/inode.c +18
-3+ inode_core_big_dextcnt_count, FLD_COUNT, TYP_NONE }, + {"v3_pad" ,FLDT_UINT8X ,OI (OFF (v3_pad)), + inode_core_v3_pad_count, FLD_ARRAY|FLD_COUNT|FLD_SKIPALL, TYP_NONE }, + { "v2_pad", FLDT_UINT8X, OI(OFF(v2_pad)), + inode_core_v2_pad_count, FLD_ARRAY|FLD_COUNT|FLD_SKIPALL, TYP_NONE }, { "uid", FLDT_UINT32D, OI(COFF(uid)), C1, 0, TYP_NONE }, { "gid", FLDT_UINT32D, OI(COFF(gid)), C1, 0, TYP_NONE }, - { "flushiter", FLDT_UINT16D, OI(COFF(flushiter)), C1, 0, TYP_NONE }, + { "flushiter", FLDT_UINT16D, OI(COFF(flushiter)), + inode_core_flushiter_count, FLD_COUNT, TYP_NONE }, { "atime", FLDT_TIMESTAMP, OI(COFF(atime)), C1, 0, TYP_NONE }, { "mtime", FLDT_TIMESTAMP, OI(COFF(mtime)), C1, 0, TYP_NONE }, { "ctime", FLDT_TIMESTAMP, OI(COFF(ctime)), C1, 0, TYP_NONE }, { "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 }, - { "nextents", FLDT_EXTNUM, OI(COFF(nextents)), C1, 0, TYP_NONE }, - { "naextents", FLDT_AEXTNUM, OI(COFF(anextents)), C1, 0, TYP_NONE }, + { "big_aextcnt", FLDT_UINT32D, OI(COFF(big_aextcnt)), + inode_core_big_aextcnt_count, FLD_COUNT, TYP_NONE }, + { "nrext64_pad", FLDT_UINT16D, OI(COFF(nrext64_pad)), + inode_core_nrext64_pad_count, FLD_COUNT, TYP_NONE }, + { "nextents", FLDT_UINT32D, OI(COFF(nextents)), + inode_core_nextents_count, FLD_COUNT, TYP_NONE }, + { "naextents", FLDT_UINT16D, OI(COFF(anextents)), + inode_core_anextents_count, FLD_COUNT, 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 },@@ -403,6 +423,148 @@ inode_core_projid_count(return dic->di_version >=2 ; } +static int +inode_core_big_dextcnt_count( + void *obj,db/inode.c inode_core_projid_count( · line 438
Quoted 10 lines
db/inode.c +10
-0+ int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 && + (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 ))(
dic->di_flags2&cpu_to_be64(XFS_DIFLAG2_NREXT64)) ?(I forget, does userspace's version of those macros elide constants?)
--D
Quoted 423 lines
db/inode.c +129
-0+return 1 ; + else + return 0; +} + +static int +inode_core_v3_pad_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if ((dic->di_version ==3 ) + && !(be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 8 ; +else +return 0 ; +} + +static int +inode_core_v2_pad_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 ) +return 0 ; +else +return 6 ; +} + +static int +inode_core_flushiter_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 ) +return 0 ; +else +return 1 ; +} + +static int +inode_core_big_aextcnt_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 && + (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 1 ; +else +return 0 ; +} + +static int +inode_core_nrext64_pad_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if (dic->di_version ==3 && + (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 1 ; +else +return 0 ; +} + +static int +inode_core_nextents_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if ((dic->di_version ==3 ) + && (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 0 ; +else +return 1 ; +} + +static int +inode_core_anextents_count ( +void *obj, +int startoff) +{ +struct xfs_dinode *dic; + +ASSERT (startoff ==0 ); +ASSERT (obj == iocur_top->data); + dic = obj; + +if ((dic->di_version ==3 ) + && (be64_to_cpu (dic->di_flags2) &XFS_DIFLAG2_NREXT64 )) +return 0 ; +else +return 1 ; +} + static int inode_f( int argc,libxfs/xfs_format.h +18
-4@@ -980,16 +980,30 @@ typedef struct xfs_dinode {__be32 di_nlink;/* number of links to file */ __be16 di_projid_lo;/* lower part of owner's project id */ __be16 di_projid_hi;/* higher part owner's project id */ -__u8 di_pad[6 ];/* unused, zeroed space */ -__be16 di_flushiter;/* incremented on flush */ +union { +__be64 di_big_dextcnt;/* NREXT64 data extents */ +__u8 di_v3_pad[8 ];/* !NREXT64 V3 inode zeroed space */ +struct { +__u8 di_v2_pad[6 ];/* V2 inode zeroed space */ +__be16 di_flushiter;/* V2 inode incremented on flush */ + }; + };xfs_timestamp_t di_atime;/* time last accessed */ xfs_timestamp_t di_mtime;/* time last modified */ xfs_timestamp_t di_ctime;/* time created/inode modified */ __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 */ -__be32 di_nextents;/* number of extents in data fork */ -__be16 di_anextents;/* number of extents in attribute fork*/ +union { +struct { +__be32 di_big_aextcnt;/* NREXT64 attr extents */ +__be16 di_nrext64_pad;/* NREXT64 unused, zero */ + } __packed; +struct { +__be32 di_nextents;/* !NREXT64 data extents */ +__be16 di_anextents;/* !NREXT64 attr extents */ + } __packed; + };__u8 di_forkoff;/* attr fork offs, <<3 for 64b align */ __s8 di_aformat;/* format of attr fork's data */ __be32 di_dmevmask;/* DMIG event mask */ libxfs/xfs_inode_buf.c +23
-4@@ -276,6 +276,25 @@ 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_big_dextcnt =cpu_to_be64 (xfs_ifork_nextents (&ip->i_df)); + to->di_big_aextcnt =cpu_to_be32 (xfs_ifork_nextents (ip->i_afp)); +/* +* We might be upgrading the inode to use larger extent counters +* than was previously used. Hence zero the unused field. +*/ + to->di_nrext64_pad =cpu_to_be16 (0 ); + }else { + to->di_nextents =cpu_to_be32 (xfs_ifork_nextents (&ip->i_df)); + to->di_anextents =cpu_to_be16 (xfs_ifork_nextents (ip->i_afp)); + } +} + void xfs_inode_to_disk( struct xfs_inode *ip,@@ -293,7 +312,6 @@ xfs_inode_to_disk( to->di_projid_lo =cpu_to_be16 (ip->i_projid &0xffff ); to->di_projid_hi =cpu_to_be16 (ip->i_projid >>16 ); -memset (to->di_pad,0 ,sizeof (to->di_pad)); to->di_atime =xfs_inode_to_disk_ts (ip, inode->i_atime); to->di_mtime =xfs_inode_to_disk_ts (ip, inode->i_mtime); to->di_ctime =xfs_inode_to_disk_ts (ip, inode->i_ctime);@@ -304,8 +322,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_nextents =cpu_to_be32 (xfs_ifork_nextents (&ip->i_df)); - to->di_anextents =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);@@ -320,11 +336,14 @@ xfs_inode_to_disk( to->di_lsn =cpu_to_be64 (lsn);memset (to->di_pad2,0 ,sizeof (to->di_pad2));uuid_copy (&to->di_uuid, &ip->i_mount->m_sb.sb_meta_uuid); - to->di_flushiter =0 ; +memset (to->di_v3_pad,0 ,sizeof (to->di_v3_pad)); }else { to->di_version =2 ; to->di_flushiter =cpu_to_be16 (ip->i_flushiter); +memset (to->di_v2_pad,0 ,sizeof (to->di_v2_pad)); } + +xfs_inode_to_disk_iext_counters (ip, to); } static xfs_failaddr_tlibxfs/xfs_inode_fork.h +8
-2@@ -156,14 +156,20 @@ static inline xfs_extnum_txfs_dfork_data_extents ( struct xfs_dinode *dip) { -return be32_to_cpu (dip->di_nextents); +if (xfs_dinode_has_nrext64 (dip)) +return be64_to_cpu (dip->di_big_dextcnt); +else +return be32_to_cpu (dip->di_nextents); }static inline xfs_extnum_t xfs_dfork_attr_extents (struct xfs_dinode *dip) { -return be16_to_cpu (dip->di_anextents); +if (xfs_dinode_has_nrext64 (dip)) +return be32_to_cpu (dip->di_big_aextcnt); +else +return be16_to_cpu (dip->di_anextents); } static inline xfs_extnum_tlibxfs/xfs_log_format.h +18
-4@@ -388,16 +388,30 @@ struct xfs_log_dinode {uint32_t di_nlink;/* number of links to file */ uint16_t di_projid_lo;/* lower part of owner's project id */ uint16_t di_projid_hi;/* higher part of owner's project id */ -uint8_t di_pad[6 ];/* unused, zeroed space */ -uint16_t di_flushiter;/* incremented on flush */ +union { +uint64_t di_big_dextcnt;/* NREXT64 data extents */ +uint8_t di_v3_pad[8 ];/* !NREXT64 V3 inode zeroed space */ +struct { +uint8_t di_v2_pad[6 ];/* V2 inode zeroed space */ +uint16_t di_flushiter;/* V2 inode incremented on flush */ + }; + };xfs_log_timestamp_t di_atime;/* time last accessed */ xfs_log_timestamp_t di_mtime;/* time last modified */ xfs_log_timestamp_t di_ctime;/* time created/inode modified */ xfs_fsize_t di_size;/* number of bytes in file */ xfs_rfsblock_t di_nblocks;/* # of direct & btree blocks used */ xfs_extlen_t di_extsize;/* basic/minimum extent size for file */ -uint32_t di_nextents;/* number of extents in data fork */ -uint16_t di_anextents;/* number of extents in attribute fork*/ +union { +struct { +uint32_t di_big_aextcnt;/* NREXT64 attr extents */ +uint16_t di_nrext64_pad;/* NREXT64 unused, zero */ + } __packed; +struct { +uint32_t di_nextents;/* !NREXT64 data extents */ +uint16_t di_anextents;/* !NREXT64 attr extents */ + } __packed; + };uint8_t di_forkoff;/* attr fork offs, <<3 for 64b align */ int8_t di_aformat;/* format of attr fork's data */ uint32_t di_dmevmask;/* DMIG event mask */ logprint/log_misc.c +16
-4@@ -440,6 +440,8 @@ static voidxlog_print_trans_inode_core ( 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 +452,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_big_dextcnt; +else + nextents = ip->di_nextents; +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_nextents); -printf (_ ("naextents 0x%x forkoff %d dmevmask 0x%x dmstate 0x%hx\n" ), - ip->di_anextents, (int )ip->di_forkoff, ip->di_dmevmask, + ip->di_extsize, nextents); + +if (ip->di_flags2 &XFS_DIFLAG2_NREXT64 ) + nextents = ip->di_big_aextcnt; +else + nextents = ip->di_anextents; +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);logprint/log_print_all.c +15
-3@@ -240,7 +240,10 @@ STATIC voidxlog_recover_print_inode_core ( 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 +257,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_big_dextcnt; + anextents = di->di_big_aextcnt; + }else { + nextents = di->di_nextents; + anextents = di->di_anextents; + } +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_nextents, (int )di->di_anextents); + 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,repair/dinode.c +15
-3@@ -71,7 +71,12 @@ _("would have cleared inode %" PRIu64 " attributes\n"), ino_num);if (xfs_dfork_attr_extents (dino) !=0 ) {if (no_modify)return (1 ); - dino->di_anextents =cpu_to_be16 (0 ); + +if (xfs_dinode_has_nrext64 (dino)) + dino->di_big_aextcnt =0 ; +else + dino->di_anextents =0 ; + }if (dino->di_aformat !=XFS_DINODE_FMT_EXTENTS ) {@@ -1818,7 +1823,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_nextents =cpu_to_be32 (nextents); +if (xfs_dinode_has_nrext64 (dino)) + dino->di_big_dextcnt =cpu_to_be64 (nextents); +else + dino->di_nextents =cpu_to_be32 (nextents); *dirty =1 ; }else { do_warn(@@ -1841,7 +1849,11 @@ _("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_anextents =cpu_to_be16 (anextents); +if (xfs_dinode_has_nrext64 (dino)) + dino->di_big_aextcnt =cpu_to_be32 (anextents); +else + dino->di_anextents =cpu_to_be16 (anextents); + *dirty =1 ; }else { do_warn(Signature · 1 line
2.30.2
Signature · 1 line
chandan
PATCH v4 14/20 xfsprogs: Conditionally upgrade existing inodes to use 64-bit extent counters
In reply to Chandan Babu RThis commit upgrades inodes to use 64-bit extent counters when they are read from disk. Inodes are upgraded only when the filesystem instance has XFS_SB_FEAT_INCOMPAT_NREXT64 incompat flag set.
--- libxfs/xfs_inode_buf.c | 6 ++++++ 1 file changed, 6 insertions(+)
libxfs/xfs_inode_buf.c +6 -0
@@ -250,6 +250,12 @@ xfs_inode_from_disk( }if (xfs_is_reflink_inode (ip))xfs_ifork_init_cow (ip); + +if ((from->di_version ==3 ) && +xfs_sb_version_hasnrext64 (&ip->i_mount->m_sb) && + !xfs_dinode_has_nrext64 (from)) + ip->i_diflags2 |=XFS_DIFLAG2_NREXT64 ; +return 0 ; out_destroy_data_fork:
Signature · 1 line
2.30.2
PATCH v4 15/20 xfsprogs: Enable bulkstat ioctl to support 64-bit extent counters
In reply to Chandan Babu RThis commit adds support to libfrog to enable reporting 64-bit extent counters to its users. In order to do so, bulkstat ioctl is now invoked with the newly introduced XFS_BULK_IREQ_NREXT64 flag if the underlying filesystem's geometry supports 64-bit extent counters.
--- fsr/xfs_fsr.c | 4 ++-- io/bulkstat.c | 1 + libfrog/bulkstat.c | 29 +++++++++++++++++++++++++++-- libxfs/xfs_fs.h | 12 ++++++++---- 4 files changed, 38 insertions(+), 8 deletions(-)
fsr/xfs_fsr.c +2 -2
@@ -590,7 +590,7 @@ cmp(const void *s1, const void *s2) (bs1->bs_version ==XFS_BULKSTAT_VERSION_V5 && bs2->bs_version == XFS_BULKSTAT_VERSION_V5)); -return (bs2->bs_extents - bs1->bs_extents); +return (bs2->bs_extents64 - bs1->bs_extents64); }/*
@@ -655,7 +655,7 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange)for (p = buf, endp = (buf + buflenout); p < endp ; p++) {/* Do some obvious checks now */ if (((p->bs_mode &S_IFMT ) !=S_IFREG ) || - (p->bs_extents <2 )) + (p->bs_extents64 <2 ))continue ; ret = -xfrog_bulkstat_v5_to_v1 (&fsxfd, &bs1, p);
io/bulkstat.c +1 -0
@@ -57,6 +57,7 @@ dump_bulkstat(printf ("\tbs_sick = 0x%" PRIx16"\n" , bstat->bs_sick);printf ("\tbs_checked = 0x%" PRIx16"\n" , bstat->bs_checked);printf ("\tbs_mode = 0%" PRIo16"\n" , bstat->bs_mode); +printf ("\tbs_extents64 = %" PRIu64"\n" , bstat->bs_extents64); }; static void
libfrog/bulkstat.c +27 -2
@@ -56,6 +56,9 @@ xfrog_bulkstat_single5(if (flags & ~(XFS_BULK_IREQ_SPECIAL ))return -EINVAL ; +if (xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 ) + flags |=XFS_BULK_IREQ_NREXT64 ; + ret =xfrog_bulkstat_alloc_req (1 , ino, &req);if (ret)return ret;
@@ -73,6 +76,12 @@ xfrog_bulkstat_single5( }memcpy (bulkstat, req->bulkstat,sizeof (struct xfs_bulkstat )); + +if (!(xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 )) { + bulkstat->bs_extents64 = bulkstat->bs_extents; + bulkstat->bs_extents =0 ; + } + free:free (req);return ret;
@@ -129,6 +138,7 @@ xfrog_bulkstat_single(switch (error) {case -EOPNOTSUPP :case -ENOTTY : +assert (!(xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 )); xfd->flags |=XFROG_FLAG_BULKSTAT_FORCE_V1 ;break ; }
@@ -259,10 +269,23 @@ xfrog_bulkstat5( struct xfs_bulkstat_req *req) {int ret; +int i; + +if (xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 ) + req->hdr.flags |=XFS_BULK_IREQ_NREXT64 ; ret =ioctl (xfd->fd,XFS_IOC_BULKSTAT , req);if (ret)return -errno; + +if (!(xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 )) { +for (i =0 ; i < req->hdr.ocount; i++) { + req->bulkstat[i].bs_extents64 = + req->bulkstat[i].bs_extents; + req->bulkstat[i].bs_extents =0 ; + } + } +return 0 ; }
@@ -316,6 +339,7 @@ xfrog_bulkstat(switch (error) {case -EOPNOTSUPP :case -ENOTTY : +assert (!(xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 )); xfd->flags |=XFROG_FLAG_BULKSTAT_FORCE_V1 ;break ; }
@@ -342,6 +366,7 @@ xfrog_bulkstat_v5_to_v1( const struct xfs_bulkstat *bs5) { if (bs5->bs_aextents > UINT16_MAX || + bs5->bs_extents64 > INT32_MAX || cvt_off_fsb_to_b(xfd, bs5->bs_extsize_blks) > UINT32_MAX || cvt_off_fsb_to_b(xfd, bs5->bs_cowextsize_blks) > UINT32_MAX || time_too_big(bs5->bs_atime) ||
@@ -366,7 +391,7 @@ xfrog_bulkstat_v5_to_v1( bs1->bs_blocks = bs5->bs_blocks; bs1->bs_xflags = bs5->bs_xflags; bs1->bs_extsize =cvt_off_fsb_to_b (xfd, bs5->bs_extsize_blks); - bs1->bs_extents = bs5->bs_extents; + bs1->bs_extents = bs5->bs_extents64; bs1->bs_gen = bs5->bs_gen; bs1->bs_projid_lo = bs5->bs_projectid &0xFFFF ; bs1->bs_forkoff = bs5->bs_forkoff;
@@ -407,7 +432,6 @@ xfrog_bulkstat_v1_to_v5( bs5->bs_blocks = bs1->bs_blocks; bs5->bs_xflags = bs1->bs_xflags; bs5->bs_extsize_blks =cvt_b_to_off_fsbt (xfd, bs1->bs_extsize); - bs5->bs_extents = bs1->bs_extents; bs5->bs_gen = bs1->bs_gen; bs5->bs_projectid =bstat_get_projid (bs1); bs5->bs_forkoff = bs1->bs_forkoff;
@@ -415,6 +439,7 @@ xfrog_bulkstat_v1_to_v5( bs5->bs_checked = bs1->bs_checked; bs5->bs_cowextsize_blks =cvt_b_to_off_fsbt (xfd, bs1->bs_cowextsize); bs5->bs_aextents = bs1->bs_aextents; + bs5->bs_extents64 = bs1->bs_extents; }/* Allocate a bulkstat request. Returns zero or a negative error code. */
libxfs/xfs_fs.h +8 -4
@@ -391,7 +391,7 @@ struct xfs_bulkstat {uint32_t bs_extsize_blks;/* extent size hint, blocks */ uint32_t bs_nlink;/* number of links */ -uint32_t bs_extents;/* number of extents */ +uint32_t bs_extents;/* 32-bit data fork extent counter */ uint32_t bs_aextents;/* attribute number of extents */ uint16_t bs_version;/* structure version */ uint16_t bs_forkoff;/* inode fork offset in bytes */
@@ -400,8 +400,9 @@ struct xfs_bulkstat {uint16_t bs_checked;/* checked inode metadata */ uint16_t bs_mode;/* type and mode */ uint16_t bs_pad2;/* zeroed */ +uint64_t bs_extents64;/* 64-bit data fork extent counter */ -uint64_t bs_pad[7 ];/* zeroed */ +uint64_t bs_pad[6 ];/* zeroed */ };#define XFS_BULKSTAT_VERSION_V1 (1)
@@ -482,8 +483,11 @@ struct xfs_bulk_ireq {*/ #define XFS_BULK_IREQ_SPECIAL (1 << 1) -#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \ - XFS_BULK_IREQ_SPECIAL) +#define XFS_BULK_IREQ_NREXT64 (1 << 3) + +#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \ + XFS_BULK_IREQ_SPECIAL | \ + XFS_BULK_IREQ_NREXT64)/* Operate on the root directory inode. */ #define XFS_BULK_IREQ_SPECIAL_ROOT (1)
Signature · 1 line
2.30.2
Re: [PATCH V4 15/20] xfsprogs: Enable bulkstat ioctl to support 64-bit extent counters
Quoted 6 lines · Chandan Babu R
This commit adds support to libfrog to enable reporting 64-bit extent counters to its users. In order to do so, bulkstat ioctl is now invoked with the newly introduced
XFS_BULK_IREQ_NREXT64flag if the underlying filesystem's geometry supports 64-bit extent counters.Signed-off-by Chandan Babu R <[email protected]>
For all the non libxfs/ changes,
--D
Quoted 182 lines
--- fsr/xfs_fsr.c | 4 ++-- io/bulkstat.c | 1 + libfrog/bulkstat.c | 29 +++++++++++++++++++++++++++-- libxfs/xfs_fs.h | 12 ++++++++---- 4 files changed, 38 insertions(+), 8 deletions(-)fsr/xfs_fsr.c +2
-2@@ -590,7 +590,7 @@ cmp(const void *s1, const void *s2) (bs1->bs_version ==XFS_BULKSTAT_VERSION_V5 && bs2->bs_version == XFS_BULKSTAT_VERSION_V5)); -return (bs2->bs_extents - bs1->bs_extents); +return (bs2->bs_extents64 - bs1->bs_extents64); }/* @@ -655,7 +655,7 @@ fsrfs(char *mntdir, xfs_ino_t startino, int targetrange)for (p = buf, endp = (buf + buflenout); p < endp ; p++) {/* Do some obvious checks now */ if (((p->bs_mode &S_IFMT ) !=S_IFREG ) || - (p->bs_extents <2 )) + (p->bs_extents64 <2 ))continue ; ret = -xfrog_bulkstat_v5_to_v1 (&fsxfd, &bs1, p);io/bulkstat.c +1
-0@@ -57,6 +57,7 @@ dump_bulkstat(printf ("\tbs_sick = 0x%" PRIx16"\n" , bstat->bs_sick);printf ("\tbs_checked = 0x%" PRIx16"\n" , bstat->bs_checked);printf ("\tbs_mode = 0%" PRIo16"\n" , bstat->bs_mode); +printf ("\tbs_extents64 = %" PRIu64"\n" , bstat->bs_extents64); }; static voidlibfrog/bulkstat.c +27
-2@@ -56,6 +56,9 @@ xfrog_bulkstat_single5(if (flags & ~(XFS_BULK_IREQ_SPECIAL ))return -EINVAL ; +if (xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 ) + flags |=XFS_BULK_IREQ_NREXT64 ; + ret =xfrog_bulkstat_alloc_req (1 , ino, &req);if (ret)return ret;@@ -73,6 +76,12 @@ xfrog_bulkstat_single5( }memcpy (bulkstat, req->bulkstat,sizeof (struct xfs_bulkstat )); + +if (!(xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 )) { + bulkstat->bs_extents64 = bulkstat->bs_extents; + bulkstat->bs_extents =0 ; + } + free:free (req);return ret;@@ -129,6 +138,7 @@ xfrog_bulkstat_single(switch (error) {case -EOPNOTSUPP :case -ENOTTY : +assert (!(xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 )); xfd->flags |=XFROG_FLAG_BULKSTAT_FORCE_V1 ;break ; }@@ -259,10 +269,23 @@ xfrog_bulkstat5( struct xfs_bulkstat_req *req) {int ret; +int i; + +if (xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 ) + req->hdr.flags |=XFS_BULK_IREQ_NREXT64 ; ret =ioctl (xfd->fd,XFS_IOC_BULKSTAT , req);if (ret)return -errno; + +if (!(xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 )) { +for (i =0 ; i < req->hdr.ocount; i++) { + req->bulkstat[i].bs_extents64 = + req->bulkstat[i].bs_extents; + req->bulkstat[i].bs_extents =0 ; + } + } +return 0 ; }@@ -316,6 +339,7 @@ xfrog_bulkstat(switch (error) {case -EOPNOTSUPP :case -ENOTTY : +assert (!(xfd->fsgeom.flags &XFS_FSOP_GEOM_FLAGS_NREXT64 )); xfd->flags |=XFROG_FLAG_BULKSTAT_FORCE_V1 ;break ; }@@ -342,6 +366,7 @@ xfrog_bulkstat_v5_to_v1( const struct xfs_bulkstat *bs5) { if (bs5->bs_aextents > UINT16_MAX || + bs5->bs_extents64 > INT32_MAX || cvt_off_fsb_to_b(xfd, bs5->bs_extsize_blks) > UINT32_MAX || cvt_off_fsb_to_b(xfd, bs5->bs_cowextsize_blks) > UINT32_MAX || time_too_big(bs5->bs_atime) ||@@ -366,7 +391,7 @@ xfrog_bulkstat_v5_to_v1( bs1->bs_blocks = bs5->bs_blocks; bs1->bs_xflags = bs5->bs_xflags; bs1->bs_extsize =cvt_off_fsb_to_b (xfd, bs5->bs_extsize_blks); - bs1->bs_extents = bs5->bs_extents; + bs1->bs_extents = bs5->bs_extents64; bs1->bs_gen = bs5->bs_gen; bs1->bs_projid_lo = bs5->bs_projectid &0xFFFF ; bs1->bs_forkoff = bs5->bs_forkoff;@@ -407,7 +432,6 @@ xfrog_bulkstat_v1_to_v5( bs5->bs_blocks = bs1->bs_blocks; bs5->bs_xflags = bs1->bs_xflags; bs5->bs_extsize_blks =cvt_b_to_off_fsbt (xfd, bs1->bs_extsize); - bs5->bs_extents = bs1->bs_extents; bs5->bs_gen = bs1->bs_gen; bs5->bs_projectid =bstat_get_projid (bs1); bs5->bs_forkoff = bs1->bs_forkoff;@@ -415,6 +439,7 @@ xfrog_bulkstat_v1_to_v5( bs5->bs_checked = bs1->bs_checked; bs5->bs_cowextsize_blks =cvt_b_to_off_fsbt (xfd, bs1->bs_cowextsize); bs5->bs_aextents = bs1->bs_aextents; + bs5->bs_extents64 = bs1->bs_extents; }/* Allocate a bulkstat request. Returns zero or a negative error code. */ libxfs/xfs_fs.h +8
-4@@ -391,7 +391,7 @@ struct xfs_bulkstat {uint32_t bs_extsize_blks;/* extent size hint, blocks */ uint32_t bs_nlink;/* number of links */ -uint32_t bs_extents;/* number of extents */ +uint32_t bs_extents;/* 32-bit data fork extent counter */ uint32_t bs_aextents;/* attribute number of extents */ uint16_t bs_version;/* structure version */ uint16_t bs_forkoff;/* inode fork offset in bytes */ @@ -400,8 +400,9 @@ struct xfs_bulkstat {uint16_t bs_checked;/* checked inode metadata */ uint16_t bs_mode;/* type and mode */ uint16_t bs_pad2;/* zeroed */ +uint64_t bs_extents64;/* 64-bit data fork extent counter */ -uint64_t bs_pad[7 ];/* zeroed */ +uint64_t bs_pad[6 ];/* zeroed */ };#define XFS_BULKSTAT_VERSION_V1 (1)@@ -482,8 +483,11 @@ struct xfs_bulk_ireq {*/ #define XFS_BULK_IREQ_SPECIAL (1 << 1) -#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \ - XFS_BULK_IREQ_SPECIAL) +#define XFS_BULK_IREQ_NREXT64 (1 << 3) + +#define XFS_BULK_IREQ_FLAGS_ALL (XFS_BULK_IREQ_AGNO | \ + XFS_BULK_IREQ_SPECIAL | \ + XFS_BULK_IREQ_NREXT64)/* Operate on the root directory inode. */ #define XFS_BULK_IREQ_SPECIAL_ROOT (1)Signature · 1 line
2.30.2
PATCH v4 16/20 xfsprogs: Add XFS_SB_FEAT_INCOMPAT_NREXT64 to the list of supported flags
In reply to Chandan Babu RThis commit enables XFS module to work with fs instances having 64-bit per-inode extent counters by adding XFS_SB_FEAT_INCOMPAT_NREXT64 flag to the list of supported incompat feature flags.
--- libxfs/xfs_format.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
libxfs/xfs_format.h +2 -1
@@ -475,7 +475,8 @@ xfs_sb_has_ro_compat_feature( XFS_SB_FEAT_INCOMPAT_SPINODES| \ XFS_SB_FEAT_INCOMPAT_META_UUID| \ XFS_SB_FEAT_INCOMPAT_BIGTIME| \ - XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR) + XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR| \ + XFS_SB_FEAT_INCOMPAT_NREXT64)#define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL static inline bool
Signature · 1 line
2.30.2
PATCH v4 17/20 xfsprogs: xfs_info: Report NREXT64 feature status
In reply to Chandan Babu RThis commit adds support to libfrog to obtain information about the availability of NREXT64 feature in the underlying filesystem.
--- libfrog/fsgeom.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
libfrog/fsgeom.c +4 -2
@@ -30,6 +30,7 @@ xfs_report_geom(int reflink_enabled;int bigtime_enabled;int inobtcount; +int nrext64; isint = geo->logstart >0 ; lazycount = geo->flags &XFS_FSOP_GEOM_FLAGS_LAZYSB ?1 :0 ;
@@ -47,12 +48,13 @@ xfs_report_geom( reflink_enabled = geo->flags &XFS_FSOP_GEOM_FLAGS_REFLINK ?1 :0 ; bigtime_enabled = geo->flags &XFS_FSOP_GEOM_FLAGS_BIGTIME ?1 :0 ; inobtcount = geo->flags &XFS_FSOP_GEOM_FLAGS_INOBTCNT ?1 :0 ; + nrext64 = geo->flags &XFS_FSOP_GEOM_FLAGS_NREXT64 ?1 :0 ; printf(_( "meta-data=%-22s isize=%-6d agcount=%u, agsize=%u blks\n" " =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n" " =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u\n" -" =%-22s reflink=%-4u bigtime=%u inobtcount=%u\n" +" =%-22s reflink=%-4u bigtime=%u inobtcount=%u nrext64=%u\n" "data =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n" " =%-22s sunit=%-6u swidth=%u blks\n" "naming =version %-14u bsize=%-6u ascii-ci=%d, ftype=%d\n"
@@ -62,7 +64,7 @@ xfs_report_geom( mntpoint, geo->inodesize, geo->agcount, geo->agblocks,"" , geo->sectsize, attrversion, projid32bit,"" , crcs_enabled, finobt_enabled, spinodes, rmapbt_enabled, -"" , reflink_enabled, bigtime_enabled, inobtcount, +"" , reflink_enabled, bigtime_enabled, inobtcount, nrext64,"" , geo->blocksize, (unsigned long long )geo->datablocks, geo->imaxpct, "", geo->sunit, geo->swidth,
Signature · 1 line
2.30.2
Re: [PATCH V4 17/20] xfsprogs: xfs_info: Report NREXT64 feature status
Quoted 4 lines · Chandan Babu R
This commit adds support to libfrog to obtain information about the availability of NREXT64 feature in the underlying filesystem.
Signed-off-by Chandan Babu R <[email protected]>
LGTM
--D
Quoted 43 lines
--- libfrog/fsgeom.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)libfrog/fsgeom.c +4
-2@@ -30,6 +30,7 @@ xfs_report_geom(int reflink_enabled;int bigtime_enabled;int inobtcount; +int nrext64; isint = geo->logstart >0 ; lazycount = geo->flags &XFS_FSOP_GEOM_FLAGS_LAZYSB ?1 :0 ;@@ -47,12 +48,13 @@ xfs_report_geom( reflink_enabled = geo->flags &XFS_FSOP_GEOM_FLAGS_REFLINK ?1 :0 ; bigtime_enabled = geo->flags &XFS_FSOP_GEOM_FLAGS_BIGTIME ?1 :0 ; inobtcount = geo->flags &XFS_FSOP_GEOM_FLAGS_INOBTCNT ?1 :0 ; + nrext64 = geo->flags &XFS_FSOP_GEOM_FLAGS_NREXT64 ?1 :0 ; printf(_( "meta-data=%-22s isize=%-6d agcount=%u, agsize=%u blks\n" " =%-22s sectsz=%-5u attr=%u, projid32bit=%u\n" " =%-22s crc=%-8u finobt=%u, sparse=%u, rmapbt=%u\n" -" =%-22s reflink=%-4u bigtime=%u inobtcount=%u\n" +" =%-22s reflink=%-4u bigtime=%u inobtcount=%u nrext64=%u\n" "data =%-22s bsize=%-6u blocks=%llu, imaxpct=%u\n" " =%-22s sunit=%-6u swidth=%u blks\n" "naming =version %-14u bsize=%-6u ascii-ci=%d, ftype=%d\n"@@ -62,7 +64,7 @@ xfs_report_geom( mntpoint, geo->inodesize, geo->agcount, geo->agblocks,"" , geo->sectsize, attrversion, projid32bit,"" , crcs_enabled, finobt_enabled, spinodes, rmapbt_enabled, -"" , reflink_enabled, bigtime_enabled, inobtcount, +"" , reflink_enabled, bigtime_enabled, inobtcount, nrext64,"" , geo->blocksize, (unsigned long long )geo->datablocks, geo->imaxpct, "", geo->sunit, geo->swidth,Signature · 1 line
2.30.2
PATCH v4 18/20 xfsprogs: Add mkfs option to create filesystem with large extent counters
In reply to Chandan Babu REnabling nrext64 option on mkfs.xfs command line extends the maximum values of inode data and attr fork extent counters to 2^48 - 1 and 2^32 - 1 respectively. This also sets the XFS_SB_FEAT_INCOMPAT_NREXT64 incompat flag on the superblock preventing older kernels from mounting such a filesystem.
--- man/man8/mkfs.xfs.8 | 7 +++++++ mkfs/xfs_mkfs.c | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+)
man/man8/mkfs.xfs.8 +7 -0
@@ -639,6 +639,13 @@ space over time such that no free extents are large enough to accommodate a chunk of 64 inodes. Without this feature enabled, inode allocations can fail with out of space errors under severe fragmented free space conditions. +.TP +.BI nrext64[= value] +Extend maximum values of inode data and attr fork extent counters from 2^31 - +1 and 2^15 - 1 to 2^48 - 1 and 2^32 - 1 respectively. If the value is +omitted, 1 is assumed. This feature is disabled by default. This feature is +only available for filesystems formatted with -m crc=1. +.TP .RE .PP .PD 0
mkfs/xfs_mkfs.c +23 -0
@@ -78,6 +78,7 @@ enum {I_ATTR ,I_PROJID32BIT ,I_SPINODES , +I_NREXT64 , I_MAX_OPTS, };
@@ -432,6 +433,7 @@ static struct opt_params iopts = { [I_ATTR] = "attr", [I_PROJID32BIT] = "projid32bit", [I_SPINODES] = "sparse", + [I_NREXT64 ] ="nrext64" , }, .subopt_params = { { .index =I_ALIGN ,
@@ -480,6 +482,12 @@ static struct opt_params iopts = { .maxval = 1, .defaultval = 1, }, + { .index = I_NREXT64, + .conflicts = { { NULL, LAST_CONFLICT } }, + .minval = 0, + .maxval = 1, + .defaultval = 1, + } }, };
@@ -804,6 +812,7 @@ struct sb_feat_args {bool bigtime;/* XFS_SB_FEAT_INCOMPAT_BIGTIME */ bool nodalign;bool nortalign; +bool nrext64; };struct cli_params {
@@ -1585,6 +1594,9 @@ inode_opts_parser(case I_SPINODES : cli->sb_feat.spinodes =getnum (value, opts, subopt);break ; +case I_NREXT64 : + cli->sb_feat.nrext64 =getnum (value, opts, subopt); +break ;default :return -EINVAL ; }
@@ -2153,6 +2165,14 @@ _("timestamps later than 2038 not supported without CRC support\n"));usage (); } cli->sb_feat.bigtime = false; + +if (cli->sb_feat.nrext64 && +cli_opt_set (&iopts,I_NREXT64 )) { +fprintf (stderr, +_ ("64 bit extent count not supported without CRC support\n" )); +usage (); + } + cli->sb_feat.nrext64 = false; }if (!cli->sb_feat.finobt) {
@@ -3145,6 +3165,8 @@ sb_set_features( sbp->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_SPINODES ; } +if (fp->nrext64) + sbp->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NREXT64 ; }/*
@@ -3854,6 +3876,7 @@ main( .nodalign = false, .nortalign = false, .bigtime = false, + .nrext64 = false, }, };
Signature · 1 line
2.30.2
Re: [PATCH V4 18/20] xfsprogs: Add mkfs option to create filesystem with large extent counters
Quoted 6 lines · Chandan Babu R
Enabling nrext64 option on mkfs.xfs command line extends the maximum values of inode data and attr fork extent counters to 2^48 - 1 and 2^32 - 1 respectively. This also sets the
XFS_SB_FEAT_INCOMPAT_NREXT64incompat flag on the superblock preventing older kernels from mounting such a filesystem.Signed-off-by Chandan Babu R <[email protected]>
Looks reasonable. There's a silly nit that mtk prefers that each sentence in a Linux man page start on a separate line, but I'll let Eric decide if he cares about that for xfsprogs manpages.
--D
Quoted 109 lines
--- man/man8/mkfs.xfs.8 | 7 +++++++ mkfs/xfs_mkfs.c | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+)man/man8/mkfs.xfs.8 +7
-0@@ -639,6 +639,13 @@ space over time such that no free extents are large enough to accommodate a chunk of 64 inodes. Without this feature enabled, inode allocations can fail with out of space errors under severe fragmented free space conditions. +.TP +.BI nrext64[= value] +Extend maximum values of inode data and attr fork extent counters from 2^31 - +1 and 2^15 - 1 to 2^48 - 1 and 2^32 - 1 respectively. If the value is +omitted, 1 is assumed. This feature is disabled by default. This feature is +only available for filesystems formatted with -m crc=1. +.TP .RE .PP .PD 0mkfs/xfs_mkfs.c +23
-0@@ -78,6 +78,7 @@ enum {I_ATTR ,I_PROJID32BIT ,I_SPINODES , +I_NREXT64 , I_MAX_OPTS, };@@ -432,6 +433,7 @@ static struct opt_params iopts = { [I_ATTR] = "attr", [I_PROJID32BIT] = "projid32bit", [I_SPINODES] = "sparse", + [I_NREXT64 ] ="nrext64" , }, .subopt_params = { { .index =I_ALIGN ,@@ -480,6 +482,12 @@ static struct opt_params iopts = { .maxval = 1, .defaultval = 1, }, + { .index = I_NREXT64, + .conflicts = { { NULL, LAST_CONFLICT } }, + .minval = 0, + .maxval = 1, + .defaultval = 1, + } }, };@@ -804,6 +812,7 @@ struct sb_feat_args {bool bigtime;/* XFS_SB_FEAT_INCOMPAT_BIGTIME */ bool nodalign;bool nortalign; +bool nrext64; };struct cli_params {@@ -1585,6 +1594,9 @@ inode_opts_parser(case I_SPINODES : cli->sb_feat.spinodes =getnum (value, opts, subopt);break ; +case I_NREXT64 : + cli->sb_feat.nrext64 =getnum (value, opts, subopt); +break ;default :return -EINVAL ; }@@ -2153,6 +2165,14 @@ _("timestamps later than 2038 not supported without CRC support\n"));usage (); } cli->sb_feat.bigtime = false; + +if (cli->sb_feat.nrext64 && +cli_opt_set (&iopts,I_NREXT64 )) { +fprintf (stderr, +_ ("64 bit extent count not supported without CRC support\n" )); +usage (); + } + cli->sb_feat.nrext64 = false; }if (!cli->sb_feat.finobt) {@@ -3145,6 +3165,8 @@ sb_set_features( sbp->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_SPINODES ; } +if (fp->nrext64) + sbp->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NREXT64 ; }/* @@ -3854,6 +3876,7 @@ main( .nodalign = false, .nortalign = false, .bigtime = false, + .nrext64 = false, }, };Signature · 1 line
2.30.2
PATCH v4 19/20 xfsprogs: Add support for upgrading to NREXT64 feature
In reply to Chandan Babu RThis commit adds support to xfs_repair to allow upgrading an existing filesystem to support per-inode large extent counters.
--- repair/globals.c | 1 + repair/globals.h | 1 + repair/phase2.c | 35 ++++++++++++++++++++++++++++++++++- repair/xfs_repair.c | 11 +++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-)
repair/globals.c +1 -0
@@ -53,6 +53,7 @@ bool add_bigtime; /* add support for timestamps up to 2486 */bool add_finobt;/* add free inode btrees */ bool add_reflink;/* add reference count btrees */ bool add_rmapbt;/* add reverse mapping btrees */ +bool add_nrext64;/* misc status variables */
repair/globals.h +1 -0
@@ -94,6 +94,7 @@ extern bool add_bigtime; /* add support for timestamps up to 2486 */extern bool add_finobt;/* add free inode btrees */ extern bool add_reflink;/* add reference count btrees */ extern bool add_rmapbt;/* add reverse mapping btrees */ +extern bool add_nrext64;/* misc status variables */
repair/phase2.c +34 -1
@@ -191,6 +191,7 @@ check_new_v5_geometry(struct xfs_perag *pag;xfs_agnumber_t agno;xfs_ino_t rootino; +uint old_bm_maxlevels[2 ];int min_logblocks;int error;
@@ -201,6 +202,12 @@ check_new_v5_geometry(memcpy (&old_sb, &mp->m_sb,sizeof (struct xfs_sb ));memcpy (&mp->m_sb, new_sb,sizeof (struct xfs_sb )); + old_bm_maxlevels[0 ] = mp->m_bm_maxlevels[0 ]; + old_bm_maxlevels[1 ] = mp->m_bm_maxlevels[1 ]; + +xfs_bmap_compute_maxlevels (mp,XFS_DATA_FORK ); +xfs_bmap_compute_maxlevels (mp,XFS_ATTR_FORK ); +/* Do we have a big enough log? */ min_logblocks =libxfs_log_calc_minimum_size (mp);if (old_sb.sb_logblocks < min_logblocks) {
@@ -288,6 +295,9 @@ check_new_v5_geometry( pag->pagi_init =0 ; } + mp->m_bm_maxlevels[0 ] = old_bm_maxlevels[0 ]; + mp->m_bm_maxlevels[1 ] = old_bm_maxlevels[1 ]; +/* * Put back the old superblock. */
@@ -366,6 +376,28 @@ set_rmapbt(return true; } +static bool +set_nrext64 ( +struct xfs_mount *mp, +struct xfs_sb *new_sb) +{ +if (!xfs_sb_version_hascrc (&mp->m_sb)) { +printf ( +_ ("Nrext64 only supported on V5 filesystems.\n" )); +exit (0 ); + } + +if (xfs_sb_version_hasnrext64 (&mp->m_sb)) { +printf (_ ("Filesystem already supports nrext64.\n" )); +exit (0 ); + } + +printf (_ ("Adding nrext64 to filesystem.\n" )); + new_sb->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NREXT64 ; + new_sb->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR ; +return true; +} +/* Perform the user's requested upgrades on filesystem. */ static void upgrade_filesystem(
@@ -388,7 +420,8 @@ upgrade_filesystem( dirty |=set_reflink (mp, &new_sb);if (add_rmapbt) dirty |=set_rmapbt (mp, &new_sb); - +if (add_nrext64) + dirty |=set_nrext64 (mp, &new_sb);if (!dirty)return ;
repair/xfs_repair.c +11 -0
@@ -70,6 +70,7 @@ enum c_opt_nums {CONVERT_FINOBT ,CONVERT_REFLINK ,CONVERT_RMAPBT , +CONVERT_NREXT64 , C_MAX_OPTS, };
@@ -80,6 +81,7 @@ static char *c_opts[] = { [CONVERT_FINOBT] = "finobt", [CONVERT_REFLINK] = "reflink", [CONVERT_RMAPBT] = "rmapbt", + [CONVERT_NREXT64] = "nrext64", [C_MAX_OPTS] = NULL, };
@@ -357,6 +359,15 @@ process_args(int argc, char **argv) _("-c rmapbt only supports upgrades\n")); add_rmapbt = true;break ; +case CONVERT_NREXT64 : +if (!val) +do_abort ( +_ ("-c nrext64 requires a parameter\n" )); +if (strtol (val,NULL ,0 ) !=1 ) +do_abort ( +_ ("-c nrext64 only supports upgrades\n" )); + add_nrext64 = true; +break ;default :unknown ('c' , val);break ;
Signature · 1 line
2.30.2
Re: [PATCH V4 19/20] xfsprogs: Add support for upgrading to NREXT64 feature
Quoted 48 lines · Chandan Babu R
This commit adds support to
xfs_repairto allow upgrading an existing filesystem to support per-inode large extent counters.Signed-off-by Chandan Babu R <[email protected]>--- repair/globals.c | 1 + repair/globals.h | 1 + repair/phase2.c | 35 ++++++++++++++++++++++++++++++++++- repair/xfs_repair.c | 11 +++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-)repair/globals.c +1
-0@@ -53,6 +53,7 @@ bool add_bigtime; /* add support for timestamps up to 2486 */bool add_finobt;/* add free inode btrees */ bool add_reflink;/* add reference count btrees */ bool add_rmapbt;/* add reverse mapping btrees */ +bool add_nrext64;/* misc status variables */ repair/globals.h +1
-0@@ -94,6 +94,7 @@ extern bool add_bigtime; /* add support for timestamps up to 2486 */extern bool add_finobt;/* add free inode btrees */ extern bool add_reflink;/* add reference count btrees */ extern bool add_rmapbt;/* add reverse mapping btrees */ +extern bool add_nrext64;/* misc status variables */ repair/phase2.c +1
-0@@ -191,6 +191,7 @@ check_new_v5_geometry(struct xfs_perag *pag;xfs_agnumber_t agno;xfs_ino_t rootino; +uint old_bm_maxlevels[2 ];int min_logblocks;int error;
repair/phase2.c check_new_v5_geometry( · line 209
Quoted 8 lines
repair/phase2.c +5
-0@@ -201,6 +202,12 @@ check_new_v5_geometry(memcpy (&old_sb, &mp->m_sb,sizeof (struct xfs_sb ));memcpy (&mp->m_sb, new_sb,sizeof (struct xfs_sb )); + old_bm_maxlevels[0 ] = mp->m_bm_maxlevels[0 ]; + old_bm_maxlevels[1 ] = mp->m_bm_maxlevels[1 ]; + +xfs_bmap_compute_maxlevels (mp,XFS_DATA_FORK ); +xfs_bmap_compute_maxlevels (mp,XFS_ATTR_FORK );
Ahh... I see why you added my (evil) patch that allows upgrading a filesystem to reflink -- you need the check_new_v5_geometry function so that you can check if the log size is big enough to handle larger bmbt trees.
Hmm, I guess I should work on separating this from the actual rmap/reflink/finobt upgrade code, since I have no idea if we /ever/ want to support that.
--D
Quoted 92 lines
repair/phase2.c +28
-1+/* Do we have a big enough log? */ min_logblocks =libxfs_log_calc_minimum_size (mp);if (old_sb.sb_logblocks < min_logblocks) {@@ -288,6 +295,9 @@ check_new_v5_geometry( pag->pagi_init =0 ; } + mp->m_bm_maxlevels[0 ] = old_bm_maxlevels[0 ]; + mp->m_bm_maxlevels[1 ] = old_bm_maxlevels[1 ]; +/* * Put back the old superblock. */ @@ -366,6 +376,28 @@ set_rmapbt(return true; } +static bool +set_nrext64 ( +struct xfs_mount *mp, +struct xfs_sb *new_sb) +{ +if (!xfs_sb_version_hascrc (&mp->m_sb)) { +printf ( +_ ("Nrext64 only supported on V5 filesystems.\n" )); +exit (0 ); + } + +if (xfs_sb_version_hasnrext64 (&mp->m_sb)) { +printf (_ ("Filesystem already supports nrext64.\n" )); +exit (0 ); + } + +printf (_ ("Adding nrext64 to filesystem.\n" )); + new_sb->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NREXT64 ; + new_sb->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR ; +return true; +} +/* Perform the user's requested upgrades on filesystem. */ static void upgrade_filesystem(@@ -388,7 +420,8 @@ upgrade_filesystem( dirty |=set_reflink (mp, &new_sb);if (add_rmapbt) dirty |=set_rmapbt (mp, &new_sb); - +if (add_nrext64) + dirty |=set_nrext64 (mp, &new_sb);if (!dirty)return ;repair/xfs_repair.c +11
-0@@ -70,6 +70,7 @@ enum c_opt_nums {CONVERT_FINOBT ,CONVERT_REFLINK ,CONVERT_RMAPBT , +CONVERT_NREXT64 , C_MAX_OPTS, };@@ -80,6 +81,7 @@ static char *c_opts[] = { [CONVERT_FINOBT] = "finobt", [CONVERT_REFLINK] = "reflink", [CONVERT_RMAPBT] = "rmapbt", + [CONVERT_NREXT64] = "nrext64", [C_MAX_OPTS] = NULL, };@@ -357,6 +359,15 @@ process_args(int argc, char **argv) _("-c rmapbt only supports upgrades\n")); add_rmapbt = true;break ; +case CONVERT_NREXT64 : +if (!val) +do_abort ( +_ ("-c nrext64 requires a parameter\n" )); +if (strtol (val,NULL ,0 ) !=1 ) +do_abort ( +_ ("-c nrext64 only supports upgrades\n" )); + add_nrext64 = true; +break ;default :unknown ('c' , val);break ;Signature · 1 line
2.30.2
Re: [PATCH V4 19/20] xfsprogs: Add support for upgrading to NREXT64 feature
Quoted 63 lines · Darrick J. Wong
Quoted 48 lines · Chandan Babu R
This commit adds support to
xfs_repairto allow upgrading an existing filesystem to support per-inode large extent counters.Signed-off-by Chandan Babu R <[email protected]>--- repair/globals.c | 1 + repair/globals.h | 1 + repair/phase2.c | 35 ++++++++++++++++++++++++++++++++++- repair/xfs_repair.c | 11 +++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-)repair/globals.c +1
-0@@ -53,6 +53,7 @@ bool add_bigtime; /* add support for timestamps up to 2486 */bool add_finobt;/* add free inode btrees */ bool add_reflink;/* add reference count btrees */ bool add_rmapbt;/* add reverse mapping btrees */ +bool add_nrext64;/* misc status variables */ repair/globals.h +1
-0@@ -94,6 +94,7 @@ extern bool add_bigtime; /* add support for timestamps up to 2486 */extern bool add_finobt;/* add free inode btrees */ extern bool add_reflink;/* add reference count btrees */ extern bool add_rmapbt;/* add reverse mapping btrees */ +extern bool add_nrext64;/* misc status variables */ repair/phase2.c +1
-0@@ -191,6 +191,7 @@ check_new_v5_geometry(struct xfs_perag *pag;xfs_agnumber_t agno;xfs_ino_t rootino; +uint old_bm_maxlevels[2 ];int min_logblocks;int error;repair/phase2.c check_new_v5_geometry( · line 209
Quoted 8 lines
repair/phase2.c +5
-0@@ -201,6 +202,12 @@ check_new_v5_geometry(memcpy (&old_sb, &mp->m_sb,sizeof (struct xfs_sb ));memcpy (&mp->m_sb, new_sb,sizeof (struct xfs_sb )); + old_bm_maxlevels[0 ] = mp->m_bm_maxlevels[0 ]; + old_bm_maxlevels[1 ] = mp->m_bm_maxlevels[1 ]; + +xfs_bmap_compute_maxlevels (mp,XFS_DATA_FORK ); +xfs_bmap_compute_maxlevels (mp,XFS_ATTR_FORK );Ahh... I see why you added my (evil) patch that allows upgrading a filesystem to reflink -- you need the
check_new_v5_geometryfunction so that you can check if the log size is big enough to handle larger bmbt trees.
Quoted 4 lines
Hmm, I guess I should work on separating this from the actual rmap/reflink/finobt upgrade code, since I have no idea if we /ever/ want to support that.
I can do that. I will include the trimmed down version of the patch before posting the patchset once again.
Quoted 94 lines
--D
Quoted 92 lines
repair/phase2.c +28
-1+/* Do we have a big enough log? */ min_logblocks =libxfs_log_calc_minimum_size (mp);if (old_sb.sb_logblocks < min_logblocks) {@@ -288,6 +295,9 @@ check_new_v5_geometry( pag->pagi_init =0 ; } + mp->m_bm_maxlevels[0 ] = old_bm_maxlevels[0 ]; + mp->m_bm_maxlevels[1 ] = old_bm_maxlevels[1 ]; +/* * Put back the old superblock. */ @@ -366,6 +376,28 @@ set_rmapbt(return true; } +static bool +set_nrext64 ( +struct xfs_mount *mp, +struct xfs_sb *new_sb) +{ +if (!xfs_sb_version_hascrc (&mp->m_sb)) { +printf ( +_ ("Nrext64 only supported on V5 filesystems.\n" )); +exit (0 ); + } + +if (xfs_sb_version_hasnrext64 (&mp->m_sb)) { +printf (_ ("Filesystem already supports nrext64.\n" )); +exit (0 ); + } + +printf (_ ("Adding nrext64 to filesystem.\n" )); + new_sb->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NREXT64 ; + new_sb->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR ; +return true; +} +/* Perform the user's requested upgrades on filesystem. */ static void upgrade_filesystem(@@ -388,7 +420,8 @@ upgrade_filesystem( dirty |=set_reflink (mp, &new_sb);if (add_rmapbt) dirty |=set_rmapbt (mp, &new_sb); - +if (add_nrext64) + dirty |=set_nrext64 (mp, &new_sb);if (!dirty)return ;repair/xfs_repair.c +11
-0@@ -70,6 +70,7 @@ enum c_opt_nums {CONVERT_FINOBT ,CONVERT_REFLINK ,CONVERT_RMAPBT , +CONVERT_NREXT64 , C_MAX_OPTS, };@@ -80,6 +81,7 @@ static char *c_opts[] = { [CONVERT_FINOBT] = "finobt", [CONVERT_REFLINK] = "reflink", [CONVERT_RMAPBT] = "rmapbt", + [CONVERT_NREXT64] = "nrext64", [C_MAX_OPTS] = NULL, };@@ -357,6 +359,15 @@ process_args(int argc, char **argv) _("-c rmapbt only supports upgrades\n")); add_rmapbt = true;break ; +case CONVERT_NREXT64 : +if (!val) +do_abort ( +_ ("-c nrext64 requires a parameter\n" )); +if (strtol (val,NULL ,0 ) !=1 ) +do_abort ( +_ ("-c nrext64 only supports upgrades\n" )); + add_nrext64 = true; +break ;default :unknown ('c' , val);break ;Signature · 1 line
2.30.2
Signature · 1 line
chandan
Re: [PATCH V4 19/20] xfsprogs: Add support for upgrading to NREXT64 feature
Quoted 64 lines · Chandan Babu R
Quoted 63 lines · Darrick J. Wong
Quoted 48 lines · Chandan Babu R
This commit adds support to
xfs_repairto allow upgrading an existing filesystem to support per-inode large extent counters.Signed-off-by Chandan Babu R <[email protected]>--- repair/globals.c | 1 + repair/globals.h | 1 + repair/phase2.c | 35 ++++++++++++++++++++++++++++++++++- repair/xfs_repair.c | 11 +++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-)repair/globals.c +1
-0@@ -53,6 +53,7 @@ bool add_bigtime; /* add support for timestamps up to 2486 */bool add_finobt;/* add free inode btrees */ bool add_reflink;/* add reference count btrees */ bool add_rmapbt;/* add reverse mapping btrees */ +bool add_nrext64;/* misc status variables */ repair/globals.h +1
-0@@ -94,6 +94,7 @@ extern bool add_bigtime; /* add support for timestamps up to 2486 */extern bool add_finobt;/* add free inode btrees */ extern bool add_reflink;/* add reference count btrees */ extern bool add_rmapbt;/* add reverse mapping btrees */ +extern bool add_nrext64;/* misc status variables */ repair/phase2.c +1
-0@@ -191,6 +191,7 @@ check_new_v5_geometry(struct xfs_perag *pag;xfs_agnumber_t agno;xfs_ino_t rootino; +uint old_bm_maxlevels[2 ];int min_logblocks;int error;repair/phase2.c check_new_v5_geometry( · line 209
Quoted 8 lines
repair/phase2.c +5
-0@@ -201,6 +202,12 @@ check_new_v5_geometry(memcpy (&old_sb, &mp->m_sb,sizeof (struct xfs_sb ));memcpy (&mp->m_sb, new_sb,sizeof (struct xfs_sb )); + old_bm_maxlevels[0 ] = mp->m_bm_maxlevels[0 ]; + old_bm_maxlevels[1 ] = mp->m_bm_maxlevels[1 ]; + +xfs_bmap_compute_maxlevels (mp,XFS_DATA_FORK ); +xfs_bmap_compute_maxlevels (mp,XFS_ATTR_FORK );Ahh... I see why you added my (evil) patch that allows upgrading a filesystem to reflink -- you need the
check_new_v5_geometryfunction so that you can check if the log size is big enough to handle larger bmbt trees.
Quoted 7 lines
Quoted 4 lines
Hmm, I guess I should work on separating this from the actual rmap/reflink/finobt upgrade code, since I have no idea if we /ever/ want to support that.
I can do that. I will include the trimmed down version of the patch before posting the patchset once again.
I separated that megapatch into smaller pieces yesterday, so I'll point you to it once it all goes through QA.
--D
Quoted 98 lines
Quoted 94 lines
--D
Quoted 92 lines
repair/phase2.c +28
-1+/* Do we have a big enough log? */ min_logblocks =libxfs_log_calc_minimum_size (mp);if (old_sb.sb_logblocks < min_logblocks) {@@ -288,6 +295,9 @@ check_new_v5_geometry( pag->pagi_init =0 ; } + mp->m_bm_maxlevels[0 ] = old_bm_maxlevels[0 ]; + mp->m_bm_maxlevels[1 ] = old_bm_maxlevels[1 ]; +/* * Put back the old superblock. */ @@ -366,6 +376,28 @@ set_rmapbt(return true; } +static bool +set_nrext64 ( +struct xfs_mount *mp, +struct xfs_sb *new_sb) +{ +if (!xfs_sb_version_hascrc (&mp->m_sb)) { +printf ( +_ ("Nrext64 only supported on V5 filesystems.\n" )); +exit (0 ); + } + +if (xfs_sb_version_hasnrext64 (&mp->m_sb)) { +printf (_ ("Filesystem already supports nrext64.\n" )); +exit (0 ); + } + +printf (_ ("Adding nrext64 to filesystem.\n" )); + new_sb->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NREXT64 ; + new_sb->sb_features_incompat |=XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR ; +return true; +} +/* Perform the user's requested upgrades on filesystem. */ static void upgrade_filesystem(@@ -388,7 +420,8 @@ upgrade_filesystem( dirty |=set_reflink (mp, &new_sb);if (add_rmapbt) dirty |=set_rmapbt (mp, &new_sb); - +if (add_nrext64) + dirty |=set_nrext64 (mp, &new_sb);if (!dirty)return ;repair/xfs_repair.c +11
-0@@ -70,6 +70,7 @@ enum c_opt_nums {CONVERT_FINOBT ,CONVERT_REFLINK ,CONVERT_RMAPBT , +CONVERT_NREXT64 , C_MAX_OPTS, };@@ -80,6 +81,7 @@ static char *c_opts[] = { [CONVERT_FINOBT] = "finobt", [CONVERT_REFLINK] = "reflink", [CONVERT_RMAPBT] = "rmapbt", + [CONVERT_NREXT64] = "nrext64", [C_MAX_OPTS] = NULL, };@@ -357,6 +359,15 @@ process_args(int argc, char **argv) _("-c rmapbt only supports upgrades\n")); add_rmapbt = true;break ; +case CONVERT_NREXT64 : +if (!val) +do_abort ( +_ ("-c nrext64 requires a parameter\n" )); +if (strtol (val,NULL ,0 ) !=1 ) +do_abort ( +_ ("-c nrext64 only supports upgrades\n" )); + add_nrext64 = true; +break ;default :unknown ('c' , val);break ;Signature · 1 line
2.30.2Signature · 1 line
chandan
Re: [PATCH V4 19/20] xfsprogs: Add support for upgrading to NREXT64 feature
Quoted 70 lines · Darrick J. Wong
Quoted 69 lines · Chandan Babu R
Quoted 67 lines · Darrick J. Wong
Quoted 48 lines · Chandan Babu R
This commit adds support to
xfs_repairto allow upgrading an existing filesystem to support per-inode large extent counters.Signed-off-by Chandan Babu R <[email protected]>--- repair/globals.c | 1 + repair/globals.h | 1 + repair/phase2.c | 35 ++++++++++++++++++++++++++++++++++- repair/xfs_repair.c | 11 +++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-)repair/globals.c +1
-0@@ -53,6 +53,7 @@ bool add_bigtime; /* add support for timestamps up to 2486 */bool add_finobt;/* add free inode btrees */ bool add_reflink;/* add reference count btrees */ bool add_rmapbt;/* add reverse mapping btrees */ +bool add_nrext64;/* misc status variables */ repair/globals.h +1
-0@@ -94,6 +94,7 @@ extern bool add_bigtime; /* add support for timestamps up to 2486 */extern bool add_finobt;/* add free inode btrees */ extern bool add_reflink;/* add reference count btrees */ extern bool add_rmapbt;/* add reverse mapping btrees */ +extern bool add_nrext64;/* misc status variables */ repair/phase2.c +1
-0@@ -191,6 +191,7 @@ check_new_v5_geometry(struct xfs_perag *pag;xfs_agnumber_t agno;xfs_ino_t rootino; +uint old_bm_maxlevels[2 ];int min_logblocks;int error;repair/phase2.c check_new_v5_geometry( · line 209
Quoted 8 lines
repair/phase2.c +5
-0@@ -201,6 +202,12 @@ check_new_v5_geometry(memcpy (&old_sb, &mp->m_sb,sizeof (struct xfs_sb ));memcpy (&mp->m_sb, new_sb,sizeof (struct xfs_sb )); + old_bm_maxlevels[0 ] = mp->m_bm_maxlevels[0 ]; + old_bm_maxlevels[1 ] = mp->m_bm_maxlevels[1 ]; + +xfs_bmap_compute_maxlevels (mp,XFS_DATA_FORK ); +xfs_bmap_compute_maxlevels (mp,XFS_ATTR_FORK );Ahh... I see why you added my (evil) patch that allows upgrading a filesystem to reflink -- you need the
check_new_v5_geometryfunction so that you can check if the log size is big enough to handle larger bmbt trees.Hmm, I guess I should work on separating this from the actual rmap/reflink/finobt upgrade code, since I have no idea if we /ever/ want to support that.
Quoted 6 lines
Quoted 2 lines
I can do that. I will include the trimmed down version of the patch before posting the patchset once again.
I separated that megapatch into smaller pieces yesterday, so I'll point you to it once it all goes through QA.
Ok. I will wait.
Signature · 1 line
chandan
Re: [PATCH V4 19/20] xfsprogs: Add support for upgrading to NREXT64 feature
Quoted 71 lines · Chandan Babu R
Quoted 70 lines · Darrick J. Wong
Quoted 69 lines · Chandan Babu R
Quoted 67 lines · Darrick J. Wong
Quoted 48 lines · Chandan Babu R
This commit adds support to
xfs_repairto allow upgrading an existing filesystem to support per-inode large extent counters.Signed-off-by Chandan Babu R <[email protected]>--- repair/globals.c | 1 + repair/globals.h | 1 + repair/phase2.c | 35 ++++++++++++++++++++++++++++++++++- repair/xfs_repair.c | 11 +++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-)repair/globals.c +1
-0@@ -53,6 +53,7 @@ bool add_bigtime; /* add support for timestamps up to 2486 */bool add_finobt;/* add free inode btrees */ bool add_reflink;/* add reference count btrees */ bool add_rmapbt;/* add reverse mapping btrees */ +bool add_nrext64;/* misc status variables */ repair/globals.h +1
-0@@ -94,6 +94,7 @@ extern bool add_bigtime; /* add support for timestamps up to 2486 */extern bool add_finobt;/* add free inode btrees */ extern bool add_reflink;/* add reference count btrees */ extern bool add_rmapbt;/* add reverse mapping btrees */ +extern bool add_nrext64;/* misc status variables */ repair/phase2.c +1
-0@@ -191,6 +191,7 @@ check_new_v5_geometry(struct xfs_perag *pag;xfs_agnumber_t agno;xfs_ino_t rootino; +uint old_bm_maxlevels[2 ];int min_logblocks;int error;repair/phase2.c check_new_v5_geometry( · line 209
Quoted 8 lines
repair/phase2.c +5
-0@@ -201,6 +202,12 @@ check_new_v5_geometry(memcpy (&old_sb, &mp->m_sb,sizeof (struct xfs_sb ));memcpy (&mp->m_sb, new_sb,sizeof (struct xfs_sb )); + old_bm_maxlevels[0 ] = mp->m_bm_maxlevels[0 ]; + old_bm_maxlevels[1 ] = mp->m_bm_maxlevels[1 ]; + +xfs_bmap_compute_maxlevels (mp,XFS_DATA_FORK ); +xfs_bmap_compute_maxlevels (mp,XFS_ATTR_FORK );Ahh... I see why you added my (evil) patch that allows upgrading a filesystem to reflink -- you need the
check_new_v5_geometryfunction so that you can check if the log size is big enough to handle larger bmbt trees.Hmm, I guess I should work on separating this from the actual rmap/reflink/finobt upgrade code, since I have no idea if we /ever/ want to support that.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I can do that. I will include the trimmed down version of the patch before posting the patchset once again.
I separated that megapatch into smaller pieces yesterday, so I'll point you to it once it all goes through QA.
Ok. I will wait.
Here's one patch to fix a bug I found in the upgrade code, because apparently we weren't resyncing the secondary superblocks
And here's an updated version of xfs_repair infrastructure you need to add nrext64, without the extraneous code to add other features. It also now recomputes m_features and the maxlevels values so you don't have to do that anymore.
--D
Quoted 3 lines
Signature · 2 lines
-- chandan
Re: [PATCH V4 19/20] xfsprogs: Add support for upgrading to NREXT64 feature
Quoted 84 lines · Darrick J. Wong
Quoted 71 lines · Chandan Babu R
Quoted 70 lines · Darrick J. Wong
Quoted 69 lines · Chandan Babu R
Quoted 67 lines · Darrick J. Wong
Quoted 48 lines · Chandan Babu R
This commit adds support to
xfs_repairto allow upgrading an existing filesystem to support per-inode large extent counters.Signed-off-by Chandan Babu R <[email protected]>--- repair/globals.c | 1 + repair/globals.h | 1 + repair/phase2.c | 35 ++++++++++++++++++++++++++++++++++- repair/xfs_repair.c | 11 +++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-)repair/globals.c +1
-0@@ -53,6 +53,7 @@ bool add_bigtime; /* add support for timestamps up to 2486 */bool add_finobt;/* add free inode btrees */ bool add_reflink;/* add reference count btrees */ bool add_rmapbt;/* add reverse mapping btrees */ +bool add_nrext64;/* misc status variables */ repair/globals.h +1
-0@@ -94,6 +94,7 @@ extern bool add_bigtime; /* add support for timestamps up to 2486 */extern bool add_finobt;/* add free inode btrees */ extern bool add_reflink;/* add reference count btrees */ extern bool add_rmapbt;/* add reverse mapping btrees */ +extern bool add_nrext64;/* misc status variables */ repair/phase2.c +1
-0@@ -191,6 +191,7 @@ check_new_v5_geometry(struct xfs_perag *pag;xfs_agnumber_t agno;xfs_ino_t rootino; +uint old_bm_maxlevels[2 ];int min_logblocks;int error;repair/phase2.c check_new_v5_geometry( · line 209
Quoted 8 lines
repair/phase2.c +5
-0@@ -201,6 +202,12 @@ check_new_v5_geometry(memcpy (&old_sb, &mp->m_sb,sizeof (struct xfs_sb ));memcpy (&mp->m_sb, new_sb,sizeof (struct xfs_sb )); + old_bm_maxlevels[0 ] = mp->m_bm_maxlevels[0 ]; + old_bm_maxlevels[1 ] = mp->m_bm_maxlevels[1 ]; + +xfs_bmap_compute_maxlevels (mp,XFS_DATA_FORK ); +xfs_bmap_compute_maxlevels (mp,XFS_ATTR_FORK );Ahh... I see why you added my (evil) patch that allows upgrading a filesystem to reflink -- you need the
check_new_v5_geometryfunction so that you can check if the log size is big enough to handle larger bmbt trees.Hmm, I guess I should work on separating this from the actual rmap/reflink/finobt upgrade code, since I have no idea if we /ever/ want to support that.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
I can do that. I will include the trimmed down version of the patch before posting the patchset once again.
I separated that megapatch into smaller pieces yesterday, so I'll point you to it once it all goes through QA.
Ok. I will wait.
Here's one patch to fix a bug I found in the upgrade code, because apparently we weren't resyncing the secondary superblocks
Quoted 9 lines
And here's an updated version of
xfs_repairinfrastructure you need to add nrext64, without the extraneous code to add other features. It also now recomputesm_featuresand the maxlevels values so you don't have to do that anymore.
Thank you!
I have rebased my xfsprogs patchset on top of the above commit. I have also removed the commits associated with atomic swapext feature though.
Signature · 1 line
chandan
PATCH v4 20/20 xfsprogs: Define max extent length based on on-disk format definition
In reply to Chandan Babu RThe maximum extent length depends on maximum block count that can be stored in a BMBT record. Hence this commit defines MAXEXTLEN based on BMBT_BLOCKCOUNT_BITLEN.
While at it, the commit also renames MAXEXTLEN to XFS_MAX_BMBT_EXTLEN.
--- db/metadump.c | 2 +- libxfs/xfs_bmap.c | 53 +++++++++++++++++++++-------------------- libxfs/xfs_format.h | 23 +++++++++--------- libxfs/xfs_inode_buf.c | 4 ++-- libxfs/xfs_trans_resv.c | 10 ++++---- mkfs/xfs_mkfs.c | 6 ++--- repair/phase4.c | 2 +- 7 files changed, 51 insertions(+), 49 deletions(-)
db/metadump.c +1 -1
@@ -20,7 +20,7 @@#include "field.h" #include "dir2.h" -#define DEFAULT_MAX_EXT_SIZE MAXEXTLEN +#define DEFAULT_MAX_EXT_SIZE XFS_MAX_BMBT_EXTLEN/* copy all metadata structures to/from a file */
libxfs/xfs_bmap.c +27 -26
173 lines not on this page · raw message
libxfs/xfs_format.h +12 -11
@@ -1073,15 +1073,6 @@ enum xfs_dinode_fmt { { XFS_DINODE_FMT_BTREE, "btree" }, \ { XFS_DINODE_FMT_UUID, "uuid" } -/* -* Max values for extlen, extnum, aextnum. -*/ -#define MAXEXTLEN ((xfs_extlen_t)0x1fffff)/* 21 bits */ -#define XFS_MAX_EXTCNT_DATA_FORK ((xfs_extnum_t)0xffffffffffff)/* Unsigned 48-bits */ -#define XFS_MAX_EXTCNT_ATTR_FORK ((xfs_aextnum_t)0xffffffff)/* Unsigned 32-bits */ -#define XFS_MAX_EXTCNT_DATA_FORK_OLD ((xfs_extnum_t)0x7fffffff)/* Signed 32-bits */ -#define XFS_MAX_EXTCNT_ATTR_FORK_OLD ((xfs_aextnum_t)0x7fff)/* Signed 16-bits */ -/* * Inode minimum and maximum sizes. */
@@ -1810,8 +1801,18 @@ typedef struct xfs_bmdr_block {#define BMBT_STARTBLOCK_BITLEN 52#define BMBT_BLOCKCOUNT_BITLEN 21 -#define BMBT_STARTOFF_MASK ((1ULL << BMBT_STARTOFF_BITLEN) - 1) -#define BMBT_BLOCKCOUNT_MASK ((1ULL << BMBT_BLOCKCOUNT_BITLEN) - 1) +#define BMBT_STARTOFF_MASK ((1ULL << BMBT_STARTOFF_BITLEN) - 1) + +/* +* Max values for extlen, extnum, aextnum. +*/ +#define XFS_MAX_BMBT_EXTLEN ((xfs_extlen_t)(1ULL << BMBT_BLOCKCOUNT_BITLEN) - 1) +#define XFS_MAX_EXTCNT_DATA_FORK ((xfs_extnum_t)0xffffffffffff)/* Unsigned 48-bits */ +#define XFS_MAX_EXTCNT_ATTR_FORK ((xfs_aextnum_t)0xffffffff)/* Unsigned 32-bits */ +#define XFS_MAX_EXTCNT_DATA_FORK_OLD ((xfs_extnum_t)0x7fffffff)/* Signed 32-bits */ +#define XFS_MAX_EXTCNT_ATTR_FORK_OLD ((xfs_aextnum_t)0x7fff)/* Signed 16-bits */ + +#define BMBT_BLOCKCOUNT_MASK XFS_MAX_BMBT_EXTLEN/* * bmbt records have a file offset (block) field that is 54 bits wide, so this
libxfs/xfs_inode_buf.c +2 -2
@@ -666,7 +666,7 @@ xfs_inode_validate_extsize(if (extsize_bytes % blocksize_bytes)return __this_address; -if (extsize >MAXEXTLEN ) +if (extsize >XFS_MAX_BMBT_EXTLEN )return __this_address;if (!rt_flag && extsize > mp->m_sb.sb_agblocks /2 )
@@ -723,7 +723,7 @@ xfs_inode_validate_cowextsize(if (cowextsize_bytes % mp->m_sb.sb_blocksize)return __this_address; -if (cowextsize >MAXEXTLEN ) +if (cowextsize >XFS_MAX_BMBT_EXTLEN )return __this_address;if (cowextsize > mp->m_sb.sb_agblocks /2 )
libxfs/xfs_trans_resv.c +5 -5
@@ -198,8 +198,8 @@ xfs_calc_inode_chunk_res(/* * Per-extent log reservation for the btree changes involved in freeing or * allocating a realtime extent. We have to be able to log as many rtbitmap -* blocks as needed to mark inuse MAXEXTLEN blocks' worth of realtime extents, -* as well as the realtime summary block. +* blocks as needed to mark inuse XFS_MAX_BMBT_EXTLEN blocks' worth of realtime +* extents, as well as the realtime summary block. */ static unsigned int xfs_rtalloc_log_count(
@@ -209,7 +209,7 @@ xfs_rtalloc_log_count(unsigned int blksz =XFS_FSB_TO_B (mp,1 );unsigned int rtbmp_bytes; - rtbmp_bytes = (MAXEXTLEN / mp->m_sb.sb_rextsize) /NBBY ; + rtbmp_bytes = (XFS_MAX_BMBT_EXTLEN / mp->m_sb.sb_rextsize) /NBBY ;return (howmany (rtbmp_bytes, blksz) +1 ) * num_ops; }
@@ -246,7 +246,7 @@ xfs_rtalloc_log_count(* the inode's bmap btree: max depth * block size * the agfs of the ags from which the extents are allocated: 2 * sector * the superblock free block counter: sector size -* the realtime bitmap: ((MAXEXTLEN / rtextsize) / NBBY) bytes +* the realtime bitmap: ((XFS_MAX_BMBT_EXTLEN / rtextsize) / NBBY) bytes * the realtime summary: 1 block * the allocation btrees: 2 trees * (2 * max depth - 1) * block size * And the bmap_finish transaction can free bmap blocks in a join (t3):
@@ -298,7 +298,7 @@ xfs_calc_write_reservation(* the agf for each of the ags: 2 * sector size * the agfl for each of the ags: 2 * sector size * the super block to reflect the freed blocks: sector size -* the realtime bitmap: 2 exts * ((MAXEXTLEN / rtextsize) / NBBY) bytes +* the realtime bitmap: 2 exts * ((XFS_MAX_BMBT_EXTLEN / rtextsize) / NBBY) bytes * the realtime summary: 2 exts * 1 block * worst case split in allocation btrees per extent assuming 2 extents: * 2 exts * 2 trees * (2 * max depth - 1) * block size
mkfs/xfs_mkfs.c +3 -3
@@ -2399,7 +2399,7 @@ validate_extsize_hint(fprintf (stderr,_ ("illegal extent size hint %lld, must be less than %u.\n" ), (long long )cli->fsx.fsx_extsize, -min (MAXEXTLEN , mp->m_sb.sb_agblocks /2 )); +min (XFS_MAX_BMBT_EXTLEN , mp->m_sb.sb_agblocks /2 ));usage (); }
@@ -2422,7 +2422,7 @@ _("illegal extent size hint %lld, must be less than %u.\n"),fprintf (stderr,_ ("illegal extent size hint %lld, must be less than %u and a multiple of %u.\n" ), (long long )cli->fsx.fsx_extsize, -min (MAXEXTLEN , mp->m_sb.sb_agblocks /2 ), +min (XFS_MAX_BMBT_EXTLEN , mp->m_sb.sb_agblocks /2 ), mp->m_sb.sb_rextsize);usage (); }
@@ -2451,7 +2451,7 @@ validate_cowextsize_hint(fprintf (stderr,_ ("illegal CoW extent size hint %lld, must be less than %u.\n" ), (long long )cli->fsx.fsx_cowextsize, -min (MAXEXTLEN , mp->m_sb.sb_agblocks /2 )); +min (XFS_MAX_BMBT_EXTLEN , mp->m_sb.sb_agblocks /2 ));usage (); } }
repair/phase4.c +1 -1
@@ -372,7 +372,7 @@ phase4(xfs_mount_t *mp)if (rt_start ==0 ) { rt_start = bno; rt_len =1 ; - }else if (rt_len ==MAXEXTLEN ) { + }else if (rt_len ==XFS_MAX_BMBT_EXTLEN ) {/* * large extent case */
Signature · 1 line
2.30.2