From patchwork Mon Jan 16 08:55:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13102761 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 aib29ajc252.phx1.oracleemaildelivery.com (aib29ajc252.phx1.oracleemaildelivery.com [192.29.103.252]) (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 75894C67871 for ; Mon, 16 Jan 2023 08:55:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=lSLHW6NBJEWSo4eRLy1SR6gt7q4rfkqrhZNyZZDlLz0=; b=POTOpgnnoJ8L5dtRJtTq7cZwGhxpL6OzpGE4BQfCQfogVW6c5fceBhnMpZJNA5ti8kg2F8nbgWym GFemQsVxOT7bYAf0gi2S3eUDNONai7GH3ietccVQ2vlm+j6qGIsrozWyohaIK9Wgs8bz9t59QYrU OgXSbeLySs/yPOa5RL1UyOv5H2Z8GmcTIbho1Kib7RD9jp/gQB9qiP3fYK6ehReLkgrNtbZWqkrG WA2CHScxxF2hiWUVuA4lKM9mndWPsXEniegdFjFXEEgfaqrRerOJYZC2FtdZBSH5RfaB84mYThrt Cogk+qTPiAS8SY8nqSx7yQDjUNvsugRgk3cJaA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=lSLHW6NBJEWSo4eRLy1SR6gt7q4rfkqrhZNyZZDlLz0=; b=Zv/cckhRrVJ3a2+WyGXh2YqxCtpZDri64eE+gCLJdMCJ1BzMl2nLF6urXuxt4ygHXQmeom6qRs2Y 3PZ1uIw5F84DRjrTDnq/zIPuLhVQX6CeSvMDS8yqCdJ/ylHEvBEehZ+nHF8UkwJzpuOI+vLs+myS FxlVwCgiEaqaKQKrsx6iY3YcUXX4hdfq+TdBmvz4tvJewG6nluNu8S1fGLhLkISrZNXZbAQyFtwW PpNpjno4iJr1JFW82wOLpY3op2/kFxKUnAGEBWpoEZ2V9WM71uhWe3E2DJzBiALgkLgnsPDzj3Dn qTzvD+BccLKYaqYpz9QIpa/t0ve2d/I45MYYQA== Received: by omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0ROK00IQGM53SPC0@omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Mon, 16 Jan 2023 08:55:51 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=OG2B/ZSWByZRN4fMNjXk/odq7YMNkG/R7DDN5iMhUtQ=; b=Jv+WhniY9VGch/zC8+PJm+chhT /+rHupK5uBALMlQaZjsepoMcl0mFl8uuNrYuXeGgWwGj280ui4kquded1Op5jmigdG0CjbLd+GpKk XFjxxRaTMGGMYG/Opr2gTEVG87otTdyk3f8TYMf9cI3e7X5AhB4ud2Di9Ptan7y6agqCRO2RhWRsv Hhx+g/gzwuId7dh/3Wc8WfDcAdvNfyWswpDFfQCatswiEOV9LxxHcAHtjbj0lRK9O/lYSyK3ZTARP 3MFPat1picSmsva4N/FL6ON2qSYkYLSo9kJf0HEAU3aCjtxxKnU9sMTH3fcrzJ3qOIfIKQjh4fQoa FeKc/8kQ==; To: Andrew Morton , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Mon, 16 Jan 2023 09:55:18 +0100 Message-id: <20230116085523.2343176-2-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-reply-to: <20230116085523.2343176-1-hch@lst.de> References: <20230116085523.2343176-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10591 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 impostorscore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 bulkscore=0 mlxlogscore=999 priorityscore=0 suspectscore=0 spamscore=0 adultscore=0 malwarescore=0 clxscore=281 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301160065 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 1/6] minix: fix error handling in minix_delete_entry X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christoph Hellwig via Ocfs2-devel Reply-to: Christoph Hellwig Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-ServerName: bombadil.infradead.org X-Proofpoint-SPF-Result: None X-Spam: Clean X-Proofpoint-ORIG-GUID: DanXZ6hxo3XOQpq-OGDLTcMrVxFta0iO X-Proofpoint-GUID: DanXZ6hxo3XOQpq-OGDLTcMrVxFta0iO Reporting-Meta: AAF52hXlZbKCsi6KFkGGog+inSxsRNW1S0LLVo6sX5gGWAfuAlerj1MVinMqhUmM DdxDBLr7OYWKUm/ELd0hQoVuekn4JDgm4Fszmy/KpJ+I1NaUqdoK8cod8TepjM0Q FlRlsSz3gGKvHvwXJrR1L9cvhuxm4GwmcSJPy0pc0B9fwt/afwLjv0D/vo9hFa6E NGu99JBWSdq2eDfNdVlBhhW7dpn4Qv5LipPhNIqB2lOtlf6iExxV376HQBAyZeEx 1jpyFD4iN3j1QfNG0FHkDW8TQOzwbMeC87zMjcyY2rBMofQrytWqntmGyXqPJRyi USi/GbzEIpoYw48YBffENEHgLDLzHNFEkrw1IJiN64saqHdbJOkL4kX3x74elkc9 Be4YsT2Qa0XcA9dPrPGt58fSYepzZnFazZxpuzPg7uRR7Lmir0mqstvjBzQPPts8 m6B+qpdnpefmH5uasZycqWGFBhGcuYrqsZjBAI+rlO0hKcYz1MDcpyWlEJRaZgEd a0ivh0pZWo4eOprt45gl2jpV/9kwkQEHGgGeKUwPN9++ If minix_prepare_chunk fails, updating c/mtime and marking the dir inode dirty is wrong, as the inode hasn't been modified. Note that this moves the dir_put_page call later, but that matches other uses of this helper in the directory code. Signed-off-by: Christoph Hellwig --- fs/minix/dir.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index dcfe5b25378b54..a8e76284cb71ec 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c @@ -297,18 +297,19 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page) lock_page(page); err = minix_prepare_chunk(page, pos, len); - if (err == 0) { - if (sbi->s_version == MINIX_V3) - ((minix3_dirent *) de)->inode = 0; - else - de->inode = 0; - err = dir_commit_chunk(page, pos, len); - } else { + if (err) { unlock_page(page); + goto out_put_page; } - dir_put_page(page); + if (sbi->s_version == MINIX_V3) + ((minix3_dirent *)de)->inode = 0; + else + de->inode = 0; + err = dir_commit_chunk(page, pos, len); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); +out_put_page: + dir_put_page(page); return err; } From patchwork Mon Jan 16 08:55:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13102762 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 aib29ajc253.phx1.oracleemaildelivery.com (aib29ajc253.phx1.oracleemaildelivery.com [192.29.103.253]) (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 87BC3C678D6 for ; Mon, 16 Jan 2023 08:55:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=r3sNFF30Jb5j31at7//39hlfpCm9ShvYjX1GGodt/tc=; b=oyaHrVWziMrmhiJCT25M9KoToN34vTGSnKdBmmaKQ6iokWXOfftKOGOOXfZ07kyRFRKFwgQ5zahM b7JIXEwAhTWbBcAk33BgQtbszxc2iBCSMR6BBNTIpRwweXkPBbsBzZAO0a6HD7rj1NZ1XpcgGkDI JhDNAd4pMLa82K+9yHkA0D1FdHlY6LswgkgsYnzO2lmbsa06APxGQoKIj9UUno8MJ95WnPzD1Dx7 p9XxC64JhI94+aIcvjrJ8QEl0ooTFezJJVwajTt6qw3+kHf7OoUODOoyHpsTeOrrRC7pOaMkenvk 1hHtfBjml84wGojQxcisvgwy2Rx6XsZk7ntmxw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=r3sNFF30Jb5j31at7//39hlfpCm9ShvYjX1GGodt/tc=; b=DSS6YpTz3e52pIhN8S5D+V0Mb2vtlSCnVST/NTaUXUA2m71qHcRafMJ1Z4LXPdG3+YSsxKanx+/b 6kDIEK41IMZbsfzv1B45N1CBE9eCJ9SOdjhGuqZ4meAWl+5mK/R8ZMgV7ZdsbJdIf4MGHm/wREjA fe89G+aJ1iAMTyBf+yqsSkV7dSo3voCFTDdK84c5EmwWrfvhqPQCOEuzahaTgAGDL/ELqBiR+uqb sBLp5cYhKlsMToQap9AuxEKzyTklrRhxjzWWg7Nbtb7VEIpAJ8A0QS84ueKJ0ZFBRLyG26weC25x PDKHYlZ0LpLRJH48lqxabqkkO6DtUgATvj20hg== Received: by omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0ROK0043CM56J040@omta-ad3-fd1-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Mon, 16 Jan 2023 08:55:54 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=NG71ox6jr7uM23QDAMDsMfdxiN0WqWQj6pY4BZkkyg4=; b=ax/Y5gnTZrhv4w+jf2OeQVm0tO ApYJIKsK4ZXfMVwKWlqPdLSJGP7kZIKwE+8CcUbfwwIAFByrMjNSd07pUOBcF66nJ5xWCREc2zMkU 6mQdASNdx+VRTkGlDR6nv34V1Gyn0I0mgWr5vC6NPNwqutc4UvBh0Fclq2irNimI4eewwgg36uQdO fLLkCZXLsoD2eFF6L1iPPsq0srwwA50/WBOJGtJgd6NxY3jjsggeAISiUmyxXvl/WudhRuyFHtfm1 mUmQWnGtNpkbvWi694jhOU5G5hCEQcsB1/CbOSDSPOS+AuNO46i3WVwUrCXrGG3oKZbpzYuFdcpMd vHS2daEQ==; To: Andrew Morton , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Mon, 16 Jan 2023 09:55:19 +0100 Message-id: <20230116085523.2343176-3-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-reply-to: <20230116085523.2343176-1-hch@lst.de> References: <20230116085523.2343176-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10591 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=275 lowpriorityscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 malwarescore=0 bulkscore=0 adultscore=0 phishscore=0 priorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301160065 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 2/6] minix: fix error handling in minix_set_link X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christoph Hellwig via Ocfs2-devel Reply-to: Christoph Hellwig Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-ServerName: bombadil.infradead.org X-Proofpoint-SPF-Result: None X-Spam: Clean X-Proofpoint-GUID: 0nBdLdAVXX77i_YjZY8Qy1T6NkKpxvQd X-Proofpoint-ORIG-GUID: 0nBdLdAVXX77i_YjZY8Qy1T6NkKpxvQd Reporting-Meta: AAFnVytbt0/eJ7/RdC2BiIivGX9wK+sJZBVltpOYkowhFnx3Uy1k5whBcKwCCL7i /REqb++KN70BnDf28oTf7JRfSUFhVOxLvYpqHPTdk+oeTnuLpeFLTXFMGemgg5NJ 6X8i5s0JyGlnTLuTXlpKTe00rhDB2GpZI9FP1Td2ggW50YCecm131ItzJPWTKKdV cUa+cVsokNu396o72TB1XFYDiww6tK7K1lVwS9eT6T+ZUVJEuQRQ9Sar9hg4wpKc I7EjkWecYTNAo9MhM7dKDTSnEuZHo1TANHvsRqWpySgYSUBVRWBzOcoV8d5ZGfrT 5AgvZjD0Ok+wyZpHjVD/htMbrjlYsbGmUFdyKVJ0yMZ0YCm5mfKi6W99jRvdin7M 3u2Br+YQXcUcP9OTnZtiB3JGR8z1wJjETBdvUcu4/ilqWEQUUw6Lj3QcExcxgT43 dEhoD+GomOBx5HgjLrEuSyHYwMXJxA4oqS8lWJ1PaNTzBTE+MZleyHm4eiWzWl70 EfRNKihqL/N5bDsbUXKG3wqlDeeEdL4b6USVURYhsKRH If minix_prepare_chunk fails, updating c/mtime and marking the dir inode dirty is wrong, as the inode hasn't been modified. Also propagate the error to the caller. Note that this moves the dir_put_page call later, but that matches other uses of this helper in the directory code. Signed-off-by: Christoph Hellwig --- fs/minix/dir.c | 23 ++++++++++++----------- fs/minix/minix.h | 3 ++- fs/minix/namei.c | 8 +++++--- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index a8e76284cb71ec..c9a3d520b72671 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c @@ -410,8 +410,8 @@ int minix_empty_dir(struct inode * inode) } /* Releases the page */ -void minix_set_link(struct minix_dir_entry *de, struct page *page, - struct inode *inode) +int minix_set_link(struct minix_dir_entry *de, struct page *page, + struct inode *inode) { struct inode *dir = page->mapping->host; struct minix_sb_info *sbi = minix_sb(dir->i_sb); @@ -420,20 +420,21 @@ void minix_set_link(struct minix_dir_entry *de, struct page *page, int err; lock_page(page); - err = minix_prepare_chunk(page, pos, sbi->s_dirsize); - if (err == 0) { - if (sbi->s_version == MINIX_V3) - ((minix3_dirent *) de)->inode = inode->i_ino; - else - de->inode = inode->i_ino; - err = dir_commit_chunk(page, pos, sbi->s_dirsize); - } else { + if (err) { unlock_page(page); + goto out_put_page; } - dir_put_page(page); + if (sbi->s_version == MINIX_V3) + ((minix3_dirent *)de)->inode = inode->i_ino; + else + de->inode = inode->i_ino; + err = dir_commit_chunk(page, pos, sbi->s_dirsize); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); +out_put_page: + dir_put_page(page); + return err; } struct minix_dir_entry * minix_dotdot (struct inode *dir, struct page **p) diff --git a/fs/minix/minix.h b/fs/minix/minix.h index 20217336802570..8f7a636bd1b241 100644 --- a/fs/minix/minix.h +++ b/fs/minix/minix.h @@ -69,7 +69,8 @@ extern int minix_add_link(struct dentry*, struct inode*); extern int minix_delete_entry(struct minix_dir_entry*, struct page*); extern int minix_make_empty(struct inode*, struct inode*); extern int minix_empty_dir(struct inode*); -extern void minix_set_link(struct minix_dir_entry*, struct page*, struct inode*); +int minix_set_link(struct minix_dir_entry *de, struct page *page, + struct inode *inode); extern struct minix_dir_entry *minix_dotdot(struct inode*, struct page**); extern ino_t minix_inode_by_name(struct dentry*); diff --git a/fs/minix/namei.c b/fs/minix/namei.c index 8afdc408ca4fd5..82d46c28f01b01 100644 --- a/fs/minix/namei.c +++ b/fs/minix/namei.c @@ -223,7 +223,9 @@ static int minix_rename(struct user_namespace *mnt_userns, new_de = minix_find_entry(new_dentry, &new_page); if (!new_de) goto out_dir; - minix_set_link(new_de, new_page, old_inode); + err = minix_set_link(new_de, new_page, old_inode); + if (err) + goto out_dir; new_inode->i_ctime = current_time(new_inode); if (dir_de) drop_nlink(new_inode); @@ -240,10 +242,10 @@ static int minix_rename(struct user_namespace *mnt_userns, mark_inode_dirty(old_inode); if (dir_de) { - minix_set_link(dir_de, dir_page, new_dir); + err = minix_set_link(dir_de, dir_page, new_dir); inode_dec_link_count(old_dir); } - return 0; + return err; out_dir: if (dir_de) { From patchwork Mon Jan 16 08:55:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13102763 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 aib29ajc248.phx1.oracleemaildelivery.com (aib29ajc248.phx1.oracleemaildelivery.com [192.29.103.248]) (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 AD43CC678D6 for ; Mon, 16 Jan 2023 08:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=F1auAvIMZEMOti+brYay4j0Wk9vbu4v2Z9rSsrjpsW4=; b=uGsdAdNQnIQKKGxNuPcy/m9iTMlj6pFCum+x+R5kXpuExulbOk2jWeeG7KkTJMfTD4aC0NHbr6lM SPF1pb+546OZsTEXXLqSwb7W1fQJxBGKbE0vP5nOmYk3AZMItXjWtvNBqV1Au+X6wb88VoQOAw8b xQ1WwmPL4k/97ObjzRivnVpW3RbecACgRdLa+HI1QxqpKUnuq/VyTKEsaIIaIVmtpPsfXAZOg97t SZzG/Zo40dT41zYwWe+edW4O7xi749WDfOHv1q9I2H/YFaRRjHI5JPQkxzizefnT6PyTCWLUrQtK 7O7a3Ig7OPvWr4BsPM5FAatFmr6899z/1nbwYQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=F1auAvIMZEMOti+brYay4j0Wk9vbu4v2Z9rSsrjpsW4=; b=rw7/E+SblHCuooA+F424RzXO//wsTpmzv4WQI01zfF9NhZ3noaSZdzCeWM40uIu1E3/z6bit6SUW KO/5iLQD2u7VRkxx5tMcGcv9vgcRkohPEnemD4PUNaQ3WbYnLVSBWjgvlD1tKXfBLYfsnSeV6a9l /6TuD936V08fm4G7liCUIG4S+681orKEPq2zDWz/4LuhjOzlNQNM4UwXY+l9S3F0SPw3UQIsT3ie 5vL5jl8wHH7ja56dOYTdh41m/lIUEWHHHarAwACHjlbQRaZDAKsM+U8uROXztuigpNJxSCPF4Bk/ hpdVvFIAY93hlartDKfbQOJkGfnp5EcUXBByrw== Received: by omta-ad2-fd1-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0ROK00GDTM59PF20@omta-ad2-fd1-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Mon, 16 Jan 2023 08:55:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=QCNp0MjEp23ArfIJ213HXzBCfkQxI9y/8H4Y/9jbIO4=; b=mRy4maM935+DV+YcCBIpsd71Lr 7sZO4iblXJf5AMYHhO9W/mCToFpztmdszLYgqR5sKv/vM9fAVUnf8efucn9dFSYbGcXlFHeiTHAf3 0C0h/yd1xVkdjYOBQQHk4u+/ydG55Gjr1yOASZm1MR2zrEQViFDCxXIc0GJEMZNHUtEr3KS1spLKr 2SaJQ5nr+iG1qcoZcGMaZCop5lBypWU0JzxeBIminN4jXsulD9HnMZYB4ZV/fu1AVAnVEoX3fjx/0 TRpSLxdIeo8qB9j6igNDIPhTzcuk/YMJbKfUZnM9nwuogF3O1RN/a//yMYM1fCsddLUO9lVdY4xA8 02hxatDw==; To: Andrew Morton , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Mon, 16 Jan 2023 09:55:20 +0100 Message-id: <20230116085523.2343176-4-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-reply-to: <20230116085523.2343176-1-hch@lst.de> References: <20230116085523.2343176-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10591 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 priorityscore=0 phishscore=0 suspectscore=0 bulkscore=0 spamscore=0 impostorscore=0 malwarescore=0 mlxscore=0 lowpriorityscore=0 mlxlogscore=544 adultscore=0 clxscore=280 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301160065 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 3/6] minix: don't flush page immediately for DIRSYNC directories X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christoph Hellwig via Ocfs2-devel Reply-to: Christoph Hellwig Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-ServerName: bombadil.infradead.org X-Proofpoint-SPF-Result: None X-Spam: Clean X-Proofpoint-GUID: 2Hv26w6oInA3zUlsBFT6DzQQmCNo6JuJ X-Proofpoint-ORIG-GUID: 2Hv26w6oInA3zUlsBFT6DzQQmCNo6JuJ Reporting-Meta: AAEmll2kw/q7mz8YJY77ANaDo51nlTSwck8H9vBb+35GXh94j7QbYTe7PDMoY7Rf nYMIqA/6BXmf75jpHqiWjGDl8sGJ7sBNtYUcUrqUE6mbm1SUIwTyb8f/EFJ+Y63O YKoyhYnMRVefMa7XFyszdVfOXJAfJDEjhhbDpNG1jYiFVXvB6WSegh+5p43AEKcU pFXU5hZtHJwCLhoy5OWfVam5Pbls5GV2AXXvWOU1oSkW5fFiIpNdctUcoKsOYZMU +vTGwIPowTKraoiDuELodcA5497WycB5pd76ik1KTXqx7mg4RMzYgnGx97t3SWR6 l3CcDzch00IksLltONicrrcuLmNlN6zMy+VW24a0SY2iwSN13D9YaHloEn72tP8T EeRgHZ7nGaZk5nitgq4Ut5D4RajhlHhkU6IewZyGaJqIR12bcc0cXrCWIuuU+SXn YnWa+cH9/ux6Hn6DMuDletygLuXk0e51wDc/TSFL5ifP7yBHPwONoFJh4DmNcW9q hZCBQCSUpr6h2EentC0N2NAfow7AzUG9qwhXeqsxdDI= We do not need to writeout modified directory blocks immediately when modifying them while the page is locked. It is enough to do the flush somewhat later which has the added benefit that inode times can be flushed as well. It also allows us to stop depending on write_one_page() function. Ported from an ext2 patch by Jan Kara. Signed-off-by: Christoph Hellwig --- fs/minix/dir.c | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index c9a3d520b72671..e9a1dc6bdfb0a1 100644 --- a/fs/minix/dir.c +++ b/fs/minix/dir.c @@ -46,21 +46,27 @@ minix_last_byte(struct inode *inode, unsigned long page_nr) return last_byte; } -static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len) +static void dir_commit_chunk(struct page *page, loff_t pos, unsigned len) { struct address_space *mapping = page->mapping; struct inode *dir = mapping->host; - int err = 0; + block_write_end(NULL, mapping, pos, len, len, page, NULL); if (pos+len > dir->i_size) { i_size_write(dir, pos+len); mark_inode_dirty(dir); } - if (IS_DIRSYNC(dir)) - err = write_one_page(page); - else - unlock_page(page); + unlock_page(page); +} + +static int minix_handle_dirsync(struct inode *dir) +{ + int err; + + err = filemap_write_and_wait(dir->i_mapping); + if (!err) + err = sync_inode_metadata(dir, 1); return err; } @@ -274,9 +280,10 @@ int minix_add_link(struct dentry *dentry, struct inode *inode) memset (namx + namelen, 0, sbi->s_dirsize - namelen - 2); de->inode = inode->i_ino; } - err = dir_commit_chunk(page, pos, sbi->s_dirsize); + dir_commit_chunk(page, pos, sbi->s_dirsize); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + err = minix_handle_dirsync(dir); out_put: dir_put_page(page); out: @@ -305,9 +312,11 @@ int minix_delete_entry(struct minix_dir_entry *de, struct page *page) ((minix3_dirent *)de)->inode = 0; else de->inode = 0; - err = dir_commit_chunk(page, pos, len); + dir_commit_chunk(page, pos, len); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); + if (!err) + err = minix_handle_dirsync(inode); out_put_page: dir_put_page(page); return err; @@ -350,7 +359,8 @@ int minix_make_empty(struct inode *inode, struct inode *dir) } kunmap_atomic(kaddr); - err = dir_commit_chunk(page, 0, 2 * sbi->s_dirsize); + dir_commit_chunk(page, 0, 2 * sbi->s_dirsize); + err = minix_handle_dirsync(inode); fail: put_page(page); return err; @@ -429,9 +439,10 @@ int minix_set_link(struct minix_dir_entry *de, struct page *page, ((minix3_dirent *)de)->inode = inode->i_ino; else de->inode = inode->i_ino; - err = dir_commit_chunk(page, pos, sbi->s_dirsize); + dir_commit_chunk(page, pos, sbi->s_dirsize); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + err = minix_handle_dirsync(dir); out_put_page: dir_put_page(page); return err; From patchwork Mon Jan 16 08:55:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13102765 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 aib29ajc255.phx1.oracleemaildelivery.com (aib29ajc255.phx1.oracleemaildelivery.com [192.29.103.255]) (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 D31FBC678D7 for ; Mon, 16 Jan 2023 08:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=trOpjgJk2GZZm7axUl/DEU8hjzTQYBLQK9GRo7R+Dlk=; b=JjIolYYO4MatI69LyFL/nQKJJ+1k6gOl7WgS2ji96hVnr2HVxgZCqFtHbZkT8dj9Sr84i2ioFCv4 rAiK46iIDEobW9+iB4NYyWPXxhMKAUwHIfFDANMvHXmam3fNP6fHpbGiIzbNLaZShd3HPUmuw8Pb KCsnFqAPVeQtd9vy75OSJxDnTJt46KMzobizSe7F1IwF4Q6iGOabv/T2OfC+JaVx7a6eya38cjVK ArFAfUuXArbNVaJna0I3V/hI8qU4W2c/kdaBH0Fwt3yb6u55S9zB8VzHxG98TRWbCG0yTMeNa+UY SbkssV9VBn+a/sNI9wiUtnK7TtFuGDGRv1uXOQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=trOpjgJk2GZZm7axUl/DEU8hjzTQYBLQK9GRo7R+Dlk=; b=gruit+A6hhiKjllRK5lDJAqT1PpXpT6Lk0LDEkt8TojTe7gh0Y+yb7pNoOm23PWGrz7z4I/igz9T doe+ttoaUW9BnP1Pw/hJsCGAhxUIZQLPFbDNMeHzDPVFQRf0+lZIERTpAJTwsOOXQqAUOaNhSU6d c4PfVnhDm/IqDcXqBGkZ4Tpxh4y2u/EhaFymTPiR6pk6akzps/DkQHZvRborIu/++cE2Vb12QqNF 5TSCln6pgnwCcudeo/5eq+zRxs/gQP4eb4kENpfwsBSlRwhDysy4tN+RkkAU91Izs4r1aRz01cG6 5awVWIOCelIBRD8HN1DOej0bLeUNVC8/7WGNJQ== Received: by omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0ROK00LHKM59H4A0@omta-ad3-fd3-302-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Mon, 16 Jan 2023 08:55:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=RiDLIEceuZ9xYcAquYO1xUuvp0itrlt5jINwhutKHnw=; b=45KjjDK9HcGMupbHi8/ccd2lsk fppYv0+p3TbWlTYws63J9CCnCl/AjpUsqGf6TmfN1ePwYYudyAtmZ7Unotrxgp2ANUKUK5KL7BHR4 XA4mCttnzQ8oVfaW6fBs2R/evPrQ3GwRokqUv7AfYrw/mu4L2IROYrxoD9Yw7fUYfhtP00HKihi/q Y87KScBT9rsWb3KqrM9iZM2WU0eTnF9eVl8y+AFynnB6puXTb1ojZ3/NatLxoXwNQJ5LMF2tkinht tR4wbttPfOvNRgbB+u/+C0jDHTsi82wKIzzYrY9Nmmejm1QgKrISw+bDPG+QRL4x4PZmRF3knVCA8 Gg+V8y5A==; To: Andrew Morton , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Mon, 16 Jan 2023 09:55:21 +0100 Message-id: <20230116085523.2343176-5-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-reply-to: <20230116085523.2343176-1-hch@lst.de> References: <20230116085523.2343176-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10591 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=0 lowpriorityscore=0 mlxlogscore=483 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 clxscore=276 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301160065 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 4/6] sysv: don't flush page immediately for DIRSYNC directories X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christoph Hellwig via Ocfs2-devel Reply-to: Christoph Hellwig Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-ServerName: bombadil.infradead.org X-Proofpoint-SPF-Result: None X-Spam: Clean X-Proofpoint-GUID: b5Qd5vdMELa2agFA0YXcpPHKdLvi5A6v X-Proofpoint-ORIG-GUID: b5Qd5vdMELa2agFA0YXcpPHKdLvi5A6v Reporting-Meta: AAEjYhdOjgDA6VEfS04/4tcQu8BI6IeubDUIwZJ+sTI1dSWzpaxsx6UhxpKotcdO I5gFJb4w93S6y6XcZEh3fmyoTRVeNP1dvWsv7zWLYdmJnL1vD+5sYro3kPmpJQOz jSG44djkC/J59o9AGqJucKZyQ7ChNUGavRl7agPrWHcZQ8TDXhOmr9g0eUtOiquJ MIezsIZitZ9QgE/VFrCXTtOYvnBERVgCMBU3S7BJvwV9HxjKEDt+vokAziXeeI1A LT6Nu3fC176KNFmNkgPoLlGp/F8gZdordQUGj6pm0FoyoIyAnfXOGDqHkqrv8WS9 59ZXjHp90CQkGnEBB9KH4hhubORcGum8xIB+jTo2QGQBoWcTHbNOGN/cSjomKPV/ LwreVipZo9RAjepxdMi+JZXL0z0YrG8wosaRbqXtZzFucN7N2+PJoiwusvM4aLZ7 jz6OOlP9X2YKiMB65Sba/JlFJQZk5iePR5rsnNPonRW1ywd2RkUup9knJZM0tMt+ 4Pt7y5hMiBctQDpHBY8qfE3mJ3sk7tXhLXcpHdUw6dJQ We do not need to writeout modified directory blocks immediately when modifying them while the page is locked. It is enough to do the flush somewhat later which has the added benefit that inode times can be flushed as well. It also allows us to stop depending on write_one_page() function. Ported from an ext2 patch by Jan Kara. Signed-off-by: Christoph Hellwig --- fs/sysv/dir.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 88e38cd8f5c9ae..16730795a62161 100644 --- a/fs/sysv/dir.c +++ b/fs/sysv/dir.c @@ -34,21 +34,26 @@ static inline void dir_put_page(struct page *page) put_page(page); } -static int dir_commit_chunk(struct page *page, loff_t pos, unsigned len) +static void dir_commit_chunk(struct page *page, loff_t pos, unsigned len) { struct address_space *mapping = page->mapping; struct inode *dir = mapping->host; - int err = 0; block_write_end(NULL, mapping, pos, len, len, page, NULL); if (pos+len > dir->i_size) { i_size_write(dir, pos+len); mark_inode_dirty(dir); } - if (IS_DIRSYNC(dir)) - err = write_one_page(page); - else - unlock_page(page); + unlock_page(page); +} + +static int sysv_handle_dirsync(struct inode *dir) +{ + int err; + + err = filemap_write_and_wait(dir->i_mapping); + if (!err) + err = sync_inode_metadata(dir, 1); return err; } @@ -215,9 +220,10 @@ int sysv_add_link(struct dentry *dentry, struct inode *inode) memcpy (de->name, name, namelen); memset (de->name + namelen, 0, SYSV_DIRSIZE - namelen - 2); de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); - err = dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(page, pos, SYSV_DIRSIZE); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + err = sysv_handle_dirsync(dir); out_page: dir_put_page(page); out: @@ -238,11 +244,11 @@ int sysv_delete_entry(struct sysv_dir_entry *de, struct page *page) err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); BUG_ON(err); de->inode = 0; - err = dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(page, pos, SYSV_DIRSIZE); dir_put_page(page); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); - return err; + return sysv_handle_dirsync(inode); } int sysv_make_empty(struct inode *inode, struct inode *dir) @@ -272,7 +278,8 @@ int sysv_make_empty(struct inode *inode, struct inode *dir) strcpy(de->name,".."); kunmap(page); - err = dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE); + dir_commit_chunk(page, 0, 2 * SYSV_DIRSIZE); + err = sysv_handle_dirsync(inode); fail: put_page(page); return err; @@ -336,10 +343,11 @@ void sysv_set_link(struct sysv_dir_entry *de, struct page *page, err = sysv_prepare_chunk(page, pos, SYSV_DIRSIZE); BUG_ON(err); de->inode = cpu_to_fs16(SYSV_SB(inode->i_sb), inode->i_ino); - err = dir_commit_chunk(page, pos, SYSV_DIRSIZE); + dir_commit_chunk(page, pos, SYSV_DIRSIZE); dir_put_page(page); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + sysv_handle_dirsync(inode); } struct sysv_dir_entry * sysv_dotdot (struct inode *dir, struct page **p) From patchwork Mon Jan 16 08:55:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13102764 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 aib29ajc252.phx1.oracleemaildelivery.com (aib29ajc252.phx1.oracleemaildelivery.com [192.29.103.252]) (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 AD0E7C67871 for ; Mon, 16 Jan 2023 08:55:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=xyzvg/rCCly/SrrfRleNW2jwCQ0kCf7XT3oFjPPb4Ao=; b=cwxFkXDOKt8ADm1rCicWhaKJXyUg5tFr3FnQ0UFUva0BvAzavN767OXqiW2d+DkfgrDuqBGjBfyp QAU9lLCyzQV5P/X/1KMq2lxopTEgjZdgDyh6NAxRBKGhwtoXZ+7XdHOlGM2kwoFCWaSlG1jjuBd2 3jGASc6aGjD6qzc+jlplLHHChrQC0KHet21ePwoKrip3VslDfWM+f/bjnVCfesE9qDJR7cjDjpBh FSJ5xV7MSxVVlsMfsLshzg95yVwjuHmCQJ1DYv8zDPWJHeg+mRi7v4VhoczwNylD8LRk4H9W9R5H 9/nn4MNPCOq9xN8WTyE1UkA1rPTpDhwYkbiZ1g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=xyzvg/rCCly/SrrfRleNW2jwCQ0kCf7XT3oFjPPb4Ao=; b=Q33PluJdnBMi76zHDe9ECId/67aELmSWF3sVpJqzK81A3UUwZyDeVOfMkN2KDeG6/mZpZv65Ay06 1MNC11I4RhJiBqxUCbgl3gqHXoZmf8q3dKhnL1MJDV7/uNwVstQIv/Mn6Kwwe57AmE1x8Qov9+/3 ORck4ke8vMTQ9dNZw0RaAZPpO8tYepxWTZIB7iAKVD2bdGbCJZDOZNBVB0dm3Ah4Dp1KFERmoq9b nPOpA5pzS7l40umz8PvSmZqyZBV2qZqXfHW4geX+vLR5nromU3c4l6nzV0Y2vlNhl9exYHeIVcTb uBhKklFCBoZhjlGJwkMeeMt72OxnqZgYi1WBJw== Received: by omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0ROK00IRDM59SPC0@omta-ad3-fd1-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Mon, 16 Jan 2023 08:55:57 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=v3PglRWzIOokZtWskK857KErIsUBx1dUWoEIj+rmors=; b=DixsK5MM2bUui4MhH0EvJ72lp2 WhWrahLLw2Q/qCkiyikiq6XfFLKWN9P3q0gTvzEOIuokGykPQDu36/ApNtX+68TdqIpsiIvwbKmBK WChJb99QuBiIiAmdjFhPdecye2p2/hbTlow+e87ry4NaVYuv45yJKbm1BSHtCEMeY9IzsEzuyhHsI cRF5YIYL5sx5LSKyoLnapfmAikJcKAOPzh5nCv/DESlQiHoqGnAZbDOD/SpNLlksyaLknUB1nwSFN tFu76c7m97LBY5Ji5xIZkKBmr+3mJx0/EGuTioAoPwY/iSj9JSHSAP1zp2XtLL4UKxG2kuc2qdJzB MyLorMnw==; To: Andrew Morton , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Mon, 16 Jan 2023 09:55:22 +0100 Message-id: <20230116085523.2343176-6-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-reply-to: <20230116085523.2343176-1-hch@lst.de> References: <20230116085523.2343176-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10591 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=259 lowpriorityscore=0 spamscore=0 suspectscore=0 mlxlogscore=417 impostorscore=0 mlxscore=0 malwarescore=0 bulkscore=0 adultscore=0 phishscore=0 priorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301160065 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 5/6] ufs: don't flush page immediately for DIRSYNC directories X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christoph Hellwig via Ocfs2-devel Reply-to: Christoph Hellwig Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-ServerName: bombadil.infradead.org X-Proofpoint-SPF-Result: None X-Spam: Clean X-Proofpoint-GUID: uCl-_kK1KY1O8ms07xg03W8qPVnoUrxw X-Proofpoint-ORIG-GUID: uCl-_kK1KY1O8ms07xg03W8qPVnoUrxw Reporting-Meta: AAHWEiHEKT2F17+vsDDjuC9ZMnCo+jqVBiBQl8w0K3rzd9smAPnyGRmzxYEHRv3H /CuT08iYl79DlH06lQEVYwMSvDFQwsZNk/WXgObKZNakoP5VVj0tfhxMMl2XPs7r vtMAY6s2QlqVhqqfsoiWxXQHoz99kut/XJ0CeDxi/XZ4ymZlh4Ojd32ny3OHLmIV Ld9fModujoq6JM+zltL4zd6lOJzlim8xR5Xh/1SDdkvyXNUj4BPMpmG7YPeIdwRs 7PdkBwEHI3NIvxm2ZjgK65SHPyKEkWwvcEwPtGeJQ0zkSFeNOrbxG8/TSyDKHLvb xuP6rgHU4r9lQWJr6oOMQVjaTkSzYSXVb9dr3YEZZD7K4rzDimyy2q3P1fU/oVLR /hEnqfQFEa8px9IvO5expaIvBO6h10r0kgtyY1JvQ82t1CToPYM7Y4GSbiBgf41q ReEdzigzmMAy5QW4UD/zyiTmpU9uUhR2DJZGLTubwI//ee6+u5l2ocDmG01bx01N zPul59p4e99ohHPptqaEpNPguKvUZQHw3MSOdEuUYFc= We do not need to writeout modified directory blocks immediately when modifying them while the page is locked. It is enough to do the flush somewhat later which has the added benefit that inode times can be flushed as well. It also allows us to stop depending on write_one_page() function. Ported from an ext2 patch by Jan Kara. Signed-off-by: Christoph Hellwig --- fs/ufs/dir.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/fs/ufs/dir.c b/fs/ufs/dir.c index 391efaf1d52897..379d75796a5ce3 100644 --- a/fs/ufs/dir.c +++ b/fs/ufs/dir.c @@ -42,11 +42,10 @@ static inline int ufs_match(struct super_block *sb, int len, return !memcmp(name, de->d_name, len); } -static int ufs_commit_chunk(struct page *page, loff_t pos, unsigned len) +static void ufs_commit_chunk(struct page *page, loff_t pos, unsigned len) { struct address_space *mapping = page->mapping; struct inode *dir = mapping->host; - int err = 0; inode_inc_iversion(dir); block_write_end(NULL, mapping, pos, len, len, page, NULL); @@ -54,10 +53,16 @@ static int ufs_commit_chunk(struct page *page, loff_t pos, unsigned len) i_size_write(dir, pos+len); mark_inode_dirty(dir); } - if (IS_DIRSYNC(dir)) - err = write_one_page(page); - else - unlock_page(page); + unlock_page(page); +} + +static int ufs_handle_dirsync(struct inode *dir) +{ + int err; + + err = filemap_write_and_wait(dir->i_mapping); + if (!err) + err = sync_inode_metadata(dir, 1); return err; } @@ -99,11 +104,12 @@ void ufs_set_link(struct inode *dir, struct ufs_dir_entry *de, de->d_ino = cpu_to_fs32(dir->i_sb, inode->i_ino); ufs_set_de_type(dir->i_sb, de, inode->i_mode); - err = ufs_commit_chunk(page, pos, len); + ufs_commit_chunk(page, pos, len); ufs_put_page(page); if (update_times) dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + ufs_handle_dirsync(dir); } @@ -390,10 +396,11 @@ int ufs_add_link(struct dentry *dentry, struct inode *inode) de->d_ino = cpu_to_fs32(sb, inode->i_ino); ufs_set_de_type(sb, de, inode->i_mode); - err = ufs_commit_chunk(page, pos, rec_len); + ufs_commit_chunk(page, pos, rec_len); dir->i_mtime = dir->i_ctime = current_time(dir); mark_inode_dirty(dir); + err = ufs_handle_dirsync(dir); /* OFFSET_CACHE */ out_put: ufs_put_page(page); @@ -531,9 +538,10 @@ int ufs_delete_entry(struct inode *inode, struct ufs_dir_entry *dir, if (pde) pde->d_reclen = cpu_to_fs16(sb, to - from); dir->d_ino = 0; - err = ufs_commit_chunk(page, pos, to - from); + ufs_commit_chunk(page, pos, to - from); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); + err = ufs_handle_dirsync(inode); out: ufs_put_page(page); UFSD("EXIT\n"); @@ -579,7 +587,8 @@ int ufs_make_empty(struct inode * inode, struct inode *dir) strcpy (de->d_name, ".."); kunmap(page); - err = ufs_commit_chunk(page, 0, chunk_size); + ufs_commit_chunk(page, 0, chunk_size); + err = ufs_handle_dirsync(inode); fail: put_page(page); return err; From patchwork Mon Jan 16 08:55:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13102766 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 aib29ajc245.phx1.oracleemaildelivery.com (aib29ajc245.phx1.oracleemaildelivery.com [192.29.103.245]) (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 E3CDFC46467 for ; Mon, 16 Jan 2023 08:55:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=oss-phx-1109; d=oss.oracle.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=uFIfJZTxNMzakcMU5GTGdqmKGvvQwZnc6NLbwDpoeY0=; b=1IN+9MsV5CsEfv4BL4zHLFBDqz9Dc181GbbxcQwLkfSIstM17sNoo/7QMGUrYPCtPwZnv+KyxNtI bvfZQJRTuF5MrMFfVkNxbSAIzcFo4Bk0F9UsNHKfGxnb4iNQZTSzwYWmrcxKgZIM7rXd64iv+NFM d9z5Qn96FWkpVVy1ehGVpWU9eZv4g6qf09V/LYQJWdH7I+48497t2SJjAylz7eFNls6028GKMdVk f5ugfVIXd7TjgFoikRmgcVAI+EjNjRPBr/aiexJjcx4g4/XkQh0nsiJJPEwc7da8/6oPzuxcNE0a yH2rSKS33PsygVegzzpFymj2EJitxFxhHxOoiQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; s=prod-phx-20191217; d=phx1.rp.oracleemaildelivery.com; h=Date:To:From:Subject:Message-Id:MIME-Version:Sender; bh=uFIfJZTxNMzakcMU5GTGdqmKGvvQwZnc6NLbwDpoeY0=; b=D3TrjWHWUBb+QrhssB6SSxilbNvu8OOHUbYhZQAyq/btlqEzlEhT1/4quiIfIR/Kp0jK14x7prIn DJwdySnRJe46dzlh6fQDjV7DTdf1zr/CHPXWCHYkQ/6bnITlPr2ifNWhHt3cP/Uk+ewEJps+0cm1 1PPCSD721u636UMMSkjkQjlx/7Lc4j9z580xnY9vLJA32IGT0tUH8MBLWhHRq6HoL+rcSBCyEPte 9AYCBYVDmminRYYfhVnnouwwl3QiknoMxe6XTDj6FrttShUM4qb8azswEFJbrudWngQLuqHGHg1j YOdGXLUgJhESSbwOEOKmytP/BVwbppCCcayDAg== Received: by omta-ad1-fd1-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0ROK0066LM5BOG40@omta-ad1-fd1-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Mon, 16 Jan 2023 08:55:59 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=jmbxaw5WGTdQC+qZyQllTG4rSUOzrNtp0wkWOB0SkzU=; b=S1YQa0jo9I3cRIkKUvmK7E0LAe gZA9QpBJWq/4q1yWw44YdYIyo5lTBj41So0EskMqctZHNAseMRrJiewDt8OHaWv56VCtYWSDkMM/w w9ki30AiFExrhcC68KG48eFoFc6lR/EH5r3SoH2VIHGXyq2Oux6Ef4eqSFbmDtn/RMWJ3tT9q01W7 1hzO9c3PXTWZ+Jn6jZqG5P/iproorCh01i/UL1Yb4qwCDtNfv7F5qAirB3ZYt8p/CzRfUY29D8sYc UQ8L5Sp2s3JkHGZy4ZoyT7sXuZbUM0oSRzKF17mun/YTTCQV0TkAwQe1al7rQ1YAH2adR+oAfZlCz wb0LDk/g==; To: Andrew Morton , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Mon, 16 Jan 2023 09:55:23 +0100 Message-id: <20230116085523.2343176-7-hch@lst.de> X-Mailer: git-send-email 2.39.0 In-reply-to: <20230116085523.2343176-1-hch@lst.de> References: <20230116085523.2343176-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10591 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 malwarescore=0 bulkscore=0 phishscore=0 adultscore=0 priorityscore=0 lowpriorityscore=0 mlxlogscore=710 mlxscore=0 impostorscore=0 spamscore=0 suspectscore=0 clxscore=276 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301160065 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Jan Kara , ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 6/6] ocfs2: don't use write_one_page in ocfs2_duplicate_clusters_by_page X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Christoph Hellwig via Ocfs2-devel Reply-to: Christoph Hellwig Content-type: text/plain; charset="us-ascii" Content-transfer-encoding: 7bit Errors-to: ocfs2-devel-bounces@oss.oracle.com X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-ServerName: bombadil.infradead.org X-Proofpoint-SPF-Result: None X-Spam: Clean X-Proofpoint-GUID: vTJkmDFMf7kKVIL8RE4-95XiOBGXs5B3 X-Proofpoint-ORIG-GUID: vTJkmDFMf7kKVIL8RE4-95XiOBGXs5B3 Reporting-Meta: AAGxzO42fTkOWpF0j0vfY9y5MVgZ79lHtQBNFpM4owXgNW4WFL/GVXL8hTM1QoBH OiFjsjVbk6Zam8cDOvmTqIp2LTTVnzB+YKtvXi4FAD6rcS1g0YqypAbDhpLihOXb X2jdHSI76nyP+W28kjWNfBAUhX37NQRhZtT0f6kFhRr41Oli/V8E0XgTpofhDe41 Tvdj+7fVeA8mvVGhXvn7GBxWVOn4oLpWFaACoZPestjpERWoZ92i15Vj1mhlzebH 2ptycp02LoLYQOrcqajAFtRQ4k0oGoR9zvcNxS5JmwzwIIKJcRYCoSMqyWivnwju Lo1y3F6saRjylI6Lv4J/3uPddYsC+hg52ApcF0I/XzLcqMLzu8CMTVzWcTkvPWZR LHWup2mtedLl/glXWEtbKVEa/meckWybIptCYzWORaaOOOdq+cY9VB2SNq9rf6kS Jp1sn6UvwA9Az01iuGoF4J5F0V8FiehYsqPur6X87WPPnSbgmOO3r0IW82r0Rj3a EvrQVE3jKnBjRM1GnDe8mH0+GuEHOtLwKYASHJbiwuN3 Use filemap_write_and_wait_range to write back the range of the dirty page instead of write_one_page in preparation of removing write_one_page and eventually ->writepage. Signed-off-by: Christoph Hellwig Reviewed-by: Jan Kara Reviewed-by: Joseph Qi --- fs/ocfs2/refcounttree.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 623db358b1efa8..4a73405962ec4f 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -2952,10 +2952,11 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle, */ if (PAGE_SIZE <= OCFS2_SB(sb)->s_clustersize) { if (PageDirty(page)) { - /* - * write_on_page will unlock the page on return - */ - ret = write_one_page(page); + unlock_page(page); + put_page(page); + + ret = filemap_write_and_wait_range(mapping, + offset, map_end - 1); goto retry; } }