From: Greg Kroah-Hartman Date: Fri, 17 Mar 2023 13:02:53 +0000 (+0100) Subject: 5.4-stable patches X-Git-Tag: v4.14.311~70 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=23bcc7943e11fa9b59d6521214840b4d7b160961;p=thirdparty%2Fkernel%2Fstable-queue.git 5.4-stable patches added patches: ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch series --- diff --git a/queue-5.4/ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch b/queue-5.4/ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch new file mode 100644 index 00000000000..1210b2e5334 --- /dev/null +++ b/queue-5.4/ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch @@ -0,0 +1,69 @@ +From ffec85d53d0f39ee4680a2cf0795255e000e1feb Mon Sep 17 00:00:00 2001 +From: Eric Biggers +Date: Thu, 2 Feb 2023 16:55:03 -0800 +Subject: ext4: fix cgroup writeback accounting with fs-layer encryption + +From: Eric Biggers + +commit ffec85d53d0f39ee4680a2cf0795255e000e1feb upstream. + +When writing a page from an encrypted file that is using +filesystem-layer encryption (not inline encryption), ext4 encrypts the +pagecache page into a bounce page, then writes the bounce page. + +It also passes the bounce page to wbc_account_cgroup_owner(). That's +incorrect, because the bounce page is a newly allocated temporary page +that doesn't have the memory cgroup of the original pagecache page. +This makes wbc_account_cgroup_owner() not account the I/O to the owner +of the pagecache page as it should. + +Fix this by always passing the pagecache page to +wbc_account_cgroup_owner(). + +Fixes: 001e4a8775f6 ("ext4: implement cgroup writeback support") +Cc: stable@vger.kernel.org +Reported-by: Matthew Wilcox (Oracle) +Signed-off-by: Eric Biggers +Acked-by: Tejun Heo +Link: https://lore.kernel.org/r/20230203005503.141557-1-ebiggers@kernel.org +Signed-off-by: Theodore Ts'o +Signed-off-by: Greg Kroah-Hartman +--- + fs/ext4/page-io.c | 10 ++++++---- + 1 file changed, 6 insertions(+), 4 deletions(-) + +--- a/fs/ext4/page-io.c ++++ b/fs/ext4/page-io.c +@@ -380,7 +380,8 @@ static int io_submit_init_bio(struct ext + + static int io_submit_add_bh(struct ext4_io_submit *io, + struct inode *inode, +- struct page *page, ++ struct page *pagecache_page, ++ struct page *bounce_page, + struct buffer_head *bh) + { + int ret; +@@ -395,10 +396,11 @@ submit_and_retry: + return ret; + io->io_bio->bi_write_hint = inode->i_write_hint; + } +- ret = bio_add_page(io->io_bio, page, bh->b_size, bh_offset(bh)); ++ ret = bio_add_page(io->io_bio, bounce_page ?: pagecache_page, ++ bh->b_size, bh_offset(bh)); + if (ret != bh->b_size) + goto submit_and_retry; +- wbc_account_cgroup_owner(io->io_wbc, page, bh->b_size); ++ wbc_account_cgroup_owner(io->io_wbc, pagecache_page, bh->b_size); + io->io_next_block++; + return 0; + } +@@ -511,7 +513,7 @@ int ext4_bio_write_page(struct ext4_io_s + do { + if (!buffer_async_write(bh)) + continue; +- ret = io_submit_add_bh(io, inode, bounce_page ?: page, bh); ++ ret = io_submit_add_bh(io, inode, page, bounce_page, bh); + if (ret) { + /* + * We only get here on ENOMEM. Not much else diff --git a/queue-5.4/series b/queue-5.4/series new file mode 100644 index 00000000000..3718ee38d00 --- /dev/null +++ b/queue-5.4/series @@ -0,0 +1 @@ +ext4-fix-cgroup-writeback-accounting-with-fs-layer-encryption.patch