[Ocfs2-tools-devel] [PATCH 2/6] mkfs.ocfs2: Add vmstore fs type

Sunil Mushran sunil.mushran at oracle.com
Tue Feb 16 15:54:53 PST 2010


Patch adds a new fs type, vmstore, that allows users to make fs
to store vm images.

It also matches the default features to the fs type. As in, for
every fs type, we can now have different set of default features.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 include/ocfs2/ocfs2.h     |    8 ++++++++
 libocfs2/feature_string.c |   35 +++++++++++++++++++++++++++++++++--
 mkfs.ocfs2/mkfs.c         |   15 +++++++++++++++
 mkfs.ocfs2/mkfs.h         |    6 ------
 4 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index 09f12ef..c5f0064 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -239,6 +239,13 @@ struct _ocfs2_fs_options {
 	uint32_t opt_ro_compat;
 };
 
+enum ocfs2_fs_types {
+	FS_DEFAULT,
+	FS_DATAFILES,
+	FS_MAIL,
+	FS_VMSTORE,
+};
+
 struct _ocfs2_quota_hash {
 	int alloc_entries;
 	int used_entries;
@@ -899,6 +906,7 @@ errcode_t ocfs2_parse_feature_level(const char *typestr,
 				    enum ocfs2_feature_levels *level);
 
 errcode_t ocfs2_merge_feature_flags_with_level(ocfs2_fs_options *dest,
+					       enum ocfs2_fs_types fstype,
 					       int level,
 					       ocfs2_fs_options *feature_set,
 					       ocfs2_fs_options *reverse_set);
diff --git a/libocfs2/feature_string.c b/libocfs2/feature_string.c
index 6e773f3..30a34b1 100644
--- a/libocfs2/feature_string.c
+++ b/libocfs2/feature_string.c
@@ -94,6 +94,30 @@ static ocfs2_fs_options feature_level_defaults[] = {
 	 OCFS2_FEATURE_RO_COMPAT_GRPQUOTA }, /* OCFS2_FEATURE_LEVEL_MAX_FEATURES */
 };
 
