Exemplo n.º 1
0
static int set_journal_block64_run(struct tunefs_operation *op,
				ocfs2_filesys *fs, int flags)
{
	errcode_t err;
	int rc = 0;
	ocfs2_fs_options mask, options;
	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);

	memset(&mask, 0, sizeof(ocfs2_fs_options));
	memset(&options, 0, sizeof(ocfs2_fs_options));
	mask.opt_incompat |= JBD2_FEATURE_INCOMPAT_64BIT;
	options.opt_incompat |= JBD2_FEATURE_INCOMPAT_64BIT;

	if (!tools_interact("Enable block64 journal feature on device \"%s\"? ",
			    fs->fs_devname))
		goto out;

	tunefs_block_signals();
	super->s_feature_compat |= OCFS2_FEATURE_COMPAT_JBD2_SB;
	err = ocfs2_write_super(fs);
	if (!err)
		err = tunefs_set_journal_size(fs, 0, mask, options);
	tunefs_unblock_signals();
	if (err) {
		rc = 1;
		tcom_err(err,
			"; unable to enable block64 journal feature on "
			"device \"%s\"", fs->fs_devname);
	}

out:
	return rc;
}
Exemplo n.º 2
0
static int enable_backup_super(ocfs2_filesys *fs, int flags)
{
	errcode_t err = 0;
	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
	struct tools_progress *prog;

	if (OCFS2_HAS_COMPAT_FEATURE(super,
				     OCFS2_FEATURE_COMPAT_BACKUP_SB)) {
		verbosef(VL_APP,
			 "Backup superblock feature is already enabled; "
			 "nothing to enable\n");
		goto out;
	}

	if (!tools_interact("Enable the backup superblock feature on "
			    "device \"%s\"? ",
			    fs->fs_devname))
		goto out;

	prog = tools_progress_start("Enable backup-super", "backup-super",
				    2);
	if (!prog) {
		err = TUNEFS_ET_NO_MEMORY;
		tcom_err(err, "while initializing the progress display");
		goto out;
	}

	tunefs_block_signals();
	err = check_backup_offsets(fs);
	tools_progress_step(prog, 1);
	if (!err)
		err = fill_backup_supers(fs);
	if (!err) {
		super->s_feature_compat |= OCFS2_FEATURE_COMPAT_BACKUP_SB;
		err = ocfs2_write_super(fs);
		if (err)
			tcom_err(err, "while writing out the superblock\n");
	}
	tunefs_unblock_signals();

	tools_progress_step(prog, 1);
	tools_progress_stop(prog);

	if (err)
		errorf("Unable to enable the backup superblock feature on "
		       "device \"%s\"\n",
		       fs->fs_devname);
out:
	return err;
}
Exemplo n.º 3
0
static int disable_grpquota(ocfs2_filesys *fs, int flags)
{
	errcode_t ret;
	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
	struct tools_progress *prog = NULL;

	if (!OCFS2_HAS_RO_COMPAT_FEATURE(super,
	    OCFS2_FEATURE_RO_COMPAT_GRPQUOTA)) {
		verbosef(VL_APP, "Group quotas are already disabled; "
			 "nothing to disable\n");
		return 0;
	}

	if (!tools_interact("Disable group quota feature on device "
			    "\"%s\"? ",
			    fs->fs_devname))
		return 0;
	prog = tools_progress_start("Disabling user quota", "nousrquota", 2);
	if (!prog) {
		ret = TUNEFS_ET_NO_MEMORY;
		tcom_err(ret, "while initializing progress display");
		return ret;
	}

	tunefs_block_signals();
	ret = remove_quota_files(fs, GRPQUOTA, prog);
	if (ret) {
		tcom_err(ret, "while removing group quota files");
		goto bail;
	}
	OCFS2_CLEAR_RO_COMPAT_FEATURE(super,
				      OCFS2_FEATURE_RO_COMPAT_GRPQUOTA);
	ret = ocfs2_write_super(fs);
	tools_progress_step(prog, 1);
bail:
	tools_progress_stop(prog);
	tunefs_unblock_signals();
	return ret;
}
Exemplo n.º 4
0
static errcode_t cloned_volume(ocfs2_filesys *fs, const char *new_label)
{
	errcode_t err;
	struct tools_progress *prog;

	if (!tools_interact_critical(
		"Updating the UUID and label on cloned volume \"%s\".\n"
		"DANGER: THIS WILL MODIFY THE UUID WITHOUT ACCESSING THE "
		"CLUSTER SOFTWARE.  YOU MUST BE ABSOLUTELY SURE THAT NO "
		"OTHER NODE IS USING THIS FILESYSTEM BEFORE MODIFYING "
		"ITS UUID.\n"
	        "Update the UUID and label? ",
		fs->fs_devname))
		return 0;

	prog = tools_progress_start("Cloning volume", "cloning", 3);
	if (!prog) {
		err = TUNEFS_ET_NO_MEMORY;
		tcom_err(err, "while initializing the progress display");
		goto out;
	}

	update_volume_uuid(fs);
	tools_progress_step(prog, 1);

	update_volume_label(fs, new_label);
	tools_progress_step(prog, 1);

	tunefs_block_signals();
	err = ocfs2_write_super(fs);
	tunefs_unblock_signals();
	tools_progress_step(prog, 1);

	tools_progress_stop(prog);

out:
	return err;
}
Exemplo n.º 5
0
static errcode_t write_out_superblock(o2fsck_state *ost)
{
	struct ocfs2_dinode *di = ost->ost_fs->fs_super;
	struct ocfs2_super_block *sb = OCFS2_RAW_SB(di);

	if (sb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG)
		sb->s_feature_incompat &= ~OCFS2_FEATURE_INCOMPAT_RESIZE_INPROG;

	if (sb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG) {
		sb->s_feature_incompat &=
				 ~OCFS2_FEATURE_INCOMPAT_TUNEFS_INPROG;
		sb->s_tunefs_flag = 0;
	}

	if (ost->ost_num_clusters)
		di->i_clusters = ost->ost_num_clusters;

	sb->s_errors = ost->ost_saw_error;
	sb->s_lastcheck = time(NULL);
	sb->s_mnt_count = 0;

	return ocfs2_write_super(ost->ost_fs);
}
Exemplo n.º 6
0
static errcode_t remove_quota_files(ocfs2_filesys *fs, int type,
				    struct tools_progress *prog)
{
	struct remove_quota_files_ctxt ctxt = {
		.fs = fs,
		.type = type,
		.err = 0,
	};

