fs: don't allocate blocks beyond EOF from __mpage_writepage
authorJan Kara <jack@suse.cz>
Tue, 3 Jan 2023 10:44:30 +0000 (11:44 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 19 Jan 2023 01:12:56 +0000 (17:12 -0800)
commit4b89a37d54a0b5ed6b2e5a9afc44a15a22e563f5
tree8bdbc93c57930559198ec064b2900ce46eccb392
parent6c364edc194e104566f4de72f7a2af5b8fc17110
fs: don't allocate blocks beyond EOF from __mpage_writepage

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