diff mbox series

[V2,23/23] mdrestore: Add support for passing log device as an argument

Message ID 20230606092806.1604491-24-chandan.babu@oracle.com (mailing list archive)
State Superseded
Headers show
Series Metadump v2 | expand

Commit Message

Chandan Babu R June 6, 2023, 9:28 a.m. UTC
metadump v2 format allows dumping metadata from external log devices. This
commit allows passing the device file to which log data must be restored from
the corresponding metadump file.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
---
 man/man8/xfs_mdrestore.8  |  8 ++++++++
 mdrestore/xfs_mdrestore.c | 11 +++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

Comments

Darrick J. Wong July 12, 2023, 6:10 p.m. UTC | #1
On Tue, Jun 06, 2023 at 02:58:06PM +0530, Chandan Babu R wrote:
> metadump v2 format allows dumping metadata from external log devices. This
> commit allows passing the device file to which log data must be restored from
> the corresponding metadump file.
> 
> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>

Woot, thanks for working on this!
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  man/man8/xfs_mdrestore.8  |  8 ++++++++
>  mdrestore/xfs_mdrestore.c | 11 +++++++++--
>  2 files changed, 17 insertions(+), 2 deletions(-)
> 
> diff --git a/man/man8/xfs_mdrestore.8 b/man/man8/xfs_mdrestore.8
> index 72f3b297..6e7457c0 100644
> --- a/man/man8/xfs_mdrestore.8
> +++ b/man/man8/xfs_mdrestore.8
> @@ -5,6 +5,9 @@ xfs_mdrestore \- restores an XFS metadump image to a filesystem image
>  .B xfs_mdrestore
>  [
>  .B \-gi
> +] [
> +.B \-l
> +.I logdev
>  ]
>  .I source
>  .I target
> @@ -49,6 +52,11 @@ Shows metadump information on stdout.  If no
>  is specified, exits after displaying information.  Older metadumps man not
>  include any descriptive information.
>  .TP
> +.B \-l " logdev"
> +Metadump in v2 format can contain metadata dumped from an external log.
> +In such a scenario, the user has to provide a device to which the log device
> +contents from the metadump file are copied.
> +.TP
>  .B \-V
>  Prints the version number and exits.
>  .SH DIAGNOSTICS
> diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
> index 7b484071..7d7c22fe 100644
> --- a/mdrestore/xfs_mdrestore.c
> +++ b/mdrestore/xfs_mdrestore.c
> @@ -460,7 +460,8 @@ static struct mdrestore_ops mdrestore_ops_v2 = {
>  static void
>  usage(void)
>  {
> -	fprintf(stderr, "Usage: %s [-V] [-g] [-i] source target\n", progname);
> +	fprintf(stderr, "Usage: %s [-V] [-g] [-i] [-l logdev] source target\n",
> +		progname);
>  	exit(1);
>  }
>  
> @@ -490,7 +491,7 @@ main(
>  
>  	progname = basename(argv[0]);
>  
> -	while ((c = getopt(argc, argv, "giV")) != EOF) {
> +	while ((c = getopt(argc, argv, "gil:V")) != EOF) {
>  		switch (c) {
>  			case 'g':
>  				mdrestore.show_progress = true;
> @@ -498,6 +499,10 @@ main(
>  			case 'i':
>  				mdrestore.show_info = true;
>  				break;
> +			case 'l':
> +				logdev = optarg;
> +				mdrestore.external_log = true;
> +				break;
>  			case 'V':
>  				printf("%s version %s\n", progname, VERSION);
>  				exit(0);
> @@ -536,6 +541,8 @@ main(
>  
>  	switch (be32_to_cpu(magic)) {
>  	case XFS_MD_MAGIC_V1:
> +		if (logdev != NULL)
> +			usage();
>  		mdrestore.mdrops = &mdrestore_ops_v1;
>  		break;
>  
> -- 
> 2.39.1
>
Chandan Babu R July 13, 2023, 6:48 a.m. UTC | #2
On Thu, Jul 13, 2023 at 12:04:25 PM +0530, Chandan Babu R wrote:
> On Wed, Jul 12, 2023 at 11:10:28 AM -0700, Darrick J. Wong wrote:
>> On Tue, Jun 06, 2023 at 02:58:06PM +0530, Chandan Babu R wrote:
>>> metadump v2 format allows dumping metadata from external log devices. This
>>> commit allows passing the device file to which log data must be restored from
>>> the corresponding metadump file.
>>> 
>>> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
>>
>> Woot, thanks for working on this!
>> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
>>
>
> Thanks a lot for reviewing the entire patchset.
diff mbox series

Patch

diff --git a/man/man8/xfs_mdrestore.8 b/man/man8/xfs_mdrestore.8
index 72f3b297..6e7457c0 100644
--- a/man/man8/xfs_mdrestore.8
+++ b/man/man8/xfs_mdrestore.8
@@ -5,6 +5,9 @@  xfs_mdrestore \- restores an XFS metadump image to a filesystem image
 .B xfs_mdrestore
 [
 .B \-gi
+] [
+.B \-l
+.I logdev
 ]
 .I source
 .I target
@@ -49,6 +52,11 @@  Shows metadump information on stdout.  If no
 is specified, exits after displaying information.  Older metadumps man not
 include any descriptive information.
 .TP
+.B \-l " logdev"
+Metadump in v2 format can contain metadata dumped from an external log.
+In such a scenario, the user has to provide a device to which the log device
+contents from the metadump file are copied.
+.TP
 .B \-V
 Prints the version number and exits.
 .SH DIAGNOSTICS
diff --git a/mdrestore/xfs_mdrestore.c b/mdrestore/xfs_mdrestore.c
index 7b484071..7d7c22fe 100644
--- a/mdrestore/xfs_mdrestore.c
+++ b/mdrestore/xfs_mdrestore.c
@@ -460,7 +460,8 @@  static struct mdrestore_ops mdrestore_ops_v2 = {
 static void
 usage(void)
 {
-	fprintf(stderr, "Usage: %s [-V] [-g] [-i] source target\n", progname);
+	fprintf(stderr, "Usage: %s [-V] [-g] [-i] [-l logdev] source target\n",
+		progname);
 	exit(1);
 }
 
@@ -490,7 +491,7 @@  main(
 
 	progname = basename(argv[0]);
 
-	while ((c = getopt(argc, argv, "giV")) != EOF) {
+	while ((c = getopt(argc, argv, "gil:V")) != EOF) {
 		switch (c) {
 			case 'g':
 				mdrestore.show_progress = true;
@@ -498,6 +499,10 @@  main(
 			case 'i':
 				mdrestore.show_info = true;
 				break;
+			case 'l':
+				logdev = optarg;
+				mdrestore.external_log = true;
+				break;
 			case 'V':
 				printf("%s version %s\n", progname, VERSION);
 				exit(0);
@@ -536,6 +541,8 @@  main(
 
 	switch (be32_to_cpu(magic)) {
 	case XFS_MD_MAGIC_V1:
+		if (logdev != NULL)
+			usage();
 		mdrestore.mdrops = &mdrestore_ops_v1;
 		break;