Skip to contentSkip to conversation

Ocfs2-tools: Add a new tool 'o2info'.

PATCH New Tristan Ye 1 participant 8 messages Oct 25, 2010

Subsystems (2)
lore
Share & tools
lore

Tristan Ye

author
#0 lore raw

cover Ocfs2-tools: Add a new tool 'o2info'.

Now it's a good time to introduce the new tool 'o2info' since kernel part of OCFS2_IOC_INFO ioctl has been pulld upstream by linus.

The following 6 patches have already got sunil's SOBs, and now they're trying to attract more reviewers before it goes to central repo with a modification of getting manual pages being introduced.

author
#1 lore raw

PATCH 1/6 O2info: Add all structures and commands OCFS2_IOC_INFO needed into ocfs2_ioctl.h

---
 include/ocfs2-kernel/ocfs2_ioctl.h |   95 ++++++++++++++++++++++++++++++++++++
 1 files changed, 95 insertions(+), 0 deletions(-)
include/ocfs2-kernel/ocfs2_ioctl.h +95 -0
index 2d3420a..9bc5354 100644
@@ -76,4 +76,99 @@ struct reflink_arguments {
 };
 #define OCFS2_IOC_REFLINK	_IOW('o', 4, struct reflink_arguments)
 
+/* Following definitions dedicated for ocfs2_info_request ioctls. */
+#define OCFS2_INFO_MAX_REQUEST		(50)
+#define OCFS2_TEXT_UUID_LEN		(OCFS2_VOL_UUID_LEN * 2)
+
+/* Magic number of all requests */
+#define OCFS2_INFO_MAGIC		(0x4F32494E)
+
+/*
+ * Always try to separate info request into small pieces to
+ * guarantee the backward&forward compatibility.
+ */
+struct ocfs2_info {
+	__u64 oi_requests;	/* Array of __u64 pointers to requests */
+	__u32 oi_count;		/* Number of requests in info_requests */
+	__u32 oi_pad;
+};
+
+struct ocfs2_info_request {
+/*00*/	__u32 ir_magic;	/* Magic number */
+	__u32 ir_code;	/* Info request code */
+	__u32 ir_size;	/* Size of request */
+	__u32 ir_flags;	/* Request flags */
+/*10*/			/* Request specific fields */
+};
+
+struct ocfs2_info_clustersize {
+	struct ocfs2_info_request ic_req;
+	__u32 ic_clustersize;
+	__u32 ic_pad;
+};
+
+struct ocfs2_info_blocksize {
+	struct ocfs2_info_request ib_req;
+	__u32 ib_blocksize;
+	__u32 ib_pad;
+};
+
+struct ocfs2_info_maxslots {
+	struct ocfs2_info_request im_req;
+	__u32 im_max_slots;
+	__u32 im_pad;
+};
+
+struct ocfs2_info_label {
+	struct ocfs2_info_request il_req;
+	__u8	il_label[OCFS2_MAX_VOL_LABEL_LEN];
+} __attribute__ ((packed));
+
+struct ocfs2_info_uuid {
+	struct ocfs2_info_request iu_req;
+	__u8	iu_uuid_str[OCFS2_TEXT_UUID_LEN + 1];
+} __attribute__ ((packed));
+
+struct ocfs2_info_fs_features {
+	struct ocfs2_info_request if_req;
+	__u32 if_compat_features;
+	__u32 if_incompat_features;
+	__u32 if_ro_compat_features;
+	__u32 if_pad;
+};
+
+struct ocfs2_info_journal_size {
+	struct ocfs2_info_request ij_req;
+	__u64 ij_journal_size;
+};
+
+/* Codes for ocfs2_info_request */
+enum ocfs2_info_type {
+	OCFS2_INFO_CLUSTERSIZE = 1,
+	OCFS2_INFO_BLOCKSIZE,
+	OCFS2_INFO_MAXSLOTS,
+	OCFS2_INFO_LABEL,
+	OCFS2_INFO_UUID,
+	OCFS2_INFO_FS_FEATURES,
+	OCFS2_INFO_JOURNAL_SIZE,
+	OCFS2_INFO_NUM_TYPES
+};
+
+/* Flags for struct ocfs2_info_request */
+/* Filled by the caller */
+#define OCFS2_INFO_FL_NON_COHERENT	(0x00000001)	/* Cluster coherency not
+							   required. This is a hint.
+							   It is up to ocfs2 whether
+							   the request can be fulfilled
+							   without locking. */
+/* Filled by ocfs2 */
+#define OCFS2_INFO_FL_FILLED		(0x40000000)	/* Filesystem understood
+							   this request and
+							   filled in the answer */
+
+#define OCFS2_INFO_FL_ERROR		(0x80000000)	/* Error happened during
+							   request handling. */
+
+#define OCFS2_IOC_INFO		_IOR('o', 5, struct ocfs2_info)
+
 #endif /* OCFS2_IOCTL_H */
