xfsprogs: consolidate stripe validation
A message that is not in the archive (sent off-list or not yet received): [email protected]
v4 cover xfsprogs: consolidate stripe validation
From: Gao Xiang <[email protected]>
Hi,
v3: https://lore.kernel.org/r/[email protected]
This is another approach suggested by Eric in the reply of v3 (if I understand correctly), which also attempts to use i18n-enabled xfsprogs xfs_notice() to error out sanity check failure suggested by Dave on IRC.
In addition, I manually ported [PATCH 2/3] to the kernel side as well then fault injection with xfs_db and it seems work as expected.
Thanks,
Gao Xiang
changes since v3:
- mainly follow Eric suggestion mentioned in the reply of v3, e.g directly prints the error using xfs_notice/warn() and return bool;
- with an exception that it doesn't need the unit of sunit/swidth are in bytes if sectorsize is not specified, since the sanity check logic condition only needs these are in the same unit, so it saves calculation for these FSB / sector-based representation.
Gao Xiang (3):
xfsprogs: allow i18n to xfs printk
xfs: introduce xfs_validate_stripe_factors()
xfsprogs: make use of xfs_validate_stripe_factors()
libxfs/libxfs_priv.h | 8 +++---- libxfs/xfs_sb.c | 54 +++++++++++++++++++++++++++++++++++--------- libxfs/xfs_sb.h | 3 +++ mkfs/xfs_mkfs.c | 23 ++++++------------- 4 files changed, 57 insertions(+), 31 deletions(-)
Signature · 1 line
2.24.0
PATCH v4 1/3 xfsprogs: allow i18n to xfs printk
From: Gao Xiang <[email protected]>
In preparation to a common stripe validation helper, allow i18n to xfs_{notice,warn,err,alert} so that xfsprogs can share code with kernel.
--- libxfs/libxfs_priv.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
libxfs/libxfs_priv.h +4 -4
@@ -121,10 +121,10 @@ extern char *progname;extern void cmn_err (int ,char *, ...);enum ce {CE_DEBUG ,CE_CONT ,CE_NOTE ,CE_WARN ,CE_ALERT ,CE_PANIC }; -#define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE,fmt, ## args) -#define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN,fmt, ## args) -#define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) -#define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) +#define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE, _(fmt), ## args) +#define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN, _(fmt), ## args) +#define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args) +#define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args)#define xfs_buf_ioerror_alert (bp,f) ((void) 0);
Signature · 1 line
2.24.0
Re: [PATCH v4 1/3] xfsprogs: allow i18n to xfs printk
Quoted 18 lines · Gao Xiang
From: Gao Xiang <[email protected]>
In preparation to a common stripe validation helper, allow i18n to xfs_{notice,warn,err,alert} so that xfsprogs can share code with kernel.
Suggested-by Dave Chinner <[email protected]>Signed-off-by Gao Xiang <[email protected]>--- libxfs/libxfs_priv.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)libxfs/libxfs_priv.h +0
-0@@ -121,10 +121,10 @@ extern char *progname;extern void cmn_err (int ,char *, ...);
libxfs/libxfs_priv.h extern char *progname; · line 127
Quoted 10 lines
libxfs/libxfs_priv.h +4
-4enum ce {CE_DEBUG ,CE_CONT ,CE_NOTE ,CE_WARN ,CE_ALERT ,CE_PANIC }; -#define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE,fmt, ## args) -#define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN,fmt, ## args) -#define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) -#define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) +#define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE, _(fmt), ## args) +#define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN, _(fmt), ## args) +#define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args) +#define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args)
AFAICT there isn't anything that passes a _() string to xfs_{alert,notice,warn,err} so this looks ok to me. It'll be nice to add the libxfs strings to the message catalogue at last...
--D
Quoted 6 lines
libxfs/libxfs_priv.h +0
-0#define xfs_buf_ioerror_alert (bp,f) ((void) 0);Signature · 1 line
2.24.0
Re: [PATCH v4 1/3] xfsprogs: allow i18n to xfs printk
Quoted 34 lines · Darrick J. Wong
Quoted 18 lines · Gao Xiang
From: Gao Xiang <[email protected]>
In preparation to a common stripe validation helper, allow i18n to xfs_{notice,warn,err,alert} so that xfsprogs can share code with kernel.
Suggested-by Dave Chinner <[email protected]>Signed-off-by Gao Xiang <[email protected]>--- libxfs/libxfs_priv.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)libxfs/libxfs_priv.h +0
-0@@ -121,10 +121,10 @@ extern char *progname;extern void cmn_err (int ,char *, ...);libxfs/libxfs_priv.h extern char *progname; · line 127
Quoted 10 lines
libxfs/libxfs_priv.h +4
-4enum ce {CE_DEBUG ,CE_CONT ,CE_NOTE ,CE_WARN ,CE_ALERT ,CE_PANIC }; -#define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE,fmt, ## args) -#define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN,fmt, ## args) -#define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) -#define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT,fmt, ## args) +#define xfs_notice(mp,fmt,args...) cmn_err(CE_NOTE, _(fmt), ## args) +#define xfs_warn(mp,fmt,args...) cmn_err(CE_WARN, _(fmt), ## args) +#define xfs_err(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args) +#define xfs_alert(mp,fmt,args...) cmn_err(CE_ALERT, _(fmt), ## args)AFAICT there isn't anything that passes a
_()string to xfs_{alert,notice,warn,err} so this looks ok to me. It'll be nice to add the libxfs strings to the message catalogue at last...
Quoted 1 line
Reviewed-by Darrick J. Wong <[email protected]>
Ok, assume that I don't have to update this patch
if my reading is correct. will resend this with
this RVB tag.
Thanks,
Gao Xiang
Quoted 3 lines
--D
PATCH v4 2/3 xfs: introduce xfs_validate_stripe_factors()
In reply to Gao XiangFrom: Gao Xiang <[email protected]>
Introduce a common helper to consolidate
stripe validation process. Also make kernel
code xfs_validate_sb_common() use it first.
--- libxfs/xfs_sb.c | 54 +++++++++++++++++++++++++++++++++++++++---------- libxfs/xfs_sb.h | 3 +++ 2 files changed, 46 insertions(+), 11 deletions(-)
libxfs/xfs_sb.c +43 -11
@@ -357,21 +357,13 @@ xfs_validate_sb_common( } } -if (sbp->sb_unit) { -if (!xfs_sb_version_hasdalign (sbp) || - sbp->sb_unit > sbp->sb_width || - (sbp->sb_width % sbp->sb_unit) !=0 ) { -xfs_notice (mp,"SB stripe unit sanity check failed" ); -return -EFSCORRUPTED ; - } - }else if (xfs_sb_version_hasdalign (sbp)) { +if (!sbp->sb_unit ^ !xfs_sb_version_hasdalign (sbp)) {xfs_notice (mp,"SB stripe alignment sanity check failed" );return -EFSCORRUPTED ; - }else if (sbp->sb_width) { -xfs_notice (mp,"SB stripe width sanity check failed" ); -return -EFSCORRUPTED ; } +if (!xfs_validate_stripe_factors (mp, sbp->sb_unit, sbp->sb_width,0 )) +return -EFSCORRUPTED ;if (xfs_sb_version_hascrc (&mp->m_sb) && sbp->sb_blocksize <XFS_MIN_CRC_BLOCKSIZE ) {
@@ -1208,3 +1200,43 @@ xfs_sb_get_secondary( *bpp = bp;return 0 ; } + +/* +* If sectorsize is specified, sunit / swidth must be in bytes; +* or both can be in any kind of units (e.g. 512B sector or blocksize). +*/ +bool +xfs_validate_stripe_factors ( +struct xfs_mount *mp, +int sunit, +int swidth, +int sectorsize) +{ +if (sectorsize && sunit % sectorsize) { +xfs_notice (mp, +"stripe unit (%d) must be a multiple of the sector size (%d)" , + sunit, sectorsize); +return false; + } + +if ((sunit && !swidth) || (!sunit && swidth)) { +xfs_notice (mp, +"stripe unit (%d) and width (%d) are partially valid" , sunit, swidth); +return false; + } + +if (sunit > swidth) { +xfs_notice (mp, +"stripe unit (%d) is too large of the stripe width (%d)" , sunit, swidth); +return false; + } + +if (sunit && (swidth % sunit)) { +xfs_notice (mp, +"stripe width (%d) must be a multiple of the stripe unit (%d)" , + swidth, sunit); +return false; + } +return true; +} +
libxfs/xfs_sb.h +3 -0
@@ -42,4 +42,7 @@ extern int xfs_sb_get_secondary(struct xfs_mount *mp, struct xfs_trans *tp, xfs_agnumber_t agno, struct xfs_buf **bpp); +extern bool xfs_validate_stripe_factors (struct xfs_mount *mp, +int sunit,int swidth,int sectorsize); +#endif /* __XFS_SB_H__ */
Signature · 1 line
2.24.0
Re: [PATCH v4 2/3] xfs: introduce xfs_validate_stripe_factors()
Quoted 5 lines · Gao Xiang
From: Gao Xiang <[email protected]>
Introduce a common helper to consolidate
stripe validation process. Also make kernel
codexfs_validate_sb_common()use it first.
Please use all 72(?) columns here.
Quoted 5 lines
Signed-off-by Gao Xiang <[email protected]>--- libxfs/xfs_sb.c | 54 +++++++++++++++++++++++++++++++++++++++---------- libxfs/xfs_sb.h | 3 +++
These libxfs changes will have to go through the kernel first.
Quoted 9 lines
2 files changed, 46 insertions(+), 11 deletions(-)libxfs/xfs_sb.c +0
-0@@ -357,21 +357,13 @@ xfs_validate_sb_common( } }
libxfs/xfs_sb.c xfs_validate_sb_common( · line 360
Quoted 10 lines
libxfs/xfs_sb.c +1
-8-if (sbp->sb_unit) { -if (!xfs_sb_version_hasdalign (sbp) || - sbp->sb_unit > sbp->sb_width || - (sbp->sb_width % sbp->sb_unit) !=0 ) { -xfs_notice (mp,"SB stripe unit sanity check failed" ); -return -EFSCORRUPTED ; - } - }else if (xfs_sb_version_hasdalign (sbp)) { +if (!sbp->sb_unit ^ !xfs_sb_version_hasdalign (sbp)) {
Urgh, this logic makes my brain hurt.
"If the zeroness of sb_unit differs from the unsetness of the dalign feature"? This might need some kind of comment, such as:
/*
* Either sb_unit and hasdalign are both set, or they are zero
* and not set, respectively.
*/
if (!sbp->sb_unit ^ !xfs_sb_version_hasdalign(sbp)) {Quoted 28 lines
libxfs/xfs_sb.c +14
-3xfs_notice (mp,"SB stripe alignment sanity check failed" );return -EFSCORRUPTED ; - }else if (sbp->sb_width) { -xfs_notice (mp,"SB stripe width sanity check failed" ); -return -EFSCORRUPTED ; } +if (!xfs_validate_stripe_factors (mp, sbp->sb_unit, sbp->sb_width,0 )) +return -EFSCORRUPTED ;if (xfs_sb_version_hascrc (&mp->m_sb) && sbp->sb_blocksize <XFS_MIN_CRC_BLOCKSIZE ) {@@ -1208,3 +1200,43 @@ xfs_sb_get_secondary( *bpp = bp;return 0 ; } + +/* +* If sectorsize is specified, sunit / swidth must be in bytes; +* or both can be in any kind of units (e.g. 512B sector or blocksize). +*/ +bool +xfs_validate_stripe_factors ( +struct xfs_mount *mp, +int sunit, +int swidth, +int sectorsize) +{
libxfs/xfs_sb.c xfs_sb_get_secondary( · line 1224
Quoted 10 lines
libxfs/xfs_sb.c +10
-0+if (sectorsize && sunit % sectorsize) { +xfs_notice (mp, +"stripe unit (%d) must be a multiple of the sector size (%d)" , + sunit, sectorsize); +return false; + } + +if ((sunit && !swidth) || (!sunit && swidth)) { +xfs_notice (mp, +"stripe unit (%d) and width (%d) are partially valid" , sunit, swidth);
I would break these into separate checks and messages.
libxfs/xfs_sb.c xfs_sb_get_secondary( · line 1230
Quoted 6 lines
libxfs/xfs_sb.c +6
-0+return false; + } + +if (sunit > swidth) { +xfs_notice (mp, +"stripe unit (%d) is too large of the stripe width (%d)" , sunit, swidth);
"stripe unit (%d) is larger than the stripe width..."
--D
Quoted 27 lines
libxfs/xfs_sb.c +12
-0+return false; + } + +if (sunit && (swidth % sunit)) { +xfs_notice (mp, +"stripe width (%d) must be a multiple of the stripe unit (%d)" , + swidth, sunit); +return false; + } +return true; +} +libxfs/xfs_sb.h +3
-0@@ -42,4 +42,7 @@ extern int xfs_sb_get_secondary(struct xfs_mount *mp, struct xfs_trans *tp, xfs_agnumber_t agno, struct xfs_buf **bpp); +extern bool xfs_validate_stripe_factors (struct xfs_mount *mp, +int sunit,int swidth,int sectorsize); +#endif /* __XFS_SB_H__ */ Signature · 1 line
2.24.0
Re: [PATCH v4 2/3] xfs: introduce xfs_validate_stripe_factors()
Quoted 8 lines · Darrick J. Wong
Quoted 5 lines · Gao Xiang
From: Gao Xiang <[email protected]>
Introduce a common helper to consolidate
stripe validation process. Also make kernel
codexfs_validate_sb_common()use it first.Please use all 72(?) columns here.
will fix.
Quoted 8 lines
Quoted 6 lines
Signed-off-by Gao Xiang <[email protected]>--- libxfs/xfs_sb.c | 54 +++++++++++++++++++++++++++++++++++++++---------- libxfs/xfs_sb.h | 3 +++These libxfs changes will have to go through the kernel first.
will send another patch together with the next version.
Quoted 23 lines
Quoted 10 lines
2 files changed, 46 insertions(+), 11 deletions(-)libxfs/xfs_sb.c +0
-0@@ -357,21 +357,13 @@ xfs_validate_sb_common( } }libxfs/xfs_sb.c xfs_validate_sb_common( · line 360
Quoted 10 lines
libxfs/xfs_sb.c +1
-8-if (sbp->sb_unit) { -if (!xfs_sb_version_hasdalign (sbp) || - sbp->sb_unit > sbp->sb_width || - (sbp->sb_width % sbp->sb_unit) !=0 ) { -xfs_notice (mp,"SB stripe unit sanity check failed" ); -return -EFSCORRUPTED ; - } - }else if (xfs_sb_version_hasdalign (sbp)) { +if (!sbp->sb_unit ^ !xfs_sb_version_hasdalign (sbp)) {Urgh, this logic makes my brain hurt.
Quoted 9 lines
"If the zeroness of
sb_unitdiffers from the unsetness of the dalign feature"? This might need some kind of comment, such as:/* * Either sb_unit and hasdalign are both set, or they are zero * and not set, respectively. */ if (!sbp->sb_unit ^ !xfs_sb_version_hasdalign(sbp)) {
Ok, yet I think the comment might describe failure condition (which causes -EFSCORRUPTED) instead directly, like,
/* * Either (sb_unit and !hasdalign) or (!sb_unit and hasdalign) * would imply the image is corrupted. */
if (!sbp->sb_unit ^ !xfs_sb_version_hasdalign(sbp)) {
Quoted 33 lines
Quoted 33 lines
libxfs/xfs_sb.c +18
-3xfs_notice (mp,"SB stripe alignment sanity check failed" );return -EFSCORRUPTED ; - }else if (sbp->sb_width) { -xfs_notice (mp,"SB stripe width sanity check failed" ); -return -EFSCORRUPTED ; } +if (!xfs_validate_stripe_factors (mp, sbp->sb_unit, sbp->sb_width,0 )) +return -EFSCORRUPTED ;if (xfs_sb_version_hascrc (&mp->m_sb) && sbp->sb_blocksize <XFS_MIN_CRC_BLOCKSIZE ) {@@ -1208,3 +1200,43 @@ xfs_sb_get_secondary( *bpp = bp;return 0 ; } + +/* +* If sectorsize is specified, sunit / swidth must be in bytes; +* or both can be in any kind of units (e.g. 512B sector or blocksize). +*/ +bool +xfs_validate_stripe_factors ( +struct xfs_mount *mp, +int sunit, +int swidth, +int sectorsize) +{ +if (sectorsize && sunit % sectorsize) { +xfs_notice (mp, +"stripe unit (%d) must be a multiple of the sector size (%d)" , + sunit, sectorsize);
Quoted 8 lines
libxfs/xfs_sb.c xfs_sb_get_secondary( · line 1224
Quoted 6 lines
libxfs/xfs_sb.c +6
-0+return false; + } + +if ((sunit && !swidth) || (!sunit && swidth)) { +xfs_notice (mp, +"stripe unit (%d) and width (%d) are partially valid" , sunit, swidth);I would break these into separate checks and messages.
Ok, will update in the next version.
Quoted 9 lines
libxfs/xfs_sb.c xfs_sb_get_secondary( · line 1230
Quoted 7 lines
libxfs/xfs_sb.c +6
-0+return false; + } + +if (sunit > swidth) { +xfs_notice (mp, +"stripe unit (%d) is too large of the stripe width (%d)" , sunit, swidth);"stripe unit (%d) is larger than the stripe width..."
Will update too.
Thanks,
Gao Xiang
Quoted 2 lines
--D
PATCH v4 3/3 xfsprogs: make use of xfs_validate_stripe_factors()
In reply to Gao XiangFrom: Gao Xiang <[email protected]>
Check stripe numbers in calc_stripe_factors() by
using xfs_validate_stripe_factors().
--- mkfs/xfs_mkfs.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
mkfs/xfs_mkfs.c +7 -16
@@ -2289,12 +2289,6 @@ _("both data su and data sw options must be specified\n"));usage (); } -if (dsu % cfg->sectorsize) { -fprintf (stderr, -_ ("data su must be a multiple of the sector size (%d)\n" ), cfg->sectorsize); -usage (); - } - dsunit = (int )BTOBBT (dsu); big_dswidth = (long long int )dsunit * dsw;if (big_dswidth >INT_MAX ) {
@@ -2306,13 +2300,9 @@ _("data stripe width (%lld) is too large of a multiple of the data stripe unit ( dswidth = big_dswidth; } -if ((dsunit && !dswidth) || (!dsunit && dswidth) || - (dsunit && (dswidth % dsunit !=0 ))) { -fprintf (stderr, -_ ("data stripe width (%d) must be a multiple of the data stripe unit (%d)\n" ), - dswidth, dsunit); +if (!xfs_validate_stripe_factors (NULL ,BBTOB (dsunit),BBTOB (dswidth), + cfg->sectorsize))usage (); - }/* If sunit & swidth were manually specified as 0, same as noalign */ if ((cli_opt_set(&dopts, D_SUNIT) || cli_opt_set(&dopts, D_SU)) &&
@@ -2328,11 +2318,12 @@ _("data stripe width (%d) must be a multiple of the data stripe unit (%d)\n"),/* if no stripe config set, use the device default */ if (!dsunit) { -/* Ignore nonsense from device. XXX add more validation */ -if (ft->dsunit && ft->dswidth ==0 ) { +/* Ignore nonsense from device report. */ +if (!xfs_validate_stripe_factors (NULL , ft->dsunit, + ft->dswidth,0 )) {fprintf (stderr, -_ ("%s: Volume reports stripe unit of %d bytes and stripe width of 0, ignoring.\n" ), - progname,BBTOB (ft->dsunit)); +_ ("%s: Volume reports invalid stripe unit (%d) and stripe width (%d), ignoring.\n" ), + progname,BBTOB (ft->dsunit),BBTOB (ft->dswidth)); ft->dsunit =0 ; ft->dswidth =0 ; }else {
Signature · 1 line
2.24.0
Re: [PATCH v4 3/3] xfsprogs: make use of xfs_validate_stripe_factors()
Quoted 28 lines · Gao Xiang
From: Gao Xiang <[email protected]>
Check stripe numbers in
calc_stripe_factors()by
usingxfs_validate_stripe_factors().Signed-off-by Gao Xiang <[email protected]>--- mkfs/xfs_mkfs.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)mkfs/xfs_mkfs.c +0
-6@@ -2289,12 +2289,6 @@ _("both data su and data sw options must be specified\n"));usage (); } -if (dsu % cfg->sectorsize) { -fprintf (stderr, -_ ("data su must be a multiple of the sector size (%d)\n" ), cfg->sectorsize); -usage (); - } - dsunit = (int )BTOBBT (dsu); big_dswidth = (long long int )dsunit * dsw;if (big_dswidth >INT_MAX ) {
mkfs/xfs_mkfs.c _("data stripe width (%lld) is too large of a multiple of the data stripe unit ( · line 2303
Quoted 9 lines
mkfs/xfs_mkfs.c +1
-5@@ -2306,13 +2300,9 @@ _("data stripe width (%lld) is too large of a multiple of the data stripe unit ( dswidth = big_dswidth; } -if ((dsunit && !dswidth) || (!dsunit && dswidth) || - (dsunit && (dswidth % dsunit !=0 ))) { -fprintf (stderr, -_ ("data stripe width (%d) must be a multiple of the data stripe unit (%d)\n" ), - dswidth, dsunit); + if (!xfs_validate_stripe_factors(NULL, BBTOB(dsunit), BBTOB(dswidth),
if (!libxfs_validate_stripe_factors(...))
Unless we get rid of the weird libxfs macro thing, you're supposed to use prefixes in userspace.
--D
Quoted 26 lines
mkfs/xfs_mkfs.c +6
-5+ cfg->sectorsize))usage (); - }/* If sunit & swidth were manually specified as 0, same as noalign */ if ((cli_opt_set(&dopts, D_SUNIT) || cli_opt_set(&dopts, D_SU)) &&@@ -2328,11 +2318,12 @@ _("data stripe width (%d) must be a multiple of the data stripe unit (%d)\n"),/* if no stripe config set, use the device default */ if (!dsunit) { -/* Ignore nonsense from device. XXX add more validation */ -if (ft->dsunit && ft->dswidth ==0 ) { +/* Ignore nonsense from device report. */ +if (!xfs_validate_stripe_factors (NULL , ft->dsunit, + ft->dswidth,0 )) {fprintf (stderr, -_ ("%s: Volume reports stripe unit of %d bytes and stripe width of 0, ignoring.\n" ), - progname,BBTOB (ft->dsunit)); +_ ("%s: Volume reports invalid stripe unit (%d) and stripe width (%d), ignoring.\n" ), + progname,BBTOB (ft->dsunit),BBTOB (ft->dswidth)); ft->dsunit =0 ; ft->dswidth =0 ; }else {Signature · 1 line
2.24.0
Re: [PATCH v4 3/3] xfsprogs: make use of xfs_validate_stripe_factors()
Quoted 41 lines · Darrick J. Wong
Quoted 28 lines · Gao Xiang
From: Gao Xiang <[email protected]>
Check stripe numbers in
calc_stripe_factors()by
usingxfs_validate_stripe_factors().Signed-off-by Gao Xiang <[email protected]>--- mkfs/xfs_mkfs.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)mkfs/xfs_mkfs.c +0
-6@@ -2289,12 +2289,6 @@ _("both data su and data sw options must be specified\n"));usage (); } -if (dsu % cfg->sectorsize) { -fprintf (stderr, -_ ("data su must be a multiple of the sector size (%d)\n" ), cfg->sectorsize); -usage (); - } - dsunit = (int )BTOBBT (dsu); big_dswidth = (long long int )dsunit * dsw;if (big_dswidth >INT_MAX ) {mkfs/xfs_mkfs.c _("data stripe width (%lld) is too large of a multiple of the data stripe unit ( · line 2303
Quoted 9 lines
mkfs/xfs_mkfs.c +1
-5@@ -2306,13 +2300,9 @@ _("data stripe width (%lld) is too large of a multiple of the data stripe unit ( dswidth = big_dswidth; } -if ((dsunit && !dswidth) || (!dsunit && dswidth) || - (dsunit && (dswidth % dsunit !=0 ))) { -fprintf (stderr, -_ ("data stripe width (%d) must be a multiple of the data stripe unit (%d)\n" ), - dswidth, dsunit); + if (!xfs_validate_stripe_factors(NULL, BBTOB(dsunit), BBTOB(dswidth),if (!libxfs_validate_stripe_factors(...))
Quoted 2 lines
Unless we get rid of the weird libxfs macro thing, you're supposed to use prefixes in userspace.
I vaguely remembered Christoph sent out a patch intending to get rid of xfsprogs libxfs_ prefix months ago, so I assumed there was no need to introduce any new libxfs_ userspace API wrappers anymore.
But yeah, will add such libxfs_ marco wrapper in the next version.
Thanks,
Gao Xiang
Quoted 2 lines
--D
Re: [PATCH v4 3/3] xfsprogs: make use of xfs_validate_stripe_factors()
Quoted 5 lines · Gao Xiang
Quoted 2 lines
Unless we get rid of the weird libxfs macro thing, you're supposed to use prefixes in userspace.
I vaguely remembered Christoph sent out a patch intending to get rid of xfsprogs
libxfs_prefix months ago, so I assumed there was no need to introduce any newlibxfs_userspace API wrappers anymore.
He did, and it's on my (perpetual) TODO list to get that finally reviewed, sorry.
For now we still have libxfs*
-Eric
Quoted 5 lines
But yeah, will add such
libxfs_marco wrapper in the next version.Thanks,
Gao Xiang
Re: [PATCH v4 3/3] xfsprogs: make use of xfs_validate_stripe_factors()
Quoted 11 lines · Eric Sandeen
Quoted 5 lines · Gao Xiang
Quoted 2 lines
Unless we get rid of the weird libxfs macro thing, you're supposed to use prefixes in userspace.
I vaguely remembered Christoph sent out a patch intending to get rid of xfsprogs
libxfs_prefix months ago, so I assumed there was no need to introduce any newlibxfs_userspace API wrappers anymore.He did, and it's on my (perpetual) TODO list to get that finally reviewed, sorry.
For now we still have libxfs*
Yeah, I've sent out the next version with libxfs_ prefix at
https://lore.kernel.org/r/[email protected]
Thanks for the information as well!
Thanks,
Gao Xiang
Quoted 9 lines
-Eric
Quoted 5 lines
But yeah, will add such
libxfs_marco wrapper in the next version.Thanks,
Gao Xiang