On Tue, May 23, 2023 at 02:30:39PM +0530, Chandan Babu R wrote: > The new option allows the user to explicitly specify the version of metadump > to use. However, we will default to using the v1 format. > > Signed-off-by: Chandan Babu R <chandan.babu@xxxxxxxxxx> Looks fine, Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx> --D > --- > db/metadump.c | 18 ++++++++++++++++-- > 1 file changed, 16 insertions(+), 2 deletions(-) > > diff --git a/db/metadump.c b/db/metadump.c > index 627436e68..df508b987 100644 > --- a/db/metadump.c > +++ b/db/metadump.c > @@ -37,7 +37,7 @@ static void metadump_help(void); > > static const cmdinfo_t metadump_cmd = > { "metadump", NULL, metadump_f, 0, -1, 0, > - N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"), > + N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] [-v 1|2] filename"), > N_("dump metadata to a file"), metadump_help }; > > struct metadump_ops { > @@ -91,6 +91,7 @@ metadump_help(void) > " -g -- Display dump progress\n" > " -m -- Specify max extent size in blocks to copy (default = %d blocks)\n" > " -o -- Don't obfuscate names and extended attributes\n" > +" -v -- Metadump version to be used\n" > " -w -- Show warnings of bad metadata information\n" > "\n"), DEFAULT_MAX_EXT_SIZE); > } > @@ -3112,6 +3113,7 @@ metadump_f( > int outfd = -1; > int ret; > char *p; > + bool version_opt_set = false; > > exitcode = 1; > > @@ -3140,7 +3142,7 @@ metadump_f( > return 0; > } > > - while ((c = getopt(argc, argv, "aegm:ow")) != EOF) { > + while ((c = getopt(argc, argv, "aegm:ov:w")) != EOF) { > switch (c) { > case 'a': > metadump.zero_stale_data = 0; > @@ -3164,6 +3166,15 @@ metadump_f( > case 'o': > metadump.obfuscate = 0; > break; > + case 'v': > + metadump.version = (int)strtol(optarg, &p, 0); > + if (*p != '\0' || (metadump.version != 1 && metadump.version != 2)) { > + print_warning("bad metadump version: %s", > + optarg); > + return 0; > + } > + version_opt_set = true; > + break; > case 'w': > metadump.show_warnings = 1; > break; > @@ -3178,6 +3189,9 @@ metadump_f( > return 0; > } > > + if (mp->m_logdev_targp != mp->m_ddev_targp && version_opt_set == false) > + metadump.version = 2; > + > /* If we'll copy the log, see if the log is dirty */ > if (mp->m_logdev_targp == mp->m_ddev_targp || metadump.version == 2) { > log_type = TYP_LOG; > -- > 2.39.1 >