Signature · 1 line
1.5.5
author
#2 lore raw

PATCH 2/6 O2info: Build a main framework for o2info.

In reply to Tristan Ye

This patch tries to build main framework with necessary *.h and *.c files being generated. it did the option parsing and initialization, and only works for --help and --version, more operations will be elaborated in later patches.

To be more detail: all of o2info's operations will be linked to a task list, and executed one by one later.

Workflow of adding a new operation task for o2info(such as --volinfo) will be like following:

1. Declare a new extern operation structure.
extern struct o2info_operation volinfo_op;

2. Add a new option:
static struct o2info_option volinfo_option = {
.opt_option = {
.name = "volinfo",
.val = 'V',
.has_arg = 0,
.flag = NULL,
},
.opt_help =
"-V|--volinfo",
.opt_handler = NULL,
.opt_op = &volinfo_op,
.opt_private = NULL,
};

3. Implement necessary utility func in utils.c.

4. Implement the real running codes for volinfo_op in operation.c.

---
 CREDITS                                   |    3 +
 Makefile                                  |    2 +-
 configure.in                              |    1 +
 debian/ocfs2-tools.install                |    2 +
 debian/ocfs2-tools.manpages               |    1 +
 o2info/.gitignore                         |    6 +
 o2info/Makefile                           |   38 +++
 o2info/o2info.1.in                        |   28 ++
 o2info/o2info.c                           |  484 +++++++++++++++++++++++++++++
 o2info/o2info.h                           |   82 +++++
 o2info/operations.c                       |   61 ++++
 o2info/utils.c                            |  109 +++++++
 o2info/utils.h                            |   30 ++
 vendor/common/ocfs2-tools.spec-generic.in |    2 +
 14 files changed, 848 insertions(+), 1 deletions(-)
 create mode 100644 o2info/.gitignore
 create mode 100644 o2info/Makefile
 create mode 100644 o2info/o2info.1.in
 create mode 100644 o2info/o2info.c
 create mode 100644 o2info/o2info.h
 create mode 100644 o2info/operations.c
 create mode 100644 o2info/utils.c
 create mode 100644 o2info/utils.h
CREDITS +3 -0
index d15ca67..042b8e1 100644
@@ -29,6 +29,9 @@ ocfs2cdsl:
 ocfs2console:
 	Written by Manish Singh.
 
+o2info:
+	Written by Tristan Ye.
+
 ocfs2console/blkid:
 	From e2fsprogs 1.37, by Theodore Ts'o and Andreas Dilger.
 
Makefile +1 -1
index 88106fb..8b71e72 100644
@@ -20,7 +20,7 @@ CHKCONFIG_DEP = chkconfig
 COMPILE_PY = 1
 endif
 
-SUBDIRS = include libtools-internal libo2dlm libo2cb libocfs2 fsck.ocfs2 mkfs.ocfs2 mounted.ocfs2 tunefs.ocfs2 debugfs.ocfs2 o2cb_ctl ocfs2_hb_ctl mount.ocfs2 ocfs2_controld o2image listuuid sizetest extras fswreck patches
+SUBDIRS = include libtools-internal libo2dlm libo2cb libocfs2 fsck.ocfs2 mkfs.ocfs2 mounted.ocfs2 tunefs.ocfs2 debugfs.ocfs2 o2cb_ctl ocfs2_hb_ctl mount.ocfs2 ocfs2_controld o2image o2info listuuid sizetest extras fswreck patches
 
 ifdef BUILD_OCFS2CONSOLE
 SUBDIRS += ocfs2console