	ocfs2_dir_iterate(fs, fs->fs_sysdir_blkno,
			  OCFS2_DIRENT_FLAG_EXCLUDE_DOTS, NULL,
			  remove_quota_files_iterate, &ctxt);
	tools_progress_step(prog, 1);
	return ctxt.err;
}

static int enable_usrquota(ocfs2_filesys *fs, int flags)
{
	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
	errcode_t ret;
	struct tools_progress *prog = NULL;

	if (OCFS2_HAS_RO_COMPAT_FEATURE(super,
	    OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
		verbosef(VL_APP, "User quotas are already enabled; "
			 "nothing to enable\n");
		return 0;
	}

	if (!tools_interact("Enable user quota feature on device "
			    "\"%s\"? ",
			    fs->fs_devname))
		return 0;

	prog = tools_progress_start("Enabling user quota", "usrquota", 6);
	if (!prog) {
		ret = TUNEFS_ET_NO_MEMORY;
		tcom_err(ret, "while initializing progress display");
		return ret;
	}
	tunefs_block_signals();
	ret = create_quota_files(fs, USRQUOTA, prog);
	if (ret) {
		tcom_err(ret, "while creating user quota files");
		goto bail;
	}
	OCFS2_SET_RO_COMPAT_FEATURE(super,
				    OCFS2_FEATURE_RO_COMPAT_USRQUOTA);
	ret = ocfs2_write_super(fs);
	tools_progress_step(prog, 1);
bail:
	tunefs_unblock_signals();
	tools_progress_stop(prog);
	return ret;
}

static int disable_usrquota(ocfs2_filesys *fs, int flags)
{
	errcode_t ret;
	struct ocfs2_super_block *super = OCFS2_RAW_SB(fs->fs_super);
	struct tools_progress *prog = NULL;

	if (!OCFS2_HAS_RO_COMPAT_FEATURE(super,
	    OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) {
		verbosef(VL_APP, "User quotas are already disabled; "
			 "nothing to disable\n");
		return 0;
	}

	if (!tools_interact("Disable user quota feature on device "
			    "\"%s\"? ",
			    fs->fs_devname))
		return 0;

	prog = tools_progress_start("Disabling user quota", "nousrquota", 2);
	if (!prog) {
		ret = TUNEFS_ET_NO_MEMORY;
		tcom_err(ret, "while initializing progress display");
		return ret;
	}
	tunefs_block_signals();
	ret = remove_quota_files(fs, USRQUOTA, prog);
	if (ret) {
		tcom_err(ret, "while removing user quota files");
		goto bail;
	}
	OCFS2_CLEAR_RO_COMPAT_FEATURE(super,
				      OCFS2_FEATURE_RO_COMPAT_USRQUOTA);
	ret = ocfs2_write_super(fs);
	tools_progress_step(prog, 1);
bail:
	tunefs_unblock_signals();
	tools_progress_stop(prog);
	return ret;
}
Exemplo n.º 7
0
static errcode_t update_slot_count(ocfs2_filesys *fs, int num_slots)
{
	errcode_t ret = 0;
	int orig_slots = OCFS2_RAW_SB(fs->fs_super)->s_max_slots;

	if (num_slots == orig_slots) {
		verbosef(VL_APP,
			 "Device \"%s\" already has %d node slots; "
			 "nothing to do\n",
			 fs->fs_devname, num_slots);
		goto out;
	}

	if (!tools_interact("Change the number of node slots on device "
			    "\"%s\" from %d to %d? ",
			    fs->fs_devname, orig_slots, num_slots))
		goto out;

	tunefs_block_signals();
	if (num_slots > orig_slots)
		ret = add_slots(fs, num_slots);
	else
		ret = remove_slots(fs, num_slots);
	if (ret)
		goto out_unblock;

	OCFS2_RAW_SB(fs->fs_super)->s_max_slots = num_slots;

	if (num_slots > orig_slots) {
		/* Grow the new journals to match the first slot */
		verbosef(VL_APP,
			 "Allocating space for the new journals\n");
		ret = tunefs_set_journal_size(fs, 0);
		if (!ret)
			verbosef(VL_APP, "Journal space allocated\n");
		else {
			verbosef(VL_APP,
				 "%s while trying to size the new journals\n",
				 error_message(ret));
			goto out_unblock;
		}
	}

	ret = ocfs2_format_slot_map(fs);
	if (ret)
		goto out_unblock;

	if (num_slots < orig_slots) {
		ret = tunefs_clear_in_progress(fs,
					       OCFS2_TUNEFS_INPROG_REMOVE_SLOT);
		if (ret)
			goto out_unblock;
	}

	ret = ocfs2_write_super(fs);

out_unblock:
	tunefs_unblock_signals();

out:
	return ret;
}