usage();
}
- if (dsu % cfg->sectorsize) {
+ big_dswidth = (long long int)dsu * dsw;
+ if (BTOBBT(big_dswidth) > INT_MAX) {
fprintf(stderr,
-_("data su must be a multiple of the sector size (%d)\n"), cfg->sectorsize);
+_("data stripe width (%lld) is too large of a multiple of the data stripe unit (%d)\n"),
+ big_dswidth, dsu);
usage();
}
- dsunit = (int)BTOBBT(dsu);
- big_dswidth = (long long int)dsunit * dsw;
- if (big_dswidth > INT_MAX) {
- fprintf(stderr,
-_("data stripe width (%lld) is too large of a multiple of the data stripe unit (%d)\n"),
- big_dswidth, dsunit);
+ if (!libxfs_validate_stripe_geometry(NULL, dsu, big_dswidth,
+ cfg->sectorsize, false))
usage();
- }
- 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);
+ dsunit = BTOBBT(dsu);
+ dswidth = BTOBBT(big_dswidth);
+ } else if (!libxfs_validate_stripe_geometry(NULL, BBTOB(dsunit),
+ BBTOB(dswidth), cfg->sectorsize, false)) {
usage();
}
/* 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 (!libxfs_validate_stripe_geometry(NULL, BBTOB(ft->dsunit),
+ BBTOB(ft->dswidth), 0, true)) {
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 {