diff mbox series

[V3,12/23] xfs_db: Add support to read from external log device

Message ID 20230724043527.238600-13-chandan.babu@oracle.com (mailing list archive)
State Superseded, archived
Headers show
Series Metadump v2 | expand

Commit Message

Chandan Babu R July 24, 2023, 4:35 a.m. UTC
This commit introduces a new function set_log_cur() allowing xfs_db to read
from an external log device. This is required by a future commit which will
add the ability to dump metadata from external log devices.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
---
 db/io.c | 56 +++++++++++++++++++++++++++++++++++++++++++-------------
 db/io.h |  2 ++
 2 files changed, 45 insertions(+), 13 deletions(-)

Comments

Darrick J. Wong Aug. 1, 2023, 11:49 p.m. UTC | #1
On Mon, Jul 24, 2023 at 10:05:16AM +0530, Chandan Babu R wrote:
> This commit introduces a new function set_log_cur() allowing xfs_db to read
> from an external log device. This is required by a future commit which will
> add the ability to dump metadata from external log devices.
> 
> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>

Looks good now,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  db/io.c | 56 +++++++++++++++++++++++++++++++++++++++++++-------------
>  db/io.h |  2 ++
>  2 files changed, 45 insertions(+), 13 deletions(-)
> 
> diff --git a/db/io.c b/db/io.c
> index 3d257236..5ccfe3b5 100644
> --- a/db/io.c
> +++ b/db/io.c
> @@ -508,18 +508,19 @@ write_cur(void)
>  
>  }
>  
> -void
> -set_cur(
> -	const typ_t	*type,
> -	xfs_daddr_t	blknum,
> -	int		len,
> -	int		ring_flag,
> -	bbmap_t		*bbmap)
> +static void
> +__set_cur(
> +	struct xfs_buftarg	*btargp,
> +	const typ_t		*type,
> +	xfs_daddr_t		 blknum,
> +	int			 len,
> +	int			 ring_flag,
> +	bbmap_t			*bbmap)
>  {
> -	struct xfs_buf	*bp;
> -	xfs_ino_t	dirino;
> -	xfs_ino_t	ino;
> -	uint16_t	mode;
> +	struct xfs_buf		*bp;
> +	xfs_ino_t		dirino;
> +	xfs_ino_t		ino;
> +	uint16_t		mode;
>  	const struct xfs_buf_ops *ops = type ? type->bops : NULL;
>  	int		error;
>  
> @@ -548,11 +549,11 @@ set_cur(
>  		if (!iocur_top->bbmap)
>  			return;
>  		memcpy(iocur_top->bbmap, bbmap, sizeof(struct bbmap));
> -		error = -libxfs_buf_read_map(mp->m_ddev_targp, bbmap->b,
> +		error = -libxfs_buf_read_map(btargp, bbmap->b,
>  				bbmap->nmaps, LIBXFS_READBUF_SALVAGE, &bp,
>  				ops);
>  	} else {
> -		error = -libxfs_buf_read(mp->m_ddev_targp, blknum, len,
> +		error = -libxfs_buf_read(btargp, blknum, len,
>  				LIBXFS_READBUF_SALVAGE, &bp, ops);
>  		iocur_top->bbmap = NULL;
>  	}
> @@ -589,6 +590,35 @@ set_cur(
>  		ring_add();
>  }
>  
> +void
> +set_cur(
> +	const typ_t	*type,
> +	xfs_daddr_t	blknum,
> +	int		len,
> +	int		ring_flag,
> +	bbmap_t		*bbmap)
> +{
> +	__set_cur(mp->m_ddev_targp, type, blknum, len, ring_flag, bbmap);
> +}
> +
> +void
> +set_log_cur(
> +	const typ_t	*type,
> +	xfs_daddr_t	blknum,
> +	int		len,
> +	int		ring_flag,
> +	bbmap_t		*bbmap)
> +{
> +	if (mp->m_logdev_targp->bt_bdev == mp->m_ddev_targp->bt_bdev) {
> +		fprintf(stderr, "no external log specified\n");
> +		exitcode = 1;
> +		return;
> +	}
> +
> +	__set_cur(mp->m_logdev_targp, type, blknum, len, ring_flag, bbmap);
> +}
> +
> +
>  void
>  set_iocur_type(
>  	const typ_t	*type)
> diff --git a/db/io.h b/db/io.h
> index c29a7488..bd86c31f 100644
> --- a/db/io.h
> +++ b/db/io.h
> @@ -49,6 +49,8 @@ extern void	push_cur_and_set_type(void);
>  extern void	write_cur(void);
>  extern void	set_cur(const struct typ *type, xfs_daddr_t blknum,
>  			int len, int ring_add, bbmap_t *bbmap);
> +extern void	set_log_cur(const struct typ *type, xfs_daddr_t blknum,
> +			int len, int ring_add, bbmap_t *bbmap);
>  extern void     ring_add(void);
>  extern void	set_iocur_type(const struct typ *type);
>  extern void	xfs_dummy_verify(struct xfs_buf *bp);
> -- 
> 2.39.1
>
diff mbox series

Patch

diff --git a/db/io.c b/db/io.c
index 3d257236..5ccfe3b5 100644
--- a/db/io.c
+++ b/db/io.c
@@ -508,18 +508,19 @@  write_cur(void)
 
 }
 
-void
-set_cur(
-	const typ_t	*type,
-	xfs_daddr_t	blknum,
-	int		len,
-	int		ring_flag,
-	bbmap_t		*bbmap)
+static void
+__set_cur(
+	struct xfs_buftarg	*btargp,
+	const typ_t		*type,
+	xfs_daddr_t		 blknum,
+	int			 len,
+	int			 ring_flag,
+	bbmap_t			*bbmap)
 {
-	struct xfs_buf	*bp;
-	xfs_ino_t	dirino;
-	xfs_ino_t	ino;
-	uint16_t	mode;
+	struct xfs_buf		*bp;
+	xfs_ino_t		dirino;
+	xfs_ino_t		ino;
+	uint16_t		mode;
 	const struct xfs_buf_ops *ops = type ? type->bops : NULL;
 	int		error;
 
@@ -548,11 +549,11 @@  set_cur(
 		if (!iocur_top->bbmap)
 			return;
 		memcpy(iocur_top->bbmap, bbmap, sizeof(struct bbmap));
-		error = -libxfs_buf_read_map(mp->m_ddev_targp, bbmap->b,
+		error = -libxfs_buf_read_map(btargp, bbmap->b,
 				bbmap->nmaps, LIBXFS_READBUF_SALVAGE, &bp,
 				ops);
 	} else {
-		error = -libxfs_buf_read(mp->m_ddev_targp, blknum, len,
+		error = -libxfs_buf_read(btargp, blknum, len,
 				LIBXFS_READBUF_SALVAGE, &bp, ops);
 		iocur_top->bbmap = NULL;
 	}
@@ -589,6 +590,35 @@  set_cur(
 		ring_add();
 }
 
+void
+set_cur(
+	const typ_t	*type,
+	xfs_daddr_t	blknum,
+	int		len,
+	int		ring_flag,
+	bbmap_t		*bbmap)
+{
+	__set_cur(mp->m_ddev_targp, type, blknum, len, ring_flag, bbmap);
+}
+
+void
+set_log_cur(
+	const typ_t	*type,
+	xfs_daddr_t	blknum,
+	int		len,
+	int		ring_flag,
+	bbmap_t		*bbmap)
+{
+	if (mp->m_logdev_targp->bt_bdev == mp->m_ddev_targp->bt_bdev) {
+		fprintf(stderr, "no external log specified\n");
+		exitcode = 1;
+		return;
+	}
+
+	__set_cur(mp->m_logdev_targp, type, blknum, len, ring_flag, bbmap);
+}
+
+
 void
 set_iocur_type(
 	const typ_t	*type)
diff --git a/db/io.h b/db/io.h
index c29a7488..bd86c31f 100644
--- a/db/io.h
+++ b/db/io.h
@@ -49,6 +49,8 @@  extern void	push_cur_and_set_type(void);
 extern void	write_cur(void);
 extern void	set_cur(const struct typ *type, xfs_daddr_t blknum,
 			int len, int ring_add, bbmap_t *bbmap);
+extern void	set_log_cur(const struct typ *type, xfs_daddr_t blknum,
+			int len, int ring_add, bbmap_t *bbmap);
 extern void     ring_add(void);
 extern void	set_iocur_type(const struct typ *type);
 extern void	xfs_dummy_verify(struct xfs_buf *bp);