Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo 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;
}
Ejemplo n.º 4
0
static int set_journal_block32_run(struct tunefs_operation *op,
				ocfs2_filesys *fs, int flags)
{
	errcode_t err;
	int rc = 0;
	ocfs2_fs_options mask, options;

	if (fs->fs_blocks > UINT32_MAX) {
		tcom_err(TUNEFS_ET_OPERATION_FAILED,
			"; cannot enable block32 journal feature on "
			"device \"%s\" having more that %u blocks",
			fs->fs_devname, UINT32_MAX);
		rc = 1;
		goto out;
	}

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

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

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

out:
	return rc;
}
Ejemplo n.º 5
0
static int update_sync_interval(ocfs2_filesys *fs, int type,
				unsigned long syncms)
{
	errcode_t err;
	struct tools_progress *prog;
	int feature = (type == USRQUOTA) ? OCFS2_FEATURE_RO_COMPAT_USRQUOTA :
					   OCFS2_FEATURE_RO_COMPAT_GRPQUOTA;
	struct ocfs2_global_disk_dqinfo *qinfo;

	if (!OCFS2_HAS_RO_COMPAT_FEATURE(OCFS2_RAW_SB(fs->fs_super), feature)) {
		errorf("The %s quota is not enabled on device \"%s\"\n",
		       type2name(type), fs->fs_devname);
		return 1;
	}
	err = ocfs2_init_fs_quota_info(fs, type);
	if (err) {
		tcom_err(err, "while looking up %s quota file on device "
			 "\"%s\"", type2name(type), fs->fs_devname);
		return 1;
	}
	err = ocfs2_read_global_quota_info(fs, type);
	if (err) {
		tcom_err(err, "while reading %s quota info on device \"%s\"",
			 type2name(type), fs->fs_devname);
		return 1;
	}
	qinfo = &fs->qinfo[type].qi_info;
	if (qinfo->dqi_syncms == syncms) {
		verbosef(VL_APP,
			 "Device \"%s\" already has interval %lu set; "
			 "nothing to do\n", fs->fs_devname, syncms);
		return 0;
	}

	if (!tools_interact("Change quota syncing interval on device \"%s\" "
			    "from %lu to %lu? ", fs->fs_devname,
			    (unsigned long)qinfo->dqi_syncms, syncms))
		return 0;

	prog = tools_progress_start("Setting syncing interval", "interval", 1);
	if (!prog) {
		tcom_err(err, "while initializing the progress display");
		return 1;
	}

	tunefs_block_signals();
	qinfo->dqi_syncms = syncms;
	err = ocfs2_write_global_quota_info(fs, type);
	tunefs_unblock_signals();

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

	if (err) {
		tcom_err(err,
			 "- unable to update %s quota syncing interval on "
			 "device \"%s\"", type2name(type), fs->fs_devname);
		return 1;
	}

	return 0;
}
Ejemplo 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;
}
Ejemplo 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;
}