aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChandan Babu R <chandan.babu@oracle.com>2023-11-06 18:40:40 +0530
committerCarlos Maiolino <cem@kernel.org>2023-11-21 14:09:36 +0100
commitbe75f7d73be22eb89d48eceeff191049f7e16f4e (patch)
tree8b3da4e3e39912a1eaa3085c07ad7775e78ad5b1
parent1e4702774a2d1e78d81cb63b5f4338625ea7cea2 (diff)
downloadxfsprogs-dev-be75f7d73be22eb89d48eceeff191049f7e16f4e.tar.gz
metadump: Introduce struct metadump_ops
We will need two sets of functions to implement two versions of metadump. This commit adds the definition for 'struct metadump_ops' to hold pointers to version specific metadump functions. Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com> Signed-off-by: Carlos Maiolino <cem@kernel.org>
-rw-r--r--db/metadump.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/db/metadump.c b/db/metadump.c
index 24f0b41fda..a2ec6ab569 100644
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -41,6 +41,30 @@ static const cmdinfo_t metadump_cmd =
N_("[-a] [-e] [-g] [-m max_extent] [-w] [-o] filename"),
N_("dump metadata to a file"), metadump_help };
+struct metadump_ops {
+ /*
+ * Initialize Metadump. This may perform actions such as
+ * 1. Allocating memory for structures required for dumping the
+ * metadata.
+ * 2. Writing a header to the beginning of the metadump file.
+ */
+ int (*init)(void);
+ /*
+ * Write metadata to the metadump file along with the required ancillary
+ * data. @off and @len are in units of 512 byte blocks.
+ */
+ int (*write)(enum typnm type, const char *data, xfs_daddr_t off,
+ int len);
+ /*
+ * Flush any in-memory remanents of metadata to the metadump file.
+ */
+ int (*finish_dump)(void);
+ /*
+ * Free resources allocated during metadump process.
+ */
+ void (*release)(void);
+};
+
static struct metadump {
int version;
bool show_progress;
@@ -55,6 +79,7 @@ static struct metadump {
xfs_ino_t cur_ino;
/* Metadump file */
FILE *outf;
+ struct metadump_ops *mdops;
/* header + index + buffers */
struct xfs_metablock *metablock;
__be64 *block_index;