XFS_SB_VERSION_ATTRBIT);
error++;
}
- if ((sbversion & XFS_SB_VERSION_NLINKBIT) &&
- !xfs_sb_version_hasnlink(&mp->m_sb)) {
- if (!sflag)
- dbprintf(_("sb versionnum missing nlink bit %x\n"),
- XFS_SB_VERSION_NLINKBIT);
- error++;
- }
if ((sbversion & XFS_SB_VERSION_QUOTABIT) &&
!xfs_sb_version_hasquota(&mp->m_sb)) {
if (!sflag)
else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5)
strcpy(s, "V5");
+ /*
+ * We assume the state of these features now, so macros don't exist for
+ * them any more.
+ */
+ if (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT)
+ strcat(s, ",NLINK");
+ if (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT)
+ strcat(s, ",SHARED");
+ if (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)
+ strcat(s, ",DIRV2");
+
if (xfs_sb_version_hasattr(sbp))
strcat(s, ",ATTR");
- if (xfs_sb_version_hasnlink(sbp))
- strcat(s, ",NLINK");
if (xfs_sb_version_hasquota(sbp))
strcat(s, ",QUOTA");
if (xfs_sb_version_hasalign(sbp))
strcat(s, ",ALIGN");
if (xfs_sb_version_hasdalign(sbp))
strcat(s, ",DALIGN");
- if (xfs_sb_version_hasshared(sbp))
- strcat(s, ",SHARED");
- if (xfs_sb_version_hasdirv2(sbp))
- strcat(s, ",DIRV2");
if (xfs_sb_version_haslogv2(sbp))
strcat(s, ",LOGV2");
if (xfs_sb_version_hasextflgbit(sbp))
else if (xfs_sb_version_hassector(sb))
size = offsetof(xfs_sb_t, sb_logsectsize)
+ sizeof(sb->sb_logsectsize);
- else if (xfs_sb_version_hasdirv2(sb))
+ else /* only support dirv2 or more recent */
size = offsetof(xfs_sb_t, sb_dirblklog)
+ sizeof(sb->sb_dirblklog);
- else
- size = offsetof(xfs_sb_t, sb_width)
- + sizeof(sb->sb_width);
/* Check the buffer we read from disk for garbage outside size */
for (ip = XFS_BUF_PTR(sbuf) + size;
if (sb->sb_flags) {
if (!no_modify)
sb->sb_flags = 0;
- if (sb->sb_versionnum & XR_PART_SECSB_VNMASK || !do_bzero) {
+ if (!do_bzero) {
rval |= XR_AG_SB;
do_warn(_("bad flags field in superblock %d\n"), i);
} else
if (sb->sb_inprogress == 1 && sb->sb_uquotino != NULLFSINO) {
if (!no_modify)
sb->sb_uquotino = 0;
- if (sb->sb_versionnum & XR_PART_SECSB_VNMASK || !do_bzero) {
+ if (!do_bzero) {
rval |= XR_AG_SB;
do_warn(
_("non-null user quota inode field in superblock %d\n"),
sb->sb_gquotino = 0;
dsb->sb_gquotino = 0;
}
- if (sb->sb_versionnum & XR_PART_SECSB_VNMASK || !do_bzero) {
+ if (!do_bzero) {
rval |= XR_AG_SB;
do_warn(
_("non-null group quota inode field in superblock %d\n"),
sb->sb_pquotino = 0;
dsb->sb_pquotino = 0;
}
- if (sb->sb_versionnum & XR_PART_SECSB_VNMASK || !do_bzero) {
+ if (!do_bzero) {
rval |= XR_AG_SB;
do_warn(
_("non-null project quota inode field in superblock %d\n"),
if (sb->sb_inprogress == 1 && sb->sb_qflags) {
if (!no_modify)
sb->sb_qflags = 0;
- if (sb->sb_versionnum & XR_PART_SECSB_VNMASK || !do_bzero) {
+ if (!do_bzero) {
rval |= XR_AG_SB;
do_warn(_("non-null quota flags in superblock %d\n"),
i);
* written at mkfs time (and the corresponding sb version bits
* are set).
*/
- if (!xfs_sb_version_hasshared(sb) && sb->sb_shared_vn != 0) {
- if (!no_modify)
- sb->sb_shared_vn = 0;
- if (sb->sb_versionnum & XR_PART_SECSB_VNMASK || !do_bzero) {
- rval |= XR_AG_SB;
- do_warn(
- _("bad shared version number in superblock %d\n"),
- i);
- } else
- rval |= XR_AG_SB_SEC;
- }
-
if (!xfs_sb_version_hasalign(sb) && sb->sb_inoalignmt != 0) {
if (!no_modify)
sb->sb_inoalignmt = 0;
- if (sb->sb_versionnum & XR_PART_SECSB_VNMASK || !do_bzero) {
+ if (!do_bzero) {
rval |= XR_AG_SB;
do_warn(
_("bad inode alignment field in superblock %d\n"),
(sb->sb_unit != 0 || sb->sb_width != 0)) {
if (!no_modify)
sb->sb_unit = sb->sb_width = 0;
- if (sb->sb_versionnum & XR_GOOD_SECSB_VNMASK || !do_bzero) {
+ if (!do_bzero) {
rval |= XR_AG_SB;
do_warn(
_("bad stripe unit/width fields in superblock %d\n"),
sb->sb_logsectsize = 0;
sb->sb_logsectlog = 0;
}
- if (sb->sb_versionnum & XR_GOOD_SECSB_VNMASK || !do_bzero) {
+ if (!do_bzero) {
rval |= XR_AG_SB;
do_warn(
_("bad log/data device sector size fields in superblock %d\n"),
dinoc->di_magic = cpu_to_be16(XFS_DINODE_MAGIC);
}
- if (!XFS_DINODE_GOOD_VERSION(dinoc->di_version) ||
- (!fs_inode_nlink && dinoc->di_version > 1)) {
+ if (!XFS_DINODE_GOOD_VERSION(dinoc->di_version)) {
__dirty_no_modify_ret(dirty);
if (xfs_sb_version_hascrc(&mp->m_sb))
dinoc->di_version = 3;
else
- dinoc->di_version = (fs_inode_nlink) ? 2 : 1;
+ dinoc->di_version = 2;
}
if (be16_to_cpu(dinoc->di_mode) != 0) {
{
int dirty = 0;
- if (dino->di_version > 1 && !fs_inode_nlink) {
- /*
- * do we have a fs/inode version mismatch with a valid
- * version 2 inode here that has to stay version 2 or
- * lose links?
- */
- if (be32_to_cpu(dino->di_nlink) > XFS_MAXLINK_1) {
- /*
- * yes. are nlink inodes allowed?
- */
- if (fs_inode_nlink_allowed) {
- /*
- * yes, update status variable which will
- * cause sb to be updated later.
- */
- fs_inode_nlink = 1;
- do_warn
- (_("version 2 inode %" PRIu64 " claims > %u links, "),
- lino, XFS_MAXLINK_1);
- if (!no_modify) {
- do_warn(
- _("updating superblock version number\n"));
- } else {
- do_warn(
- _("would update superblock version number\n"));
- }
- } else {
- /*
- * no, have to convert back to onlinks
- * even if we lose some links
- */
- do_warn(
- _("WARNING: version 2 inode %" PRIu64 " claims > %u links, "),
- lino, XFS_MAXLINK_1);
- if (!no_modify) {
- do_warn(_("converting back to version 1,\n"
- "this may destroy %d links\n"),
- be32_to_cpu(dino->di_nlink) -
- XFS_MAXLINK_1);
-
- dino->di_version = 1;
- dino->di_nlink = cpu_to_be32(XFS_MAXLINK_1);
- dino->di_onlink = cpu_to_be16(XFS_MAXLINK_1);
- dirty = 1;
- } else {
- do_warn(_("would convert back to version 1,\n"
- "\tthis might destroy %d links\n"),
- be32_to_cpu(dino->di_nlink) -
- XFS_MAXLINK_1);
- }
- }
- } else {
- /*
- * do we have a v2 inode that we could convert back
- * to v1 without losing any links? if we do and
- * we have a mismatch between superblock bits and the
- * version bit, alter the version bit in this case.
- *
- * the case where we lost links was handled above.
- */
- do_warn(_("found version 2 inode %" PRIu64 ", "), lino);
- if (!no_modify) {
- do_warn(_("converting back to version 1\n"));
- dino->di_version = 1;
- dino->di_onlink = cpu_to_be16(
- be32_to_cpu(dino->di_nlink));
- dirty = 1;
- } else {
- do_warn(_("would convert back to version 1\n"));
- }
- }
- }
-
/*
- * ok, if it's still a version 2 inode, it's going
- * to stay a version 2 inode. it should have a zero
+ * if it's a version 2 inode, it should have a zero
* onlink field, so clear it.
*/
- if (dino->di_version > 1 &&
- dino->di_onlink != 0 && fs_inode_nlink > 0) {
+ if (dino->di_version > 1 && dino->di_onlink != 0) {
if (!no_modify) {
do_warn(
_("clearing obsolete nlink field in version 2 inode %" PRIu64 ", was %d, now 0\n"),
}
if (!XFS_DINODE_GOOD_VERSION(dino->di_version) ||
- (!fs_inode_nlink && dino->di_version > 1) ||
(xfs_sb_version_hascrc(&mp->m_sb) && dino->di_version < 3) ) {
retval = 1;
if (!uncertain)
if (!no_modify) {
do_warn(_(" resetting version number\n"));
dino->di_version =
- xfs_sb_version_hascrc(&mp->m_sb) ? 3 :
- (fs_inode_nlink) ? 2 : 1;
+ xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
*dirty = 1;
} else
do_warn(_(" would reset version number\n"));
#define NUM_AGH_SECTS 4 /* # of components in an ag header */
-/*
- * secondary sb mask -- if the secondary sb feature bits has a
- * the partial sb mask bit set, then you depend on the fields
- * in it up to and including sb_inoalignmt but the unused part of the
- * sector may have trash in it. If the sb has any bits set that are in
- * the good mask, then the entire sb and sector are good (was zero'ed
- * by mkfs). The third mask is for filesystems made by pre-6.5 campus
- * alpha mkfs's. Those are rare so we'll check for those under
- * a special option.
- */
-#define XR_PART_SECSB_VNMASK 0x0F80 /* >= XFS_SB_VERSION_ALIGNBIT */
-#define XR_GOOD_SECSB_VNMASK 0x0F00 /* >= XFS_SB_VERSION_DALIGNBIT */
-#define XR_ALPHA_SECSB_VNMASK 0x0180 /* DALIGN|ALIGN bits */
-
/* global variables for xfs_repair */
/* arguments and argument flag variables */
int vers;
int times;
- ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb));
-
tp = libxfs_trans_alloc(mp, 0);
ip = NULL;
/*
* take care of the core -- initialization from xfs_ialloc()
*/
- vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 1;
+ vers = xfs_sb_version_hascrc(&mp->m_sb) ? 3 : 2;
memset(&ip->i_d, 0, xfs_icdinode_size(vers));
ip->i_d.di_magic = XFS_DINODE_MAGIC;
int nres;
struct xfs_name xname;
- ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb));
-
/*
* check for an existing lost+found first, if it exists, return
* its inode. Otherwise, we can create it. Bad lost+found inodes
int ino_offset = 0;
struct xfs_name xname;
- ASSERT(xfs_sb_version_hasdirv2(&mp->m_sb));
-
xname.name = fname;
xname.len = snprintf((char *)fname, sizeof(fname), "%llu",
(unsigned long long)ino);
do_warn(_("resetting inode %" PRIu64 " nlinks from %u to %u\n"),
ino, dinoc->di_nlink, nrefs);
- if (dinoc->di_version == 1 && nrefs > XFS_MAXLINK_1) {
- ASSERT(fs_inode_nlink);
- do_warn(
-_("nlinks %u will overflow v1 ino, ino %" PRIu64 " will be converted to version 2\n"),
- nrefs, ino);
-
- }
+ ASSERT(dinoc->di_version > 1);
dinoc->di_nlink = nrefs;
} else {
do_warn(
if (be16_to_cpu(dino->di_magic) != XFS_DINODE_MAGIC)
continue;
- if (!XFS_DINODE_GOOD_VERSION(dino->di_version) ||
- (!fs_inode_nlink && dino->di_version > 1))
+ if (!XFS_DINODE_GOOD_VERSION(dino->di_version))
continue;
if (be64_to_cpu(dino->di_size) <= XFS_DFORK_DSIZE(dino, mp))
return(XR_BAD_SB_WIDTH);
}
- /*
- * if shared bit is set, verify that the version number is sane
- */
- if (xfs_sb_version_hasshared(sb)) {
- if (sb->sb_shared_vn > XFS_SB_MAX_SHARED_VN)
- return(XR_BAD_SVN);
- }
-
- /*
- * mkfs's that stamped a feature bit besides the ones in the
- * mask below could leave garbage in the secondary superblock
- * sectors. Anything stamping the shared fs bit or better into
- * the secondaries is ok and should generate clean secondary
- * superblock sectors.
- *
- * check primary and clean secondary superblocks more strictly
- */
- if (is_primary_sb || sb->sb_versionnum & XR_PART_SECSB_VNMASK) {
- /*
- * return errors if shared vn or alignment fields
- * are set without their feature bits being set
- */
- if ((!pre_65_beta && (sb->sb_versionnum & XR_PART_SECSB_VNMASK)) ||
- (pre_65_beta && (sb->sb_versionnum & XR_ALPHA_SECSB_VNMASK))) {
- /*
- * shared version # and inode alignment fields
- * should be valid
- */
- if (sb->sb_shared_vn && !xfs_sb_version_hasshared(sb))
- return(XR_BAD_SVN);
- if (sb->sb_inoalignmt && !xfs_sb_version_hasalign(sb))
- return(XR_BAD_INO_ALIGN);
- }
- if ((!pre_65_beta &&
- (sb->sb_versionnum & XR_GOOD_SECSB_VNMASK)) ||
- (pre_65_beta &&
- (sb->sb_versionnum & XFS_SB_VERSION_DALIGNBIT))) {
- /*
- * stripe alignment values should be valid
- */
- if (sb->sb_unit && !xfs_sb_version_hasdalign(sb))
- return(XR_BAD_SB_UNIT);
- if (sb->sb_width && !xfs_sb_version_hasdalign(sb))
- return(XR_BAD_SB_WIDTH);
- }
-
-#if 0
- /*
- * checks involving later superblock fields get added here...
- */
- if (sb->sb_versionnum & XR_GOOD_SECSB_VNMASK) {
- }
-#endif
- }
-
return(XR_OK);
}
if (xfs_sb_version_hasalign(sbp))
geo->sb_ialignbit = 1;
- if (xfs_sb_version_hasshared(sbp) ||
- sbp->sb_versionnum & XR_PART_SECSB_VNMASK)
- geo->sb_sharedbit = 1;
-
if (xfs_sb_version_hasdalign(sbp))
geo->sb_salignbit = 1;
if (xfs_sb_version_hasextflgbit(sbp))
geo->sb_extflgbit = 1;
- /*
- * protect against pre-6.5 mkfs-generated garbaged
- * fields in the secondary superblocks. pay attention
- * to those fields if and only if their corresponding
- * feature bits are set in the feature bits of the
- * version number or we can deduce from the version bits
- * that are set that our field was properly initialized
- * because a field after the field we care about was
- * properly initialized as well.
- */
-
- /*
- * inode alignment field lives before the data alignment field
- */
- if ((!pre_65_beta && (sbp->sb_versionnum & XR_PART_SECSB_VNMASK)) ||
- (pre_65_beta && (sbp->sb_versionnum & XR_ALPHA_SECSB_VNMASK)))
- geo->sb_inoalignmt = sbp->sb_inoalignmt;
-
- if ((!pre_65_beta && (sbp->sb_versionnum & XR_GOOD_SECSB_VNMASK)) ||
- (pre_65_beta && xfs_sb_version_hasdalign(sbp))) {
- geo->sb_unit = sbp->sb_unit;
- geo->sb_width = sbp->sb_width;
- }
-
- /*
- * shared vn always set if either ino or data alignment is on
- * since that field lives between the quota and inode alignment
- * fields
- */
- if (sbp->sb_versionnum & XR_PART_SECSB_VNMASK)
- geo->sb_shared_vn = sbp->sb_shared_vn;
-
- /*
- * superblock fields located after sb_widthfields get set
- * into the geometry structure only if we can determine
- * from the features enabled in this superblock whether
- * or not the sector was zero'd at mkfs time.
- */
- if ((!pre_65_beta && (sbp->sb_versionnum & XR_GOOD_SECSB_VNMASK)) ||
- (pre_65_beta && (sbp->sb_versionnum & XR_ALPHA_SECSB_VNMASK))) {
- geo->sb_fully_zeroed = 1;
- }
+ geo->sb_fully_zeroed = 1;
}
/*
update_sb_version(xfs_mount_t *mp)
{
xfs_sb_t *sb;
- __uint16_t vn;
sb = &mp->m_sb;
xfs_sb_version_addattr2(sb);
}
- if (fs_inode_nlink && !xfs_sb_version_hasnlink(sb)) {
- ASSERT(fs_inode_nlink_allowed);
- xfs_sb_version_addnlink(sb);
- }
+ /* V2 inode conversion is now always going to happen */
+ if (!(sb->sb_versionnum & XFS_SB_VERSION_NLINKBIT))
+ sb->sb_versionnum |= XFS_SB_VERSION_NLINKBIT;
/*
* fix up the superblock version number and feature bits,
if (xfs_sb_version_hasquota(sb)) {
lost_quotas = 1;
- vn = sb->sb_versionnum;
- vn &= ~XFS_SB_VERSION_QUOTABIT;
-
- if (!(vn & XFS_SB_VERSION_ALLFBITS))
- vn = xfs_sb_version_toold(vn);
-
- ASSERT(vn != 0);
- sb->sb_versionnum = vn;
+ sb->sb_versionnum &= ~XFS_SB_VERSION_QUOTABIT;
}
}
fs_attributes = 0;
fs_attributes2 = 0;
- fs_inode_nlink = 0;
+ fs_inode_nlink = 1;
fs_quotas = 0;
fs_aligned_inodes = 0;
fs_sb_feature_bits = 0;
have_pquotino = 0;
issue_warning = 0;
+ if (sb->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) {
+ do_warn(_("Shared Version bit set. Not supported. Ever.\n"));
+ return 1;
+ }
+
+ if (sb->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) {
+ do_warn(_("Shared Version bit set. Not supported. Ever.\n"));
+ return 1;
+ }
+
/*
* ok, check to make sure that the sb isn't newer
* than we are
}
}
- if (xfs_sb_version_hasshared(sb)) {
- fs_shared = 1;
- if (!fs_shared_allowed) {
- issue_warning = 1;
- do_warn(_("This filesystem is marked shared.\n"));
- }
- }
-
if (issue_warning) {
do_warn(
_("This filesystem uses feature(s) not yet supported in this release.\n"
}
}
- if (xfs_sb_version_hasnlink(sb)) {
- if (!fs_inode_nlink_allowed) {
- if (!no_modify) {
- do_warn(
-_("WARNING: you have disallowed version 2 inodes but this filesystem\n"
- "\thas version 2 inodes. The filesystem will be downgraded and\n"
- "\tall version 2 inodes will be converted to version 1 inodes.\n"
- "\tThis may cause some hard links to files to be destroyed\n"));
- } else {
- do_warn(
-_("WARNING: you have disallowed version 2 inodes but this filesystem\n"
- "\thas version 2 inodes. The filesystem would be downgraded and\n"
- "\tall version 2 inodes would be converted to version 1 inodes.\n"
- "\tThis might cause some hard links to files to be destroyed\n"));
- }
- } else {
- fs_inode_nlink = 1;
- }
+ if (!(sb->sb_versionnum & XFS_SB_VERSION_NLINKBIT)) {
+ do_warn(
+_("WARNING: you have a V1 inode filesystem. It %s be converted to a\n"
+ "\tversion 2 inode filesystem. If you do not want this, run an older\n"
+ "\tversion of xfs_repair.\n"), no_modify ? "would" : "will");
}
if (xfs_sb_version_hasquota(sb)) {
EXTERN int fs_attributes_allowed;
EXTERN int fs_attributes2_allowed;
-EXTERN int fs_inode_nlink_allowed;
EXTERN int fs_quotas_allowed;
EXTERN int fs_aligned_inodes_allowed;
EXTERN int fs_sb_feature_bits_allowed;
sb_width = 0;
fs_attributes_allowed = 1;
fs_attributes2_allowed = 1;
- fs_inode_nlink_allowed = 1;
fs_quotas_allowed = 1;
fs_aligned_inodes_allowed = 1;
fs_sb_feature_bits_allowed = 1;