+// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
* All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "libxfs.h"
int
sb_logcheck(void)
{
- struct xlog log;
int dirty;
if (mp->m_sb.sb_logstart) {
libxfs_buftarg_init(mp, x.ddev, x.logdev, x.rtdev);
- dirty = xlog_is_dirty(mp, &log, &x, 0);
+ dirty = xlog_is_dirty(mp, mp->m_log, &x, 0);
if (dirty == -1) {
dbprintf(_("ERROR: cannot find log head/tail, run xfs_repair\n"));
return 0;
static int
sb_logzero(uuid_t *uuidp)
{
+ int cycle = XLOG_INIT_CYCLE;
+ int error;
+
if (!sb_logcheck())
return 0;
+ /*
+ * The log must always move forward on v5 superblocks. Bump it to the
+ * next cycle.
+ */
+ if (xfs_sb_version_hascrc(&mp->m_sb))
+ cycle = mp->m_log->l_curr_cycle + 1;
+
dbprintf(_("Clearing log and setting UUID\n"));
- if (libxfs_log_clear(mp->m_logdev_targp,
+ error = libxfs_log_clear(mp->m_logdev_targp, NULL,
XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
(xfs_extlen_t)XFS_FSB_TO_BB(mp, mp->m_sb.sb_logblocks),
uuidp,
xfs_sb_version_haslogv2(&mp->m_sb) ? 2 : 1,
- mp->m_sb.sb_logsunit, XLOG_FMT, XLOG_INIT_CYCLE)) {
+ mp->m_sb.sb_logsunit, XLOG_FMT, cycle, true);
+ if (error) {
dbprintf(_("ERROR: cannot clear the log\n"));
return 0;
}
+
return 1;
}
/* Not set; nothing to do. Success! */
if (!xfs_sb_version_hasmetauuid(&tsb))
return 0;
-
+
memcpy(&uu, mp->m_sb.sb_meta_uuid, sizeof(uuid_t));
} else {
if (platform_uuid_parse(argv[1], &uu)) {
}
static int
-do_version(xfs_agnumber_t agno, __uint16_t version, __uint32_t features)
+do_version(xfs_agnumber_t agno, uint16_t version, uint32_t features)
{
xfs_sb_t tsb;
strcat(s, ",DALIGN");
if (xfs_sb_version_haslogv2(sbp))
strcat(s, ",LOGV2");
- if (xfs_sb_version_hasextflgbit(sbp))
+ /* This feature is required now as well */
+ if (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT)
strcat(s, ",EXTFLG");
if (xfs_sb_version_hassector(sbp))
strcat(s, ",SECTOR");
strcat(s, ",SPARSE_INODES");
if (xfs_sb_version_hasmetauuid(sbp))
strcat(s, ",META_UUID");
+ if (xfs_sb_version_hasrmapbt(sbp))
+ strcat(s, ",RMAPBT");
+ if (xfs_sb_version_hasreflink(sbp))
+ strcat(s, ",REFLINK");
return s;
}
int argc,
char **argv)
{
- __uint16_t version = 0;
- __uint32_t features = 0;
+ uint16_t version = 0;
+ uint32_t features = 0;
xfs_agnumber_t ag;
if (argc == 2) { /* WRITE VERSION */
version = 0x0034 | XFS_SB_VERSION_EXTFLGBIT;
break;
case XFS_SB_VERSION_4:
- if (xfs_sb_version_hasextflgbit(&mp->m_sb))
+ if (mp->m_sb.sb_versionnum &
+ XFS_SB_VERSION_EXTFLGBIT)
dbprintf(
_("unwritten extents flag is already enabled\n"));
else