diff mbox series

[06/24] metadump: Dump external log device contents

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

Commit Message

Chandan Babu R May 23, 2023, 9 a.m. UTC
metadump will now read and dump from external log device when the log is
placed on an external device and metadump v2 is supported by xfsprogs.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
---
 db/metadump.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

Comments

Darrick J. Wong May 23, 2023, 5:02 p.m. UTC | #1
On Tue, May 23, 2023 at 02:30:32PM +0530, Chandan Babu R wrote:
> metadump will now read and dump from external log device when the log is
> placed on an external device and metadump v2 is supported by xfsprogs.
> 
> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
> ---
>  db/metadump.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/db/metadump.c b/db/metadump.c
> index e7a433c21..62a36427d 100644
> --- a/db/metadump.c
> +++ b/db/metadump.c
> @@ -2921,7 +2921,7 @@ copy_sb_inodes(void)
>  }
>  
>  static int
> -copy_log(void)
> +copy_log(enum typnm log_type)
>  {
>  	struct xlog	log;
>  	int		dirty;
> @@ -2934,7 +2934,7 @@ copy_log(void)
>  		print_progress("Copying log");
>  
>  	push_cur();
> -	set_cur(&typtab[TYP_LOG], XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
> +	set_cur(&typtab[log_type], XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
>  			mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL);
>  	if (iocur_top->data == NULL) {
>  		pop_cur();
> @@ -3038,6 +3038,7 @@ metadump_f(
>  	char 		**argv)
>  {
>  	xfs_agnumber_t	agno;
> +	enum typnm	log_type;
>  	int		c;
>  	int		start_iocur_sp;
>  	int		outfd = -1;
> @@ -3110,9 +3111,13 @@ metadump_f(
>  	}
>  
>  	/* If we'll copy the log, see if the log is dirty */
> -	if (mp->m_sb.sb_logstart) {
> +	if (mp->m_logdev_targp == mp->m_ddev_targp || metadump.version == 2) {
> +		log_type = TYP_LOG;
> +		if (mp->m_logdev_targp != mp->m_ddev_targp)
> +			log_type = TYP_ELOG;
> +
>  		push_cur();
> -		set_cur(&typtab[TYP_LOG],
> +		set_cur(&typtab[log_type],
>  			XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
>  			mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL);
>  		if (iocur_top->data) {	/* best effort */
> @@ -3185,9 +3190,10 @@ metadump_f(
>  	if (!exitcode)
>  		exitcode = !copy_sb_inodes();
>  
> -	/* copy log if it's internal */
> -	if ((mp->m_sb.sb_logstart != 0) && !exitcode)
> -		exitcode = !copy_log();
> +	/* copy log */
> +	if (!exitcode && (mp->m_logdev_targp == mp->m_ddev_targp ||
> +				metadump.version == 2))

Version 2?  I don't think that's been introduced yet. ;)

--D

> +		exitcode = !copy_log(log_type);
>  
>  	/* write the remaining index */
>  	if (!exitcode)
> -- 
> 2.39.1
>
Chandan Babu R May 26, 2023, 6:54 a.m. UTC | #2
On Tue, May 23, 2023 at 10:02:12 AM -0700, Darrick J. Wong wrote:
> On Tue, May 23, 2023 at 02:30:32PM +0530, Chandan Babu R wrote:
>> metadump will now read and dump from external log device when the log is
>> placed on an external device and metadump v2 is supported by xfsprogs.
>> 
>> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
>> ---
>>  db/metadump.c | 20 +++++++++++++-------
>>  1 file changed, 13 insertions(+), 7 deletions(-)
>> 
>> diff --git a/db/metadump.c b/db/metadump.c
>> index e7a433c21..62a36427d 100644
>> --- a/db/metadump.c
>> +++ b/db/metadump.c
>> @@ -2921,7 +2921,7 @@ copy_sb_inodes(void)
>>  }
>>  
>>  static int
>> -copy_log(void)
>> +copy_log(enum typnm log_type)
>>  {
>>  	struct xlog	log;
>>  	int		dirty;
>> @@ -2934,7 +2934,7 @@ copy_log(void)
>>  		print_progress("Copying log");
>>  
>>  	push_cur();
>> -	set_cur(&typtab[TYP_LOG], XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
>> +	set_cur(&typtab[log_type], XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
>>  			mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL);
>>  	if (iocur_top->data == NULL) {
>>  		pop_cur();
>> @@ -3038,6 +3038,7 @@ metadump_f(
>>  	char 		**argv)
>>  {
>>  	xfs_agnumber_t	agno;
>> +	enum typnm	log_type;
>>  	int		c;
>>  	int		start_iocur_sp;
>>  	int		outfd = -1;
>> @@ -3110,9 +3111,13 @@ metadump_f(
>>  	}
>>  
>>  	/* If we'll copy the log, see if the log is dirty */
>> -	if (mp->m_sb.sb_logstart) {
>> +	if (mp->m_logdev_targp == mp->m_ddev_targp || metadump.version == 2) {
>> +		log_type = TYP_LOG;
>> +		if (mp->m_logdev_targp != mp->m_ddev_targp)
>> +			log_type = TYP_ELOG;
>> +
>>  		push_cur();
>> -		set_cur(&typtab[TYP_LOG],
>> +		set_cur(&typtab[log_type],
>>  			XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
>>  			mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL);
>>  		if (iocur_top->data) {	/* best effort */
>> @@ -3185,9 +3190,10 @@ metadump_f(
>>  	if (!exitcode)
>>  		exitcode = !copy_sb_inodes();
>>  
>> -	/* copy log if it's internal */
>> -	if ((mp->m_sb.sb_logstart != 0) && !exitcode)
>> -		exitcode = !copy_log();
>> +	/* copy log */
>> +	if (!exitcode && (mp->m_logdev_targp == mp->m_ddev_targp ||
>> +				metadump.version == 2))
>
> Version 2?  I don't think that's been introduced yet. ;)
>

I will move the aboves changes to the patch which adds the "-v" option.
diff mbox series

Patch

diff --git a/db/metadump.c b/db/metadump.c
index e7a433c21..62a36427d 100644
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -2921,7 +2921,7 @@  copy_sb_inodes(void)
 }
 
 static int
-copy_log(void)
+copy_log(enum typnm log_type)
 {
 	struct xlog	log;
 	int		dirty;
@@ -2934,7 +2934,7 @@  copy_log(void)
 		print_progress("Copying log");
 
 	push_cur();
-	set_cur(&typtab[TYP_LOG], XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
+	set_cur(&typtab[log_type], XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
 			mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL);
 	if (iocur_top->data == NULL) {
 		pop_cur();
@@ -3038,6 +3038,7 @@  metadump_f(
 	char 		**argv)
 {
 	xfs_agnumber_t	agno;
+	enum typnm	log_type;
 	int		c;
 	int		start_iocur_sp;
 	int		outfd = -1;
@@ -3110,9 +3111,13 @@  metadump_f(
 	}
 
 	/* If we'll copy the log, see if the log is dirty */
-	if (mp->m_sb.sb_logstart) {
+	if (mp->m_logdev_targp == mp->m_ddev_targp || metadump.version == 2) {
+		log_type = TYP_LOG;
+		if (mp->m_logdev_targp != mp->m_ddev_targp)
+			log_type = TYP_ELOG;
+
 		push_cur();
-		set_cur(&typtab[TYP_LOG],
+		set_cur(&typtab[log_type],
 			XFS_FSB_TO_DADDR(mp, mp->m_sb.sb_logstart),
 			mp->m_sb.sb_logblocks * blkbb, DB_RING_IGN, NULL);
 		if (iocur_top->data) {	/* best effort */
@@ -3185,9 +3190,10 @@  metadump_f(
 	if (!exitcode)
 		exitcode = !copy_sb_inodes();
 
-	/* copy log if it's internal */
-	if ((mp->m_sb.sb_logstart != 0) && !exitcode)
-		exitcode = !copy_log();
+	/* copy log */
+	if (!exitcode && (mp->m_logdev_targp == mp->m_ddev_targp ||
+				metadump.version == 2))
+		exitcode = !copy_log(log_type);
 
 	/* write the remaining index */
 	if (!exitcode)