configure.in +1 -0
index 246c8e7..5db6601 100644
@@ -443,6 +443,7 @@ ocfs2_hb_ctl/ocfs2_hb_ctl.8
 ocfs2console/ocfs2console.8
 tunefs.ocfs2/tunefs.ocfs2.8
 o2image/o2image.8
+o2info/o2info.1
 libo2cb/o2cb.7
 vendor/common/ocfs2-tools.spec-generic
 ])
debian/ocfs2-tools.install +2 -0
index 4ca7d34..6c74383 100644
@@ -6,6 +6,7 @@ sbin/mounted.ocfs2
 sbin/o2cb_ctl
 sbin/ocfs2_hb_ctl
 sbin/tunefs.ocfs2
+usr/bin/o2info
 usr/share/man/man8/debugfs.ocfs2.8
 usr/share/man/man8/fsck.ocfs2.8
 usr/share/man/man8/fsck.ocfs2.checks.8
@@ -16,3 +17,4 @@ usr/share/man/man7/o2cb.7
 usr/share/man/man8/o2cb_ctl.8
 usr/share/man/man8/ocfs2_hb_ctl.8
 usr/share/man/man8/tunefs.ocfs2.8
+usr/share/man/man1/o2info.1
debian/ocfs2-tools.manpages +1 -0
index 439fa68..22c1560 100644
@@ -8,3 +8,4 @@ debian/tmp/usr/share/man/man8/o2cb_ctl.8
 debian/tmp/usr/share/man/man8/ocfs2_hb_ctl.8
 debian/tmp/usr/share/man/man8/o2image.8
 debian/tmp/usr/share/man/man7/o2cb.7
