From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org, willy@infradead.org,
viro@zeniv.linux.org.uk, hch@lst.de, jack@suse.cz,
akpm@linux-foundation.org
Subject: [merged mm-stable] fs-dont-allocate-blocks-beyond-eof-from-__mpage_writepage.patch removed from -mm tree
Date: Wed, 18 Jan 2023 17:16:25 -0800 [thread overview]
Message-ID: <20230119011626.028EBC433D2@smtp.kernel.org> (raw)
The quilt patch titled
Subject: fs: don't allocate blocks beyond EOF from __mpage_writepage
has been removed from the -mm tree. Its filename was
fs-dont-allocate-blocks-beyond-eof-from-__mpage_writepage.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Jan Kara <jack@suse.cz>
Subject: fs: don't allocate blocks beyond EOF from __mpage_writepage
Date: Tue, 3 Jan 2023 11:44:30 +0100
When __mpage_writepage() is called for a page beyond EOF, it will go and
allocate all blocks underlying the page. This is not only unnecessary but
this way blocks can get leaked (e.g. if a page beyond EOF is marked dirty
but in the end write fails and i_size is not extended).
Link: https://lkml.kernel.org/r/20230103104430.27749-1-jack@suse.cz
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/mpage.c | 6 ++++++
1 file changed, 6 insertions(+)
--- a/fs/mpage.c~fs-dont-allocate-blocks-beyond-eof-from-__mpage_writepage
+++ a/fs/mpage.c
@@ -524,6 +524,12 @@ static int __mpage_writepage(struct page
*/
BUG_ON(!PageUptodate(page));
block_in_file = (sector_t)page->index << (PAGE_SHIFT - blkbits);
+ /*
+ * Whole page beyond EOF? Skip allocating blocks to avoid leaking
+ * space.
+ */
+ if (block_in_file >= (i_size + (1 << blkbits) - 1) >> blkbits)
+ goto page_is_mapped;
last_block = (i_size - 1) >> blkbits;
map_bh.b_page = page;
for (page_block = 0; page_block < blocks_per_page; ) {
_
Patches currently in -mm which might be from jack@suse.cz are
reply other threads:[~2023-01-19 1:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20230119011626.028EBC433D2@smtp.kernel.org \
--to=akpm@linux-foundation.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.