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/95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SPw3EOnhBfZKGXMh/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,