+debian/tmp/usr/share/man/man1/o2info.1
o2info/.gitignore new file +6 -0
new file mode 100644
index 0000000..46c8063
@@ -0,0 +1,6 @@
+.*.sw?
+*.d
+.*.cmd
+stamp-md5
+cscope*
+o2info
o2info/Makefile new file +38 -0
new file mode 100644
index 0000000..70d9cac
@@ -0,0 +1,38 @@
+TOPDIR = ..
+
+include $(TOPDIR)/Preamble.make
+
+WARNINGS = -Wall -Wstrict-prototypes -Wno-format -Wmissing-prototypes \
+           -Wmissing-declarations
+
+CFLAGS = $(OPTS) $(WARNINGS)
+
+LIBTOOLS_INTERNAL_LIBS = -L$(TOPDIR)/libtools-internal -ltools-internal
+LIBTOOLS_INTERNAL_DEPS = $(TOPDIR)/libtools-internal/libtools-internal.a
+
+LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
+LIBOCFS2_DEPS = $(TOPDIR)/libocfs2/libocfs2.a
+
+BIN_PROGRAMS = o2info
+
+INCLUDES = -I$(TOPDIR)/include -I.
+DEFINES = -DVERSION=\"$(VERSION)\"
+
+MANS = o2info.1
+
+HFILES = o2info.h		\
+	 utils.h
+
+CFILES =			\
+	o2info.c		\
+	operations.c	\
+	utils.c
+
+OBJS = $(subst .c,.o,$(CFILES))
+
+DIST_FILES = $(CFILES) $(HFILES) o2info.1.in
+
+o2info: $(OBJS) $(LIBOCFS2_DEPS)
+	$(LINK) $(LIBOCFS2_LIBS) $(LIBTOOLS_INTERNAL_LIBS) $(COM_ERR_LIBS)
+
+include $(TOPDIR)/Postamble.make
o2info/o2info.1.in new file +28 -0
new file mode 100644
index 0000000..fe32d70
@@ -0,0 +1,28 @@
+.TH "o2info" "1" "October 2010" "Version @VERSION@" "OCFS2 Manual Pages"
+.SH "NAME"
+o2info \- Dump \fIOCFS2\fR file system information on disk.
+.SH "SYNOPSIS"
+\fBo2info\fR <\fBdevice or file\fR>
+
+.SH "DESCRIPTION"
+.PP
+\fBo2info\fR is designed to be an information tool, to display \fIOCFS2\fR file system information on disk. Its main goal on one hand, is to provide a tool to display fs info in a comprehensive way and providing the information which may be missing in \fBdebugfs.ocfs\fR and \fBtunefs.ocfs2\fR such as global bitmap free space fragmentation and free inode info for each slot, on the other hand, it also aims to become a info tool(\fBnot\fR an administration one), which therefore allows all users who may have no read privilege on the underlying device to use the utility. In practice, \fB'o2info /path/to/file/on/ocfs2/vol'\fR use a new \fBOCFS2_IOC_INFO\fR ioctl to get info from fs for a mounted case. For a privileged user(e.g, root), the same info however, can also be accessed by \fB'o2info /dev/sdxN'\fR to direcly manipulate the raw device.
+
+.SH "OPTIONS"
+.TP
+\fB\-V, \-\-version\fR
+Show version and exit.
+
+.TP
+\fB\-h, \-\-help\fR
+Display help and exit.
+
+.SH "SEE ALSO"
+.BR debugfs.ocfs2(8)
+.BR tunefs.ocfs2(8)
+
+.SH "AUTHORS"
+Oracle Corporation
+
+.SH "COPYRIGHT"
+Copyright \(co 2010 Oracle. All rights reserved.
o2info/o2info.c new file +484 -0

484 lines not on this page · raw message

o2info/o2info.h new file +82 -0

82 lines not on this page · raw message

o2info/operations.c new file +61 -0

61 lines not on this page · raw message

o2info/utils.c new file +109 -0

109 lines not on this page · raw message

o2info/utils.h new file +30 -0
new file mode 100644
index 0000000..6d55d39
@@ -0,0 +1,30 @@
+/* -*- mode: c; c-basic-offset: 8; -*-
+ * vim: noexpandtab sw=8 ts=8 sts=0:
+ *
+ * utils.h
+ *
+ * Common utility function prototypes
+ *
+ * Copyright (C) 2010 Oracle.  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.
+ */
+
+#ifndef __UTILS_H__
+#define __UTILS_H__
+
+#include "o2info.h"
+
+int o2info_method(const char *path);
+
+errcode_t o2info_open(struct o2info_method *om, int flags);
+errcode_t o2info_close(struct o2info_method *om);
+
+#endif		/* __UTILS_H__ */
vendor/common/ocfs2-tools.spec-generic.in +2 -0
index 3e9b46a..0192c48 100644
@@ -119,6 +119,7 @@ fi
 /sbin/mount.ocfs2
 /sbin/o2image
 /sbin/ocfs2_hb_ctl
+/usr/bin/o2info
 /etc/init.d/o2cb
 /etc/init.d/ocfs2
 %config(noreplace) /etc/sysconfig/o2cb
@@ -133,6 +134,7 @@ fi
 /usr/share/man/man8/ocfs2_hb_ctl.8.gz
 /usr/share/man/man8/o2image.8.gz
 /usr/share/man/man7/o2cb.7.gz
+/usr/share/man/man1/o2info.1.gz
 
 
 %files -n ocfs2console
Signature · 1 line
1.5.5
author
#3 lore raw

PATCH 3/6 O2info: Add '--cluster-coherent' option for o2info.

In reply to Tristan Ye

Default will be no cluster-in-coherency.

---
 o2info/o2info.1.in |    6 +++++-
 o2info/o2info.c    |   22 ++++++++++++++++++++++
 2 files changed, 27 insertions(+), 1 deletions(-)
o2info/o2info.1.in +5 -1
index fe32d70..d748df8 100644
@@ -2,7 +2,7 @@
 .SH "NAME"
 o2info \- Dump \fIOCFS2\fR file system information on disk.
 .SH "SYNOPSIS"
-\fBo2info\fR <\fBdevice or file\fR>
+\fBo2info\fR [\fB\-C|\-\-cluster\-coherent\fR] <\fBdevice or file\fR>
 
 .SH "DESCRIPTION"
 .PP
@@ -10,6 +10,10 @@ o2info \- Dump \fIOCFS2\fR file system information on disk.
 
 .SH "OPTIONS"
 .TP
+\fB\-C, \-\-cluster\-coherent\fR
+Enable cluster (in)coherency for mounted case, means it will attempt to acquire a global PR lock when querying info from a cluster filesystem, which may degrade the performance, default is none cluster-coherency.
+
+.TP
 \fB\-V, \-\-version\fR
 Show version and exit.
 
o2info/o2info.c +22 -0
index 02058af..3fa4627 100644
@@ -51,6 +51,13 @@ static int version_handler(struct o2info_option *opt, char *arg)
 	exit(0);
 }
 
