[Ocfs2-tools-devel] [PATCH 4/5] tunefs.ocfs2: Add [no]block32, [no]block64 in journal options
Goldwyn Rodrigues
rgoldwyn at gmail.com
Tue Jan 17 12:10:18 PST 2012
Signed-off-by: Michal Srb <msrb at suse.com>
Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>
---
tunefs.ocfs2/Makefile | 1 +
tunefs.ocfs2/libocfs2ne.c | 26 +++++++-
tunefs.ocfs2/libocfs2ne.h | 4 +-
tunefs.ocfs2/ocfs2ne.c | 30 ++++++++++
tunefs.ocfs2/op_resize_volume.c | 7 +-
tunefs.ocfs2/op_set_journal_block.c | 110 +++++++++++++++++++++++++++++++++++
tunefs.ocfs2/op_set_journal_size.c | 6 +-
tunefs.ocfs2/op_set_slot_count.c | 5 +-
8 files changed, 178 insertions(+), 11 deletions(-)
create mode 100644 tunefs.ocfs2/op_set_journal_block.c
diff --git a/tunefs.ocfs2/Makefile b/tunefs.ocfs2/Makefile
index 3847d0f..995d717 100644
--- a/tunefs.ocfs2/Makefile
+++ b/tunefs.ocfs2/Makefile
@@ -40,6 +40,7 @@ OCFS2NE_OPERATIONS = \
op_resize_volume \
op_set_label \
op_set_journal_size \
+ op_set_journal_block \
op_set_slot_count \
op_update_cluster_stack \
op_set_quota_sync_interval \
diff --git a/tunefs.ocfs2/libocfs2ne.c b/tunefs.ocfs2/libocfs2ne.c
index 709951c..c654aa7 100644
--- a/tunefs.ocfs2/libocfs2ne.c
+++ b/tunefs.ocfs2/libocfs2ne.c
@@ -331,7 +331,9 @@ errcode_t tunefs_clear_in_progress(ocfs2_filesys
*fs, int flag)
return ocfs2_write_primary_super(fs);
}
-errcode_t tunefs_set_journal_size(ocfs2_filesys *fs, uint64_t new_size)
+errcode_t tunefs_set_journal_size(ocfs2_filesys *fs, uint64_t new_size,
+ ocfs2_fs_options mask,
+ ocfs2_fs_options options)
{
errcode_t ret = 0;
char jrnl_file[OCFS2_MAX_FILENAME_LEN];
@@ -343,6 +345,8 @@ errcode_t tunefs_set_journal_size(ocfs2_filesys
*fs, uint64_t new_size)
struct ocfs2_dinode *di;
struct tunefs_filesystem_state *state = tunefs_get_state(fs);
struct tools_progress *prog;
+ ocfs2_fs_options new_features, *newfeat = &new_features, *curfeat;
+ int features_change;
num_clusters =
ocfs2_clusters_in_blocks(fs,
@@ -379,6 +383,21 @@ errcode_t tunefs_set_journal_size(ocfs2_filesys
*fs, uint64_t new_size)
return ret;
}
+ curfeat = &state->ts_journal_features;
+ newfeat->opt_compat =
+ (curfeat->opt_compat & ~mask.opt_compat) |
+ (options.opt_compat & mask.opt_compat);
+ newfeat->opt_incompat =
+ (curfeat->opt_incompat & ~mask.opt_incompat) |
+ (options.opt_incompat & mask.opt_incompat);
+ newfeat->opt_ro_compat =
+ (curfeat->opt_ro_compat & ~mask.opt_ro_compat) |
+ (options.opt_ro_compat & mask.opt_ro_compat);
+ features_change =
+ (newfeat->opt_compat ^ curfeat->opt_compat) ||
+ (newfeat->opt_incompat ^ curfeat->opt_incompat) ||
+ (newfeat->opt_ro_compat ^ curfeat->opt_ro_compat);
+
for (i = 0; i < max_slots; ++i) {
ocfs2_sprintf_system_inode_name(jrnl_file,
OCFS2_MAX_FILENAME_LEN,
@@ -404,7 +423,7 @@ errcode_t tunefs_set_journal_size(ocfs2_filesys
*fs, uint64_t new_size)
}
di = (struct ocfs2_dinode *)buf;
- if (num_clusters == di->i_clusters) {
+ if (num_clusters == di->i_clusters && !features_change) {
tools_progress_step(prog, 1);
continue;
}
@@ -412,8 +431,7 @@ errcode_t tunefs_set_journal_size(ocfs2_filesys
*fs, uint64_t new_size)
verbosef(VL_LIB,
"Resizing journal \"%s\" to %"PRIu32" clusters\n",
jrnl_file, num_clusters);
- ret = ocfs2_make_journal(fs, blkno, num_clusters,
- &state->ts_journal_features);
+ ret = ocfs2_make_journal(fs, blkno, num_clusters, newfeat);
if (ret) {
verbosef(VL_LIB,
"%s while resizing \"%s\" at block "
diff --git a/tunefs.ocfs2/libocfs2ne.h b/tunefs.ocfs2/libocfs2ne.h
index 848840f..d71757d 100644
--- a/tunefs.ocfs2/libocfs2ne.h
+++ b/tunefs.ocfs2/libocfs2ne.h
@@ -220,7 +220,9 @@ errcode_t tunefs_get_number(char *arg, uint64_t *res);
* Set all journals to new_size. If new_size is 0, it will set all
* journals to the size of the largest existing journal.
*/
-errcode_t tunefs_set_journal_size(ocfs2_filesys *fs, uint64_t new_size);
+errcode_t tunefs_set_journal_size(ocfs2_filesys *fs, uint64_t new_size,
+ ocfs2_fs_options mask,
+ ocfs2_fs_options options);
/* Determine how many clusters the filesystem has free */
errcode_t tunefs_get_free_clusters(ocfs2_filesys *fs, uint32_t *clusters);
diff --git a/tunefs.ocfs2/ocfs2ne.c b/tunefs.ocfs2/ocfs2ne.c
index df4beb9..32cdb61 100644
--- a/tunefs.ocfs2/ocfs2ne.c
+++ b/tunefs.ocfs2/ocfs2ne.c
@@ -94,6 +94,8 @@ extern struct tunefs_operation reset_uuid_op;
extern struct tunefs_operation features_op;
extern struct tunefs_operation resize_volume_op;
extern struct tunefs_operation set_journal_size_op;
+extern struct tunefs_operation set_journal_block32_op;
+extern struct tunefs_operation set_journal_block64_op;
extern struct tunefs_operation set_label_op;
extern struct tunefs_operation set_slot_count_op;
extern struct tunefs_operation update_cluster_stack_op;
@@ -115,9 +117,37 @@ static struct tunefs_journal_option
set_journal_size_option = {
.jo_op = &set_journal_size_op,
};
+static struct tunefs_journal_option set_journal_block64_option = {
+ .jo_name = "block64",
+ .jo_help = "block64",
+ .jo_op = &set_journal_block64_op,
+};
+
+static struct tunefs_journal_option set_journal_block32_option = {
+ .jo_name = "block32",
+ .jo_help = "block32",
+ .jo_op = &set_journal_block32_op,
+};
+
+static struct tunefs_journal_option set_journal_noblock64_option = {
+ .jo_name = "noblock64",
+ .jo_help = "noblock64",
+ .jo_op = &set_journal_block32_op,
+};
+
+static struct tunefs_journal_option set_journal_noblock32_option = {
+ .jo_name = "noblock32",
+ .jo_help = "noblock32",
+ .jo_op = &set_journal_block64_op,
+};
+
/* The list of all supported journal options */
static struct tunefs_journal_option *tunefs_journal_options[] = {
&set_journal_size_option,
+ &set_journal_block64_option,
+ &set_journal_block32_option,
+ &set_journal_noblock64_option,
+ &set_journal_noblock32_option,
NULL,
};
diff --git a/tunefs.ocfs2/op_resize_volume.c b/tunefs.ocfs2/op_resize_volume.c
index 80311f7..076bda0 100644
--- a/tunefs.ocfs2/op_resize_volume.c
+++ b/tunefs.ocfs2/op_resize_volume.c
@@ -584,9 +584,10 @@ static errcode_t check_new_size(ocfs2_filesys
*fs, uint64_t new_size,
"Requested %"PRIu32" clusters (%"PRIu64" "
"blocks)\n",
try_clusters, try_blocks);
- errorf("The Journaled Block Device (JBD) cannot "
- "support more than %"PRIu32" blocks\n",
- UINT32_MAX);
+ errorf("The file system journal is not configured to support "
+ "more than %"PRIu32" blocks.\n"
+ "Please enable \"block64\" journal feature before "
+ "resizing the file system.\n", UINT32_MAX);
return TUNEFS_ET_INVALID_NUMBER;
}
diff --git a/tunefs.ocfs2/op_set_journal_block.c
b/tunefs.ocfs2/op_set_journal_block.c
new file mode 100644
index 0000000..266e47e
--- /dev/null
+++ b/tunefs.ocfs2/op_set_journal_block.c
@@ -0,0 +1,110 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+* vim: noexpandtab sw=8 ts=8 sts=0:
+*
+* op_set_journal_block.c
+*
+* ocfs2 tune utility for updating the block attribute of all journals.
+*
+* Copyright (C) 2011, 2012 SUSE. 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 version 2 as published by the Free Software Foundation.
+*
+* This program is distributed in the hope that it will 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.
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <inttypes.h>
+
+#include "ocfs2/ocfs2.h"
+
+#include "libocfs2ne.h"
+
+
+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;
+
+ 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;
+}
+
+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;
+}
+
+
+DEFINE_TUNEFS_OP(set_journal_block32,
+ "Usage: op_set_journal_block32 <device>\n",
+ TUNEFS_FLAG_RW | TUNEFS_FLAG_ALLOCATION,
+ 0,
+ set_journal_block32_run);
+
+DEFINE_TUNEFS_OP(set_journal_block64,
+ "Usage: op_set_journal_block64 <device>\n",
+ TUNEFS_FLAG_RW | TUNEFS_FLAG_ALLOCATION,
+ 0,
+ set_journal_block64_run);
+
+#ifdef DEBUG_EXE
+int main(int argc, char *argv[])
+{
+ return tunefs_op_main(argc, argv, &set_journal_block32_op);
+}
+#endif
diff --git a/tunefs.ocfs2/op_set_journal_size.c
b/tunefs.ocfs2/op_set_journal_size.c
index b671950..045170c 100644
--- a/tunefs.ocfs2/op_set_journal_size.c
+++ b/tunefs.ocfs2/op_set_journal_size.c
@@ -34,7 +34,6 @@ static int set_journal_size_parse_option(struct
tunefs_operation *op,
errcode_t err;
uint64_t *new_size;
-
if (!arg) {
errorf("No size specified\n");
goto out;
@@ -66,6 +65,7 @@ static int set_journal_size_run(struct tunefs_operation *op,
int rc = 0;
uint64_t *argp = (uint64_t *)op->to_private;
uint64_t new_size = *argp;
+ ocfs2_fs_options null_options;
ocfs2_free(&argp);
op->to_private = NULL;
@@ -75,8 +75,10 @@ static int set_journal_size_run(struct tunefs_operation *op,
fs->fs_devname, new_size))
goto out;
+ memset(&null_options, 0, sizeof(ocfs2_fs_options));
+
tunefs_block_signals();
- err = tunefs_set_journal_size(fs, new_size);
+ err = tunefs_set_journal_size(fs, new_size, null_options, null_options);
tunefs_unblock_signals();
if (err) {
rc = 1;
diff --git a/tunefs.ocfs2/op_set_slot_count.c b/tunefs.ocfs2/op_set_slot_count.c
index cdd4f1a..a409087 100644
--- a/tunefs.ocfs2/op_set_slot_count.c
+++ b/tunefs.ocfs2/op_set_slot_count.c
@@ -1071,6 +1071,9 @@ 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;
+ ocfs2_fs_options null_options;
+
+ memset(&null_options, 0, sizeof(ocfs2_fs_options));
if (num_slots == orig_slots) {
verbosef(VL_APP,
@@ -1099,7 +1102,7 @@ static errcode_t update_slot_count(ocfs2_filesys
*fs, int num_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);
+ ret = tunefs_set_journal_size(fs, 0, null_options, null_options);
if (!ret)
verbosef(VL_APP, "Journal space allocated\n");
else {
--
1.7.7
More information about the Ocfs2-tools-devel
mailing list