From: Andrew Price Date: Thu, 13 Apr 2017 17:57:39 +0100 Subject: [Cluster-devel] [PATCH 1/3] mkfs.gfs2: Free unnecessary cached pages, disable readahead Message-ID: <20170413165741.21722-1-anprice@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit With a 300T file system, cached pages built up quite heavily and could be left over from previous io on the device. Use POSIX_FADV_DONTNEED where appropriate. Also, readahead isn't required as mkfs.gfs2 mainly writing full block ranges at unpredictable locations so use POSIX_FADV_RANDOM to minimise the overhead from that. Signed-off-by: Andrew Price --- gfs2/mkfs/main_mkfs.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c index 0801a4b..83065fb 100644 --- a/gfs2/mkfs/main_mkfs.c +++ b/gfs2/mkfs/main_mkfs.c @@ -817,6 +817,7 @@ static int place_rgrps(struct gfs2_sbd *sdp, lgfs2_rgrps_t rgs, struct mkfs_opts gfs2_progress_update(&progress, (sdp->rgrps)); } gfs2_progress_close(&progress, _("Done\n")); + posix_fadvise(sdp->device_fd, 0, sdp->fssize * sdp->bsize, POSIX_FADV_DONTNEED); return 0; } @@ -909,6 +910,11 @@ static void open_dev(struct mkfs_dev *dev, int withprobe) exit(1); } + /* Freshen up the cache */ + posix_fadvise(dev->fd, 0, 0, POSIX_FADV_DONTNEED); + /* Turn off readahead, we're just writing new blocks */ + posix_fadvise(dev->fd, 0, 0, POSIX_FADV_RANDOM); + error = fstat(dev->fd, &dev->stat); if (error < 0) { perror(dev->path); @@ -1075,7 +1081,7 @@ int main(int argc, char *argv[]) perror(opts.dev.path); exit(EXIT_FAILURE); } - + posix_fadvise(opts.dev.fd, 0, 0, POSIX_FADV_DONTNEED); error = close(opts.dev.fd); if (error){ perror(opts.dev.path); -- 2.9.3