+static int coherency_handler(struct o2info_option *opt, char *arg)
+{
+	cluster_coherent = 1;
+
+	return 0;
+}
+
 static struct o2info_option help_option = {
 	.opt_option	= {
 		.name		= "help",
@@ -77,9 +84,24 @@ static struct o2info_option version_option = {
 	.opt_private = NULL,
 };
 
+static struct o2info_option coherency_option = {
+	.opt_option	= {
+		.name		= "cluster-coherent",
+		.val		= 'C',
+		.has_arg	= 0,
+		.flag		= NULL,
+	},
+	.opt_help	=
+		"-C|--cluster-coherent",
+	.opt_handler	= coherency_handler,
+	.opt_op		= NULL,
+	.opt_private = NULL,
+};
+
 static struct o2info_option *options[] = {
 	&help_option,
 	&version_option,
+	&coherency_option,
 	NULL,
 };
 
Signature · 1 line
1.5.5
author
#4 lore raw

PATCH 4/6 O2info: Add running codes for '--fs-features'.

In reply to Tristan Ye

This patch teaches o2info to dump fs's features on volume.

Task of dumping 'fs-features' will be capable of two approaches, including libocfs2 and ioctl methods.

---
 o2info/o2info.1.in  |    6 +-
 o2info/o2info.c     |   16 ++++
 o2info/operations.c |  227 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 o2info/utils.c      |   75 +++++++++++++++++
 o2info/utils.h      |    4 +
 5 files changed, 326 insertions(+), 2 deletions(-)
o2info/o2info.1.in +5 -1
index d748df8..2622a8e 100644
@@ -2,7 +2,7 @@
 .SH "NAME"
 o2info \- Dump \fIOCFS2\fR file system information on disk.
 .SH "SYNOPSIS"
-\fBo2info\fR [\fB\-C|\-\-cluster\-coherent\fR] <\fBdevice or file\fR>
+\fBo2info\fR [\fB\-C|\-\-cluster\-coherent\fR] [\fB\-\-fs\-features\fR] <\fBdevice or file\fR>
 
 .SH "DESCRIPTION"
 .PP
@@ -14,6 +14,10 @@ o2info \- Dump \fIOCFS2\fR file system information on disk.
 Enable cluster (in)coherency for mounted case, means it will attempt to acquire a global PR lock when querying info from a cluster filesystem, which may degrade the performance, default is none cluster-coherency.
 
 .TP
+\fB\-\-fs\-features\fR
+List all compat, incompat and ro-compat fs features on \fIOCFS2\fR filesystem.
+
+.TP
 \fB\-V, \-\-version\fR
 Show version and exit.
 
o2info/o2info.c +16 -0
index 3fa4627..c91317a 100644
@@ -34,6 +34,8 @@
 
 #include "utils.h"
 
+extern struct o2info_operation fs_features_op;
+
 static LIST_HEAD(o2info_op_task_list);
 static int o2info_op_task_count;
 int cluster_coherent;
@@ -98,10 +100,24 @@ static struct o2info_option coherency_option = {
 	.opt_private = NULL,
 };
 
+static struct o2info_option fs_features_option = {
+	.opt_option	= {
+		.name		= "fs-features",
+		.val		= CHAR_MAX,
+		.has_arg	= 0,
+		.flag		= NULL,
+	},
+	.opt_help	= "   --fs-features",
+	.opt_handler	= NULL,
+	.opt_op		= &fs_features_op,
+	.opt_private	= NULL,
+};
+
 static struct o2info_option *options[] = {
 	&help_option,
 	&version_option,
 	&coherency_option,
+	&fs_features_option,
 	NULL,
 };
 
o2info/operations.c +226 -1

239 lines not on this page · raw message

o2info/utils.c +75 -0

81 lines not on this page · raw message

o2info/utils.h +4 -0
index 6d55d39..69446c2 100644
@@ -22,6 +22,10 @@
 
 #include "o2info.h"
 
+int o2info_get_compat_flag(uint32_t flag, char **compat);
+int o2info_get_incompat_flag(uint32_t flag, char **incompat);
+int o2info_get_rocompat_flag(uint32_t flag, char **rocompat);
+
 int o2info_method(const char *path);
 
 errcode_t o2info_open(struct o2info_method *om, int flags);
Signature · 1 line
1.5.5
author
#5 lore raw

PATCH 5/6 O2info: Add running codes for '--volinfo'.

In reply to Tristan Ye

Patch teaches o2info to dump volume's basic info.

Task of '--volinfo' will also be capable of two approaches, including libocfs2 and ioctl solutions.

---
 o2info/o2info.1.in  |   26 ++++++++-
 o2info/o2info.c     |   15 +++++
 o2info/operations.c |  164 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 204 insertions(+), 1 deletions(-)
o2info/o2info.1.in +25 -1
index 2622a8e..a814d54 100644
@@ -2,7 +2,7 @@
 .SH "NAME"
 o2info \- Dump \fIOCFS2\fR file system information on disk.
 .SH "SYNOPSIS"
-\fBo2info\fR [\fB\-C|\-\-cluster\-coherent\fR] [\fB\-\-fs\-features\fR] <\fBdevice or file\fR>
+\fBo2info\fR [\fB\-C|\-\-cluster\-coherent\fR] [\fB\-\-fs\-features\fR] [\fB\-\-volinfo\fR] <\fBdevice or file\fR>
 
 .SH "DESCRIPTION"
 .PP
@@ -18,6 +18,10 @@ Enable cluster (in)coherency for mounted case, means it will attempt to acquire
 List all compat, incompat and ro-compat fs features on \fIOCFS2\fR filesystem.
 
 .TP
+\fB\-\-volinfo\fR
+Dump basic volume information, such as blocksize, clustersize, volume label and UUID etc.
+
+.TP
 \fB\-V, \-\-version\fR
 Show version and exit.
 
@@ -25,6 +29,26 @@ Show version and exit.
 \fB\-h, \-\-help\fR
 Display help and exit.
 
+.SH "EXAMPLES"
+[oracle at node1 ~]# o2info --volinfo /storage/testfile      # For none-privileged users.
+.br
+[root at node1 ~]# o2info --volinfo /dev/sda1
+.br
+       Label: ocfs2-volume
+.br
+        UUID: 976D8E630B3A4F1F95497311A92901FC
+.br
+  Block Size: 4096
+.br
+Cluster Size: 4096
+.br
+  Node Slots: 4
+.br
+    Features: backup-super strict-journal-super sparse inline-data xattr
+.br
+    Features: unwritten
+
+
 .SH "SEE ALSO"
 .BR debugfs.ocfs2(8)
 .BR tunefs.ocfs2(8)
o2info/o2info.c +15 -0
index c91317a..3ad3c90 100644
@@ -35,6 +35,7 @@
 #include "utils.h"
 
 extern struct o2info_operation fs_features_op;
+extern struct o2info_operation volinfo_op;
 
 static LIST_HEAD(o2info_op_task_list);
 static int o2info_op_task_count;
@@ -113,11 +114,25 @@ static struct o2info_option fs_features_option = {
 	.opt_private	= NULL,
 };
 
+static struct o2info_option volinfo_option = {
+	.opt_option	= {
+		.name		= "volinfo",
+		.val		= CHAR_MAX,
+		.has_arg	= 0,
+		.flag		= NULL,
+	},
+	.opt_help	= "   --volinfo",
+	.opt_handler	= NULL,
+	.opt_op		= &volinfo_op,
+	.opt_private	= NULL,
+};
+
 static struct o2info_option *options[] = {
 	&help_option,
 	&version_option,
 	&coherency_option,
 	&fs_features_option,
+	&volinfo_option,
 	NULL,
 };
 
o2info/operations.c +164 -0

167 lines not on this page · raw message

Signature · 1 line
1.5.5
author
#6 lore raw

PATCH 6/6 O2info: Add --mkfs support for o2info.

In reply to Tristan Ye

'--mkfs' teaches o2info to output an oringal format of mkfs.ocfs's arguments, which can be used conveniently for a fresh mkfs try:

$mkfs.ocfs2 "$(o2info --mkfs /dev/name/or/path/of/file)" /dev/sdaX

---
 o2info/o2info.1.in  |    7 ++-
 o2info/o2info.c     |   15 ++++
 o2info/operations.c |  187 +++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 208 insertions(+), 1 deletions(-)
o2info/o2info.1.in +6 -1
index a814d54..3ddfba6 100644
@@ -2,7 +2,7 @@
 .SH "NAME"
 o2info \- Dump \fIOCFS2\fR file system information on disk.
 .SH "SYNOPSIS"
-\fBo2info\fR [\fB\-C|\-\-cluster\-coherent\fR] [\fB\-\-fs\-features\fR] [\fB\-\-volinfo\fR] <\fBdevice or file\fR>
+\fBo2info\fR [\fB\-C|\-\-cluster\-coherent\fR] [\fB\-\-fs\-features\fR] [\fB\-\-volinfo\fR] [\fB\-\-mkfs\fR] <\fBdevice or file\fR>
 
 .SH "DESCRIPTION"
 .PP
@@ -22,6 +22,11 @@ List all compat, incompat and ro-compat fs features on \fIOCFS2\fR filesystem.
 Dump basic volume information, such as blocksize, clustersize, volume label and UUID etc.
 
 .TP
+\fB\-\-mkfs\fR
+Dump an original format of mkfs.ocfs's arguments, importantly, which can be used directly as a fresh mkfs retry:
+#mkfs.ocfs2 "$(o2info --mkfs /dev/name/or/path/of/file)" /dev/sdaX
+
+.TP
 \fB\-V, \-\-version\fR
 Show version and exit.
 
o2info/o2info.c +15 -0
index 3ad3c90..9e23cfb 100644
@@ -36,6 +36,7 @@
 
 extern struct o2info_operation fs_features_op;
 extern struct o2info_operation volinfo_op;
+extern struct o2info_operation mkfs_op;
 
 static LIST_HEAD(o2info_op_task_list);
 static int o2info_op_task_count;
@@ -127,12 +128,26 @@ static struct o2info_option volinfo_option = {
 	.opt_private	= NULL,
 };
 
+static struct o2info_option mkfs_option = {
+	.opt_option	= {
+		.name		= "mkfs",
+		.val		= CHAR_MAX,
+		.has_arg	= 0,
+		.flag		= NULL,
+	},
+	.opt_help	= "   --mkfs",
+	.opt_handler	= NULL,
+	.opt_op		= &mkfs_op,
+	.opt_private	= NULL,
+};
+
 static struct o2info_option *options[] = {
 	&help_option,
 	&version_option,
 	&coherency_option,
 	&fs_features_option,
 	&volinfo_option,
+	&mkfs_option,
 	NULL,
 };
 
o2info/operations.c +187 -0

190 lines not on this page · raw message

Signature · 1 line
1.5.5
author
#7 lore raw

cover Ocfs2-tools: Add a new tool 'o2info'.

In reply to Tristan Ye

Oops, sent the patches to a wrong mail list;-(

Resending them to 'ocfs2-tools-devel at oss.oracle.com' instead.

Sorry for the noise here.

Tristan.

Quoted 13 lines · Tristan Ye

Now it's a good time to introduce the new tool 'o2info' since kernel part of OCFS2_IOC_INFO ioctl has been pulld upstream by linus.

The following 6 patches have already got sunil's SOBs, and now they're trying to attract more reviewers before it goes to central repo with a modification of getting manual pages being introduced.

_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel