f2fs: fix cgroup writeback accounting with fs-layer encryption
authorEric Biggers <ebiggers@google.com>
Fri, 3 Feb 2023 01:02:39 +0000 (17:02 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 6 Feb 2023 03:34:21 +0000 (19:34 -0800)
When writing a page from an encrypted file that is using
filesystem-layer encryption (not inline encryption), f2fs 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: 578c647879f7 ("f2fs: implement cgroup writeback support")
Cc: stable@vger.kernel.org
Reported-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/data.c

index 754841bce389fb5ed1fb4a19b42b703f3dbb4633..8a636500db0ef188888e396eeb5b6b41555c13df 100644 (file)
@@ -739,7 +739,7 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
        }
 
        if (fio->io_wbc && !is_read_io(fio->op))
-               wbc_account_cgroup_owner(fio->io_wbc, page, PAGE_SIZE);
+               wbc_account_cgroup_owner(fio->io_wbc, fio->page, PAGE_SIZE);
 
        inc_page_count(fio->sbi, is_read_io(fio->op) ?
                        __read_io_type(page) : WB_DATA_TYPE(fio->page));
@@ -949,7 +949,7 @@ alloc_new:
        }
 
        if (fio->io_wbc)
-               wbc_account_cgroup_owner(fio->io_wbc, page, PAGE_SIZE);
+               wbc_account_cgroup_owner(fio->io_wbc, fio->page, PAGE_SIZE);
 
        inc_page_count(fio->sbi, WB_DATA_TYPE(page));
 
@@ -1023,7 +1023,7 @@ alloc_new:
        }
 
        if (fio->io_wbc)
-               wbc_account_cgroup_owner(fio->io_wbc, bio_page, PAGE_SIZE);
+               wbc_account_cgroup_owner(fio->io_wbc, fio->page, PAGE_SIZE);
 
        io->last_block_in_bio = fio->new_blkaddr;