From patchwork Sun Jan 8 16:56:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13092644 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 aib29ajc249.phx1.oracleemaildelivery.com (aib29ajc249.phx1.oracleemaildelivery.com [192.29.103.249]) (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 E45EFC67871 for ; Sun, 8 Jan 2023 16:57:31 +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=4P06jxon/ugyqI4xnrv2DSlt++jkzcDkkwksHopAB+4=; b=bC7zCmXa7/dez0c3PuuiBUl39OzHxIxLnR3Hzfqnwzs9X7Kb8L8jQrF9KGQ6nlY+HuKzSKfbNHdD M5LPOnZIR3yKaRIFzvUL6YtZGPmRB/hpJoxaUEmSE+k6LuC4I/va8I0UFv7R+mTMIqgTY9AqjxL8 kpcVViB9MweqYYNE5GIYn5Uwuo76mSPo03xStDVsC+JGx2jAG1dkAHIS9szsrtlTdO2CGBHTHP+o YhhVeEM52f7wIRgRByPE9ZYrZETPmMwUJGR0c//YH9Oqn9UG6Nq37ChGPEGmYcN3sJ15/tS72gmm YdG1PSPAHHGW01NIGFyNwMC58ELFrGHzcQXiwg== 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=4P06jxon/ugyqI4xnrv2DSlt++jkzcDkkwksHopAB+4=; b=M0RB9zqxmJQ3B4fII+50ywJsDQY0dbFcNu3Fy3Bin+c4RNyG56/zBDBooLwA/gTUdhO6xixXHcPa 9eAQHXs/0bvXD/WAWMChs+qyEQ5zfd7oo5bmu4OLiLaj4jLsz3MHrWVaOqp4/A8+eVTvdkrKZqeV VPUuy/hTOyGRPDr4BR9YBaYVvttupyf0GG0m2XdFaCwCPdQlIH9YFJU6qUn3U4XiDz9TlVr/qVcF kgNA1/S+oSWfColyc6tlFmY3xSqxAeEhqat5a/GvcEuHnPMLvpUTtHbEzx2Q34eiE0AI83rV5ED6 5k/dJODoko+stRTGlH+0tA9J5PBeVj8TnusU2A== Received: by omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0RO600330F3V9D30@omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sun, 08 Jan 2023 16:57:31 +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=lFvtQi+fLwMAHlLvXJj+xcXbU2gUQgSohjqo1SaHtyU=; b=oCh8q89awjYtytoZeT3pHyKMkl VyT99nkn9BUuSEHliHPt62EP8SCxWjNrcNLmisEoaHMhYjJ8blEV2oOQjss2Be8g/xEE9Xu6T3NXp cX2D3XC22yjMYecCu3dMuigB7G2U+YrmmMECKpaqBwx1GZ7mj3KW96NRON6fZ4NNOhhoCXma7S6jX kwHVVTH7ntlpydXJw1owjb0dtlCOQp1u4Psodi/w/rAdX6DMMVmMLise2oRJNsVxC9vWRy+Myt95+ CvWwxs1xVejbXQVUEiHnuz2WHplf41pBViKOvH7DT3UKkzeh0LnVga9cr6PVhw5F/KrNlu4CexH4y TUx1FMmw==; To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Sun, 8 Jan 2023 17:56:39 +0100 Message-id: <20230108165645.381077-2-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-reply-to: <20230108165645.381077-1-hch@lst.de> References: <20230108165645.381077-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10584 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=302 lowpriorityscore=0 phishscore=0 priorityscore=95 adultscore=0 mlxlogscore=823 suspectscore=0 spamscore=0 impostorscore=0 mlxscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301080126 Cc: jfs-discussion@lists.sourceforge.net, Johannes Thumshirn , linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Subject: [Ocfs2-devel] [PATCH 1/7] btrfs: don't read the disk superblock for zoned devices in btrfs_scratch_superblocks 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: 1dIgFSeD1fzRsmjZIk2cfoE2tDSfZD1c X-Proofpoint-ORIG-GUID: 1dIgFSeD1fzRsmjZIk2cfoE2tDSfZD1c Reporting-Meta: AAEZYbpWAwV9daWWqj8jGzveBcmP/a3pHnkfaqqXrwOE576U8NHcNSaNeDAcWC4x QJiTGcrKd8cVlCK5xt3IrwcI4LFGuFzXlDWXvKSjtloCfGDoAQzzaycZLyIluMS+ QvzTfd9LV5CRBTUJ+/J06crHl+cRfuo+u7mhFSFdOfAumJENFT+9A2OWRI5KRrmN cOzb012q7D7yFMIAYjYQlM1WxcQtYAXMUbZ7pCamVXRWkD5fcCLQsEywMbOq/0J0 97k8huND57fkyuHk/Tj9sI94pVU4munJP5QdGv4KLSYkPmj6jgxD1LlGlHZ0cITk JYXSZD4KdozyhyI6fPYqYx4nNWm/6PclRTxeVT8JNhPJZJM0Ilimkxxsb/VF3F95 h51fPlwxxbvO7OKVYkwLoMPrf1D/8xdr6/Z18/q86Z59aQKdMsIPQTQj1CIG5J4I 1vmT9STOU8s1LUUYezcOTTsuaA3b5OZuDkSZwayQ4/OvRMOD7FEbV6M2oIa8EQZW UxJwyI0c+UTWUHsY/+SF6JelBxjOLf9piaoxb3qr55DB For zoned devices, btrfs_scratch_superblocks just resets the sb zones, which means there is no need to even read the previous superblock. Split the code to read, zero and write the superblock for conventional devices into a separate helper so that it isn't called for zoned devices. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- fs/btrfs/volumes.c | 51 +++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index aa25fa335d3ed1..1378f5ad5ed4c4 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2005,42 +2005,43 @@ static u64 btrfs_num_devices(struct btrfs_fs_info *fs_info) return num_devices; } +static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info, + struct block_device *bdev, int copy_num) +{ + struct btrfs_super_block *disk_super; + struct page *page; + int ret; + + disk_super = btrfs_read_dev_one_super(bdev, copy_num, false); + if (IS_ERR(disk_super)) + return; + memset(&disk_super->magic, 0, sizeof(disk_super->magic)); + page = virt_to_page(disk_super); + set_page_dirty(page); + lock_page(page); + /* write_on_page() unlocks the page */ + ret = write_one_page(page); + if (ret) + btrfs_warn(fs_info, + "error clearing superblock number %d (%d)", + copy_num, ret); + btrfs_release_disk_super(disk_super); +} + void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info, struct block_device *bdev, const char *device_path) { - struct btrfs_super_block *disk_super; int copy_num; if (!bdev) return; for (copy_num = 0; copy_num < BTRFS_SUPER_MIRROR_MAX; copy_num++) { - struct page *page; - int ret; - - disk_super = btrfs_read_dev_one_super(bdev, copy_num, false); - if (IS_ERR(disk_super)) - continue; - - if (bdev_is_zoned(bdev)) { + if (bdev_is_zoned(bdev)) btrfs_reset_sb_log_zones(bdev, copy_num); - continue; - } - - memset(&disk_super->magic, 0, sizeof(disk_super->magic)); - - page = virt_to_page(disk_super); - set_page_dirty(page); - lock_page(page); - /* write_on_page() unlocks the page */ - ret = write_one_page(page); - if (ret) - btrfs_warn(fs_info, - "error clearing superblock number %d (%d)", - copy_num, ret); - btrfs_release_disk_super(disk_super); - + else + btrfs_scratch_superblock(fs_info, bdev, copy_num); } /* Notify udev that device has changed */ From patchwork Sun Jan 8 16:56:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13092643 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 aib29ajc254.phx1.oracleemaildelivery.com (aib29ajc254.phx1.oracleemaildelivery.com [192.29.103.254]) (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 CEA1DC677F1 for ; Sun, 8 Jan 2023 16:57:30 +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=jszucWulttQ5q5Drd8oOBuA+KtV7PN4RyLWi7ybtAJ0=; b=Hdj9XtwMdslWLblEazeN+9nuZMAW9N85/vdis3HcW1OpiNwLH2tFsXxgT/soMySgB7NRSaR5Umdg DT214pl3CA/TcvEGosbxb1gqpHU9Xh+W7g2XkuycW5hGEuhPcH4vwHN3sstTTNa6Wyz8XTohSrN1 ToIQKi59gIRK4iDWbGAXW9Gdw+8YCkAncqApm0mLfu244r/N4EWRsqC9a78zo27tcpGvZOtFYhho /sriFAwmglSvfJR/XL4O0bwxHsVO2vwnTBglsE9otG7DXP/E3m5zIIlIJBthgSD6VqY4PlyXW3HO zfXzLpG4WX/b2+NC2kMBUhuXXlPjhdNarEh8FQ== 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=jszucWulttQ5q5Drd8oOBuA+KtV7PN4RyLWi7ybtAJ0=; b=XjixkPQPBSEziOrINdQfRDIbdf47CwEpE4ziHq11Nn08OORaEj9ds+Q6xt+esh5442BwHv48BQbp 8L0jaZjPXz06vtRPazEYKxDM77rkYADx5Qn94E+ejAu7Wm8iHqgGaJLscfOIxyh9Q4mXssY0Ce0B iA0EdZi/XUBGn/byY7paYFIgopEeCW7XD0+ALjvmjiFmRWgoeDWJpEiwjOfrgSB2sMTEzHsvFNCm VX+S3anGS/vTyk63mpk6L+a4RAZiJT7UTnymdySpocnPMxwZnE+ait7MJEqgvQD3J77FNmY+lbGf Gm67KQwopAQJ1tg30wwaLmPVKlHM8OyscS7Crg== Received: by omta-ad3-fd3-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 <0RO600MG7F3ULXD0@omta-ad3-fd3-301-us-phoenix-1.omtaad3.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sun, 08 Jan 2023 16:57:30 +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=BznR/4w1o26qgOdWpgaXoEzrG7xwT/5BaeqDtDNhkG0=; b=KycIApiWI5yISCZouDp8O8ipc4 dsl/ueN8sUNA33Tp9c717pqGJ+DRYXWPrwamlDfC9ftc159YEu3rH4iisYVgqRu/w53sUAME1wPCf MTqnBKQrVKo99G/ggyD2TGlKA9HTNX06xjiq6D39LxRqspHtjdzrjwPj/R4YOGTbHKRoxYyqU+GgO hplk+/amqkkU5IiaF7B9o2QiTNtdVdmhnSylKAIJ1PkTIFxh3AiZkBHips001Vc6L9c4I1xFVKuNI 30m27hquq2Q0Y5e4zNu+1vbMwCxkSGN7IoC06MseeAUTxFVjrgD8hhd2XQ2oWt/MRiFklab9eYZBQ 21VcibDQ==; To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Sun, 8 Jan 2023 17:56:40 +0100 Message-id: <20230108165645.381077-3-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-reply-to: <20230108165645.381077-1-hch@lst.de> References: <20230108165645.381077-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10584 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=301 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=778 spamscore=0 phishscore=0 impostorscore=0 malwarescore=0 priorityscore=60 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301080126 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-btrfs@vger.kernel.org Subject: [Ocfs2-devel] [PATCH 2/7] btrfs: stop using write_one_page in btrfs_scratch_superblock 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: 8wJWdGAucdQjJ9K8UaxZBKbgcY20XgZX X-Proofpoint-ORIG-GUID: 8wJWdGAucdQjJ9K8UaxZBKbgcY20XgZX Reporting-Meta: AAGPFm+mo19dtJcTATGl0O4VHJNUwwD7Tl0qAD3T4Pl7VkGLloX+h0Kdj7IzOedt qV3HobP7JuosD8PdFxSAy5VKRmptp/3Kf5EZ9ImqlU0SJhstkgtFS5G0nW5c4zSr DIOOAGA9pA+iBDL1VpGN0GCitXgK70i3RIWRwWGEZDR4p1TGVJ5Spd22t6cylFoG B3WJXv7dHQpv4CaHp+N1qy80uGOXD4mIL3519r6WdlAMVSs36BG91+htW7r6jE/y 4eElunXdSmRduUtM3sfBJ5k54ey/64Kld9HGi2DtjNgG+T/3D6cYeepdoRH9eNAv cWzu0WUri71m6Kc3InXPo7idHTSAUXJwGUAk618Q8yxZaGizcHJz32FzUzMWuMvK xpJSSjyUi6evLYkTr/grBlL6HFVTmUk+7jHmJ19BGLCBJC+WE0ZQh79VT/5E221B XUuMhS6+gAFRcZRk5DNdnZn08NgrgDpSOA6YQ5054ouGRaGCF4Hv5ngwIi0tDN3Z fSv46czu+dVTJMWQqtbB1XL6pXKyEIjCVWwgZOIjb5YM write_one_page is an awkward interface that expects the page locked and ->writepage to be implemented. Just mark the sb dirty, put the page and then call the proper bdev helper to sync the range. Signed-off-by: Christoph Hellwig --- fs/btrfs/volumes.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 1378f5ad5ed4c4..10e98b004a2fa3 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -2009,23 +2009,22 @@ static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info, struct block_device *bdev, int copy_num) { struct btrfs_super_block *disk_super; - struct page *page; + const size_t len = sizeof(disk_super->magic); + u64 bytenr = btrfs_sb_offset(copy_num); int ret; - disk_super = btrfs_read_dev_one_super(bdev, copy_num, false); + disk_super = btrfs_read_disk_super(bdev, bytenr, bytenr); if (IS_ERR(disk_super)) return; - memset(&disk_super->magic, 0, sizeof(disk_super->magic)); - page = virt_to_page(disk_super); - set_page_dirty(page); - lock_page(page); - /* write_on_page() unlocks the page */ - ret = write_one_page(page); + memset(&disk_super->magic, 0, len); + set_page_dirty(virt_to_page(disk_super)); + btrfs_release_disk_super(disk_super); + + ret = sync_blockdev_range(bdev, bytenr, bytenr + len - 1); if (ret) btrfs_warn(fs_info, "error clearing superblock number %d (%d)", copy_num, ret); - btrfs_release_disk_super(disk_super); } void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info, From patchwork Sun Jan 8 16:56:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13092641 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 aib29ajc250.phx1.oracleemaildelivery.com (aib29ajc250.phx1.oracleemaildelivery.com [192.29.103.250]) (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 C5AF6C54EBE for ; Sun, 8 Jan 2023 16:57:28 +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=s+KBtfcRaVnOOVVZzz3Z+I1XODRoJF2pIwba/gH0iG0=; b=gQdZP++TNkLAbe5zkFQjuA0rmJLO1arbh6CudfQGdlq66v/RpF9VUAj8Wvofe88AGLJt0HeHIPg0 zpGGQPRJwKCP41aGBbAN7mkZtYCJ+4LFkuK+/XgfjJ6NLn1BhtfRaQUdo10INndBwbya8pdZuxEC I5t6aEN/cCmo6ljXDKo7GB4XDJVDVibTgXhYyQNpGJBt59wC2omk45X/+DXBN7Td5a08oRHhk/Ch HsHl7MY+1KiI7D/MLOJlVbmKhY75Tb7Q5aO9EyesgPWgS+kVcEyYAog36p/KL2O/qteoMNg/uxAl tP9d4N968CpCLLdxd3LvEq56c7xYKC5tN72Bpw== 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=s+KBtfcRaVnOOVVZzz3Z+I1XODRoJF2pIwba/gH0iG0=; b=pQlLjl5OACNIRNtCrZV3TvyaDZ26rFDQceQtqEmT1x0TlkEwGS9G1S54PVkp75Z7aYKIZPYCQttj 9onrPeDl+eZOdUlzWjp9AXh4Sew4Wy+Y75PxLp9m4Kb2Ubn1gHpJoODzNNOFE7JYYuMxNYOoG0Ns MiHJvczgW+Is/3YyBglf3CGVcYgTQB9o5+93PbHruhUoUulYRXlC2zJn9SUuKHz5KXTMXeITkSID +XcpKhxf+wf/S/KaeQxvQqEC0S/carGDURjQGFVbxRQOuXv7S875dpiyWAqsy3eLmLh8Q0mK9GmR /QTm4aLaSagcU6YAcD1bh9PTsdXVyFlyTrXioA== Received: by omta-ad2-fd3-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 <0RO600KI9F3SC3A0@omta-ad2-fd3-201-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sun, 08 Jan 2023 16:57:28 +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=w04Rctw8qyCjwLO2i1OjkI+LN8twYupiOrnbVDTEa+0=; b=3xxKbUYOQBIbQYRO8w6HvdN1R4 9OQTx9rAbhFdmf+fGmYydYTlIuwJkr3F4bGLLwPJxxUSG0Uwx2aYZvNXu9JdVOqkigNLVSMVUnDIE Psz+/plZU4G45A3la//6lBz9RAD3770Mote9HxQPVLHNRllqYg4M2m23173VtyGQo1F73drNUgmeW tbNy3JqZ6/44QmJbTmELuKvI/sJbV+e/ZzhVrXUj82kr1WETchKqaxpv82mrFBTS4cyy/ReyZU8N+ YsqCclyRwnDWYY6aAcNiM4Zo29IqQ4Vx8WyirZV+wC4u9rt5mnPNCpuwYKtyXQJjKrUS4Sd+CfwVD k1TB835w==; To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Sun, 8 Jan 2023 17:56:41 +0100 Message-id: <20230108165645.381077-4-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-reply-to: <20230108165645.381077-1-hch@lst.de> References: <20230108165645.381077-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10584 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=301 spamscore=0 phishscore=0 priorityscore=60 lowpriorityscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 impostorscore=0 mlxlogscore=545 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301080126 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-btrfs@vger.kernel.org Subject: [Ocfs2-devel] [PATCH 3/7] 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: CDKisM3cgsgMJcOmdVCiyqrAW_K5HRot X-Proofpoint-ORIG-GUID: CDKisM3cgsgMJcOmdVCiyqrAW_K5HRot Reporting-Meta: AAGfAWcuTdqMkV1b6n/Db34FieZRjQfxJw08BfmITaPN7a4S2Ekuhgxlg03zFhEP w5Wjtdbo6nH7WHMBD0e30IRdQkJTQB4s8bD/4lyTBDyPcGrsNkBAnScp6WMlLnI5 Pu5w4ExauhUwTHaDYigt012gu8nhiAqAfjeUmapWb/3zRS7bJV3VxCGXSWJQtYQT FamkQEDT+GbKtmSMONU1AlosR2u0QY+A/29veCytW3pPKXihD7rQob8uxRTE1lAh vi6Ui2gucMLl+Vng6snuzpu92NtpeXzxZQm+CMx/AcXhg+1+sfrGXxBFPMBbd8kb RawLQpV+AXfkbf4B+hp0y/FlbJySUqQW5yZt23kpL/pJvydKYYEYRqNGbzv5IcXW pa8g2oLrvZJK14d9/26zJg4/Zs5CHegMF1r1LjmSCStz8Lu0jAwgr1OvBUSzP7Xh W9OHcRkoYJjgZN9+149MbJYaN7IKfcPtiOT56bbFZhU97akbE3ZReM8TaqKn+0KC aI0pkOlkvJfcMgSk7VHzgmstxjQStHnNJ0HdKSxxds5E 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 | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/fs/minix/dir.c b/fs/minix/dir.c index dcfe5b25378b54..d48b09271dc48f 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); + minix_handle_dirsync(dir); out_put: dir_put_page(page); out: @@ -302,13 +309,15 @@ 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); } else { unlock_page(page); } dir_put_page(page); inode->i_ctime = inode->i_mtime = current_time(inode); mark_inode_dirty(inode); + if (!err) + err = minix_handle_dirsync(inode); return err; } @@ -349,7 +358,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; @@ -426,7 +436,7 @@ void 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); } else { unlock_page(page); } From patchwork Sun Jan 8 16:56:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13092647 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 aib29ajc249.phx1.oracleemaildelivery.com (aib29ajc249.phx1.oracleemaildelivery.com [192.29.103.249]) (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 0A701C53210 for ; Sun, 8 Jan 2023 16:57:35 +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=yiB09Ahf5KPwFvnQtoUJ/OwIQp3hALbh/b10fuQe4jY=; b=wQZLv1/JRPr1/TyhMrwMvhPwxOADqDZAUNq8GKXEZmNx7USDVqnizd5u93GDrLGHxh1NqTq9oBST R2CN+nB2LdHUYTv6PRsg0fSpYw6Exk8N2GP4o/XcBe8Ad49JqjAzOupP6Xkbcc5yRw1jw5K8FR0O vJSLqoZBgeM8Itb39qxvDJdXALSvQTHNmbqb/12fpc439jx8ucFjDur3CU7Bm/zGvrtDUBwFkhyF AkUSx5Aiwl9INXMRVD64mCMGhPxvmOHXjquuWjZU6BKXRnrjv4BwA+gkXQoZ4Vbr4g81RhPKSbW0 sTkbQzifN8i37EfJGHrXEjNnSzbn09RX0rfQVg== 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=yiB09Ahf5KPwFvnQtoUJ/OwIQp3hALbh/b10fuQe4jY=; b=GscybR5jNRiwrIVyc0+I2U3YlcIhHDME3TFthpAwI8dW52cOVTNkrAG6s6PFQAgFaAXiU+Ttbx8e XEjkJWs+gCFmdgp4NE3O+HUoZ+LcqYSFfhGWqhVF2Q9TMcqOE3pguya2xepW0HzimOpJQKPNIvZ/ HhmKfuJn5iIC1cLYymwdmQfLYWINcFIZUwLEC9SN0xiQqZhSJ4d4TFARf6yb91hGm4h/C61CGQvv ydxlRRxLc7LtwtMosSysSvdHHg1mJqR3ZWwBTs4l25yLeuAkkLAEvybm2+TLRW/K9437be3gWB6f oV4z9WtmZ912oxTVilq3t4yWIUeKsFHp80tOWQ== Received: by omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0RO60034WF3Z9D30@omta-ad2-fd1-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sun, 08 Jan 2023 16:57:35 +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=LRWqWW8CxEBUBZTClfw9RwYeRYBhCeQ4pIrtvl3s68o=; b=oQx7Rv3KHPp6gTVM17C0X1F/0A Ss7aKkMKn13YqMFTiyj9UovpO3YmHbFIkdRu6P1lm0x3YzRL/33E+Nm0c8v7BQiUB9dtCG6vzzb9d G41l8V5rOwy6wLPJHKKUyuQ6evYLtxQubPvataSaZCelc+12PgJfW96pThp+vHnLueP3p23yrcT4r T4i62q0kSRL41BsGk/4004k+MK+VqsohoC8D9EslgyHPJVq8uN74IO2CqRkbKPz+ZTHIKdyRRSA1J LI9sFgAsTdSHr/VGk8960vHaAhlEZaxW4aRfr5eGg0W61z0hBEv5IpN8Y2QgFE8AkE/5sr+NKzDRt VGJHblOw==; To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Sun, 8 Jan 2023 17:56:42 +0100 Message-id: <20230108165645.381077-5-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-reply-to: <20230108165645.381077-1-hch@lst.de> References: <20230108165645.381077-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10584 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=273 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=485 spamscore=0 phishscore=0 impostorscore=0 malwarescore=0 priorityscore=156 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301080126 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-btrfs@vger.kernel.org Subject: [Ocfs2-devel] [PATCH 4/7] 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: ppiCeQ-alhAInzjQOWWub38qWCXfwxV1 X-Proofpoint-ORIG-GUID: ppiCeQ-alhAInzjQOWWub38qWCXfwxV1 Reporting-Meta: AAFhFXs1/da6lqp+wuJi+V/C6ohBDHJCghOPykRWjbnqP/lfG4iBO0+4BZlfWNy7 mjYdILYxAMbzLBmJ5GyoBcgo0+IBLgfVczVE0B5PYCXdV1cA1MLciCEMlwlt+pbp 4d4M8BaaF86PqLMIcAXMkz8eU3XBKlaqM4626NEKZHJICmRxyGE4uwEAe4rweptX k3Kkk/R30Ryr1aYa1iyKXsc1aS6EsgiY/niSSHMMAdg1ciDbFJlC1X9bmnakHG7P 7DPEREiHoqIMzvjLVPKjYbBVacdmoNBRIcwuWzWNqjG0RcYpMLxZ65pGm7r+k2wQ gkfV1MlUAj5u/0cyoTiqcWfvdFlgJWOBFJ2bMFRKg6L3u1gHH5iFH/d19+g+lAsX PNcCGjTmdcQcPVxG8sU3ZOa3C/hOl2AdZbROa4ii6yEYKEx6//Xg+81G/rdv6YLP zTNQQihm7kpZqjw8yXqsz22NlAFSusN071HSZHGT0CXpw15CtPRFCDVg80iPv+I5 ch6JmknAkrxGAPB8SAhKa+R+zwdbjVJ34jvBmhIaarZR 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 | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/fs/sysv/dir.c b/fs/sysv/dir.c index 88e38cd8f5c9ae..1d852ca6388297 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); + sysv_handle_dirsync(dir); out_page: dir_put_page(page); out: @@ -238,10 +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); + sysv_handle_dirsync(inode); return err; } @@ -272,7 +279,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 +344,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 Sun Jan 8 16:56:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13092645 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 aib29ajc251.phx1.oracleemaildelivery.com (aib29ajc251.phx1.oracleemaildelivery.com [192.29.103.251]) (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 DFCDEC54EBD for ; Sun, 8 Jan 2023 16:57:33 +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=Lw9djdnQibzTES31sAfzBzyuXksmcG0q056leQVmjVs=; b=Nu4a30JqHwsCfKz/90/LSFIEqfN6i6MQsV+Cczsj6He3Rzth2n6wocvviFIOkVyNcyxZot5nDRNy A7l5B5q+7lK0pyGotZ2/xmqP+ael193OQjnMqvCCY519hicrN03Pckj5BOg+P3wSb73Gx1cbcPKJ 1E+S/4/pOuwrHGo07tiiVy/cVprSH0m+sO5dcg/CvKVOSMXb2/QHSH3toLYKhQOqbLAjrUINXo7j tX2nsCRKnHhev0KgrltsXlkZrt2/AaIiGZTI/Kkw87YuiRewzFz/Mq72QGqN7Rkb5XTNLyoE10ad QrNpb1/zgwdIiBp8AFS1xds/fwcO4X51vB2wMA== 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=Lw9djdnQibzTES31sAfzBzyuXksmcG0q056leQVmjVs=; b=HzEL3PkHh/2Usz58dFGTb5F0DxaX1duP/CFHanYYJ2YD3IVpBXeNWXgYGDNhBuQgtv1+NuHz4BNr Ftvo/fzeKjC+MPliwz4MbElLonhFDYQ60hZ+IsC26C0wjdkE8v9Y4Ox5ICSODDf04YPits71N3mJ 0TCBUeO5svunD+8aZsS+I/YCWuJGaysz1Z6kRz2o3VFC0O+HCFLIlQIDppjnp3r4Dar9pKGnwNtB 9ejIrkdVXy6xXGHbcsiGVSbammiIisjTLMIs5OkJbmAp8aKuFVmTWN7FTCIRfXMdieQc3oQa85hW +NhvypRSPZ0OkfWNs7xJLx3LME7/BJd39dtXig== Received: by omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0RO600L4CF3XMCF0@omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sun, 08 Jan 2023 16:57:33 +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=oMPhLOYpJNBqa4dwFa8oL6UthrVrVH8Rk8f8kVGsTX8=; b=PKwRols7MQFA6r90zKuNxTrBwU rDshHiaWkYRgvGWSV5BX9ARC7MnPg6FQjItWl5iozMErhRr/Myxp7ECTVJlvIhcjk2Vg/2LTqbzNh 88GmfJGxKVNRHcx2n7V9pWxYXUFEFMMmqXaMPAjXflzSLusxgchlMH5lAKPklqrMQsPKoIGsEjeOl amYtRU5bsHvGaTKx7PCEiCK91nyhaRkzZmd/GYz/MD+VwBAYP+oqFKTZfqNTMsoDUniL2++T+s5Wt TsUxel7JrvdxmSTtPAyuHGghIaZzQSAvOeMlwx5HJY49qQL0jDsVZaUe43cAoHOWJHlgEg8Fb6fd2 tQphvRNg==; To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Sun, 8 Jan 2023 17:56:43 +0100 Message-id: <20230108165645.381077-6-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-reply-to: <20230108165645.381077-1-hch@lst.de> References: <20230108165645.381077-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10584 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 clxscore=273 suspectscore=0 adultscore=0 bulkscore=0 mlxlogscore=419 spamscore=0 phishscore=0 impostorscore=0 malwarescore=0 priorityscore=156 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301080126 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-btrfs@vger.kernel.org Subject: [Ocfs2-devel] [PATCH 5/7] 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: RZFG15KnYiNmVIAkhd_HE_oFrtMAzuOZ X-Proofpoint-ORIG-GUID: RZFG15KnYiNmVIAkhd_HE_oFrtMAzuOZ Reporting-Meta: AAFeRtKARYZgCRCLmbX6IPTWZQyYtzAswwO1LiZwnZ3x9BLsYll47Hpfc5HkeNlM hjcbUJnNeBeGdCma196ijrrCf1wwCDQSp8ebHiHOuxnriuPkXSC521sg088J+FdJ TRv0t1kvCHOMO/DVz4TLNYaoRANQycNvVw/soD5fSUcFPQLOG9W/uwGexzdvJozv RR7hWrgvUsq7WLSOqb5sCuRE086QYV5uIOJ0Gv7a9l7r58TRgfhjoa+k7fDgImN4 1pn/q4wz1incoFX8gtwLS6WOy35J4EwJZn+sI118jMdlODPBsOrHVF1lZeQiRT0K 1aKobTQ8mq/q1no88cs6uShmNmNoE4qI+NkXQOCm3tjvbwGxhg92sSuoT7QnPhAn Lz6KqQoLM77k43iici6VVNCaOGcdFuZSVO9oIs3o99bfh74UDm6fCCQWTg0DDrPt bIK6V/kqY+9tjkxQhPbJAn6Tsc0K/Du7jqdvsXZIqVvaqSkq0fXgFiAQzl6J6MZq dT2IfmkT/n16LGs7R07RAx7gXo1I86ZkG19RPZ07pbg= 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 Sun Jan 8 16:56:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13092642 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 A71F1C54EBD for ; Sun, 8 Jan 2023 16:57:30 +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=fcLdFCnZSGCUxt/F07lnOr+xSJgQbt33POouMhiaSAU=; b=ISGR1rGxCAoIvB/fePH5yz1Y9Z37nfwK8xE9m9M4NUbcAz1VQ9J5/XqQo+qX1xCd0+7jFL/nUaSO ynXfciLulAJc1+Fw6wYxgA/mSS5dsA7qnPp9JWwgKEX2MwFiLzvoRA0J23jfpnc97CujvldddQoj npBZ87nluOfZtXFX6Z97b19t07tBjZBZ3xUcOww8mLMiwhILKZNb/6+pCXJ0bwEmf/QQ8rb8qvP3 VIqxYkAb2pu/s6L1CsQYHPOFtIkE9JNEme5E4jy+6SjCS7UjJRVf6DNfI67fw27jGjEvdGX8S+nw 1Vt93E6PVvTy6LpEOyEtpOan48B2rOUT4Gmvag== 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=fcLdFCnZSGCUxt/F07lnOr+xSJgQbt33POouMhiaSAU=; b=t7LhUDhm80g2XRlxAPTLsTB3xpoUvWCfjsfVXlAkHWpMD4UlDOvFYsA+iFBnLKtTFDGmGiC7mr7x /rroUgpHDrVPvqSrdEMsr8Akxb5zZFwgVzj7RmTQHpWOAGoWaJrYeNAfG1J7K3Y+xysWflm1Of+9 ugjILkyUVG5BK7hiXjsXif/TU6Xi8RyBS4ttX7f18mNVTd2R2b4lX/cnXp+wVidxNBsQ6KsRB9N7 PaC/ArOULsSNy8eUB26rjMC2e2JPDNNH0fDQcKoeTaGYl9l/NYZugc10SXSTK62OwTNDdxCyr5qa K9NZlvwA2UP7JCX+RIQk3aHKCx74zwlQvrb5KA== 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 <0RO600K29F3UPN90@omta-ad1-fd1-102-us-phoenix-1.omtaad1.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sun, 08 Jan 2023 16:57:30 +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=0rSqpARFgQRqBHywsTtuZPRrJbLJdUkqrGBn/TckkNw=; b=XAeNW8PvyrIFuzPCKY54kLv+Iq Nr0c94bBAgRDDYDs5fmWgHLdSM4wuFdpF0unhRSD05WKElizN+oMfOJkw/ZCfBExPH0+8eVVmc912 7+oPJRHsL5+w9Rpr4VxeL7F5SeY7g5CAteFbTDP2J+gJgCxiyFQkNBrhF7Pa7ERmrkiZnVL3g6aDV OCLJZQzxEq9s12LkEeWA6DqmpS49TRyZ/uVPnrptKfZ9FZYtvU/2AZ6auVcSG1Wcrk3eL9/aU8x7+ JbJbDjelN9hkQfgxThV2QIF6AWhJ18L87Zumj5Z/1nBQW32E6qDIlVj/jLl4R6qHf834ghBLWQjiE TsSGua7Q==; To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Sun, 8 Jan 2023 17:56:44 +0100 Message-id: <20230108165645.381077-7-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-reply-to: <20230108165645.381077-1-hch@lst.de> References: <20230108165645.381077-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10584 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 malwarescore=0 priorityscore=60 mlxlogscore=763 spamscore=0 adultscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 clxscore=244 mlxscore=0 impostorscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301080126 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-btrfs@vger.kernel.org Subject: [Ocfs2-devel] [PATCH 6/7] 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: _d5rajPJPjXNcRl6D2xtLs-UrgHVzr1v X-Proofpoint-ORIG-GUID: _d5rajPJPjXNcRl6D2xtLs-UrgHVzr1v Reporting-Meta: AAGfAWcuTdqMkV1b6n/Db34FieZRjQfxJw08BfmITaPN7a4S2Ekuhgxlg03zFhEP w5Wjtdbo6nH7WHMBD0fA0IRdQkJTQB4s8bAf1ecjW9NPJD0jNQZEv69NQfw0qmj1 45Yr0/jkVQP7ILopmKRaQXsNz0dBLpI4fzWgH7RlQvRosF7DjZ8g+SavYm3FuzhY f8M6tCGOMtpGoczoSp/joDaaoAbcUs8ibt/xmVMPWQttGhmOGWnY71zgUZKbUEt0 lu3Pgkd+J/GAyKt/26efTNxyG2/MtaQZ7o40jIWIzMDs1AJ+XVaJClrhWlLslRqW wk3UYBZckIkcOuCTZiZceKcLLbj+dCuSJ7yHoS3W4bax1Nsu7Dtq21gYHslgtCjD QboMUK9QVH0IQThUhWzq/eoFa8QjUX5HcjjzuR/0lNeuOZKBmbbXLhmvc/4eHBNy pQZETVUkouMM4d/sPq8apVCd/9kIcTFrzEPbO5QDwtPtwxJ0GJ8fF4+Xj9cvcYF6 FriI39YrtKEwYL9yVitkuXBBtxl+0LFrQWFnJ4k9ddpo 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; } } From patchwork Sun Jan 8 16:56:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13092646 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 aib29ajc251.phx1.oracleemaildelivery.com (aib29ajc251.phx1.oracleemaildelivery.com [192.29.103.251]) (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 D167CC63797 for ; Sun, 8 Jan 2023 16:57:34 +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=a41aF9AGuYyiJkKxi5F2xDPcOkTvqOZsoj7JW1cWO2M=; b=K1EZJ5AX24rnHDh6DwgcDU5RSXQWsBE34d8IHi8oJ6R5LeMUrL+5Zznvt1PN00gxPNRJdgrDy/NM OkHV17Lf35W5RtF/nr7Fk1J33daedqR2JrEh8xlUE5tGXZafLYaK59G9XqueIcQMgLvxUJPywGh+ 3ZGYzTr1gw9VbhplLjngZCAHi3hbwLcZVG67x3mhVrcRjuG+ynN0F6wEdg3uUcBT6uJS5+RJvmgf +U/OS1difxAvNt80yaezyn0Knx3NTmG75WWkEMLxG+fLKrupbF1RThRrBjWye3ZC8+Jp4HRdjS6D 6cdYiVfMO16pRtqT7v8hZdLRsEoKj7XsNyKPsQ== 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=a41aF9AGuYyiJkKxi5F2xDPcOkTvqOZsoj7JW1cWO2M=; b=gsK0omyvG2so1goNOdFjQ6suXsmFZS8to9QNQGXbAlgb5RUMVKmJE/3KupxpQZQFzKPq7nUSAyBI /lcJbbU6Edl1CI1q9arMn9xg1yw0ZMtjxZULr1p9m9YDpRabdFC0qMziFedgSOoF/daSLI/R+rbS 1RP1woOoTO99LeW4oVItEMaT/z8qFFepF/c8WBqn5maD7GbDfukMRCNqLtFc3ZiQWO2I4CHhG4Go rh0hctzWbswotGJWGk0ehEw0JanXOH+wuJYlUFI2ns5AqnCv6UxZmlk965C5Heo+B1v8FiiYDsfG y7fVINztcNd+cWwUBapo9bnfXNyYACza7M4hyQ== Received: by omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com (Oracle Communications Messaging Server 8.1.0.1.20221212 64bit (built Dec 12 2022)) with ESMTPS id <0RO600L50F3YMCF0@omta-ad2-fd3-202-us-phoenix-1.omtaad2.vcndpphx.oraclevcn.com> for ocfs2-devel@archiver.kernel.org; Sun, 08 Jan 2023 16:57:34 +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=35W1DfUpdKcvHvkmZd/iv7iohwTShFaTRVBTVeGN8KQ=; b=ptbBbqyy8J9QwzNlwXFf0pVSC9 FObnajdrui3AnmwdcRqx7yS108dlZjq/LA1FcxnBsuCPU71ZtX9OCCm2Jm8xGwS0YPhXrtKcMGdZQ aKbo16bAYFtfrmPEZ3n7MYwDAGEsyygCRN2tTqfvEQyxzZbYdOUzQfkdu8aQI8Yd/qSaCa4uRm3v1 A3aIxTvDqqrWc1GXgBRTfAWdjWi5FuMdOZZqzsr6BcukKQjm8ah9DRASE27rB0bk3R/hAO7T3QdKg jVUW5uVfr+iTFuvvy2ys19Nhv6xvcopqJwiQPvNINiTvL/wDHu+DlU8jvFyW2hJ7jgs+Q1PXdu5Qt qDlB/z8A==; To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Date: Sun, 8 Jan 2023 17:56:45 +0100 Message-id: <20230108165645.381077-8-hch@lst.de> X-Mailer: git-send-email 2.35.1 In-reply-to: <20230108165645.381077-1-hch@lst.de> References: <20230108165645.381077-1-hch@lst.de> MIME-version: 1.0 X-Source-IP: 198.137.202.133 X-Proofpoint-Virus-Version: vendor=nai engine=6500 definitions=10584 signatures=596816 X-Proofpoint-Spam-Details: rule=tap_notspam policy=tap score=0 bulkscore=0 spamscore=0 lowpriorityscore=0 mlxscore=0 priorityscore=60 malwarescore=0 phishscore=0 suspectscore=0 impostorscore=0 mlxlogscore=796 adultscore=0 clxscore=302 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301080126 Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-btrfs@vger.kernel.org Subject: [Ocfs2-devel] [PATCH 7/7] mm, jfs: move write_one_page/folio_write_one to jfs 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: l2FLspSij0-wXf0gmGbqk3zidtmInvHn X-Proofpoint-ORIG-GUID: l2FLspSij0-wXf0gmGbqk3zidtmInvHn Reporting-Meta: AAEmc7Up1U1ofCmH4xYCdlLaPjAFSVIqTy+Vx4hAI3MjUo2Z+9Zw8/xIHJTyF3gD 7CHuylDhACd1HrgCR/OTFWa8+a0DJHWLa4QWx7Hj3toQIv7qVm/UB3N+OnfIrmaK 2H4VVMepumNxWt9RL0xoxyZFx2/+Q6Ah2DGGNTpuwB1BbNCYGAP7RWEOeN4Hwe2t 1ui0K8PaUAwiY2nA/2xeGIdofNJ+r58oVKFeYBTCpPLrab6+1bWG3vT3ub0tVact QFV77ftVE8+6odLwswhf6guK4FmUWHO69xmi3SqGNb2I9QDfKqpRfIeTZlbx9MYm 99BmPDs3IfSDBEjvDaPvcMopoNSTqRTyNHTMvWQhDW5dqHrj7NdWMI/D084FHHOk q2kNO0ueEesqu6vLSvWa6H0QQ3lV/+GfylP2C0AodtcSPK7RIUaKtf1gYtCRVDXu dt+YQ5/n1Fe4K/L1li4fQL8ZL6V/CuO6040w0DuclcodrPmYelwDone/gd6Kngh3 HofWeYofeHSxhLHaTx7c06unnV3L66BBe08K9Qoh+N8= The last remaining user of folio_write_one through the write_one_page wrapper is jfs, so move the functionality there and hard code the call to metapage_writepage. Note that the use of the pagecache by the jfs 'metapage' buffer cache is a bit odd, and we could probably do without VM-level dirty tracking at all, but that's a change for another time. Signed-off-by: Christoph Hellwig --- fs/jfs/jfs_metapage.c | 39 ++++++++++++++++++++++++++++++++++----- include/linux/pagemap.h | 6 ------ mm/page-writeback.c | 40 ---------------------------------------- 3 files changed, 34 insertions(+), 51 deletions(-) diff --git a/fs/jfs/jfs_metapage.c b/fs/jfs/jfs_metapage.c index 2e8461ce74de69..961569c1115901 100644 --- a/fs/jfs/jfs_metapage.c +++ b/fs/jfs/jfs_metapage.c @@ -691,6 +691,35 @@ void grab_metapage(struct metapage * mp) unlock_page(mp->page); } +static int metapage_write_one(struct page *page) +{ + struct folio *folio = page_folio(page); + struct address_space *mapping = folio->mapping; + struct writeback_control wbc = { + .sync_mode = WB_SYNC_ALL, + .nr_to_write = folio_nr_pages(folio), + }; + int ret = 0; + + BUG_ON(!folio_test_locked(folio)); + + folio_wait_writeback(folio); + + if (folio_clear_dirty_for_io(folio)) { + folio_get(folio); + ret = metapage_writepage(page, &wbc); + if (ret == 0) + folio_wait_writeback(folio); + folio_put(folio); + } else { + folio_unlock(folio); + } + + if (!ret) + ret = filemap_check_errors(mapping); + return ret; +} + void force_metapage(struct metapage *mp) { struct page *page = mp->page; @@ -700,8 +729,8 @@ void force_metapage(struct metapage *mp) get_page(page); lock_page(page); set_page_dirty(page); - if (write_one_page(page)) - jfs_error(mp->sb, "write_one_page() failed\n"); + if (metapage_write_one(page)) + jfs_error(mp->sb, "metapage_write_one() failed\n"); clear_bit(META_forcewrite, &mp->flag); put_page(page); } @@ -746,9 +775,9 @@ void release_metapage(struct metapage * mp) set_page_dirty(page); if (test_bit(META_sync, &mp->flag)) { clear_bit(META_sync, &mp->flag); - if (write_one_page(page)) - jfs_error(mp->sb, "write_one_page() failed\n"); - lock_page(page); /* write_one_page unlocks the page */ + if (metapage_write_one(page)) + jfs_error(mp->sb, "metapage_write_one() failed\n"); + lock_page(page); } } else if (mp->lsn) /* discard_metapage doesn't remove it */ remove_from_logsync(mp); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 29e1f9e76eb6dd..4b3a7124c76712 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1062,12 +1062,6 @@ static inline void folio_cancel_dirty(struct folio *folio) bool folio_clear_dirty_for_io(struct folio *folio); bool clear_page_dirty_for_io(struct page *page); void folio_invalidate(struct folio *folio, size_t offset, size_t length); -int __must_check folio_write_one(struct folio *folio); -static inline int __must_check write_one_page(struct page *page) -{ - return folio_write_one(page_folio(page)); -} - int __set_page_dirty_nobuffers(struct page *page); bool noop_dirty_folio(struct address_space *mapping, struct folio *folio); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index dfeeceebba0ae0..2430fd09607742 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -2581,46 +2581,6 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc) return ret; } -/** - * folio_write_one - write out a single folio and wait on I/O. - * @folio: The folio to write. - * - * The folio must be locked by the caller and will be unlocked upon return. - * - * Note that the mapping's AS_EIO/AS_ENOSPC flags will be cleared when this - * function returns. - * - * Return: %0 on success, negative error code otherwise - */ -int folio_write_one(struct folio *folio) -{ - struct address_space *mapping = folio->mapping; - int ret = 0; - struct writeback_control wbc = { - .sync_mode = WB_SYNC_ALL, - .nr_to_write = folio_nr_pages(folio), - }; - - BUG_ON(!folio_test_locked(folio)); - - folio_wait_writeback(folio); - - if (folio_clear_dirty_for_io(folio)) { - folio_get(folio); - ret = mapping->a_ops->writepage(&folio->page, &wbc); - if (ret == 0) - folio_wait_writeback(folio); - folio_put(folio); - } else { - folio_unlock(folio); - } - - if (!ret) - ret = filemap_check_errors(mapping); - return ret; -} -EXPORT_SYMBOL(folio_write_one); - /* * For address_spaces which do not use buffers nor write back. */