+static ocfs2_fs_options fstypes_features_defaults[] = {
+	{OCFS2_FEATURE_COMPAT_BACKUP_SB | OCFS2_FEATURE_COMPAT_JBD2_SB,
+	 OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC |
+	 OCFS2_FEATURE_INCOMPAT_INLINE_DATA,
+	 OCFS2_FEATURE_RO_COMPAT_UNWRITTEN},  /* FS_DEFAULT */
+
+	{OCFS2_FEATURE_COMPAT_BACKUP_SB | OCFS2_FEATURE_COMPAT_JBD2_SB,
+	 OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC |
+	 OCFS2_FEATURE_INCOMPAT_INLINE_DATA,
+	 OCFS2_FEATURE_RO_COMPAT_UNWRITTEN},  /* FS_DATAFILES */
+
+	{OCFS2_FEATURE_COMPAT_BACKUP_SB | OCFS2_FEATURE_COMPAT_JBD2_SB,
+	 OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC |
+	 OCFS2_FEATURE_INCOMPAT_INLINE_DATA,
+	 OCFS2_FEATURE_RO_COMPAT_UNWRITTEN},  /* FS_MAIL */
+
+	{OCFS2_FEATURE_COMPAT_BACKUP_SB | OCFS2_FEATURE_COMPAT_JBD2_SB,
+	 OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC |
+	 OCFS2_FEATURE_INCOMPAT_INLINE_DATA |
+	 OCFS2_FEATURE_INCOMPAT_XATTR |
+	 OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE,
+	 OCFS2_FEATURE_RO_COMPAT_UNWRITTEN},  /* FS_VMSTORE */
+};
+
 /* These are the features we support in mkfs/tunefs via --fs-features */
 static struct fs_feature_flags ocfs2_supported_features[] = {
 	{
@@ -551,11 +575,17 @@ static void ocfs2_feature_clear_deps(ocfs2_fs_options *reverse_set)
  * reverse_set: all the features a user want to clear by "--fs-features".
  */
 errcode_t ocfs2_merge_feature_flags_with_level(ocfs2_fs_options *dest,
+					       enum ocfs2_fs_types fstype,
 					       int level,
 					       ocfs2_fs_options *feature_set,
 					       ocfs2_fs_options *reverse_set)
 {
-	ocfs2_fs_options level_set = feature_level_defaults[level];
+	ocfs2_fs_options level_set;
+
+	if (level == OCFS2_FEATURE_LEVEL_DEFAULT)
+		level_set = fstypes_features_defaults[fstype];
+	else
+		level_set = feature_level_defaults[level];
 
 	/*
 	 * Ensure that all dependancies are correct in the reverse set.
@@ -918,7 +948,8 @@ int main(int argc, char *argv[])
 	}
 
 	memset(&mkfs_features, 0, sizeof(ocfs2_fs_options));
-	err = ocfs2_merge_feature_flags_with_level(&mkfs_features, level,
+	err = ocfs2_merge_feature_flags_with_level(&mkfs_features, FS_DEFAULT,
+						   level,
 						   &set_features,
 						   &clear_features);
 	if (err) {
diff --git a/mkfs.ocfs2/mkfs.c b/mkfs.ocfs2/mkfs.c
index 19f5411..585643a 100644
--- a/mkfs.ocfs2/mkfs.c
+++ b/mkfs.ocfs2/mkfs.c
@@ -118,6 +118,7 @@ struct fs_type_translation {
 static struct fs_type_translation ocfs2_fs_types_table[] = {
 	{"datafiles", FS_DATAFILES},
 	{"mail", FS_MAIL},
+	{"vmstore", FS_VMSTORE},
 	{NULL, FS_DEFAULT},
 };
 
@@ -1020,6 +1021,7 @@ get_state(int argc, char **argv)
 	s->fs_type = fs_type;
 
 	ret = ocfs2_merge_feature_flags_with_level(&s->feature_flags,
+						   fs_type,
 						   level,
 						   &feature_flags,
 						   &reverse_flags);
@@ -1243,6 +1245,15 @@ static unsigned int journal_size_mail(State *s)
 	return 65536;
 }
 
+static unsigned int journal_size_vmstore(State *s)
+{
+	if (s->volume_size_in_blocks < 262144)
+		return 8192;
+	else if (s->volume_size_in_blocks < 524288)
+		return 16384;
+	return 32768;
+}
+
 /* stolen from e2fsprogs, modified to fit ocfs2 patterns */
 static uint64_t figure_journal_size(uint64_t size, State *s)
 {
@@ -1278,6 +1289,9 @@ static uint64_t figure_journal_size(uint64_t size, State *s)
 	case FS_MAIL:
 		j_blocks = journal_size_mail(s);
 		break;
+	case FS_VMSTORE:
+		j_blocks = journal_size_vmstore(s);
+		break;
 	default:
 		j_blocks = journal_size_default(s);
 		break;
@@ -1466,6 +1480,7 @@ fill_defaults(State *s)
 	if (!s->cluster_size) {
 		switch (s->fs_type) {
 		case FS_DATAFILES:
+		case FS_VMSTORE:
 			s->cluster_size = cluster_size_datafiles(s);
 			break;
 		default:
diff --git a/mkfs.ocfs2/mkfs.h b/mkfs.ocfs2/mkfs.h
index 969e4df..644f4c2 100644
--- a/mkfs.ocfs2/mkfs.h
+++ b/mkfs.ocfs2/mkfs.h
@@ -100,12 +100,6 @@ enum {
 	SFI_OTHER
 };
 
-enum ocfs2_fs_types {
-	FS_DEFAULT,
-	FS_DATAFILES,
-	FS_MAIL
-};
-
 typedef struct _SystemFileInfo SystemFileInfo;
 
 struct _SystemFileInfo {
-- 
1.6.3.3




More information about the Ocfs2-tools-devel mailing list