From: Andrew Price Date: Tue, 10 Jan 2017 14:34:43 +0000 Subject: [Cluster-devel] [PATCH 2/5] gfs2_edit savemeta: Don't read rgrp blocks twice In-Reply-To: <20170110143446.14419-1-anprice@redhat.com> References: <20170110143446.14419-1-anprice@redhat.com> Message-ID: <20170110143446.14419-3-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 When savemeta iterates over the rgrps and saves the rgrp header blocks it calls save_block which does a bread() for each block despite them already being read in earlier. Instead, call save_bh() on the existing rgrp buffers. This isn't likely to give a significant performance improvement as the duplicate reads would be cache hits but it should have a noticeable effect on very large file systems. Signed-off-by: Andrew Price --- gfs2/edit/savemeta.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 3e8dae0..9723dcd 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -855,8 +855,8 @@ void savemeta(char *out_fn, int saveoption, int gziplevel) } /* Walk through the resource groups saving everything within */ for (n = osi_first(&sbd.rgtree); n; n = osi_next(n)) { - uint64_t blk; struct rgrp_tree *rgd; + unsigned i; rgd = (struct rgrp_tree *)n; if (gfs2_rgrp_read(&sbd, rgd)) @@ -866,10 +866,9 @@ void savemeta(char *out_fn, int saveoption, int gziplevel) (unsigned long long)rgd->ri.ri_addr, rgd->ri.ri_length); /* Save off the rg and bitmaps */ - for (blk = rgd->ri.ri_addr; - blk < rgd->ri.ri_data0; blk++) { - warm_fuzzy_stuff(blk, FALSE); - save_block(sbd.device_fd, &mfd, blk, blk, NULL); + for (i = 0; i < rgd->ri.ri_length; i++) { + warm_fuzzy_stuff(rgd->ri.ri_addr + i, FALSE); + save_bh(&mfd, rgd->bits[i].bi_bh, 0, NULL); } /* Save off the other metadata: inodes, etc. if mode is not 'savergs' */ if (saveoption != 2) { -- 2.9.3