diff mbox series

[V2,06/23] metadump: Postpone invocation of init_metadump()

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

Commit Message

Chandan Babu R June 6, 2023, 9:27 a.m. UTC
The metadump v2 initialization function (introduced in a later commit) writes
the header structure into the metadump file. This will require the program to
open the metadump file before the initialization function has been invoked.

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

Comments

Darrick J. Wong July 12, 2023, 5 p.m. UTC | #1
On Tue, Jun 06, 2023 at 02:57:49PM +0530, Chandan Babu R wrote:
> The metadump v2 initialization function (introduced in a later commit) writes
> the header structure into the metadump file. This will require the program to
> open the metadump file before the initialization function has been invoked.
> 
> Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>

Reviewed-by: Darrick J. Wong <djwong@kernel.org>

--D

> ---
>  db/metadump.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/db/metadump.c b/db/metadump.c
> index ddb5c622..91150664 100644
> --- a/db/metadump.c
> +++ b/db/metadump.c
> @@ -3124,10 +3124,6 @@ metadump_f(
>  		pop_cur();
>  	}
>  
> -	ret = init_metadump();
> -	if (ret)
> -		return 0;
> -
>  	start_iocur_sp = iocur_sp;
>  
>  	if (strcmp(argv[optind], "-") == 0) {
> @@ -3172,6 +3168,10 @@ metadump_f(
>  		}
>  	}
>  
> +	ret = init_metadump();
> +	if (ret)
> +		goto out;
> +
>  	exitcode = 0;
>  
>  	for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
> @@ -3209,8 +3209,9 @@ metadump_f(
>  	/* cleanup iocur stack */
>  	while (iocur_sp > start_iocur_sp)
>  		pop_cur();
> -out:
> +
>  	release_metadump();
>  
> +out:
>  	return 0;
>  }
> -- 
> 2.39.1
>
diff mbox series

Patch

diff --git a/db/metadump.c b/db/metadump.c
index ddb5c622..91150664 100644
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -3124,10 +3124,6 @@  metadump_f(
 		pop_cur();
 	}
 
-	ret = init_metadump();
-	if (ret)
-		return 0;
-
 	start_iocur_sp = iocur_sp;
 
 	if (strcmp(argv[optind], "-") == 0) {
@@ -3172,6 +3168,10 @@  metadump_f(
 		}
 	}
 
+	ret = init_metadump();
+	if (ret)
+		goto out;
+
 	exitcode = 0;
 
 	for (agno = 0; agno < mp->m_sb.sb_agcount; agno++) {
@@ -3209,8 +3209,9 @@  metadump_f(
 	/* cleanup iocur stack */
 	while (iocur_sp > start_iocur_sp)
 		pop_cur();
-out:
+
 	release_metadump();
 
+out:
 	return 0;
 }