From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp2120.oracle.com ([156.151.31.85]:46668 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932313AbeCFXQR (ORCPT ); Tue, 6 Mar 2018 18:16:17 -0500 Date: Tue, 6 Mar 2018 15:11:11 -0800 From: "Darrick J. Wong" Subject: Re: [PATCH 2/5] libxfs: add function to free all buffers in bcache Message-ID: <20180306231111.GP18989@magnolia> References: <5b3368e5-6ce7-e225-e75c-5dc6486d4b57@sandeen.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5b3368e5-6ce7-e225-e75c-5dc6486d4b57@sandeen.net> Sender: linux-xfs-owner@vger.kernel.org List-ID: List-Id: xfs To: Eric Sandeen Cc: Eric Sandeen , linux-xfs On Tue, Mar 06, 2018 at 03:54:51PM -0600, Eric Sandeen wrote: > 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 > --- > libxfs/init.c | 5 ++++- > libxfs/libxfs_io.h | 1 + > libxfs/rdwr.c | 18 ++++++++++++++++++ > 3 files changed, 23 insertions(+), 1 deletion(-) > > diff --git a/libxfs/init.c b/libxfs/init.c > index 7bde8b7..c7d73b6 100644 > --- a/libxfs/init.c > +++ b/libxfs/init.c > @@ -888,8 +888,11 @@ libxfs_umount(xfs_mount_t *mp) > void > libxfs_destroy(void) > { > - manage_zones(1); > + /* Free everything from the buffer cache before freeing buffer zone */ > + libxfs_bcache_purge(); > + libxfs_bcache_free(); /me wonders if we should warn about unflushed buffers here, but afaict all the existing programs take care of this, so... Reviewed-by: Darrick J. Wong --D > cache_destroy(libxfs_bcache); > + manage_zones(1); > } > > int > diff --git a/libxfs/libxfs_io.h b/libxfs/libxfs_io.h > index 78b6780..6de6fcb 100644 > --- a/libxfs/libxfs_io.h > +++ b/libxfs/libxfs_io.h > @@ -188,6 +188,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 3c5def2..81701b7 100644 > --- a/libxfs/rdwr.c > +++ b/libxfs/rdwr.c > @@ -1275,6 +1275,24 @@ 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); > + if (bp->b_maps != &bp->__b_map) > + free(bp->b_maps); > + kmem_zone_free(xfs_buf_zone, 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 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html