From: Andrew Price Date: Thu, 6 Aug 2020 14:38:02 +0100 Subject: [Cluster-devel] [PATCH 27/32] savemeta: Don't trim off trailing zeroes when compressing In-Reply-To: <20200806133807.111280-1-anprice@redhat.com> References: <20200806133807.111280-1-anprice@redhat.com> Message-ID: <20200806133807.111280-28-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 The code that trims the trailing zeroes from blocks before saving them always features as one of the slow points in performance reports. When we're compressing the file anyway, the compression algos should do this much more efficiently than we can, so short circuit it when compression is enabled. Signed-off-by: Andrew Price --- gfs2/edit/savemeta.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c index 76477b79..55f64922 100644 --- a/gfs2/edit/savemeta.c +++ b/gfs2/edit/savemeta.c @@ -532,8 +532,10 @@ static int save_buf(struct metafd *mfd, const char *buf, uint64_t addr, unsigned struct saved_metablock *savedata; size_t outsz; - /* No need to save trailing zeroes */ - for (; blklen > 0 && buf[blklen - 1] == '\0'; blklen--); + /* No need to save trailing zeroes, but leave that for compression to + deal with when enabled as this adds a significant overhead */ + if (mfd->gziplevel == 0) + for (; blklen > 0 && buf[blklen - 1] == '\0'; blklen--); if (blklen == 0) /* No significant data; skip. */ return 0; -- 2.26.2