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: 13092601 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35C9CC54EBE for ; Sun, 8 Jan 2023 16:57:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A93238E0005; Sun, 8 Jan 2023 11:57:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A15C7900002; Sun, 8 Jan 2023 11:57:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 867B68E0001; Sun, 8 Jan 2023 11:57:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 55BD18E0005 for ; Sun, 8 Jan 2023 11:57:13 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 29C451C483D for ; Sun, 8 Jan 2023 16:57:13 +0000 (UTC) X-FDA: 80332237146.16.9E52030 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf21.hostedemail.com (Postfix) with ESMTP id AC5741C000E for ; Sun, 8 Jan 2023 16:57:11 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=oCh8q89a; spf=none (imf21.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673197031; a=rsa-sha256; cv=none; b=y1htDzC/U/kKl+X5na+WVyX2eG7C51J/Zgk2c23plWjcYAROiP8DMvVLyLBpv96sLHUxAR BIdoGDVMn0GHi8n9bE8wyvQbAK7RRRk0NW3sskx3EbMNYIc7e1MyNd0qAr3X+HFZFcUoKY AFblgBs1rKE68y+Sx7lSi/AnylKiGcI= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=oCh8q89a; spf=none (imf21.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673197031; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lFvtQi+fLwMAHlLvXJj+xcXbU2gUQgSohjqo1SaHtyU=; b=PYK4N9T1Ss+3FhwExlxI70LwTzecl8Tv+ZFgKywQHY8MV2jlJGqEpGbgMyyGCJKsg8VbGK fM3mU/15yX78TqMpBaF8qXChjxYGmNd8dPo30xD+YNYiJEK1SncKTog7o/zMnNrKVReH0b lw4NxEsXOmXMKBtl7c93xfj+uTQr7cE= 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==; Received: from [2001:4bb8:198:a591:1c7c:bf66:af15:b282] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEYyY-00ERqS-AO; Sun, 08 Jan 2023 16:56:50 +0000 From: Christoph Hellwig To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Cc: linux-btrfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Johannes Thumshirn Subject: [PATCH 1/7] btrfs: don't read the disk superblock for zoned devices in btrfs_scratch_superblocks 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-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: AC5741C000E X-Stat-Signature: n5eiqxw51ybao4esptswo6bxfm9x5ou5 X-HE-Tag: 1673197031-943800 X-HE-Meta: U2FsdGVkX18Rz5/bjiR6OaqSPIypS8chfcDHHUMby8a3DozmwONf1+u+4VlRZqXXSSeeB7molVS1EDzGI6Yj6N26OfcZ4R4NAqeaB8Dcc5jrLlTYpRS7/RzBiKmAT1N0hDuySxofX710JlUFHzyHjf5/FS/WRJiBcYVww160uLH+T5W+aF3In0kMUDrruV57RZqFI1adj99GLHeDpdNs+DaH2Mg0/4gu7j4AyeuN8Ml69ymhjGXDbQ7O/Pds6crEImfm0Mh853m47OZ6tfGsekffUmHLa9tilztBMUfVREQbTHhpcIpmnha8E0GoSGxK9n6iuH7dZYc08RDyMhYgiCUGephjtqQkYtVrj5FV9r8ZGoIYd+Ed998kELhZ+N5piybRvOb+JFMLXFAstPLlQphdj1uaQX3AK6dFupUh5hc26Efv8MMTNpkGBy9ZaLrPo19J7ICzE0Y9/imDL1S+o5Y4y0Tls2ZF1PDV9jGyw5FFwPWKnTt4TsVP+MA/Wc/IHHquuD3+yzs0JyddEpEi33j/VCvJim8i43atYspdDeS+P9o0ojYjCBUYMlI9i45P81ZhsRlszrTkv0xS0B25S0POzZ9tu1QCtReEpVuj7QHnEv0iRIl3we58aiXptgsOGM89BE17bGaG1NN1yBUY40YMGfjiv9ajoUWWDSXr0ctZKFMcvvFXUdF9Jwe4MpcD1NJ2v1SYhPb3DjQXnnisoF/FW6IRBXLDpgE68ADpAdRSlHR3t3xgg+uFWF9PQx94Xkt6HKvNfd/OLpmiiTBM5ZxgSE2L0NkSdxc6yHITEVJTXI9SuxEQvSnhma7pg4BqIn3MIyxN/6HB0y7/YtCNSKa0ulFBWBbTLXZFArBjE1G+lqaen5C9Yvd2qrV0M+ErKizGYE+ro+KwNHwvl8aEZ+wR1O2d7ZLHMFnEBUODn1WJrXNmp5Fqcliejd0PlAaqJf917L1lTmxikv2J/mV Yk6lWhtI iFm/GNdqI7vTXg6+kJdc3973qylEYxnsF51u4SIOog2KNCmRZfcM1Dsh0xv40S3rRhRmM/akRaXYuY4RTz0TgvZTE8EncgcjR9t8vXWsF8cpEYRmVIh35dM199cNG8uHDVJ2JWDGAAu5WVPJAOYvbmUwx4hv/KSoGuR5hapWJDzSGy4I5NIqj4+9rCNVZtfrMEMXo1ZiHg/bnFtNBl0jT8xWVBBabD/ZI2B9l4V50Z6ZSswE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13092599 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDF65C54EBD for ; Sun, 8 Jan 2023 16:57:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 645728E0002; Sun, 8 Jan 2023 11:57:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5594B8E0003; Sun, 8 Jan 2023 11:57:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 30F818E0002; Sun, 8 Jan 2023 11:57:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 1EBCD8E0001 for ; Sun, 8 Jan 2023 11:57:13 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id EF82A1C43D3 for ; Sun, 8 Jan 2023 16:57:12 +0000 (UTC) X-FDA: 80332237104.20.38D6C36 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id 80CFC40015 for ; Sun, 8 Jan 2023 16:57:10 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=KycIApiW; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673197031; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=BznR/4w1o26qgOdWpgaXoEzrG7xwT/5BaeqDtDNhkG0=; b=nbeGx2P2JkLrbkMGqLy/MdUL9Wh0iF71I7TXbrfq69891uChgPaQVy+AlpGNAi+K2QQLgo 95R/ia4Vd/GWeo1qPs48Nqp7meRwo2TXPSVyvvg2gmPBRy8eTFs0Dj+k0yyI8AO97Pz6Lz VJTBLEW/XQ08clxzsBV9NUYP0Wt6uFk= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=KycIApiW; dmarc=none; spf=none (imf17.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673197031; a=rsa-sha256; cv=none; b=ullGohmUDRM34fsjczsJDBYKrl2WlRIeKykVNsAVtkWFF4WQwgcUbpxIHcnL8oj8cngBLP ygh+6SNv4fMbksmiNpcMyRmq+BXboixMmTPAP9sUAfeMNhzWzeJbqUV7rVtvwX8LXI7AK5 IMEbxQ7eZsRtuucNns2Wtmd0Wp3nanw= 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==; Received: from [2001:4bb8:198:a591:1c7c:bf66:af15:b282] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEYyb-00ERql-3S; Sun, 08 Jan 2023 16:56:53 +0000 From: Christoph Hellwig To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Cc: linux-btrfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 2/7] btrfs: stop using write_one_page in btrfs_scratch_superblock 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-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Queue-Id: 80CFC40015 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: dt6pcn9eohsn8pcjxcrzmu48k7cnpcae X-HE-Tag: 1673197030-793150 X-HE-Meta: U2FsdGVkX19utHpRrAPhHctGxmFY4ZfASBXJlVzUrcrrYwXxi0LPcup71vBVj/95GXEPjVSFqKke1lzLaDphYIzEyOe98/WmGhT7mo5eoq5V6TnWaOWhIojbH6Ur61RQ15zJckrTI3U6KAwsFR1iQPE1TBpizhHYRd6Q50j1jh5nma7VYeRETy0PyunoH7roaTIch/TMco3H6AxLJFziDpjBYcMFySWOIUBXAk1OXdGmKCusYWl8o+IwhKHCrVpBpbXusEq8bsUui6JTskcjstsHcJJq6cb4N6tJtuhik4XxQsHXdspPWRcDP75LbGt8tOw8wwqSoI4+qZBuocd3H3W8TkGmY78H20GECgUaxNEb2q1BOahkMwZX1uBFTS0WGr70tSa3symOvVWSRIdUHEney1Uw1x5ctKf+jekJ7tHIPpZv3A4CybikCaxcuaQXLxWJ3l7pOKV9kyl/mr6oEZei0iv7JoD0Yp81uG/fgeBuU8uXpxdNgOCtpP1Wh5DT/AU52IglQDhY2wRGoYmKUAAc61x46wlqw5SshFXb8I5Y+FX+ht14iqrYY2hPxnszLORM8NUr0SvEywFpzgygA9ZCHmLHrDRxjs02OPWHlaELWxT7/ZxO3Udpfu7wpoTc5TSdVGSdxC/dG7/6SiDOlVJHi0GH1nFRkfnqXH15ePXTcPIegzbrR1wRJSzUenFOtK2sLg8F/2E0sMgJIQPHD0CP54pcudjTJ2235J+3ErHkT0qvg78dRKS8MjEijK7YUJ3r95F3kPx3nlrES09Giqq5eN/n48XT4Ot0yI3Yt35bcKXe/yHI2QAybhQzIMlZ/gFgeI5RPO3X6rBLNmusmZIsscf+XRRFpUmAjv3zy8t2PuSIBr14oCpXKIQIVkBjOiTpauu4ToDF15rCNOh8rD7XL4I0+axkbt939o+brPRFlZt8f381S5DQ9sDe/gs/MABhSDTho0KvOy7o6h6 0rZTa7rY vukuPyboz+/t1HNpMjcqk0kUHFEIBC+WykvaU+3J3L5VmfA1lD6DSmbXNNcGQQNsgq+GeDJSyyviinvhlB8ZN3QnQq4uT6d7pyrXb96KrkbCiEWhkPjyRc4vT1Ec6WwYaankkTGlRG0m37+RRV1jdtwfpCnVJwMHOS+ofNaxn2SPw3EOnhBfZKGXMh/r2c09ah/bBZsk4o3uOSRv75x42/WtYEn0J0OQub51N5bjOda5ehJw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13092600 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE76FC63797 for ; Sun, 8 Jan 2023 16:57:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86C958E0003; Sun, 8 Jan 2023 11:57:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7D0CB8E0007; Sun, 8 Jan 2023 11:57:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F5F98E0001; Sun, 8 Jan 2023 11:57:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 3AFAB8E0001 for ; Sun, 8 Jan 2023 11:57:13 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 099BEC01AC for ; Sun, 8 Jan 2023 16:57:13 +0000 (UTC) X-FDA: 80332237146.14.DCF31E0 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf27.hostedemail.com (Postfix) with ESMTP id 8C1BC40006 for ; Sun, 8 Jan 2023 16:57:10 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3xxKbUYO; spf=none (imf27.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673197031; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=w04Rctw8qyCjwLO2i1OjkI+LN8twYupiOrnbVDTEa+0=; b=6CmAU78oldRRrZzIaNKUywv80VihftdlDQDIItw9Xs0x/CbDOw24a18ZjoRThqLWyPl27G 8IXaQSZAHe4G8ziPR8EUmxoN/eoxtGPKXTYaMrTyYYuZc0qd4chgWv37ejlY82O3dP9Rs+ Mt55rujnEFlCtod7lWTkQSsO2ib5TWU= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=3xxKbUYO; spf=none (imf27.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673197031; a=rsa-sha256; cv=none; b=BqgjtDK1RtxVaz+CLs3haOP/VXFS1xMPhpNLd2LZeYUD2JDYp5f/KkiYbCjxdHWzHVYUIH 2D7ZQW7s+ucooI3KvxGmyugwOE5/JMy33Zt8bglGTnY2vi4MUhbwOz+ubZOLCOfQWMvy/F dWNE5qCVlddWrQxuGyLVgMaWpS6VKa4= 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==; Received: from [2001:4bb8:198:a591:1c7c:bf66:af15:b282] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEYyd-00ERru-V5; Sun, 08 Jan 2023 16:56:56 +0000 From: Christoph Hellwig To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Cc: linux-btrfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 3/7] minix: don't flush page immediately for DIRSYNC directories 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-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8C1BC40006 X-Rspam-User: X-Stat-Signature: zuksqew9t1qmnkauanmhrg5nitn6ptuo X-HE-Tag: 1673197030-72425 X-HE-Meta: U2FsdGVkX19uGvhO4x10/JS6gV/jeFdPj+QZMmPwntd2MFdkwSxEa2+23B3pWcGpQNWHPjC3jX/uSV+LqfEqACQZY/duCxhVMEKszB27oaw5ZJDFNe2XJGuivKY2cFyQWbsDuAtDHuPIujIoJbGol4nAq0cD3yJGUETS8KuwJDXZ6Lsxs8HuUHdCyvSXcAz2tRG/FSt4I68lhH4DSv0Rih+1EIMtRmE9ymlkhCOFfKsZvv5nJJGfmNrnvmi7KfpoAMWApv/aoWUfrzSBdAf43UA4SECYkAOCBsVLsfaEwd0lWt/AygeZbSRSB+tC8xj3zKAelF2mze9TPO5mCspd31ffwQqx2CFSpZkU48Ryc7/MbXcHwZstslkS7u2OubCrv0RU0pgN1EDclfXT0UZtt9T6CmeT9I8IE62TvHRQtKnju4mzMWNYES2ek4JoY6yZ0ExQO5gIMu4Fn9qm95biWzeIzm4wdwdKgmmcrBzu9Q+GFgfH6cB6WEjYUXLvOTAjFd9mi7ylNZI8fxD9C3InJEaNUtnXtHHOLRhBp1tm7y2gsSw2L6UATHpKiud50vTlcw/1lysSu9xjagiH3z1rYBWFn8/Ydi220mrU29+WDAnMSDzkrv0gkuEoWxInbmJptLvT+Yv2U1EXmt3SaLz8TnCHgVHDUQxnLzU5ASWmOIWEvC4Q7rJKc3qyYwiEOKcPy93Cx/+j0yCWOcp3I5clNofp6EN77UoOsIMh4omOHuc+DJGSt1wGXPp6i25Vh0MR7gDjTRwb1e4v5jnMbWTZAHcHY/GI3K5RvY23JYWmUO2WHt0F3PTy91r6Gh9A09z5m5m4Li+SOkKTVBfM7GLBhgO3o0MP/0KuPusxl1/LR+DTuBbkQGNGaWwjEMivMCXaEs/CEJioYo5202kMYtQNTpg2Vbdpbkf3QQuAiMYZLuT8TzwGffrjip3DkoWG838lNd0FEO2dWPzpG7TUwuF JQ5E+QSX Tc+0HfDzuQSdCLS4I90z1U63WINdKzOGVs3MLiRiSMnnCwXjMkoYrKXpCQnG4Ac9AP4zmjkLB6ruHvBVLNIrTFLpWCuBsNthqGxRXdjMSJjERuVJDiXvoM3S+kQEQhuniklVERRtOxR1qoFIt0Ql9e33EtljDYOqe16gYM55AieqWoa6QsWOLw/lETg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13092602 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3C41C53210 for ; Sun, 8 Jan 2023 16:57:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0843900002; Sun, 8 Jan 2023 11:57:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CAD36900003; Sun, 8 Jan 2023 11:57:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A89F78E0001; Sun, 8 Jan 2023 11:57:13 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 69C988E0006 for ; Sun, 8 Jan 2023 11:57:13 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 391A61A0292 for ; Sun, 8 Jan 2023 16:57:13 +0000 (UTC) X-FDA: 80332237146.18.B8FC99F Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf26.hostedemail.com (Postfix) with ESMTP id B02A4140003 for ; Sun, 8 Jan 2023 16:57:11 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=oQx7Rv3K; spf=none (imf26.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673197031; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LRWqWW8CxEBUBZTClfw9RwYeRYBhCeQ4pIrtvl3s68o=; b=xaUK9UI78baRLinwNQhQTnc/W/dlI2/F/BC3JU3y5nAYtNxkzSIqd6goV2IxamRxQrrJZg u6uoC/f2N1uVCI7XXi/NOBI6ou1qeAoZemm8cQc4MAaAot3UPlTj4fP2eDLFqRD4fIacxj lwiPxmpK1ls6eo6vHWeCPU7KfAg5hS0= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=oQx7Rv3K; spf=none (imf26.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673197031; a=rsa-sha256; cv=none; b=mYRFQ7yrQ0moa1vJhZYRgorMLJ46V1+woD2Rkq0mRzSlAPu28Rmm4SKx0dNSbMxGbcDPeo AqXeMJUTYErbw90UznvOmBJOwBDYXlqZ9r+Ug4qxrEUZv/A4FKtUWui7yLooCB8i4FYT+j N/y9OynpLUkf+0Ql45D1Sf5YerMzj0E= 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==; Received: from [2001:4bb8:198:a591:1c7c:bf66:af15:b282] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEYyg-00ERsb-Mk; Sun, 08 Jan 2023 16:56:59 +0000 From: Christoph Hellwig To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Cc: linux-btrfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 4/7] sysv: don't flush page immediately for DIRSYNC directories 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-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Stat-Signature: p9wjiy6q5pfbapi594joaoyy7efw48zs X-Rspam-User: X-Rspamd-Queue-Id: B02A4140003 X-Rspamd-Server: rspam06 X-HE-Tag: 1673197031-162208 X-HE-Meta: U2FsdGVkX19N5phd0BcMdWAo/o+2/55a3wUvVfEP2Q7aslHcmFW/yb18/nfBtNVy91SWdXJIK4qd6kbaukwaGe48DeysVUaTxbI+MIKlP8qpqCCrS77vKpSjgAlxS0p/n/G4uIdxNWOJ0vmqBVUVWNOL3g/MTJ72heiDMtt+I5H6OhmH0meO8vdIS3UfpJzRP903+fj6hImK5KYkGNXYRTHTrSep9nYAO6UiIwvj/cgPqTwowx6ichCmgqgqZeNj10oYfdH1vbiYEpIDYyXjJaE49UnHMN92260Ya9EDPuWKRoSkUM26Ry3CRBZWtLhuLumdRRP/QOf4MfCpwuGfL4AV4tS4J0JGlPPJ+LS2+3brrEgJH9vfRN7mTZfQ7fmWDeojjxcxJWJctiGzNs7v0FTBSGmKQd+ZmTImLwQhFF3DmeRheL78akUesqWUZDLc/HEYvY8dlEqkN21ufSEbv6bf4/i3GEy0rAfhFqClC3PKas3LMTVhCtK62DCmtjo2rUKRQOotuslCDVXbUn/3Ugp6nMSFKQTTanjpHXeaRv3NHC41f/ayXR8tUTSc0OuJnNHUpS1LcGTVQZmFPDxX04z8wFKKJ+OTQY4I87PoscN/pspJQMz5Nz6Tgy1ZWR6U4EHUylxl+8doZxfOVp8b/1KKOIopqip/IAAQWh5YK+mpEqi8k+Is28kAMdbCqhxGmLk4Fg33v0RVnh3j97CJazRVS+k0G1UgJTn34yX8NQoZsEI8HGlhsvzaXzkFJBUjXt+1vHG4LbUeaJviZ23Z3a10ohLub/xehM6HWVmT2c+7H3FeBxeS0BLhaderXP7Y4E/mHjv+KpqZB2dquBN1MAsL9uBoSAJEaAjVL9Thp5WoC9/lKyg5Qoth93hvVD97e93n8wdyZv5+NiJdG/UQIFzAbzWHDGElbLlpSgz3IKCdzoSqg3UAqeSPTDT09VCMFmubndSNvW2nRxBEjjI vLw+Esma k3EOrn7H7fyI2snNW+1JxsLIHIeDpnNB9tYf5UbucopalsPPiVLCo+dkm1K3CtVV1OMPCdDwXLzgHfqShzAOtSLz1vMZq3OltaB1W1nmdBw7+8Xdh/BAfoPwPpKivmAnkSykw/YXDiQWl7I3N0nvNXB0bJpCXOfhdhj1cDYl7bGWOPmEfB5HNHDQirA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13092603 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C3A4C54EBD for ; Sun, 8 Jan 2023 16:57:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 401DF900005; Sun, 8 Jan 2023 11:57:15 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 337A4900003; Sun, 8 Jan 2023 11:57:15 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 115EB900005; Sun, 8 Jan 2023 11:57:15 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E6799900003 for ; Sun, 8 Jan 2023 11:57:14 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id C4E5240825 for ; Sun, 8 Jan 2023 16:57:14 +0000 (UTC) X-FDA: 80332237188.06.FE878D6 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf20.hostedemail.com (Postfix) with ESMTP id 520941C0011 for ; Sun, 8 Jan 2023 16:57:13 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=PKwRols7; spf=none (imf20.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673197033; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oMPhLOYpJNBqa4dwFa8oL6UthrVrVH8Rk8f8kVGsTX8=; b=C+Um6bqVmwCut2cINyIX2pcMdVaaqIKHsBCtR63TM1zoutfpPw3+Y/5biRm4oW9+mUndXe ANNSQF5LXEFc4JzFUFAO2zk1O9Olon6gJK8Gj1dokasvAa9GHOB9cFS11IG+Xs+AeCka6U y3QWQxRstwE2NGRXzCm02LozoIPOPSo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=PKwRols7; spf=none (imf20.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673197033; a=rsa-sha256; cv=none; b=Rz/BkRjEaOPshPTZ0VnFKpkUwezLYKy0gwQ94ogTcxPZl8+aAfHzV2y5pUvabo1jgP2QdN 7FLgMLqtZVL5C/D9yabnP7aR/H9nKs1esjOc/h91YOIEJBu4cNxoOeRRGbw2VqmnGDxUH3 G8xi4M0AHl3IwOZmfqI3Em4NezfrzcI= 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==; Received: from [2001:4bb8:198:a591:1c7c:bf66:af15:b282] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEYyj-00ERtL-Ge; Sun, 08 Jan 2023 16:57:02 +0000 From: Christoph Hellwig To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Cc: linux-btrfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 5/7] ufs: don't flush page immediately for DIRSYNC directories 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-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 520941C0011 X-Stat-Signature: 5a7rwxkpjzdq37i8yeut1sr1e79xadzp X-HE-Tag: 1673197033-565523 X-HE-Meta: U2FsdGVkX1+HHhiWJf2fR5r+CQTxsyOxoGovX7YypdY2leHUCdsh569YeNGrCkoGtBol5JsodjCIYww4o6TYrjKcso+DoeicfQZY0Y6w3qUYg1+rNJARtR8eZTbHVCXydfcRPNFpic5eZkDyYneELCf7LYMYViWpjOTbe+mcXrmrTxpVWCUCNl0Z//AS9gWJ7swUjW+kQHadbSR7ZSsuvqQHs5QakZLQODIyTiMw2fazQ2zKWrCQZhIsO3R5NHCwdGijvYWXtycB6dYyRBNjH465n7XdrO0R55Z3sc3Y65xhiFYp5qvmKMpCK2oIxWX4v7FvUpyzeJ8RpY+XN8w6ySKgU2FFtKAD5GctzVM7IKIT3EEMuaNeDhKSbqEE0n7RE+k/+7tYY1ZQsiMnJa1wlHmRbJzXt6NJ2RKOEpUXdTVGGAHotZwRjXsrxG5X17+I9tEbYrgYXJgO13MbvQZpxAj1qhIzHsAWaiFLCMsEJn8dgjmut9ZGU+Mm6Vs+3blWu0iPe3wF6LCfen8vL8lFAgFmleyGBIh7KqmUr2z2wEryHA4Hc+Nqox3D3FCnIzr/XzjFV1R6a2eWF+aUBYw+kIcJrlrNDASYjFTEtVBRGDVbDmj7gog2AMRo0txlKce/n4r8uIJlY6H/fO0pw9+wsbJXgLVEHO/u22si+X8rmPI6eEV9evwwXq6GPDlEzhwkSD4KmVsOhkB0voN76RTbIR1lFJD4WjJfzpi4/LRm7IGfK8RhphBaO0Nwzy6BgaH8/D5tLZp2BgRo//U9SvBUgBAHVx+kRmiEHcOTZFmQTRDH4r8cBzAXLXpjTf7SV0+TIjIwnJ6wRSA1u4y5lRQRbu4wmkZWMRlkq5j61kKkWfZUK+giO5OKJFCMpBFeMulrGTjSSVmF4/Mzee6NFFN2RZ6AcwBR7ZpYdkjepideOCLz3UTlIRhX8GBtzvin3ThK4/jsWEYzhdXS7+64IOr JVos1MFT l+jb4AV6ociWK7XzEXlp7CrjjR1ePfdb47RuWmau4UM1M+7b++eC/ked3g8CjaA+ie/vThCaidwK+CwEKEhYq0uYW8Xng/itE0IilPYUbziG1fO4LOVHMYlgTrRTY6R9vhz+x2Ii3xuxNyYEzwQf/sT59GU4Ljrj53eESbpgNr+3Gh9Hn4adMpIPiCg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13092604 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0AA7C53210 for ; Sun, 8 Jan 2023 16:57:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3890F900006; Sun, 8 Jan 2023 11:57:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C636900003; Sun, 8 Jan 2023 11:57:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C7CE900006; Sun, 8 Jan 2023 11:57:19 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CE7B6900003 for ; Sun, 8 Jan 2023 11:57:19 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A8389A010E for ; Sun, 8 Jan 2023 16:57:19 +0000 (UTC) X-FDA: 80332237398.09.07BBF13 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf04.hostedemail.com (Postfix) with ESMTP id 34C794000A for ; Sun, 8 Jan 2023 16:57:18 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XAeNW8Pv; spf=none (imf04.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673197038; a=rsa-sha256; cv=none; b=YV7MpSoxcsclbiNGem2ft4npZJjwTmZkoMcBbQsDR0x6N2LHkrCo+2fxTz6b+9Yrgudl7S ZMtimLFfTw6Lhhqpe8tdPTwRNLXEHuIb/KKSj5NJbHP+1hn6h66KgnMXf2qe8GkkwpESC7 wzAkia2rTTipjkivRz4D+F2BZ611Jr4= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=XAeNW8Pv; spf=none (imf04.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673197038; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=0rSqpARFgQRqBHywsTtuZPRrJbLJdUkqrGBn/TckkNw=; b=b17jJbiK1Yl1y8yVcgvfyYGoGP0SFXXWq5G7Go4aI3QZE8qJ1MWpcvZwEW4saR7GoWjNlI BRE/DGUjL8kKp6UTY3A41+ODyYkD+4NZA52tmv5AXESg8Eal+OsFrFN5ac602tJTquwhRY AiG8e32DagY0vr81ZcDk+S+Ve3SZ5p0= 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==; Received: from [2001:4bb8:198:a591:1c7c:bf66:af15:b282] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEYym-00ERu3-AK; Sun, 08 Jan 2023 16:57:04 +0000 From: Christoph Hellwig To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Cc: linux-btrfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 6/7] ocfs2: don't use write_one_page in ocfs2_duplicate_clusters_by_page 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-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Queue-Id: 34C794000A X-Rspamd-Server: rspam01 X-Stat-Signature: bhe5jizppqqp57ruyp1jmsauqan4ffdb X-HE-Tag: 1673197038-414712 X-HE-Meta: U2FsdGVkX1/uZ43eHk5C3oyfa7CA2SPrywNGeOl/RR4FEZqPlaGHMYIVrox1DkGrDXJ/0/Yrq4dbQZ/VUXyVTKPw8ID0W/Yi6Ul+JQfiL4oQxYkYYC3xNgjhnmcm8lq1qmRJkTG4rczjQqjdqEjA00lRhp4Y7uQKekglxtHeN+X3+NANAcNol9IYXaUrRsCPhtpZMSFjzEmlGtCAcvWv8IXzClJXdIVT5QWxPs+06CmrU+WQQGbMvcJEd5kQ1sX+rwSqwfSBJuI/g8f3eilgucJhcxwskXxRFgMUBv/RB4neIdXbWSh3d5zNQIws2u2h3IpVPOfUL/+5pCoR0SN15hwJReDEvzTtKIllFblllRea9J9TAo6fmBn3/i31LzvQHHWiC73TxrKF11B7OTRpzzUETFquz0Ve0UVJb5nlYfIfkC/fbL+KhpzNwP1+tMIUagMeQNlcmUPzP3L0eZCeDFkuzIvqqlEiCKB7Rm2byge1u5gdAyFDhCQU+DUx5A65kxYeNykChZga75PnuduOv1DBBa2DD5fuyHP72V+iPSxdjMpeayqLxdhsLAL9jJQZ54L95SyfgOCO6KDjd93VePGJmtB4cSOlc3RA//6+8Rml0xrmLeFmp428UzLuiqR9Ahi6wRXmCCA7n/wWjgai4GA8kDXTRHvXYlJSKx4Ol/HaGbqDy/amEtmcHhaXCXp62kqBCOEEi/RDOEzhPurD7DFbkEuIZLV9ycDpbknGNlKgFI5273tC0s0783/vanD5PdDS9Ud6zeAk8JPda55AGuS92AyAzp8asa29fPASnQmBnzNNj/Pcp4gNE5AiSJkpKIZk4zcPaGaD2RJfmUqWVoDWN/4tquwsi1y/rGfnr8RjKHwbg0YAst+9rWufOuwpO/Pi8iFBavMcagpu6kl8Sqz979UXM7FL9wy9nVPK8L42klcw5p2NyGIoiklKzRluAQWhzM7v94cgE9rFT6m vgSZ8rAt IOk31vCUtgmfgzAIYYk+n9oQLbkP6hMjbLF1yI5wsGeG7VLoIQCEaZFgTEpuwKX5Ig4wG2QMz7ifP/UoxLqvSATATSYF602LF0trsSQq6lO/ZbgP5d3QuGizgdwdTtzUPSKxMFHzBDSfLv9Lvfap9AES0b/cclKxkD9koOgvlwbBzfiSnOqrXXAA9d38/l9ql09naObytSMl1eOt406dV/DZamgzwmqZEzRhYGsqzj6MqWkc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 13092605 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C22AC63797 for ; Sun, 8 Jan 2023 16:57:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B02CF900007; Sun, 8 Jan 2023 11:57:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A8A03900003; Sun, 8 Jan 2023 11:57:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B66A900007; Sun, 8 Jan 2023 11:57:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 7212C900003 for ; Sun, 8 Jan 2023 11:57:22 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 4C393140520 for ; Sun, 8 Jan 2023 16:57:22 +0000 (UTC) X-FDA: 80332237524.30.5310D0C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf14.hostedemail.com (Postfix) with ESMTP id D768B10000B for ; Sun, 8 Jan 2023 16:57:20 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ptbBbqyy; spf=none (imf14.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673197040; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=35W1DfUpdKcvHvkmZd/iv7iohwTShFaTRVBTVeGN8KQ=; b=JIk03l+lejTZjp/7Cz7K6ITgQbCEL5UInTfhQEQ3+/F6TN+YZ6LF639QMm3SGB7tiJCLNa y1Rz/3lvoFgPhN7at5vQgUGZ8c9K07mUhwAaRgrXWOP4CEND1MN6d43qcsKexx9gfWvz/O 8BRN0S+Q6ZC8yihb+EzAwlFEUe4Md3Q= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ptbBbqyy; spf=none (imf14.hostedemail.com: domain of BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+58c3238fb6e66237551a+7077+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673197040; a=rsa-sha256; cv=none; b=IKdqzYrLe68aeS4P4WXPZH1s7c9C20RSiAvuE+9OY7HFPCOeq46dN+ln4Ypwf4/zAjabjb x9rXztp5LtDJ3YjEN8MgvvJRAfTjvSgvKwLqJPuFkTvNH4gr6/DaGVPcRE9xL+LzEu94Da hC5nQeSG5W8N+I+U2TTLtCWaB1UidTw= 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==; Received: from [2001:4bb8:198:a591:1c7c:bf66:af15:b282] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1pEYyp-00ERur-0M; Sun, 08 Jan 2023 16:57:07 +0000 From: Christoph Hellwig To: Andrew Morton , Chris Mason , Josef Bacik , David Sterba , Dave Kleikamp , Mark Fasheh , Joel Becker , Joseph Qi , Evgeniy Dushistov , "Matthew Wilcox (Oracle)" Cc: linux-btrfs@vger.kernel.org, jfs-discussion@lists.sourceforge.net, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 7/7] mm,jfs: move write_one_page/folio_write_one to jfs 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-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D768B10000B X-Rspam-User: X-Stat-Signature: kac17kx5ifxhf7uai4msa6x17a55wn3q X-HE-Tag: 1673197040-413062 X-HE-Meta: U2FsdGVkX1+fAlDBUZdIBd7Nu4NkZFUgsIEqazy94EzW0GgILngTF62fCjmiyHP8P5BNmu0ximJ8xwj0K7+egorFrYkWp5oDQ3Ij4dLQYsYZFtMQGO6MAfxwd7zv25ubdyEUwZNmk8btEHY4Uh7mtclNU7ROhOnjVcIwN/baEEeVcT9eNIvbCb94DH1Jc8m5RpWrhiMJpFoARXBg4nSKVeJJTfPktN8lU3txhrttvg/NDz3/r9WWUSGY48VwFEqTLBWqFN+lKYAnzNzrBmKs9COHS0zvwpk6DhosLhZ38SaBTeDxlsYKPY/GdoOg3VwN9rXwq/oe2ak9BvC1IcaM9JcEWJrhpRUFK7QG6FRBgOjao/v2rm6vQpKle86dbP+EDNP6CkXcvEshFDZyoOil5XKbDLxrkdx3ulHUzmEEToKxbiK8Oheg73bs++7Y6HcZgzY7eYiUHx+ISRFQ0FwPNMcKhwgM66zanKqjZ6IaDWPIUOgDPS66frIVh1f+x2o0m0wM/aB/2U0J1KHdU7aZFnMGEizXRIHe/y0wyfGrKQw8a39jrIyH+4pDA8mYWEVzetQ4xKVxynqzU9Y5wbr3isFu5VUv+YhDxdStZGwP2uXV8l+rrj2tjhwlKqda1dMxuwHI7fOP29IBse/9bVqo3ntiQQyh6rEFvLiZWaV+PzeoNhre8NVAl2FaPUHAklWZP4Sd9FD2JkSpTx49il6ImRXa6llQVu4Dp6Ufz2LWK0g5KxAzfiuHcJ4uca0qA4ONYgBozcJ3dvsRSnXfmYRF+2o5U9fUt1zRSDguSOnzNsomOO33vBc7aZ7YD9wefG3h8Ibg4kJZE2wc6nQu8eLpbWDjCZzNxC6ZIqkeOEU/la7uF3YMoHNSsGB/VyHXU3a+6YC0B+K3eYLXQvULjrstbqPHchlvLIvkkHjshgnK7vcUJGr5Q1im1inO2BfeMtHL7Xi2rXuCI4LcWiROHRz +3Jlz77O 0z0WRedtJ2VLSpPxJjNmFPc0YsHMFWBB/ZCKNX7FVn1WwldAKqLtDx6K+yXJGrSIMakh3EtLkp66h9S67Ypn6SYcb/aO9utmwMHuwhAdoes3XQ12ma8oeI+3YRy1NfGStZQyZrbi9fTw35WjHGZSmgddnh6VqGvUtOmVHpWMuNO9BuAzvu4u60XxES+c+vHeBEu8g9uWaQ9UXut9aFBUVu1NJh3Dd7OdFkyajNR+bZelxeog= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. */