From patchwork Thu Jul 20 14:04:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13320584 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 AE8E1EB64DA for ; Thu, 20 Jul 2023 14:07:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45EC8280110; Thu, 20 Jul 2023 10:07:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 40E5D28004C; Thu, 20 Jul 2023 10:07:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D6F9280110; Thu, 20 Jul 2023 10:07:09 -0400 (EDT) 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 1ED0228004C for ; Thu, 20 Jul 2023 10:07:09 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E1824A0172 for ; Thu, 20 Jul 2023 14:07:07 +0000 (UTC) X-FDA: 81032166894.13.A49D27E Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP id 9324040084 for ; Thu, 20 Jul 2023 14:05:02 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=u5fs6hBa; dmarc=none; spf=none (imf11.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+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=1689861903; 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=MU6yo3/JkEwDpfVtYsrPOrA7WaINTrJRX/tZStkXyyg=; b=T/3ytujlw+aInKXNu3K/i/aTbTxJ6VvgwYqkh30LeZyhS+es4wBDSW1vgzGl/cTz6oDusb /ht6V9qCf7pwvIPSvwqmf2v0m9Ew0hh9XjapD4IuKf153MY82AzvvprDaUVMoc0s8Z4pon fs+APCAGzSoZCG1rBZxZrh2qWvfjsPI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=u5fs6hBa; dmarc=none; spf=none (imf11.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689861903; a=rsa-sha256; cv=none; b=rTblVZEi7G34taLNUj2ZnMiGgRGma+CL6uTCKbJmA2lfxbcY086rP9hw9g03hM+WJvMywK 2kwR1l+LBZWRRCzl65WNtQz2w7829Ejn0Z8tev2TYk06BMm8GUqjHIkNcGuwaWShVOADpC HJQfgSar9CPgJ8F8i8fX2gZVAqOMbsE= 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=MU6yo3/JkEwDpfVtYsrPOrA7WaINTrJRX/tZStkXyyg=; b=u5fs6hBazs5UDdEUCHFufcXQuV M8Mhc6YEu2dgb1zeZYAHYeiE99a04zapRuwjalF5XCByuAKRSTJrigMBq0DCJiRLCkuxtk6B9dmK8 T+nYF4UnUOjqOlAU9gI9CePE6IRoAKps8uMUxaYIL7cGIYDhwvqoeOdghhLfirCoeCNMzidjoIK1n 6d7+K1Ts6LvaBv35Xv6GNw1zpaFFZDUhBFclPHtdwSwC0UborwfvNvgrQncy3kUge2+lKSgE1xuPt AGEjbPHNDq+DnlTCx7zX0fJmLdVJRhHTWZCOS8F6s9d6/19YFb6+XRYMdpnoH00ELwTsZMGJwnQtn eUCBTUCA==; Received: from [2001:4bb8:19a:298e:a587:c3ea:b692:5b8d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qMUH3-00BKoB-1Q; Thu, 20 Jul 2023 14:04:57 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Darrick J. Wong" , Andrew Morton , Matthew Wilcox , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] fs: remove emergency_thaw_bdev Date: Thu, 20 Jul 2023 16:04:47 +0200 Message-Id: <20230720140452.63817-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230720140452.63817-1-hch@lst.de> References: <20230720140452.63817-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-Stat-Signature: dxzky1j7rka8mm8z4b1s4rocafqppqxd X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 9324040084 X-HE-Tag: 1689861902-216707 X-HE-Meta: U2FsdGVkX18Io1zby9u7m+ErMZhKOv5rD77HbW8yXRq2hZfRb++umY28TVBNLQP50SVZLHoTRTYfitzDSa+LEkmD8B8dXdw5glubpf6vDSUR1xNnzQ9SdmFWJHKZ1QoIglyBNHyOKT4zg7HHmsGj0Kel7HgtlXCthBA3hLph00WzUHc7rmDdLqaf90gOIviAJ+3ddIf7f+NViGjVmhFUB2kwFUloZgU69L2cIrz++Jkmrg3selUIOO+mtTlFyy/WbfYjL/zK5ogCRGTF3y+Yi7etSU/nV6m0sXngBbQkl6blhhfJ53gCJ/3PLNeWiAVy5Lr20jx5bOWxgVdS+fpNrcg1sqm+JozlEeb6e8HW3WJ2jhfjudlCIAUchzY6A0go0NL0HImjsr54EUvFQ0qjFDAeESmOBDHyxnM6eCv6XHQrg6d8d+EZimpt/ESjdsar2KqUORrBImYVxyOnC/WeiHBrVZTzG5WYZFFHEqT3XgHCCE4YJ+Apkr1CP/hV90d2cHmf4UdlDDtFbLvMLO5tLKXcgPSL3uDc0+oPVLzBY2P0ujEXAGaxv6B+sbM9MHOuLWDELniS/oEQ1Q+cQOuS+3bYhThQrr85qXmPtLlGIBe4UeoBRTtu9lJSlyuPbZhXBihgTKWdCZgtK5M70zZ3V/ghI5Y1eO2sbAJFxa+8qKi7ugXBVFdXJ1qmaRK0ktV3QO6j6RZObxJgUllHb1okmjFYw/GhX30B67/L3X1ufa3S+uM3uK4D76qvVWAaTKVaQ4hpm/V5YIwVRYbah/55k8VBon8vtZTCthjatK1/LSZ6WGP3vWS4mZ+63VqGAXCb8+Qe3wQ/z215nZocCDld5VCoA5tkIJDkmRdJ3MQYFxn9SwuDBIgFmzQ7qdtHAUckwJ4/xiZGckaRX8lMOCOVi56swB+XSAYQMtNjdNxHOvUmsj1iHkvmet4S3xAJhTwqbBxDfrehjaj4iLOlR+/ t3yEv6qV IVr3BCyLmp/WQybMCIJ5IJeC61y1lDwRyMmh+Mv5IrbwS4JGDVDZVeAjRUfEtLJEPYyKFvu/mGdDtdw+fAY+HOKosA+aySkSSfCHOmvkICIdPLDHQY920hnbvKIRoFh2FWU8YieH3hwO4z2bS6Xj1M5S5P78N9/DKh4I2UWwgqkeiqFAepLOQ5F9Pp8APZwltzbQLitCoxiW9a+1wEd9ziWmRWszt/H7o5XgKuHhGRzAep+1zsuENynRkGZHscPtGclJh7i4WCUwi+OAi9MM3IjevXtBP+0apS+UIGS5BESSHYLbaZt5TXPnO3ViySnqF2TjjDC2Aac76176zVji6oSGFEC59yJ48IPfbEViFCHlMj6KTEgtauTd+fRDPuloC2R8zmS31N38pNgL4NaYIX0qbRY93wHXCmGq6OTi4Ujj2SwZ+hb7TdfDpCNtjFqfiXGXXbCZMcReR7/Q= 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: Fold emergency_thaw_bdev into it's only caller, to prepare for buffer.c to be built only when buffer_head support is enabled. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Luis Chamberlain --- fs/buffer.c | 6 ------ fs/internal.h | 6 ------ fs/super.c | 4 +++- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/fs/buffer.c b/fs/buffer.c index bd091329026c0f..376f468e16662d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c @@ -562,12 +562,6 @@ static int osync_buffers_list(spinlock_t *lock, struct list_head *list) return err; } -void emergency_thaw_bdev(struct super_block *sb) -{ - while (sb->s_bdev && !thaw_bdev(sb->s_bdev)) - printk(KERN_WARNING "Emergency Thaw on %pg\n", sb->s_bdev); -} - /** * sync_mapping_buffers - write out & wait upon a mapping's "associated" buffers * @mapping: the mapping which wants those buffers written diff --git a/fs/internal.h b/fs/internal.h index f7a3dc11102647..d538d832fd608b 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -23,16 +23,10 @@ struct mnt_idmap; */ #ifdef CONFIG_BLOCK extern void __init bdev_cache_init(void); - -void emergency_thaw_bdev(struct super_block *sb); #else static inline void bdev_cache_init(void) { } -static inline int emergency_thaw_bdev(struct super_block *sb) -{ - return 0; -} #endif /* CONFIG_BLOCK */ /* diff --git a/fs/super.c b/fs/super.c index e781226e28800c..bc666e7ee1a984 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1029,7 +1029,9 @@ static void do_thaw_all_callback(struct super_block *sb) { down_write(&sb->s_umount); if (sb->s_root && sb->s_flags & SB_BORN) { - emergency_thaw_bdev(sb); + if (IS_ENABLED(CONFIG_BLOCK)) + while (sb->s_bdev && !thaw_bdev(sb->s_bdev)) + pr_warn("Emergency Thaw on %pg\n", sb->s_bdev); thaw_super_locked(sb); } else { up_write(&sb->s_umount); From patchwork Thu Jul 20 14:04:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13320582 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 4054CEB64DA for ; Thu, 20 Jul 2023 14:06:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71D9528010E; Thu, 20 Jul 2023 10:06:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6CD4928004C; Thu, 20 Jul 2023 10:06:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5952B28010E; Thu, 20 Jul 2023 10:06:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4A56B28004C for ; Thu, 20 Jul 2023 10:06:46 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 0D517B0B4C for ; Thu, 20 Jul 2023 14:06:46 +0000 (UTC) X-FDA: 81032166012.07.71837C0 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id E01101603E3 for ; Thu, 20 Jul 2023 14:05:04 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=pfDrP84K; spf=none (imf08.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+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=1689861906; 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=mYeu0tyilbLfTglTrpUbKQUjimXqrsdI92ERouU7b00=; b=GY6Cns7S+UxPxo6jbxMdYonIuNfnxKRe5oge3VtrS/3tA+B9Z3Dtj7Yw4opy8Jh98r+zmn WRmq/tEXLG7VDcjFnDlLjrReIFtZVxLxirR1LMPmGwCC8zM2cNsX65W78VPP2/1bHlzIDi M8rFq4qBp7e06LrbXPMw3MuGPxS1g/w= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=pfDrP84K; spf=none (imf08.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689861906; a=rsa-sha256; cv=none; b=rgHmIASqCHNh12vD0RNV1eL0EMJTL6Y2pLuCtbfAssRb9R+kF4pNAmuKw09brbszPAkYS8 QRh6UELA8Ag9IKRPSABNEAjIA/UlY3YGPtbAZNBZQ3j5CpV8aZLfT3NgT2es6UkxzmMTMB GIpqVs5xnHZ292A1ORyX0WGolPm0zWo= 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=mYeu0tyilbLfTglTrpUbKQUjimXqrsdI92ERouU7b00=; b=pfDrP84K4Ruw1GgshQgHzCQDme ++Yts7cPZnSbigxbVpQ//KJxOXm8sFa0ST/f3tVXzc4aoNC4NTzyGVWOsJs0CQ6BIng1WDivwIrxv cbwL0OaqvR6zPhBnHGiRdBvlmC3XeBQ4Xf/bQEJhRiXoAZEW+qaCdR+NL6pcGqu0AjW3ZyBoPuULc WRHzp62GGUcmNAPLYh+a/6YpTj0q2IUpeqzpUUUuDKNdq+4o+VyW/UcHE935/ZqiGfRVqQtrcIJ/W 3Jci/0RWbpyIDvi3BZiP9uFT2dSiq+Zj480cqBscAOupKuyx3TGf1JfGUlFzaEhS4jnA8TDbHvNRU 09ibZWpQ==; Received: from [2001:4bb8:19a:298e:a587:c3ea:b692:5b8d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qMUH6-00BKof-0U; Thu, 20 Jul 2023 14:05:00 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Darrick J. Wong" , Andrew Morton , Matthew Wilcox , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] fs: rename and move block_page_mkwrite_return Date: Thu, 20 Jul 2023 16:04:48 +0200 Message-Id: <20230720140452.63817-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230720140452.63817-1-hch@lst.de> References: <20230720140452.63817-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: E01101603E3 X-Rspam-User: X-Stat-Signature: piuww4qxzxa9jzfw8w8ytygpbxttoobr X-Rspamd-Server: rspam01 X-HE-Tag: 1689861904-286286 X-HE-Meta: U2FsdGVkX18fDSXodcOu17jnYRj/FNp5yAxnlyOXZpliMoO1HENUBj6VElkao75t3p5nuge9O1ZPWrZeDL9hgjolMFDyam+pfeayKhlr9Yh7dwFuw8/MGsL5WUKwTIJCx5HflzJ+LndYuZLJ6yqwdsPDxo5ORlYOIS5uzzevmRin2+9aCqvzFtfXrYAjRKoteWUtmrngp9y3yr/A0h1hEj2K++j1kZ27UZ9MNT/bCe9Nu6yryw0avRBX5HPqQEPRNeptxsDICpMaC8NOfve1QwgrP/0ny/POfU9v1EJIWRInogSB2OuMiu8fmHJ51YxgRghO0vrEkKvE4Jrtie6oJka2oJVkrQc2f8YfFmX8tgStkE5f12xSC2XdeZ4renMHeV1/XZyeJ5XUzoxrpDFP7tVqCi1HFYaeEuKwYrOKrTMQoy5pUHzQkdbDt6MIjpxN7MB7d2/fWN0QZci+HEkytfgnSuAb55mYQHXlhFnigkLB4E4ZRAaaA9gTYFWgVWrNcjZnxgmHw/shKjitUDb2ellcBC9y2KxR1OjvaQIpf25oroom+NEqLybu78suapTZn+37wPe3dugd96f+Euk6Kjatz1+uwRbgOfIqRKpRLsTyfMYfltTSZZb/HbOAh1vH+GnOiN3KV+qH7G4A1zy2B1CjPJZmV+jxG8X2JWHT+4Fg/7GqwAEFAhKjCJSbYOp4S+cwy/kdUTzphMvhC15hAANa8tzvPgqbVdHuHo1EoKQ3fJfm/nyHyWbVmISnWKo583iKtb89VPBZIUWXKPz8F1LUM0pVvNoN5owy5PL8+ef95G60MQXIvOc2gPltoxKRvVAHO+lViUQQT5jsleW4HYq76n3CHOBv2UX9JfQWhwImQhvxsV8ES+UiqTgZXhul8EIt76IC2c2Ny9qBIP2ubKX9MwquIYT2LgtoIv8euph4+YJVQnmb77REL/QBFUqGzGuq5etQT1rGS38IM1d ji/DHdMP hvVxNBuEwXiZBh5VuWrcCGxWuVI3Z6j4L0lOwzCrUPppCDrvUXTsHdXITMZaFO8tgyBd/gIJ795PldpcQEPLUap1KYgPrU+Lz2WbSbfAnD7TU0JUvnZbWvOMMV/oAi3698nQkatlSlPcvdGBGs2WJmlFeXjB+mRXqEDQc08Ep8TcxB/d1+GuQjyvyus2dmXF5Z0iS6sAz5gxltHiMWXW99mO/TyoMRoKEmzzaZBXtUKc86NXM3xPZWJKg6XE/O6IiHdzfvrZFBB29bo2KX3cZlP47beCkeSoql3wl7cEv8IZc+wV4n5KIXLHWQhStFN1YI4+1GQmPmlcanpoUGBAvzRoRH0UeWmGIygoaBDbEfyLAPcKG/49tZmH/BSAHn+/ItfegPTg6HUWVFQdaR8OM79KQtUQ3GE6BkNTLjEDsv0KEXXaktyBHirUVsnIc+xrYovKOEFMKZupE3yOQOv0DO1TYVw== 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: block_page_mkwrite_return is neither block nor mkwrite specific, and should not be under CONFIG_BLOCK. Move it to mm.h and rename it to vmf_fs_error. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Luis Chamberlain --- fs/ext4/inode.c | 2 +- fs/f2fs/file.c | 2 +- fs/gfs2/file.c | 16 ++++++++-------- fs/iomap/buffered-io.c | 2 +- fs/nilfs2/file.c | 2 +- fs/udf/file.c | 2 +- include/linux/buffer_head.h | 12 ------------ include/linux/mm.h | 18 ++++++++++++++++++ 8 files changed, 31 insertions(+), 25 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 43775a6ca5054a..6eea0886b88553 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -6140,7 +6140,7 @@ vm_fault_t ext4_page_mkwrite(struct vm_fault *vmf) if (err == -ENOSPC && ext4_should_retry_alloc(inode->i_sb, &retries)) goto retry_alloc; out_ret: - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); out: filemap_invalidate_unlock_shared(mapping); sb_end_pagefault(inode->i_sb); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 093039dee99206..9b3871fb9bfc44 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -159,7 +159,7 @@ static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf) sb_end_pagefault(inode->i_sb); err: - return block_page_mkwrite_return(err); + return vmf_fs_error(err); } static const struct vm_operations_struct f2fs_file_vm_ops = { diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 1bf3c4453516f2..897ef62d6d77a7 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -432,7 +432,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); err = gfs2_glock_nq(&gh); if (err) { - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); goto out_uninit; } @@ -474,7 +474,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) err = gfs2_rindex_update(sdp); if (err) { - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); goto out_unlock; } @@ -482,12 +482,12 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) ap.target = data_blocks + ind_blocks; err = gfs2_quota_lock_check(ip, &ap); if (err) { - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); goto out_unlock; } err = gfs2_inplace_reserve(ip, &ap); if (err) { - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); goto out_quota_unlock; } @@ -500,7 +500,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) } err = gfs2_trans_begin(sdp, rblocks, 0); if (err) { - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); goto out_trans_fail; } @@ -508,7 +508,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) if (gfs2_is_stuffed(ip)) { err = gfs2_unstuff_dinode(ip); if (err) { - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); goto out_trans_end; } } @@ -524,7 +524,7 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) err = gfs2_allocate_page_backing(page, length); if (err) - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); out_page_locked: if (ret != VM_FAULT_LOCKED) @@ -558,7 +558,7 @@ static vm_fault_t gfs2_fault(struct vm_fault *vmf) gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &gh); err = gfs2_glock_nq(&gh); if (err) { - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); goto out_uninit; } ret = filemap_fault(vmf); diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index adb92cdb24b009..0607790827b48a 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -1286,7 +1286,7 @@ vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf, const struct iomap_ops *ops) return VM_FAULT_LOCKED; out_unlock: folio_unlock(folio); - return block_page_mkwrite_return(ret); + return vmf_fs_error(ret); } EXPORT_SYMBOL_GPL(iomap_page_mkwrite); diff --git a/fs/nilfs2/file.c b/fs/nilfs2/file.c index a9eb3487efb2c2..740ce26d1e7657 100644 --- a/fs/nilfs2/file.c +++ b/fs/nilfs2/file.c @@ -108,7 +108,7 @@ static vm_fault_t nilfs_page_mkwrite(struct vm_fault *vmf) wait_for_stable_page(page); out: sb_end_pagefault(inode->i_sb); - return block_page_mkwrite_return(ret); + return vmf_fs_error(ret); } static const struct vm_operations_struct nilfs_file_vm_ops = { diff --git a/fs/udf/file.c b/fs/udf/file.c index 243840dc83addf..c0e2080e639eec 100644 --- a/fs/udf/file.c +++ b/fs/udf/file.c @@ -67,7 +67,7 @@ static vm_fault_t udf_page_mkwrite(struct vm_fault *vmf) err = block_commit_write(page, 0, end); if (err < 0) { unlock_page(page); - ret = block_page_mkwrite_return(err); + ret = vmf_fs_error(err); goto out_unlock; } out_dirty: diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 6cb3e9af78c9ed..7002a9ff63a3da 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -291,18 +291,6 @@ int generic_cont_expand_simple(struct inode *inode, loff_t size); int block_commit_write(struct page *page, unsigned from, unsigned to); int block_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf, get_block_t get_block); -/* Convert errno to return value from ->page_mkwrite() call */ -static inline vm_fault_t block_page_mkwrite_return(int err) -{ - if (err == 0) - return VM_FAULT_LOCKED; - if (err == -EFAULT || err == -EAGAIN) - return VM_FAULT_NOPAGE; - if (err == -ENOMEM) - return VM_FAULT_OOM; - /* -ENOSPC, -EDQUOT, -EIO ... */ - return VM_FAULT_SIGBUS; -} sector_t generic_block_bmap(struct address_space *, sector_t, get_block_t *); int block_truncate_page(struct address_space *, loff_t, get_block_t *); diff --git a/include/linux/mm.h b/include/linux/mm.h index 2dd73e4f3d8e3a..75777eae1c9c26 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3386,6 +3386,24 @@ static inline vm_fault_t vmf_error(int err) return VM_FAULT_SIGBUS; } +/* + * Convert errno to return value for ->page_mkwrite() calls. + * + * This should eventually be merged with vmf_error() above, but will need a + * careful audit of all vmf_error() callers. + */ +static inline vm_fault_t vmf_fs_error(int err) +{ + if (err == 0) + return VM_FAULT_LOCKED; + if (err == -EFAULT || err == -EAGAIN) + return VM_FAULT_NOPAGE; + if (err == -ENOMEM) + return VM_FAULT_OOM; + /* -ENOSPC, -EDQUOT, -EIO ... */ + return VM_FAULT_SIGBUS; +} + struct page *follow_page(struct vm_area_struct *vma, unsigned long address, unsigned int foll_flags); From patchwork Thu Jul 20 14:04:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13320583 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 ABA9AEB64DD for ; Thu, 20 Jul 2023 14:06:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FF5828010F; Thu, 20 Jul 2023 10:06:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2AEF328004C; Thu, 20 Jul 2023 10:06:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 103DC28010F; Thu, 20 Jul 2023 10:06:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0276828004C for ; Thu, 20 Jul 2023 10:06:48 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C2601140167 for ; Thu, 20 Jul 2023 14:06:47 +0000 (UTC) X-FDA: 81032166054.03.830DBA9 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id 2C5322044F for ; Thu, 20 Jul 2023 14:05:06 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=d4IXxaa5; spf=none (imf03.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689861907; a=rsa-sha256; cv=none; b=UPHndSBTrFYVVCd5KAnLECiHxm8Hhgfhx7H/Izbgd82EcYCCTTiYPuoKB1VO46jMuXT9Sd 4XRpxUPW2M+qrXuTWV0h44B9F4aj9KLo/R5Q1neF6XaQuqnPXgeJBdf6IIyPHgyqGeajsH OF1UeWlJvLKWjA29YuMLkdUOk2N1ulI= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=d4IXxaa5; spf=none (imf03.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+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=1689861907; 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=yaOs2VrbaTQ5mw1fhRctemzRO8G1izk4pie8fEUG7Pg=; b=diExclkXUz0AWj9jepWqU//BY3UOKN2Is71hftzVasUEB3tuCuUuLuH+Ro9iU7IpqrS9Dk pY5ZO/Ko6kCfjuMzLDIxByuB+HdzYTL948Iye79CAGp2PArDNXniYEEXG6E3FQKNwtqeyj kPh4BTD7vaHfnKQaNc6O/droGw5tick= 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=yaOs2VrbaTQ5mw1fhRctemzRO8G1izk4pie8fEUG7Pg=; b=d4IXxaa5wwC5+QTPqwZACF6baC JRSFT/yUddFQ4e0UY/3unt4en7V/gUFgWW3XehEy7vbuPyeS1o5h6ibusSemRJ9GF6zjuH7dy3KS5 cUxDGvI9gRPpNA/LcUNteFDRq7AWl8O6tBbyq6UHpoKIoKKAWeU5FU1J6tK1QmZ3nLpHhj9EbKUta Si1NSYxlGTurFNu21XyAt5SbSzAa8rAXLvO854DUMthK8kWTNgK8tS6tCm44djlZm8Va+f5g9nMHF KJzeetajdRSWRG1iMdLh6awhN9EeRwIUTzrv+YB+RkP13LWl919K7HA+2sCYpxjFlqyAL+zYtTXnp l3ISmLyA==; Received: from [2001:4bb8:19a:298e:a587:c3ea:b692:5b8d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qMUH8-00BKq4-2T; Thu, 20 Jul 2023 14:05:03 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Darrick J. Wong" , Andrew Morton , Matthew Wilcox , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] block: open code __generic_file_write_iter for blkdev writes Date: Thu, 20 Jul 2023 16:04:49 +0200 Message-Id: <20230720140452.63817-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230720140452.63817-1-hch@lst.de> References: <20230720140452.63817-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: rspam08 X-Rspamd-Queue-Id: 2C5322044F X-Stat-Signature: sbrungi1nncs6a1a356ficmmpmtdd118 X-Rspam-User: X-HE-Tag: 1689861906-417469 X-HE-Meta: U2FsdGVkX1+022TWu+N/idcMsbYzS117+8mUK23Pzm3aqUv8cDWLauZ4fd4K2qy9w7+Qle4qnLq8ABRYl1Iop6T4TP/FYE032Py6n4XGELKvPqxmWUPadXWkRtuYpEhyQxMFKWC+gfDIietm0VG5wSm+i8xk+ZL1VhwvOGtyyw4XzPLg0gt3v7LFcpXUAuo0udmBfpJOr0wZUrDXI/b39D7lZ/NDjfjQ7X81TZDbbIMWXFf6DoSpalXCxbYoWYcnY5YrkDBP+SsfoXQyO275vKMbKNeo1Qhf3CB6PYMM7Kq1s9cI3LjJXhxVAoRowIfe03KBGq5sShI4wdw1PmUPxvpcSEd1S5VbTOeOg5u9uG6LbZDB3reLqYBFjnLUik0P55W3aLyQrmxDZPPhnZp0Lu0piaSJ9Z+0D2P7JSvMkS61ETIfIdc7y4amIz3fI4UN0AUsXlqfC3Ng0ddx8+HO0hN08s5Y5mgbZzjnuO+W/kK31MygPJh1/fWg9r17VpmLke/I72I95iE7uBPz8Sp5bv/qEptbJalrQi9tMm5CbxLGquc9j7BoczMtz8GPNW1B98ZazYz9tDA7QLwLQvEDc//uF3uHa+05dfPq5xCcY8dqu9iKmGU8HbYWSL9+nqoHG9kcvs/on8HmE5M3N20auk2icQSOJIiKSfNYXwC8wlC43mzGzzpR/lIEcytVLpILT6VvmSZ7ILQRtwMTjJ6iI2wb7JieAE0pp2MuBlW5h+aEBRNQrlBGCY5xodMndKo8Cex5coMhKQ9JnlT/SwW0QkLcNiO+ZqXLITuewDGefpmgw3u0viCGeL21GyyTxVEzlU+iF987zfz0J2sIh5pDaBPKxsNPJnqIB1jzXdRVgN4KWu7vvqf5lXNIN27a6yu2ny6lfWPVbfTNG8hJmzoDioEPTOm4zhgPECfWTJrVADOnmYjk+6PmDJ0ZsmzHoO4N3RrdbQDDliASoS2GlS+ wU+zdWiC jS3FJoSiYDjoa6g5BcDj/dzi+nqqG+o9PEr5hxc23y59o09qAv6USjTUrPvweRWoL7sOrcAkYqY5g5ng76nCkYij8XiQD7fC0ydaTUvR8kHVE+kmWXpE5pzwVECnshg1+Em7Qqmuz4ylLUdgui3zgi6Z4zB+KpAbPC+ib+Zd8rjFaTJpaEeEndxoySJcpqgVtqsZ3D34C27/jxd14yDMrUhmI7PwrvQYQp/skzFNLdBXaPyRP5HkaXyUOAGY+e+KU4HPOxdtotBq2iNDAM4gzJA6s7gikCj3pXk87J1qfnHIjZqqBizhGqxIY7z2dvf1G982hJgwjHEJ6YivoZL6hAnlVF0Gq8vRrQ1TEwWcmhYokHnlznMJs3FaBHjBduLCA5XksWxgGq1Y62MV80irFQ7kSHabr2sHCARDjpwOSpv6WUMC1czCIlVZG8RerOQYcetx0LzVLCZ5gCLDNUXPyflwWB+nDkaT1IZYVs7UD5WPXOWs= 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: Open code __generic_file_write_iter to remove the indirect call into ->direct_IO and to prepare using the iomap based write code. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Luis Chamberlain --- block/fops.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/block/fops.c b/block/fops.c index a286bf3325c5d8..eb599a173ef02d 100644 --- a/block/fops.c +++ b/block/fops.c @@ -533,6 +533,29 @@ static int blkdev_release(struct inode *inode, struct file *filp) return 0; } +static ssize_t +blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from) +{ + size_t count = iov_iter_count(from); + ssize_t written; + + written = kiocb_invalidate_pages(iocb, count); + if (written) { + if (written == -EBUSY) + return 0; + return written; + } + + written = blkdev_direct_IO(iocb, from); + if (written > 0) { + kiocb_invalidate_post_direct_write(iocb, count); + iocb->ki_pos += written; + } + if (written != -EIOCBQUEUED) + iov_iter_revert(from, count - written - iov_iter_count(from)); + return written; +} + /* * Write data to the block device. Only intended for the block device itself * and the raw driver which basically is a fake block device. @@ -542,7 +565,8 @@ static int blkdev_release(struct inode *inode, struct file *filp) */ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) { - struct block_device *bdev = I_BDEV(iocb->ki_filp->f_mapping->host); + struct file *file = iocb->ki_filp; + struct block_device *bdev = I_BDEV(file->f_mapping->host); struct inode *bd_inode = bdev->bd_inode; loff_t size = bdev_nr_bytes(bdev); size_t shorted = 0; @@ -569,7 +593,23 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) iov_iter_truncate(from, size); } - ret = __generic_file_write_iter(iocb, from); + ret = file_remove_privs(file); + if (ret) + return ret; + + ret = file_update_time(file); + if (ret) + return ret; + + if (iocb->ki_flags & IOCB_DIRECT) { + ret = blkdev_direct_write(iocb, from); + if (ret >= 0 && iov_iter_count(from)) + ret = direct_write_fallback(iocb, from, ret, + generic_perform_write(iocb, from)); + } else { + ret = generic_perform_write(iocb, from); + } + if (ret > 0) ret = generic_write_sync(iocb, ret); iov_iter_reexpand(from, iov_iter_count(from) + shorted); From patchwork Thu Jul 20 14:04:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13320587 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 E4A35EB64DD for ; Thu, 20 Jul 2023 14:08:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79285280115; Thu, 20 Jul 2023 10:08:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 71B2728004C; Thu, 20 Jul 2023 10:08:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5BB93280115; Thu, 20 Jul 2023 10:08:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 4359928004C for ; Thu, 20 Jul 2023 10:08:50 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E2129120170 for ; Thu, 20 Jul 2023 14:08:49 +0000 (UTC) X-FDA: 81032171178.12.25898DC Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf15.hostedemail.com (Postfix) with ESMTP id D0D1FA047A for ; Thu, 20 Jul 2023 14:05:09 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=OwL7uhRk; spf=none (imf15.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+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=1689861909; 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=2edPrdL7m4BTLQgL/NuD1QkLdVOYHBfaZFGCvDQFQfg=; b=qYH57WVDP+7R0ZDop/sFY1RAY4mkVBh64nlkCfXkP8qloX4XdbjdCTJO/SgdGh5CctPAGI WZ/kUsVoN5VokPWzp3cuI0T5XptP3zX2DhBU0WSr5dtxVfzVrn/N+eBeI1oeGnxUMuQ/0O N/j7exeN6KqV1v6CUkZBsEB4YEJlmpI= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=OwL7uhRk; spf=none (imf15.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689861909; a=rsa-sha256; cv=none; b=7WxSDMuTyxSDN567tjyL1TJ97mdF0haOufHHN0mOwhnbuoWSTwzCiE1j6hL1TsOMzT0tKp 62pnmQjXYNMqyqZ5eeKSEm1+nXD/5msJFpfZ8VTuh2b28qPIGPF0rt7NwA7LdQu2XDh8Ft STVzEzNuKI/Q2bYt3My3YYK+jegRad4= 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=2edPrdL7m4BTLQgL/NuD1QkLdVOYHBfaZFGCvDQFQfg=; b=OwL7uhRkFeTFS6ZvjxdAWM3y1x RHsM4c1rRHpuWx7voqK4KAG2bGhvjTGr8Kt7Uw1rLav9sqvlOf+smv90NNU1BrwvpWhNuzQEPjJim SL6mMmrfLx/ZjL8JuHH7h8vFLzW8boQBAXQmwgjBuwOTGNhR5aOLTLtsUa/dG5QIZMfBIrNwGy9dF QtzTQ67Mn651iBrXmMGTcW6qHGY4b0TpdiUa+OZC5AyyVF0OxgqJW62fvy0q1llGNGZ+hwXJGY72W ghbu2Eg8o6DvtLDGj9CTT91ZgZrV9Db4wlhSdYAtBckdOPBs5857BWr6fo49nE/l7j9rfnWWOo4N/ ef2tG8MA==; Received: from [2001:4bb8:19a:298e:a587:c3ea:b692:5b8d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qMUHB-00BKsX-1J; Thu, 20 Jul 2023 14:05:05 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Darrick J. Wong" , Andrew Morton , Matthew Wilcox , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] block: stop setting ->direct_IO Date: Thu, 20 Jul 2023 16:04:50 +0200 Message-Id: <20230720140452.63817-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230720140452.63817-1-hch@lst.de> References: <20230720140452.63817-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: D0D1FA047A X-Rspam-User: X-Stat-Signature: ztiifsbg35bqrh5t46rk75sgiof8kbtt X-Rspamd-Server: rspam01 X-HE-Tag: 1689861909-499823 X-HE-Meta: U2FsdGVkX1/z8jGFDSL9Z7d3YdvoYWwc8EDaeb32qF/1+UWh/Wzk/wBrWBv3m89njgEjurCCqJDPlFQ/ksOz4KuKuhvk2A/o4+9eGIJVoznffcocR1S/8Ew9QScwNyF4khg1+53vJTfq4YWMEJ1mBl0GwtNSFpWpQin+IXM+DitSWvsZ6yyoNw3KGxE/ceSvjpAiWR6O4mQ4LdPSIhf4/W2Qf/f3diFpg1wBsRGijBfUGjty5am1vBh4Kq4Wtae7IlBHBMNwq6i7XpHKN17whZnv1oYsXC3eRig67pwy86iJElZk0ETx0QfG1Ghe/N5eixcb3hHKcsIad7eWChnWj8ug/n3q/9WRhuWeIz0Jbla4VxVoyrJEjtsIz/4LvWKfSCqvlT4nWkzBRveOe9aVqbXV8mD+Eub9NESHR+aDrmT2US+XApxUzTwwFOeT0gv5q/ZaLpTjHEWRjCccq4Odcs02ITTp2/sgMooDduVyOTnK9OjTYy9YIHby8GYYw1adEtOqYEFL3VsG6srgFV9Ib3S1pMLULrOOdJys8HpixkBmwgWRX7mB8HiL5u4z60Fdh5Fs5kJX3MFeFUQ4nM4gfyO/nRK4GGcKCI3rco97E8D71Gm+2ip9mR0M/9fnjPEotfDtRbMyBYZHyxAcYfdMXb0UCAKOrrA4404FgSMYFV7+MJwOAEGBvH7rU0p2c3twge4VnCdx2fFLGlmTUsQR/efFpfWNDsR6KnrEjLQxgW6VvFNbTmW87qxr3GcZYiU5K3gdlNOT3pkGP92uXVeNtTy1JFTHr44sP9kUCQKjS08++T0OyN1CfvJe2wUb6EiqWXLUk7CZ0/8ONmubi839D5CYIrl8ZgHs4Db3jRONnoM++bV6TaWiBP1ocDf/RUm5zB3Bvlyum2aK+Ifc5FEUfSvDKZ5jPISbgG9mrQ55iZahX89M5e0hd7N1/IYs4l+jchjVgcsV1f3V8gJMrzk wGzpc1gl fhlb7bAP9lK5NPkdoxFE1Ky5MqU3LEgcXdFGR7Jv7UjwdBqWEG6yKMqjkM0reHgM0HvXiOYHxSbFE+7Evhmrh721bfHlo5i4kqDMUyhXQUxjJZp4fG5vNYhJmAjk4GZyK8q2pmbs7BLVHpxCmGWwnk5korSzKKjtp0Be8csuPs/oozVn+eB10YAbhhePSI4DvITTIu2xuFw6ry6UNH4m4oru5JHfXy7VZB9ysWpWUnxV0M7vvGly+ogDwHKkq4jL/nv2b+V/nkojAhOyH7gCXGqI7Sj3KTYekQiUQkHbCVfxUvwKQ8/VxATmz2I0OyiXhdZarOB7z71wBryfvd9zfFjAPSbh3kUc4sRw0nOiLL3ddetEdswqtKV1Zu83lrM0nvF+vK+oi1B11PFktn1PobOzv41cDzRfLB1GTaY+ZVRTJr2LdYdvb89zW+bCgFC4cPP/gshZg95hPVgI= 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: Direct I/O on block devices now nevers goes through aops->direct_IO. Stop setting it and set the FMODE_CAN_ODIRECT in ->open instead. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn Reviewed-by: Hannes Reinecke Reviewed-by: Luis Chamberlain --- block/fops.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/fops.c b/block/fops.c index eb599a173ef02d..0c37c35003c3b7 100644 --- a/block/fops.c +++ b/block/fops.c @@ -428,7 +428,6 @@ const struct address_space_operations def_blk_aops = { .writepage = blkdev_writepage, .write_begin = blkdev_write_begin, .write_end = blkdev_write_end, - .direct_IO = blkdev_direct_IO, .migrate_folio = buffer_migrate_folio_norefs, .is_dirty_writeback = buffer_check_dirty_writeback, }; @@ -505,7 +504,7 @@ static int blkdev_open(struct inode *inode, struct file *filp) * during an unstable branch. */ filp->f_flags |= O_LARGEFILE; - filp->f_mode |= FMODE_BUF_RASYNC; + filp->f_mode |= FMODE_BUF_RASYNC | FMODE_CAN_ODIRECT; /* * Use the file private data to store the holder for exclusive openes. From patchwork Thu Jul 20 14:04:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13320586 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 D1524EB64DC for ; Thu, 20 Jul 2023 14:08:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 547A6280113; Thu, 20 Jul 2023 10:08:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D13128004C; Thu, 20 Jul 2023 10:08:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3722F280113; Thu, 20 Jul 2023 10:08:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 240D528004C for ; Thu, 20 Jul 2023 10:08:30 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id DEE6D140125 for ; Thu, 20 Jul 2023 14:08:29 +0000 (UTC) X-FDA: 81032170338.08.BB4D6DF Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf03.hostedemail.com (Postfix) with ESMTP id 567162051D for ; Thu, 20 Jul 2023 14:05:11 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qfgHEX10; dmarc=none; spf=none (imf03.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+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=1689861913; 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=FviJ2yeCGqBqXQbTzRBmfPSUTBs1/XNV2kCvgMLKD4c=; b=wZ2wuaf0yui6eU8JweEOBkDEikaQaR9PDQu6TyAGj3y4q3scyhmrfrh9hlPDuMSmJqfZW7 Jpul/N+grxrBs8PNPsmcWBSdk1X5A6e/vjLyFHHgKUtyIchCxaa+jQqwZxQWE5aDi7JC53 hN3XAfPw9v+vteEeMoA9boSd90j70+0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qfgHEX10; dmarc=none; spf=none (imf03.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689861913; a=rsa-sha256; cv=none; b=e2fvxYfhgauTz7hGBMgGYsSh5dRo0nsb9U1+tA1kqnGb4umwm07OS8mAdr6lBLYKdWN+eN 02RofLDczXFTqtbKhnkyv3sAOcPEZglmQHwNCTXnKO8GcY1uYejvQhvrcXT8b7MZ5IOSS9 f79Vy/+T6gzE0nVqlWdgKN5iJCECCWU= 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=FviJ2yeCGqBqXQbTzRBmfPSUTBs1/XNV2kCvgMLKD4c=; b=qfgHEX10lEj4flWctKOvhcyM0M cNFGZnU1gk4ET3nG6rquI9Tpm3hN+yb//YIrG8r1fEhPAwbMqW6LP6snaOtTo/PRc0jluPzT0O5ER hXHfYA1w/l2zF5BquPeGQsthe8FOQSfH8+blJHEQw/6Pc8KYpOY6eAwDm4b4JGyQl2cN0ivmFTl6M 0yBTKNhEK+akJ92/gXbUCDB/PU/GepysHzFcaL3q9vyJarhfjKwcqC+Sn//OJkf4oSNm0jr7cSBmr fMAWGfE0GT6ET76ehq7mLgkuf0FeEEwA1C1k11lSvMgRX94FkvQpfD6jIoDPtIOm8ALLlj5djIHrJ eM5euuXA==; Received: from [2001:4bb8:19a:298e:a587:c3ea:b692:5b8d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qMUHE-00BKuF-0C; Thu, 20 Jul 2023 14:05:08 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Darrick J. Wong" , Andrew Morton , Matthew Wilcox , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] block: use iomap for writes to block devices Date: Thu, 20 Jul 2023 16:04:51 +0200 Message-Id: <20230720140452.63817-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230720140452.63817-1-hch@lst.de> References: <20230720140452.63817-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: 567162051D X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: inni14gzyj4jxogfmx9km1dtc9qjsqj8 X-HE-Tag: 1689861911-680825 X-HE-Meta: U2FsdGVkX1/6x5gcBveC9nu9r9ewMmtC2CrZfhnNeh/Ca9Drnhkwi0hFQ7UF8fHgGsgN08hsuDOfetLhxWY0yfHSmtY9eECQKhYCADTED/M68DeHVrZLoLhXVA1jZpz29w17ra9zONnNvqpvGhAeYwrrIbusjU9oXN2XQX1Nmo2lDmreccVvIlmDqqonkFr83V+AW98dJ2WMgbIdR738/eoDMDRmcC8PTRYjlWbL2noNCZNQss1O3e8xccpNvxq+3KCQiB2xtP90OGz5GeYQ51c/f1k2LojtfJoJhk03LvRyxjVAXmIRwZc5koO3SisjxED7rsg+wsLznZVEicAIuUj9tqxZmDJlu1/eQjm8m6wBlNJaenl4WyGAJfobH1o3WwdBcsvHMQ7hN97tm8v9AjZtJNYgPg5cuOkwjhGmITuSD7BlSfbc6Nam41ndMgroN23eyoUD1zPZ+vevWI5TL+zvxvtjtmT1SSYNthzIl5TC6/8EtXYVwZ7K3LOfgUcLxCNEEazDl46S0dFMaTT5ehkF7U4k2IxTpsjtb97C9mntaObtALdrUQuKHuY8HZcuqRnT+Vb9J8LEcflSq4AIcMFQzg8HDo0LAaPrY5L9MnzxPvwsL/aZnEz0drFHM1KGFLO5kmrojUrQq9u0mISuzepxMjlgd3TBnaInkToY9HposhRFikklMNyxw42MvOAhleRlFwl+Rn3ZkJfDvOW74XB9vUeXDfbxB/dHijVBn1LuSEHasi0eyXRb419ZR2XCbJJdCMN9PGc1hvPKPvwAEz+gJch3pyDfTGhdAj0Y1pK040Pk5T8oBwxaO0PWnd0y1iKuvDe8bt9I/43YDN4X59r8ZvuHzqUNjFaPFB0u1nq2hKOybM0E97U7jjOpFbF5hOoo6QrVM195gNPeQPG4PWiQfL4zCmv9kYNJl6Dbub/pYeHq7ugtwm11FVc6aFzUlfQ+sWOFO4N192J1RrO NSHA+Ivh +ES87i9CU1ugeSVGo/6pI4gLX53tNm3+B2rG7qGd0FL7KXVwediNuDy4KEvd6bvuKlg7Y8YJkoLCOnDyGqAgREKPRyjYyaILCkS2fhpgiPbCQdAjg4D2qrUlNX1IdB196EzZ3YAUWiNcqtx9p+k50AaEMwfZ6TA8qus/9tMKlNCWu+tFhslJ+SnJwcA1aADFLxyX8fl4awmZCMBoz5dVHHZzqRaWM/JLmarfVutD2h8F1RkTqrewyKiFFPTRa/3LVnWhb49tJkOYF0ZApn0+xz0nJFEdt/QvjTCQiL2kx06F+6bH73Nd3/vGwalJvl293FAvsk40gPASWo0njuew+UZTy9GzHo6lxq72Dvyl/C0aV/NRk4o8aTY6uqTxr5wKE3iDYmLUAOecLhawocnWv1PX7LKY7JXKiQ0ro 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 iomap in buffer_head compat mode to write to block devices. Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Reviewed-by: Luis Chamberlain Reviewed-by: Pankaj Raghav --- block/Kconfig | 1 + block/fops.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/block/Kconfig b/block/Kconfig index 86122e459fe046..1a13ef0b1ca10c 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -5,6 +5,7 @@ menuconfig BLOCK bool "Enable the block layer" if EXPERT default y + select FS_IOMAP select SBITMAP help Provide block layer support for the kernel. diff --git a/block/fops.c b/block/fops.c index 0c37c35003c3b7..31d356c83f27a3 100644 --- a/block/fops.c +++ b/block/fops.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include "blk.h" @@ -386,6 +387,27 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) return __blkdev_direct_IO(iocb, iter, bio_max_segs(nr_pages)); } +static int blkdev_iomap_begin(struct inode *inode, loff_t offset, loff_t length, + unsigned int flags, struct iomap *iomap, struct iomap *srcmap) +{ + struct block_device *bdev = I_BDEV(inode); + loff_t isize = i_size_read(inode); + + iomap->bdev = bdev; + iomap->offset = ALIGN_DOWN(offset, bdev_logical_block_size(bdev)); + if (WARN_ON_ONCE(iomap->offset >= isize)) + return -EIO; + iomap->type = IOMAP_MAPPED; + iomap->addr = iomap->offset; + iomap->length = isize - iomap->offset; + iomap->flags |= IOMAP_F_BUFFER_HEAD; + return 0; +} + +static const struct iomap_ops blkdev_iomap_ops = { + .iomap_begin = blkdev_iomap_begin, +}; + static int blkdev_writepage(struct page *page, struct writeback_control *wbc) { return block_write_full_page(page, blkdev_get_block, wbc); @@ -555,6 +577,11 @@ blkdev_direct_write(struct kiocb *iocb, struct iov_iter *from) return written; } +static ssize_t blkdev_buffered_write(struct kiocb *iocb, struct iov_iter *from) +{ + return iomap_file_buffered_write(iocb, from, &blkdev_iomap_ops); +} + /* * Write data to the block device. Only intended for the block device itself * and the raw driver which basically is a fake block device. @@ -604,9 +631,9 @@ static ssize_t blkdev_write_iter(struct kiocb *iocb, struct iov_iter *from) ret = blkdev_direct_write(iocb, from); if (ret >= 0 && iov_iter_count(from)) ret = direct_write_fallback(iocb, from, ret, - generic_perform_write(iocb, from)); + blkdev_buffered_write(iocb, from)); } else { - ret = generic_perform_write(iocb, from); + ret = blkdev_buffered_write(iocb, from); } if (ret > 0) From patchwork Thu Jul 20 14:04:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13320585 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 143F7EB64DC for ; Thu, 20 Jul 2023 14:08:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 743C3280112; Thu, 20 Jul 2023 10:08:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6CD0528004C; Thu, 20 Jul 2023 10:08:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 51FAE280112; Thu, 20 Jul 2023 10:08:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 3B0ED28004C for ; Thu, 20 Jul 2023 10:08:00 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D0EA440181 for ; Thu, 20 Jul 2023 14:07:59 +0000 (UTC) X-FDA: 81032169078.29.2DA796D Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf11.hostedemail.com (Postfix) with ESMTP id 92EB0402A4 for ; Thu, 20 Jul 2023 14:05:14 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=H7gtH6oG; spf=none (imf11.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+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=1689861915; 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=byV/1AuOl1uJuOVSL+9oT305K9w4rbGaZjYZW4c/GeE=; b=fYvP0qnPjJj+jXHr8KuP0NB4MHPghMKP4ZJJEdewwgKdUbq21U5VndiNav9AaZ6wkrM/bp 8Rulk5JOYY0a5ElV/lYWdCglSTYCRcIiI37Z3QYIKwXp3LehXathICvu0ZsskQ2O8s7SCT OqAM60KZiXp45UXk4brzi2XMnkC6wAg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1689861915; a=rsa-sha256; cv=none; b=BgdNDY36N/445wWnqQGhm2lkW8ugGPsn4gzBF9Qo11be2UaH08iigbnJZ8DGxnO26H09Mz UbY++Yri2Xyf3t6Gz50j0Q9nsk6RMpE5ynWEW69g0jb/v8JCgQKr1bIVlqAb1A6VYYsMRU TtsgsMfBDOTCoR5Q6YLEhgTq59SVBWI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=H7gtH6oG; spf=none (imf11.hostedemail.com: domain of BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+ae7cc45e83adbe90d207+7270+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none 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=byV/1AuOl1uJuOVSL+9oT305K9w4rbGaZjYZW4c/GeE=; b=H7gtH6oG7I22jrDlTgunFVzSWr qaslDGDwu3PkGzv0Xk6RlX8BlHYYLxik6abgm/AJWIcAPB53EUdmsLjPLPFMUDELPDZt6oJ13W9tC xJzNa8qCjL1gZWH1ax/8GKj/e2/DyOTVmPaePdZu4A2NSAZBzjJ374kTgnxTSR7t6TQSaPgoAvVtT crYla/Q0HOeggQZ+RVubRfu0PCrge4aoXfH0hrhWwBhDa0xtyEtwMHnvIlxpbCkhqVkDtYABoZSOE gs9EEjdLFADOFX6IGfsf6tDT7xstZuKXJTsVDNT4Thmo6eYjQDJpDVIV58QlAMvTOMcWvVzwcYfda AJP7L0XA==; Received: from [2001:4bb8:19a:298e:a587:c3ea:b692:5b8d] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qMUHG-00BKvT-2B; Thu, 20 Jul 2023 14:05:11 +0000 From: Christoph Hellwig To: Jens Axboe Cc: "Darrick J. Wong" , Andrew Morton , Matthew Wilcox , Christian Brauner , linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] fs: add CONFIG_BUFFER_HEAD Date: Thu, 20 Jul 2023 16:04:52 +0200 Message-Id: <20230720140452.63817-7-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230720140452.63817-1-hch@lst.de> References: <20230720140452.63817-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: 92EB0402A4 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: g6bryxksar47nwwut1uahr575iicntc5 X-HE-Tag: 1689861914-44338 X-HE-Meta: U2FsdGVkX19fhoz253T02z9v1lPTxfysKZAtYnq9a12brA+Y8fu36tmADULa54p8mdm6SWXEGdlS+yRLasYrKQDNoPh6rLOQdtyvFjzJlXebX+kvYJ2Bq0fNtmwTejV1Hoqsoe7Uz/9CTzZmyDtEDlVYb97KgXf86v+oGIpC5rGh5JZvX1fCBc4zkgelZidI/rFa/28kJBGU6faeTj+jjzUYFbH9nuyYv7loxQRM0+8IXC3+xGjHfMug9hSWP5ydfYdQ5vZlAuj69I+lXzAkIRe0CjcvMyZJcXP/mIZRLIwDUjcxFe+oE/3jbZmTlpABTLj1dWvKvSzG2TVZtUCqAKk2RETlnMPdLx9Qg/u14mQzWjyj97m9bHziyNGlKAkM4lrLexs2w5x9DlKbo0vkNbX9jXxH2SAJci9R9KTD5dPIbcMB0WfOwZNGmz6xv5+MGCOzZACsJtZ3sCXaR07O8Fuz2IcWOjBYVo6T4prKNGJnOvWoVLq/ID+BDkKXbxAZAgXDJ/DtzXw+jDj94yNtOohoYLqxfqU5vjAqaRbAxtFmsR8JKASnELmeFXdkS/Sq+qrDMR4Qv1WP6wgBZlw4eD2v8gFc/k1ixeTbcr6j06nuLfxLShYK/Yk2Sm4vFYzJ+/LJTqlzYBrP5crVAV6okE4IO6zzDI/MtWu0aXcSI+rK5Zye/jGJQYNoFiRkZqwWmGqToxILsDIwJIwIlIKKuWCt4Ce0mLgd8JoVqnMiUzr3hNsILZLjLpD8QZ1IMNg5nKM7UuZRV16L2gdpHsRQ9ov9RmKYYmRSEXteYVvsN4eZWWSvbeXnO6gdXbE7uYuL4H1/SsTOB3Jh3NZU7XguSfwXHErmg7LI/mNujl2ZTQ15jiPiJiCQsbyJFw+SuyuSsSUP40RSc2Tfd3o2+UuzLuIF5RyTCzhpoGpehllZY/R6vvyReCpxFDQj2U9NCGe2iXIAvUPGnxrhCSkCzXz ib/9fXz0 vM0Nf6lPtT3lnuiU/hsQl9sjTKsK1PfObvDPEsbkB/xdRJda5UG0q3HijDatEP5oBkHRWcXnxBasJGx0IPhMaBlWzJerFe0o5oAf9L2QN7uMB9Jj/XOGvJc5rxuTnKaWnC0UDsxE0kd7o1mLJk52QlmrWQ4j63BAyDC9osVcLJKWWB6x0pCPl8L708DI+HpFz3X70RbA13Dt1pqxqryhEF43Nxla91TbLV6DGYFif1gA5hvjt2C2fn4qJdENZd/YYt5x5dQeCLluEFPTW5pMkSTlLzpsyH++TSes9KTbpAXxWmvgGYTxInhJwnM7weRPzxrrsghVm4lx7zqUEQ3oBvl9gwIiW8T5dpkKLMoRKSFltdviBby+f6BKev1cHKrfxrmZ9cURv0CSawtxkoSTBziJ/UA3yg6VSNUuUvMUL3cPwIbNsEerSTutlsVACzNqDKAGQdWy87TkmPO4OmshgwBJO5GktAmdR1Mx9jPl1Il5HacbmLfvgotylJA== 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: Add a new config option that controls building the buffer_head code, and select it from all file systems and stacking drivers that need it. For the block device nodes and alternative iomap based buffered I/O path is provided when buffer_head support is not enabled, and iomap needs a little tweak to be able to compile out the buffer_head based code path. Otherwise this is just Kconfig and ifdef changes. Signed-off-by: Christoph Hellwig Reviewed-by: Luis Chamberlain --- block/fops.c | 71 +++++++++++++++++++++++++++++++----- drivers/md/Kconfig | 1 + fs/Kconfig | 4 ++ fs/Makefile | 2 +- fs/adfs/Kconfig | 1 + fs/affs/Kconfig | 1 + fs/befs/Kconfig | 1 + fs/bfs/Kconfig | 1 + fs/efs/Kconfig | 1 + fs/exfat/Kconfig | 1 + fs/ext2/Kconfig | 1 + fs/ext4/Kconfig | 1 + fs/f2fs/Kconfig | 1 + fs/fat/Kconfig | 1 + fs/freevxfs/Kconfig | 1 + fs/gfs2/Kconfig | 1 + fs/hfs/Kconfig | 1 + fs/hfsplus/Kconfig | 1 + fs/hpfs/Kconfig | 1 + fs/iomap/buffered-io.c | 12 ++++-- fs/isofs/Kconfig | 1 + fs/jfs/Kconfig | 1 + fs/minix/Kconfig | 1 + fs/nilfs2/Kconfig | 1 + fs/ntfs/Kconfig | 1 + fs/ntfs3/Kconfig | 1 + fs/ocfs2/Kconfig | 1 + fs/omfs/Kconfig | 1 + fs/qnx4/Kconfig | 1 + fs/qnx6/Kconfig | 1 + fs/reiserfs/Kconfig | 1 + fs/sysv/Kconfig | 1 + fs/udf/Kconfig | 1 + fs/ufs/Kconfig | 1 + include/linux/buffer_head.h | 32 ++++++++-------- include/trace/events/block.h | 2 + mm/migrate.c | 4 +- 37 files changed, 125 insertions(+), 32 deletions(-) diff --git a/block/fops.c b/block/fops.c index 31d356c83f27a3..57909430deb150 100644 --- a/block/fops.c +++ b/block/fops.c @@ -24,15 +24,6 @@ static inline struct inode *bdev_file_inode(struct file *file) return file->f_mapping->host; } -static int blkdev_get_block(struct inode *inode, sector_t iblock, - struct buffer_head *bh, int create) -{ - bh->b_bdev = I_BDEV(inode); - bh->b_blocknr = iblock; - set_buffer_mapped(bh); - return 0; -} - static blk_opf_t dio_bio_write_op(struct kiocb *iocb) { blk_opf_t opf = REQ_OP_WRITE | REQ_SYNC | REQ_IDLE; @@ -400,7 +391,8 @@ static int blkdev_iomap_begin(struct inode *inode, loff_t offset, loff_t length, iomap->type = IOMAP_MAPPED; iomap->addr = iomap->offset; iomap->length = isize - iomap->offset; - iomap->flags |= IOMAP_F_BUFFER_HEAD; + if (IS_ENABLED(CONFIG_BUFFER_HEAD)) + iomap->flags |= IOMAP_F_BUFFER_HEAD; return 0; } @@ -408,6 +400,16 @@ static const struct iomap_ops blkdev_iomap_ops = { .iomap_begin = blkdev_iomap_begin, }; +#ifdef CONFIG_BUFFER_HEAD +static int blkdev_get_block(struct inode *inode, sector_t iblock, + struct buffer_head *bh, int create) +{ + bh->b_bdev = I_BDEV(inode); + bh->b_blocknr = iblock; + set_buffer_mapped(bh); + return 0; +} + static int blkdev_writepage(struct page *page, struct writeback_control *wbc) { return block_write_full_page(page, blkdev_get_block, wbc); @@ -453,6 +455,55 @@ const struct address_space_operations def_blk_aops = { .migrate_folio = buffer_migrate_folio_norefs, .is_dirty_writeback = buffer_check_dirty_writeback, }; +#else /* CONFIG_BUFFER_HEAD */ +static int blkdev_read_folio(struct file *file, struct folio *folio) +{ + return iomap_read_folio(folio, &blkdev_iomap_ops); +} + +static void blkdev_readahead(struct readahead_control *rac) +{ + iomap_readahead(rac, &blkdev_iomap_ops); +} + +static int blkdev_map_blocks(struct iomap_writepage_ctx *wpc, + struct inode *inode, loff_t offset) +{ + loff_t isize = i_size_read(inode); + + if (WARN_ON_ONCE(offset >= isize)) + return -EIO; + if (offset >= wpc->iomap.offset && + offset < wpc->iomap.offset + wpc->iomap.length) + return 0; + return blkdev_iomap_begin(inode, offset, isize - offset, + IOMAP_WRITE, &wpc->iomap, NULL); +} + +static const struct iomap_writeback_ops blkdev_writeback_ops = { + .map_blocks = blkdev_map_blocks, +}; + +static int blkdev_writepages(struct address_space *mapping, + struct writeback_control *wbc) +{ + struct iomap_writepage_ctx wpc = { }; + + return iomap_writepages(mapping, wbc, &wpc, &blkdev_writeback_ops); +} + +const struct address_space_operations def_blk_aops = { + .dirty_folio = filemap_dirty_folio, + .release_folio = iomap_release_folio, + .invalidate_folio = iomap_invalidate_folio, + .read_folio = blkdev_read_folio, + .readahead = blkdev_readahead, + .writepages = blkdev_writepages, + .is_partially_uptodate = iomap_is_partially_uptodate, + .error_remove_page = generic_error_remove_page, + .migrate_folio = filemap_migrate_folio, +}; +#endif /* CONFIG_BUFFER_HEAD */ /* * for a block special file file_inode(file)->i_size is zero diff --git a/drivers/md/Kconfig b/drivers/md/Kconfig index b0a22e99bade37..9ee18013b1f2ab 100644 --- a/drivers/md/Kconfig +++ b/drivers/md/Kconfig @@ -15,6 +15,7 @@ if MD config BLK_DEV_MD tristate "RAID support" select BLOCK_HOLDER_DEPRECATED if SYSFS + select BUFFER_HEAD # BLOCK_LEGACY_AUTOLOAD requirement should be removed # after relevant mdadm enhancements - to make "names=yes" # the default - are widely available. diff --git a/fs/Kconfig b/fs/Kconfig index 18d034ec79539f..e8b17c81b83a8e 100644 --- a/fs/Kconfig +++ b/fs/Kconfig @@ -18,8 +18,12 @@ config VALIDATE_FS_PARSER config FS_IOMAP bool +config BUFFER_HEAD + bool + # old blockdev_direct_IO implementation. Use iomap for new code instead config LEGACY_DIRECT_IO + depends on BUFFER_HEAD bool if BLOCK diff --git a/fs/Makefile b/fs/Makefile index e513aaee0603a0..f9541f40be4e08 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -17,7 +17,7 @@ obj-y := open.o read_write.o file_table.o super.o \ fs_types.o fs_context.o fs_parser.o fsopen.o init.o \ kernel_read_file.o mnt_idmapping.o remap_range.o -obj-$(CONFIG_BLOCK) += buffer.o mpage.o +obj-$(CONFIG_BUFFER_HEAD) += buffer.o mpage.o obj-$(CONFIG_PROC_FS) += proc_namespace.o obj-$(CONFIG_LEGACY_DIRECT_IO) += direct-io.o obj-y += notify/ diff --git a/fs/adfs/Kconfig b/fs/adfs/Kconfig index 44738fed66251f..1b97058f0c4a92 100644 --- a/fs/adfs/Kconfig +++ b/fs/adfs/Kconfig @@ -2,6 +2,7 @@ config ADFS_FS tristate "ADFS file system support" depends on BLOCK + select BUFFER_HEAD help The Acorn Disc Filing System is the standard file system of the RiscOS operating system which runs on Acorn's ARM-based Risc PC diff --git a/fs/affs/Kconfig b/fs/affs/Kconfig index 962b86374e1c15..1ae432d266c32f 100644 --- a/fs/affs/Kconfig +++ b/fs/affs/Kconfig @@ -2,6 +2,7 @@ config AFFS_FS tristate "Amiga FFS file system support" depends on BLOCK + select BUFFER_HEAD select LEGACY_DIRECT_IO help The Fast File System (FFS) is the common file system used on hard diff --git a/fs/befs/Kconfig b/fs/befs/Kconfig index 9550b6462b8147..5fcfc4024ffe6f 100644 --- a/fs/befs/Kconfig +++ b/fs/befs/Kconfig @@ -2,6 +2,7 @@ config BEFS_FS tristate "BeOS file system (BeFS) support (read only)" depends on BLOCK + select BUFFER_HEAD select NLS help The BeOS File System (BeFS) is the native file system of Be, Inc's diff --git a/fs/bfs/Kconfig b/fs/bfs/Kconfig index 3a757805b58568..8e7ef866b62a62 100644 --- a/fs/bfs/Kconfig +++ b/fs/bfs/Kconfig @@ -2,6 +2,7 @@ config BFS_FS tristate "BFS file system support" depends on BLOCK + select BUFFER_HEAD help Boot File System (BFS) is a file system used under SCO UnixWare to allow the bootloader access to the kernel image and other important diff --git a/fs/efs/Kconfig b/fs/efs/Kconfig index 2df1bac8b375b1..0833e533df9d53 100644 --- a/fs/efs/Kconfig +++ b/fs/efs/Kconfig @@ -2,6 +2,7 @@ config EFS_FS tristate "EFS file system support (read only)" depends on BLOCK + select BUFFER_HEAD help EFS is an older file system used for non-ISO9660 CD-ROMs and hard disk partitions by SGI's IRIX operating system (IRIX 6.0 and newer diff --git a/fs/exfat/Kconfig b/fs/exfat/Kconfig index 147edeb044691d..cbeca8e44d9b38 100644 --- a/fs/exfat/Kconfig +++ b/fs/exfat/Kconfig @@ -2,6 +2,7 @@ config EXFAT_FS tristate "exFAT filesystem support" + select BUFFER_HEAD select NLS select LEGACY_DIRECT_IO help diff --git a/fs/ext2/Kconfig b/fs/ext2/Kconfig index 77393fda99af09..74d98965902e16 100644 --- a/fs/ext2/Kconfig +++ b/fs/ext2/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config EXT2_FS tristate "Second extended fs support" + select BUFFER_HEAD select FS_IOMAP select LEGACY_DIRECT_IO help diff --git a/fs/ext4/Kconfig b/fs/ext4/Kconfig index 86699c8cab281c..e20d59221fc05b 100644 --- a/fs/ext4/Kconfig +++ b/fs/ext4/Kconfig @@ -28,6 +28,7 @@ config EXT3_FS_SECURITY config EXT4_FS tristate "The Extended 4 (ext4) filesystem" + select BUFFER_HEAD select JBD2 select CRC16 select CRYPTO diff --git a/fs/f2fs/Kconfig b/fs/f2fs/Kconfig index 03ef087537c7c4..68a1e23e1557c7 100644 --- a/fs/f2fs/Kconfig +++ b/fs/f2fs/Kconfig @@ -2,6 +2,7 @@ config F2FS_FS tristate "F2FS filesystem support" depends on BLOCK + select BUFFER_HEAD select NLS select CRYPTO select CRYPTO_CRC32 diff --git a/fs/fat/Kconfig b/fs/fat/Kconfig index afe83b4e717280..25fae1c83725bc 100644 --- a/fs/fat/Kconfig +++ b/fs/fat/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config FAT_FS tristate + select BUFFER_HEAD select NLS select LEGACY_DIRECT_IO help diff --git a/fs/freevxfs/Kconfig b/fs/freevxfs/Kconfig index 0e2fc08f7de492..912107ebea6f40 100644 --- a/fs/freevxfs/Kconfig +++ b/fs/freevxfs/Kconfig @@ -2,6 +2,7 @@ config VXFS_FS tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)" depends on BLOCK + select BUFFER_HEAD help FreeVxFS is a file system driver that support the VERITAS VxFS(TM) file system format. VERITAS VxFS(TM) is the standard file system diff --git a/fs/gfs2/Kconfig b/fs/gfs2/Kconfig index 03c966840422ec..be7f87a8e11ae1 100644 --- a/fs/gfs2/Kconfig +++ b/fs/gfs2/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config GFS2_FS tristate "GFS2 file system support" + select BUFFER_HEAD select FS_POSIX_ACL select CRC32 select LIBCRC32C diff --git a/fs/hfs/Kconfig b/fs/hfs/Kconfig index d985066006d588..5ea5cd8ecea9c0 100644 --- a/fs/hfs/Kconfig +++ b/fs/hfs/Kconfig @@ -2,6 +2,7 @@ config HFS_FS tristate "Apple Macintosh file system support" depends on BLOCK + select BUFFER_HEAD select NLS select LEGACY_DIRECT_IO help diff --git a/fs/hfsplus/Kconfig b/fs/hfsplus/Kconfig index 8034e7827a690b..8ce4a33a9ac788 100644 --- a/fs/hfsplus/Kconfig +++ b/fs/hfsplus/Kconfig @@ -2,6 +2,7 @@ config HFSPLUS_FS tristate "Apple Extended HFS file system support" depends on BLOCK + select BUFFER_HEAD select NLS select NLS_UTF8 select LEGACY_DIRECT_IO diff --git a/fs/hpfs/Kconfig b/fs/hpfs/Kconfig index ec975f4668775f..ac1e9318e65a4a 100644 --- a/fs/hpfs/Kconfig +++ b/fs/hpfs/Kconfig @@ -2,6 +2,7 @@ config HPFS_FS tristate "OS/2 HPFS file system support" depends on BLOCK + select BUFFER_HEAD select FS_IOMAP help OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c index 0607790827b48a..6dc585c010c020 100644 --- a/fs/iomap/buffered-io.c +++ b/fs/iomap/buffered-io.c @@ -41,6 +41,12 @@ static inline struct iomap_page *to_iomap_page(struct folio *folio) return NULL; } +static inline bool iomap_use_buffer_heads(const struct iomap *iomap) +{ + return IS_ENABLED(CONFIG_BUFFER_HEAD) && + (iomap->flags & IOMAP_F_BUFFER_HEAD); +} + static struct bio_set iomap_ioend_bioset; static struct iomap_page * @@ -675,7 +681,7 @@ static int iomap_write_begin(struct iomap_iter *iter, loff_t pos, if (srcmap->type == IOMAP_INLINE) status = iomap_write_begin_inline(iter, folio); - else if (srcmap->flags & IOMAP_F_BUFFER_HEAD) + else if (iomap_use_buffer_heads(srcmap)) status = __block_write_begin_int(folio, pos, len, NULL, srcmap); else status = __iomap_write_begin(iter, pos, len, folio); @@ -745,7 +751,7 @@ static size_t iomap_write_end(struct iomap_iter *iter, loff_t pos, size_t len, if (srcmap->type == IOMAP_INLINE) { ret = iomap_write_end_inline(iter, folio, pos, copied); - } else if (srcmap->flags & IOMAP_F_BUFFER_HEAD) { + } else if (iomap_use_buffer_heads(srcmap)) { ret = block_write_end(NULL, iter->inode->i_mapping, pos, len, copied, &folio->page, NULL); } else { @@ -1248,7 +1254,7 @@ static loff_t iomap_folio_mkwrite_iter(struct iomap_iter *iter, loff_t length = iomap_length(iter); int ret; - if (iter->iomap.flags & IOMAP_F_BUFFER_HEAD) { + if (iomap_use_buffer_heads(&iter->iomap)) { ret = __block_write_begin_int(folio, iter->pos, length, NULL, &iter->iomap); if (ret) diff --git a/fs/isofs/Kconfig b/fs/isofs/Kconfig index 08ffd37b9bb8f6..51434f2a471b0f 100644 --- a/fs/isofs/Kconfig +++ b/fs/isofs/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config ISO9660_FS tristate "ISO 9660 CDROM file system support" + select BUFFER_HEAD help This is the standard file system used on CD-ROMs. It was previously known as "High Sierra File System" and is called "hsfs" on other diff --git a/fs/jfs/Kconfig b/fs/jfs/Kconfig index 51e856f0e4b8d6..17488440eef1a9 100644 --- a/fs/jfs/Kconfig +++ b/fs/jfs/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config JFS_FS tristate "JFS filesystem support" + select BUFFER_HEAD select NLS select CRC32 select LEGACY_DIRECT_IO diff --git a/fs/minix/Kconfig b/fs/minix/Kconfig index de2003974ff0d0..90ddfad2a75e8f 100644 --- a/fs/minix/Kconfig +++ b/fs/minix/Kconfig @@ -2,6 +2,7 @@ config MINIX_FS tristate "Minix file system support" depends on BLOCK + select BUFFER_HEAD help Minix is a simple operating system used in many classes about OS's. The minix file system (method to organize files on a hard disk diff --git a/fs/nilfs2/Kconfig b/fs/nilfs2/Kconfig index 7d59567465e121..7dae168e346e30 100644 --- a/fs/nilfs2/Kconfig +++ b/fs/nilfs2/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config NILFS2_FS tristate "NILFS2 file system support" + select BUFFER_HEAD select CRC32 select LEGACY_DIRECT_IO help diff --git a/fs/ntfs/Kconfig b/fs/ntfs/Kconfig index f93e69a612833f..7b2509741735a9 100644 --- a/fs/ntfs/Kconfig +++ b/fs/ntfs/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config NTFS_FS tristate "NTFS file system support" + select BUFFER_HEAD select NLS help NTFS is the file system of Microsoft Windows NT, 2000, XP and 2003. diff --git a/fs/ntfs3/Kconfig b/fs/ntfs3/Kconfig index 96cc236f7f7bd3..cdfdf51e55d797 100644 --- a/fs/ntfs3/Kconfig +++ b/fs/ntfs3/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config NTFS3_FS tristate "NTFS Read-Write file system support" + select BUFFER_HEAD select NLS select LEGACY_DIRECT_IO help diff --git a/fs/ocfs2/Kconfig b/fs/ocfs2/Kconfig index 3123da7cfb301f..2514d36cbe0157 100644 --- a/fs/ocfs2/Kconfig +++ b/fs/ocfs2/Kconfig @@ -2,6 +2,7 @@ config OCFS2_FS tristate "OCFS2 file system support" depends on INET && SYSFS && CONFIGFS_FS + select BUFFER_HEAD select JBD2 select CRC32 select QUOTA diff --git a/fs/omfs/Kconfig b/fs/omfs/Kconfig index 42b2ec35a05bfb..8470f6c3e64e6a 100644 --- a/fs/omfs/Kconfig +++ b/fs/omfs/Kconfig @@ -2,6 +2,7 @@ config OMFS_FS tristate "SonicBlue Optimized MPEG File System support" depends on BLOCK + select BUFFER_HEAD select CRC_ITU_T help This is the proprietary file system used by the Rio Karma music diff --git a/fs/qnx4/Kconfig b/fs/qnx4/Kconfig index 45b5b98376c436..a2eb826e76c602 100644 --- a/fs/qnx4/Kconfig +++ b/fs/qnx4/Kconfig @@ -2,6 +2,7 @@ config QNX4FS_FS tristate "QNX4 file system support (read only)" depends on BLOCK + select BUFFER_HEAD help This is the file system used by the real-time operating systems QNX 4 and QNX 6 (the latter is also called QNX RTP). diff --git a/fs/qnx6/Kconfig b/fs/qnx6/Kconfig index 6a9d6bce158622..8e865d72204e75 100644 --- a/fs/qnx6/Kconfig +++ b/fs/qnx6/Kconfig @@ -2,6 +2,7 @@ config QNX6FS_FS tristate "QNX6 file system support (read only)" depends on BLOCK && CRC32 + select BUFFER_HEAD help This is the file system used by the real-time operating systems QNX 6 (also called QNX RTP). diff --git a/fs/reiserfs/Kconfig b/fs/reiserfs/Kconfig index 4d22ecfe0fab65..0e6fe26458fede 100644 --- a/fs/reiserfs/Kconfig +++ b/fs/reiserfs/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config REISERFS_FS tristate "Reiserfs support (deprecated)" + select BUFFER_HEAD select CRC32 select LEGACY_DIRECT_IO help diff --git a/fs/sysv/Kconfig b/fs/sysv/Kconfig index b4e23e03fbeba3..67b3f90afbfd67 100644 --- a/fs/sysv/Kconfig +++ b/fs/sysv/Kconfig @@ -2,6 +2,7 @@ config SYSV_FS tristate "System V/Xenix/V7/Coherent file system support" depends on BLOCK + select BUFFER_HEAD help SCO, Xenix and Coherent are commercial Unix systems for Intel machines, and Version 7 was used on the DEC PDP-11. Saying Y diff --git a/fs/udf/Kconfig b/fs/udf/Kconfig index 82e8bfa2dfd989..8f7ce30d47fdce 100644 --- a/fs/udf/Kconfig +++ b/fs/udf/Kconfig @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only config UDF_FS tristate "UDF file system support" + select BUFFER_HEAD select CRC_ITU_T select NLS select LEGACY_DIRECT_IO diff --git a/fs/ufs/Kconfig b/fs/ufs/Kconfig index 6d30adb6b890fc..9301e7ecd09210 100644 --- a/fs/ufs/Kconfig +++ b/fs/ufs/Kconfig @@ -2,6 +2,7 @@ config UFS_FS tristate "UFS file system support (read only)" depends on BLOCK + select BUFFER_HEAD help BSD and derivate versions of Unix (such as SunOS, FreeBSD, NetBSD, OpenBSD and NeXTstep) use a file system called UFS. Some System V diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 7002a9ff63a3da..c89ef50d5112fc 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h @@ -16,8 +16,6 @@ #include #include -#ifdef CONFIG_BLOCK - enum bh_state_bits { BH_Uptodate, /* Contains valid data */ BH_Dirty, /* Is dirty */ @@ -198,7 +196,6 @@ void set_bh_page(struct buffer_head *bh, struct page *page, unsigned long offset); void folio_set_bh(struct buffer_head *bh, struct folio *folio, unsigned long offset); -bool try_to_free_buffers(struct folio *); struct buffer_head *folio_alloc_buffers(struct folio *folio, unsigned long size, bool retry); struct buffer_head *alloc_page_buffers(struct page *page, unsigned long size, @@ -213,10 +210,6 @@ void end_buffer_async_write(struct buffer_head *bh, int uptodate); /* Things to do with buffers at mapping->private_list */ void mark_buffer_dirty_inode(struct buffer_head *bh, struct inode *inode); -int inode_has_buffers(struct inode *); -void invalidate_inode_buffers(struct inode *); -int remove_inode_buffers(struct inode *inode); -int sync_mapping_buffers(struct address_space *mapping); int generic_buffers_fsync_noflush(struct file *file, loff_t start, loff_t end, bool datasync); int generic_buffers_fsync(struct file *file, loff_t start, loff_t end, @@ -240,9 +233,6 @@ void __bforget(struct buffer_head *); void __breadahead(struct block_device *, sector_t block, unsigned int size); struct buffer_head *__bread_gfp(struct block_device *, sector_t block, unsigned size, gfp_t gfp); -void invalidate_bh_lrus(void); -void invalidate_bh_lrus_cpu(void); -bool has_bh_in_lru(int cpu, void *dummy); struct buffer_head *alloc_buffer_head(gfp_t gfp_flags); void free_buffer_head(struct buffer_head * bh); void unlock_buffer(struct buffer_head *bh); @@ -258,8 +248,6 @@ int __bh_read(struct buffer_head *bh, blk_opf_t op_flags, bool wait); void __bh_read_batch(int nr, struct buffer_head *bhs[], blk_opf_t op_flags, bool force_lock); -extern int buffer_heads_over_limit; - /* * Generic address_space_operations implementations for buffer_head-backed * address_spaces. @@ -304,8 +292,6 @@ extern int buffer_migrate_folio_norefs(struct address_space *, #define buffer_migrate_folio_norefs NULL #endif -void buffer_init(void); - /* * inline definitions */ @@ -465,7 +451,20 @@ __bread(struct block_device *bdev, sector_t block, unsigned size) bool block_dirty_folio(struct address_space *mapping, struct folio *folio); -#else /* CONFIG_BLOCK */ +#ifdef CONFIG_BUFFER_HEAD + +void buffer_init(void); +bool try_to_free_buffers(struct folio *folio); +int inode_has_buffers(struct inode *inode); +void invalidate_inode_buffers(struct inode *inode); +int remove_inode_buffers(struct inode *inode); +int sync_mapping_buffers(struct address_space *mapping); +void invalidate_bh_lrus(void); +void invalidate_bh_lrus_cpu(void); +bool has_bh_in_lru(int cpu, void *dummy); +extern int buffer_heads_over_limit; + +#else /* CONFIG_BUFFER_HEAD */ static inline void buffer_init(void) {} static inline bool try_to_free_buffers(struct folio *folio) { return true; } @@ -473,9 +472,10 @@ static inline int inode_has_buffers(struct inode *inode) { return 0; } static inline void invalidate_inode_buffers(struct inode *inode) {} static inline int remove_inode_buffers(struct inode *inode) { return 1; } static inline int sync_mapping_buffers(struct address_space *mapping) { return 0; } +static inline void invalidate_bh_lrus(void) {} static inline void invalidate_bh_lrus_cpu(void) {} static inline bool has_bh_in_lru(int cpu, void *dummy) { return false; } #define buffer_heads_over_limit 0 -#endif /* CONFIG_BLOCK */ +#endif /* CONFIG_BUFFER_HEAD */ #endif /* _LINUX_BUFFER_HEAD_H */ diff --git a/include/trace/events/block.h b/include/trace/events/block.h index 40e60c33cc6f3d..0e128ad5146015 100644 --- a/include/trace/events/block.h +++ b/include/trace/events/block.h @@ -12,6 +12,7 @@ #define RWBS_LEN 8 +#ifdef CONFIG_BUFFER_HEAD DECLARE_EVENT_CLASS(block_buffer, TP_PROTO(struct buffer_head *bh), @@ -61,6 +62,7 @@ DEFINE_EVENT(block_buffer, block_dirty_buffer, TP_ARGS(bh) ); +#endif /* CONFIG_BUFFER_HEAD */ /** * block_rq_requeue - place block IO request back on a queue diff --git a/mm/migrate.c b/mm/migrate.c index 24baad2571e314..fe6f8d454aff83 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -684,7 +684,7 @@ int migrate_folio(struct address_space *mapping, struct folio *dst, } EXPORT_SYMBOL(migrate_folio); -#ifdef CONFIG_BLOCK +#ifdef CONFIG_BUFFER_HEAD /* Returns true if all buffers are successfully locked */ static bool buffer_migrate_lock_buffers(struct buffer_head *head, enum migrate_mode mode) @@ -837,7 +837,7 @@ int buffer_migrate_folio_norefs(struct address_space *mapping, return __buffer_migrate_folio(mapping, dst, src, mode, true); } EXPORT_SYMBOL_GPL(buffer_migrate_folio_norefs); -#endif +#endif /* CONFIG_BUFFER_HEAD */ int filemap_migrate_folio(struct address_space *mapping, struct folio *dst, struct folio *src, enum migrate_mode mode)