From: Bob Peterson Date: Tue, 27 Oct 2020 09:52:22 -0500 Subject: [Cluster-devel] [GFS2 PATCH 3/3] gfs2: Use filemap_fdatawrite_range for gfs2_meta_sync In-Reply-To: <20201027145222.363422-1-rpeterso@redhat.com> References: <20201027145222.363422-1-rpeterso@redhat.com> Message-ID: <20201027145222.363422-4-rpeterso@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Before this patch, function gfs2_meta_sync called filemap_fdatawrite to write the address space for the metadata being synced. That's great for inodes, but for resource groups, they all point to the same superblock-address space, sdp->sd_aspace, with their own range. That meant every time an rgrp's metadata was synced, it would write all of them instead of just the range. This patch changes function gfs2_meta_sync so that instead it calls filemap_fdatawrite_range and filemap_fdatawait_range with a range of addresses appropriate to the object. For inodes, it specifies the whole range, as per filemap_fdatawrite. For rgrps, it uses only the range required. Signed-off-by: Bob Peterson 12345678901234567890123456789012345678901234567890123456789012345678901234567890 --- fs/gfs2/lops.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c index ed69298dd824..94b0e89ee7b2 100644 --- a/fs/gfs2/lops.c +++ b/fs/gfs2/lops.c @@ -827,13 +827,21 @@ void gfs2_meta_sync(struct gfs2_glock *gl) { struct address_space *mapping = gfs2_glock2aspace(gl); struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; + loff_t start = 0; + loff_t end = LLONG_MAX; int error; - if (mapping == NULL) + if (mapping == NULL) { + struct gfs2_rgrpd *rgd = gfs2_glock2rgrp(gl); + const unsigned bsize = sdp->sd_sb.sb_bsize; + mapping = &sdp->sd_aspace; + start = (rgd->rd_addr * bsize) & PAGE_MASK; + end = PAGE_ALIGN((rgd->rd_addr + rgd->rd_length) * bsize) - 1; + } - filemap_fdatawrite(mapping); - error = filemap_fdatawait(mapping); + filemap_fdatawrite_range(mapping, start, end); + error = filemap_fdatawait_range(mapping, start, end); if (error) gfs2_io_error(gl->gl_name.ln_sbd); -- 2.26.2