From patchwork Fri Feb 3 01:02:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 13126882 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85351C61DA4 for ; Fri, 3 Feb 2023 01:03:42 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1pNkUO-0005ER-Jr; Fri, 03 Feb 2023 01:03:39 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pNkUL-0005EL-VL for linux-f2fs-devel@lists.sourceforge.net; Fri, 03 Feb 2023 01:03:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=jvKtRdKzyboyHgHmgcf2t89gEFXiHc6xToK5xgfGIcU=; b=LB6P9KI/ldohsw+Ld9w9DNKFa0 gCaoZj93chVxKyDByOANy+Z5dT0sG471ndgbkKnvqlkdBXGxV7ffTo3PIMMVDeX14E5mwESyvvtoE 1SIs635NChtUmQZVJgAHlpkKvn6lWHt7YT5JQhIMWyZHhWAh/+4cxOKAKiA1+LSDy2y4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=jvKtRdKzyboyHgHmgcf2t89gEFXiHc6xToK5xgfGIcU=; b=m 8HAqLLl+ooqd+JWIzOmWYxsgAouYlHVG9kzOHMDn4zTJGGSS4gIDEBg37FkAY8QngNfgl7mM9Fg8w CpNMz7pO5aK+MBkUdDt+d5A/3J/hC/ny61P8fRCeOYDFpYkFhSPovFJ5Fnc/i4ouEMCMbhBn284mV V444Qh/Rlkhy0Jlw=; Received: from ams.source.kernel.org ([145.40.68.75]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1pNkUJ-0002zH-K4 for linux-f2fs-devel@lists.sourceforge.net; Fri, 03 Feb 2023 01:03:37 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0D3D5B828DE; Fri, 3 Feb 2023 01:03:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C9BDC433D2; Fri, 3 Feb 2023 01:03:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675386208; bh=sh0TjyWGQ9JudO9PAEgymM1IjtlW0nUu2xMRWylfafA=; h=From:To:Cc:Subject:Date:From; b=pYGKbv7GLtPxXrXlNcebSiLkqQkWtfqvrf3Ekj6KOLFIBU7lcVEq3uKBozBfFShYt ITK3HHTz+DRvde7O4jU3ZpH8DJGQiGWE2GujCxhwijWyEaSJuRg+nGOieKkBTAqtCv Z+Tpa9LXinGC7xez25ol2fXXniG0rrcQBTBm3sFfaz+rlDJd7Eh+wdyiXdPRmuM+H0 zkyxnafvPoVAj8yKFsDIP4uwhmzLPhlP1zIVVJRUPvawAe6I93d+xGVy2kBV72PVIM rGcY2ZP6SAhF2ph7XhuxzocLGD7GSHJqlwdIGLXzctf6sf8ZuKJqvPAz4+oNpbTPMh mGGl/HxcPRdSg== From: Eric Biggers To: linux-f2fs-devel@lists.sourceforge.net Date: Thu, 2 Feb 2023 17:02:39 -0800 Message-Id: <20230203010239.216421-1-ebiggers@kernel.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Headers-End: 1pNkUJ-0002zH-K4 Subject: [f2fs-dev] [PATCH] f2fs: fix cgroup writeback accounting with fs-layer encryption X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: stable@vger.kernel.org, Tejun Heo , linux-fscrypt@vger.kernel.org, Matthew Wilcox , linux-fsdevel@vger.kernel.org Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Eric Biggers 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) Signed-off-by: Eric Biggers Reviewed-by: Chao Yu Acked-by: Tejun Heo --- fs/f2fs/data.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) base-commit: de6b3a5e09b29c014bd04044b023896107cfa2ee diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 754841bce389f..8a636500db0ef 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -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 @@ int f2fs_merge_page_bio(struct f2fs_io_info *fio) } 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 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio) } 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;