[PATCH 31/37] db: Unwind the IO stack on exit

Dave Chinner
2013-11-06T01:07:49Z

xfs_db can build up a large IO stack by the time it has run to
completion. If we don't unwind this IO stack before we shut down the
libxfs caches, metadump and other db programs will exit with
unreleased buffers and emit warnings like:

cache_purge: shake on cache 0x69e4f0 left 7 nodes!?

Hence we need to unwind the iostack as we shut down.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
db/init.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/db/init.c b/db/init.c
index 4bc048a..8ad21da 100644
--- a/db/init.c
+++ b/db/init.c
@@ -183,9 +183,11 @@ main(
int c, i, done = 0;
char *input;
char **v;
+ int start_iocur_sp;

pushfile(stdin);
init(argc, argv);
+ start_iocur_sp = iocur_sp;

for (i = 0; !done && i < ncmdline; i++) {
v = breakline(cmdline[i], &c);
@@ -209,10 +211,11 @@ main(

close_devices:
/*
- * make sure that we pop the last buffer context we held so that the
- * buffer is released before purge the caches during unmount.
+ * Make sure that we pop the all the buffer contexts we hold so that
+ * they are released before we purge the caches during unmount.
*/
- pop_cur();
+ while (iocur_sp > start_iocur_sp)
+ pop_cur();
libxfs_umount(mp);
if (x.ddev)
libxfs_device_close(x.ddev);