mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 22:02:02 +00:00
ext4: fix cgroup writeback accounting with fs-layer encryption
commitffec85d53d
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:001e4a8775
("ext4: 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> Link: https://lore.kernel.org/r/20230203005503.141557-1-ebiggers@kernel.org Signed-off-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
98f6d16140
commit
a9e0ecc0ab
1 changed files with 6 additions and 5 deletions
|
@ -409,7 +409,8 @@ static void io_submit_init_bio(struct ext4_io_submit *io,
|
||||||
|
|
||||||
static void io_submit_add_bh(struct ext4_io_submit *io,
|
static void io_submit_add_bh(struct ext4_io_submit *io,
|
||||||
struct inode *inode,
|
struct inode *inode,
|
||||||
struct page *page,
|
struct page *pagecache_page,
|
||||||
|
struct page *bounce_page,
|
||||||
struct buffer_head *bh)
|
struct buffer_head *bh)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -421,10 +422,11 @@ static void io_submit_add_bh(struct ext4_io_submit *io,
|
||||||
}
|
}
|
||||||
if (io->io_bio == NULL)
|
if (io->io_bio == NULL)
|
||||||
io_submit_init_bio(io, bh);
|
io_submit_init_bio(io, bh);
|
||||||
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)
|
if (ret != bh->b_size)
|
||||||
goto submit_and_retry;
|
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++;
|
io->io_next_block++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -561,8 +563,7 @@ int ext4_bio_write_page(struct ext4_io_submit *io,
|
||||||
do {
|
do {
|
||||||
if (!buffer_async_write(bh))
|
if (!buffer_async_write(bh))
|
||||||
continue;
|
continue;
|
||||||
io_submit_add_bh(io, inode,
|
io_submit_add_bh(io, inode, page, bounce_page, bh);
|
||||||
bounce_page ? bounce_page : page, bh);
|
|
||||||
} while ((bh = bh->b_this_page) != head);
|
} while ((bh = bh->b_this_page) != head);
|
||||||
unlock:
|
unlock:
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
|
|
Loading…
Reference in a new issue