From 432f29db7a12e3da7dbfb4d54d65799e4e3cb1bb Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 8 Sep 2017 11:00:40 -0700 Subject: [PATCH] hammer2 - Improve swapcache support * Properly set B_NOTMETA on media buffers, which allows swapcache to distinguish between data and meta-data buffers. This ensures that a user desiring to only swapcache meta-data does not blow all the SSD swap on file data, particularly if there is an excessive amount of file data. * Greatly improves bulkfree performance on hard drives when SSD swapcache is enabled for meta-data only. --- sys/vfs/hammer2/hammer2_io.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sys/vfs/hammer2/hammer2_io.c b/sys/vfs/hammer2/hammer2_io.c index 68e38ecaa7..bb47e2d8d8 100644 --- a/sys/vfs/hammer2/hammer2_io.c +++ b/sys/vfs/hammer2/hammer2_io.c @@ -303,6 +303,9 @@ hammer2_io_getblk(hammer2_dev_t *hmp, int btype, off_t lbase, int lsize, int op) dio->psize, &dio->bp); } if (dio->bp) { + /* + * Handle NEW flags + */ switch(op) { case HAMMER2_DOP_NEW: bzero(hammer2_io_data(dio, lbase), lsize); @@ -314,6 +317,20 @@ hammer2_io_getblk(hammer2_dev_t *hmp, int btype, off_t lbase, int lsize, int op) default: break; } + + /* + * Tell the kernel that the buffer cache is not + * meta-data based on the btype. This allows + * swapcache to distinguish between data and + * meta-data. + */ + switch(btype) { + case HAMMER2_BREF_TYPE_DATA: + dio->bp->b_flags |= B_NOTMETA; + break; + default: + break; + } } } -- 2.41.0