#ifdef CONFIG_QUOTA
EXT4_FEATURE_RO_COMPAT_QUOTA |
#endif
- EXT4_FEATURE_RO_COMPAT_GDT_CSUM
+ EXT4_FEATURE_RO_COMPAT_METADATA_CSUM
};
+ /**
+ * Try to get journal super block if any
+ */
+ static int get_journal_sb(ext2_filsys jfs, char buf[SUPERBLOCK_SIZE])
+ {
+ int retval;
+ int start;
+ journal_superblock_t *jsb;
+
+ if (!(jfs->super->s_feature_incompat &
+ EXT3_FEATURE_INCOMPAT_JOURNAL_DEV)) {
+ return EXT2_ET_UNSUPP_FEATURE;
+ }
+
+ /* Get the journal superblock */
+ if ((retval = io_channel_read_blk64(jfs->io,
+ ext2fs_journal_sb_start(jfs->blocksize), -SUPERBLOCK_SIZE, buf))) {
+ com_err(program_name, retval, "%s",
+ _("while reading journal superblock"));
+ return retval;
+ }
+
+ jsb = (journal_superblock_t *) buf;
+ if ((jsb->s_header.h_magic != (unsigned)ntohl(JFS_MAGIC_NUMBER)) ||
+ (jsb->s_header.h_blocktype != (unsigned)ntohl(JFS_SUPERBLOCK_V2))) {
+ fputs(_("Journal superblock not found!\n"), stderr);
+ return EXT2_ET_BAD_MAGIC;
+ }
+
+ return 0;
+ }
+
+ static void *
+ journal_user(char uuid[UUID_SIZE], char s_users[JFS_USERS_SIZE], int nr_users)
+ {
+ int i;
+ for (i = 0; i < nr_users; i++) {
+ if (memcmp(uuid, &s_users[i * UUID_SIZE], UUID_SIZE) == 0)
+ return &s_users[i * UUID_SIZE];
+ }
+
+ return NULL;
+ }
+
/*
* Remove an external journal from the filesystem
*/
if (U_flag) {
int set_csum = 0;
dgrp_t i;
+ char buf[SUPERBLOCK_SIZE];
+ char old_uuid[UUID_SIZE];
- if (sb->s_feature_ro_compat &
- EXT4_FEATURE_RO_COMPAT_GDT_CSUM) {
+ if (ext2fs_has_group_desc_csum(fs)) {
/*
* Changing the UUID requires rewriting all metadata,
* which can race with a mounted fs. Don't allow that.
ext2fs_group_desc_csum_set(fs, i);
fs->flags &= ~EXT2_FLAG_SUPER_ONLY;
}
+
+ /* If this is a journal dev, we need to copy UUID into jsb */
+ if (!(rc = get_journal_sb(fs, buf))) {
+ journal_superblock_t *jsb;
+
+ jsb = (journal_superblock_t *) buf;
+ fputs(_("Need to update journal superblock.\n"), stdout);
+ memcpy(jsb->s_uuid, sb->s_uuid, sizeof(sb->s_uuid));
+
+ /* Writeback the journal superblock */
+ if ((rc = io_channel_write_blk64(fs->io,
+ ext2fs_journal_sb_start(fs->blocksize),
+ -SUPERBLOCK_SIZE, buf)))
+ goto closefs;
+ } else if (rc != EXT2_ET_UNSUPP_FEATURE)
+ goto closefs;
+ else {
+ rc = 0; /** Reset rc to avoid ext2fs_mmp_stop() */
+
+ if ((rc = fs_update_journal_user(sb, old_uuid)))
+ goto closefs;
+ }
+
ext2fs_mark_super_dirty(fs);
+ if (EXT2_HAS_RO_COMPAT_FEATURE(fs->super,
+ EXT4_FEATURE_RO_COMPAT_METADATA_CSUM))
+ rewrite_checksums = 1;
}
+ if (rewrite_checksums)
+ rewrite_metadata_checksums(fs);
if (I_flag) {
if (mount_flags & EXT2_MF_MOUNTED) {
fputs(_("The inode size may only be "