From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/7] gfs2: Fix filesystem block deallocation for short writes
Date: Fri, 13 May 2022 22:48:04 +0200 [thread overview]
Message-ID: <20220513204810.4123139-2-agruenba@redhat.com> (raw)
In-Reply-To: <20220513204810.4123139-1-agruenba@redhat.com>
When a write cannot be carried out in full, gfs2_iomap_end() releases
blocks that have been allocated for this write but haven't been used.
To compute the end of the allocation, gfs2_iomap_end() incorrectly
rounded the end of the attempted write down to the next block boundary
to arrive at the end of the allocation. It would have to round up, but
the end of the allocation is also available as iomap->offset +
iomap->length, so just use that instead.
In addition, use round_up() for computing the start of the unused range.
Fixes: 64bc06bb32ee ("gfs2: iomap buffered write support")
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/bmap.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 39080b2d6cf8..b6697333bb2b 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -1153,13 +1153,12 @@ static int gfs2_iomap_end(struct inode *inode, loff_t pos, loff_t length,
if (length != written && (iomap->flags & IOMAP_F_NEW)) {
/* Deallocate blocks that were just allocated. */
- loff_t blockmask = i_blocksize(inode) - 1;
- loff_t end = (pos + length) & ~blockmask;
+ loff_t hstart = round_up(pos + written, i_blocksize(inode));
+ loff_t hend = iomap->offset + iomap->length;
- pos = (pos + written + blockmask) & ~blockmask;
- if (pos < end) {
- truncate_pagecache_range(inode, pos, end - 1);
- punch_hole(ip, pos, end - pos);
+ if (hstart < hend) {
+ truncate_pagecache_range(inode, hstart, hend - 1);
+ punch_hole(ip, hstart, hend - hstart);
}
}
--
2.35.1
next prev parent reply other threads:[~2022-05-13 20:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 20:48 [Cluster-devel] [PATCH 0/7] gfs2 fixes Andreas Gruenbacher
2022-05-13 20:48 ` Andreas Gruenbacher [this message]
2022-05-13 20:48 ` [Cluster-devel] [PATCH 2/7] gfs2: Variable rename Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 3/7] gfs2: Clean up use of fault_in_iov_iter_{read, write}able Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 4/7] gfs2: Pull return value test out of should_fault_in_pages Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 5/7] gfs2: Align read and write chunks to the page cache Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 6/7] gfs2: buffered write prefaulting Andreas Gruenbacher
2022-05-13 20:48 ` [Cluster-devel] [PATCH 7/7] gfs2: Stop using glock holder auto-demotion for now Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220513204810.4123139-2-agruenba@redhat.com \
--to=agruenba@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).