All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 7/8] libxfs: add function to free all bufferse in bcache
Date: Thu, 11 Jan 2018 13:37:37 -0600	[thread overview]
Message-ID: <1515699458-6925-8-git-send-email-sandeen@sandeen.net> (raw)
In-Reply-To: <1515699458-6925-1-git-send-email-sandeen@sandeen.net>

libxfs_bcache_purge simply moves all "free" buffers
onto the xfs_buf_freelist mru list; add a new function to
actually free them when we tear everything down, so leak
checkers don't go nuts about lots of unfreed xfs_bufs
at exit.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
---
 libxfs/init.c      |  2 ++
 libxfs/libxfs_io.h |  1 +
 libxfs/rdwr.c      | 16 ++++++++++++++++
 3 files changed, 19 insertions(+)

diff --git a/libxfs/init.c b/libxfs/init.c
index 7bde8b7..aea308b 100644
--- a/libxfs/init.c
+++ b/libxfs/init.c
@@ -889,6 +889,8 @@ void
 libxfs_destroy(void)
 {
 	manage_zones(1);
+	libxfs_bcache_purge();
+	libxfs_bcache_free();
 	cache_destroy(libxfs_bcache);
 }
 
diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h
index 2fce04d..81d2804 100644
--- a/libxfs/libxfs_io.h
+++ b/libxfs/libxfs_io.h
@@ -191,6 +191,7 @@ extern void	libxfs_readbuf_verify(struct xfs_buf *bp,
 			const struct xfs_buf_ops *ops);
 extern xfs_buf_t *libxfs_getsb(struct xfs_mount *, int);
 extern void	libxfs_bcache_purge(void);
+extern void	libxfs_bcache_free(void);
 extern void	libxfs_bcache_flush(void);
 extern void	libxfs_purgebuf(xfs_buf_t *);
 extern int	libxfs_bcache_overflowed(void);
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index c5ffd4d..1dcabdd 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -1278,6 +1278,22 @@ libxfs_bulkrelse(
 }
 
 /*
+ * Free everything from the xfs_buf_freelist MRU, used at final teardown
+ */
+void
+libxfs_bcache_free(void)
+{
+	struct list_head	*cm_list;
+	xfs_buf_t		*bp, *next;
+
+ 	cm_list = &xfs_buf_freelist.cm_list;
+	list_for_each_entry_safe(bp, next, cm_list, b_node.cn_mru) {
+		free(bp->b_addr);
+		free(bp);
+	}
+}
+
+/*
  * When a buffer is marked dirty, the error is cleared. Hence if we are trying
  * to flush a buffer prior to cache reclaim that has an error on it it means
  * we've already tried to flush it and it failed. Prevent repeated corruption
-- 
1.8.3.1


  parent reply	other threads:[~2018-01-11 19:37 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11 19:37 [PATCH 0/8] libxfs: cleanup & leak detection Eric Sandeen
2018-01-11 19:37 ` [PATCH 1/8] xfs: remove wrappers around b_fspriv Eric Sandeen
2018-01-11 19:42   ` Darrick J. Wong
2018-01-11 19:37 ` [PATCH 2/8] xfs: add a proper transaction pointer to struct xfs_buf Eric Sandeen
2018-01-11 19:43   ` Darrick J. Wong
2018-01-11 19:37 ` [PATCH 3/8] xfs: remove unused buf_fsprivate3 Eric Sandeen
2018-01-11 19:44   ` Darrick J. Wong
2018-01-11 19:37 ` [PATCH 4/8] libxfs: use a memory zone for transactions Eric Sandeen
2018-01-11 19:48   ` Darrick J. Wong
2018-01-25 19:01   ` [PATCH 4/8 V2] " Eric Sandeen
2018-01-25 19:22     ` Darrick J. Wong
2018-01-11 19:37 ` [PATCH 5/8] libxfs: use a memory zone for log items Eric Sandeen
2018-01-11 19:49   ` Darrick J. Wong
2018-01-11 19:37 ` [PATCH 6/8] libxfs: manage xfs_buf_zone count within cache Eric Sandeen
2018-01-11 20:20   ` Darrick J. Wong
2018-01-11 20:48     ` Eric Sandeen
2018-01-11 22:09       ` Dave Chinner
2018-01-11 19:37 ` Eric Sandeen [this message]
2018-01-11 20:05   ` [PATCH 7/8] libxfs: add function to free all bufferse in bcache Darrick J. Wong
2018-01-11 20:11     ` Eric Sandeen
2018-01-11 20:22       ` Darrick J. Wong
2018-01-11 19:37 ` [PATCH 8/8] libxfs: Catch non-empty zones on destroy Eric Sandeen
2018-01-11 20:29   ` Darrick J. Wong
2018-01-11 23:42     ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515699458-6925-8-git-send-email-sandeen@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.