Received: by 2002:a05:6358:51dd:b0:131:369:b2a3 with SMTP id 29csp337459rwl; Wed, 9 Aug 2023 15:37:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcVpN2M7BUtHs9X92zVM4EaXWuumS4h+v6XJLhXi44r9Fu38qntt4R4CQ6dsm3Eo0FKBd+ X-Received: by 2002:a5d:4fcb:0:b0:316:e422:38e8 with SMTP id h11-20020a5d4fcb000000b00316e42238e8mr538696wrw.66.1691620627386; Wed, 09 Aug 2023 15:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691620627; cv=none; d=google.com; s=arc-20160816; b=LMX6gQMPzP5uHPywqywoFooC3L+EVrHo0r/wLk48fJucLnDYfWUtB+062/0DeVHCjV ifmsn0gGHDLdDA5cfdFJ1oqw41+iT52/eVHQkCdNx9sfwW8+D8GwFodV1pqxBJ4TLF5T FIl0R0MaQGF3h8WHamX3vxTD5X8CHRhD6Q0bc6weGiErJA7YM+RbQ39l6heKRMyRF/jp Y+GTLWt+GxFrPCGlSXG2QIUcdqLGYYNbeK1lkl/FUUovU1aL+f7yCelRl589HI2bkU+u /sElSbfOsn+sH4yG8C3YiXwxMWyHD0nKqASqHq5EouIRjwnzm16PbuKMNbVpXPHLxXvP BqHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kB68DmZwK80MitdBPMr8zbkuh+bDZpl9ET1tnFndqgs=; fh=xYYCMLMJ+2IbWglp0JxrsK4EkPiHh2FQHcpFdt441VM=; b=OIu2pBEBf6UCL79d94YWcdiCsO5W/jLQAiRMthhn5Ot4/WqkX2bwIAFANzfiFCdrmG hnCUwbjwliJEYHaYfcxPSrudByqo0y0bDUrvhnWMTKy4/YTlEVpcjrylnJQ1VLVhnK4R 5fV1Q3tGQ+a38svJMpkS0vjintCJzLcqiCXjuyCjl1PqvCKl7B0+j3hwBdBi/RClhbXk QQUUMw9hSRb6dUTFPQqgum+wJlhYzNHRxZEzAFmlpAbZpvWytZ4xSFyLizUbyDs7RbDn bzYlSTI+ETT2c8fa7OuNfcSvrAMI7ggP0h/Kt/hvUU42ToAsHk6wL9tJ/ZBG9EhOju35 nELA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="cMlbj/Nm"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a1709064ec800b00986749b140dsi160338ejv.894.2023.08.09.15.36.43; Wed, 09 Aug 2023 15:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b="cMlbj/Nm"; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233043AbjHIWGE (ORCPT + 99 others); Wed, 9 Aug 2023 18:06:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232992AbjHIWF4 (ORCPT ); Wed, 9 Aug 2023 18:05:56 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F29D2126; Wed, 9 Aug 2023 15:05:54 -0700 (PDT) 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=kB68DmZwK80MitdBPMr8zbkuh+bDZpl9ET1tnFndqgs=; b=cMlbj/NmcItbD7S8XxA1JTZHY/ /5HIxu65VJSGivrddkgc6edRjc5J4G7lcR9wv+EOcogyn2zqtP8X4NVYh/hSJGcK0wzYlpq+vOO7j FkusVCHZnUe5WFBkPOX1ZygMIzNdq3gSA7CIt6dQk2NIz32SuYLiAUraPm7a+SH1b/D9v/kb0fxtz s7jFEr1hQaga2FsQXhLt/tUfD/ETlvm9XSnUmvBB8ERoiz1zEUvbBG01d42yrR2h52PumboUfH4k4 8xV0wbAEykSPS8aJg7/v06S9rCT7L6NB2Vm7mU2DZqq8iuQw6aZ5ZzgWvZ2fP9fRMUcSdlwZMDRet /UCz4P8A==; Received: from [4.28.11.157] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qTrJM-005xoS-1p; Wed, 09 Aug 2023 22:05:48 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Namjae Jeon , Sungjong Seo , "Theodore Ts'o" , Andreas Dilger , Konstantin Komarov , "Darrick J. Wong" , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, ntfs3@lists.linux.dev, linux-xfs@vger.kernel.org Subject: [PATCH 07/13] xfs: document the invalidate_bdev call in invalidate_bdev Date: Wed, 9 Aug 2023 15:05:39 -0700 Message-Id: <20230809220545.1308228-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230809220545.1308228-1-hch@lst.de> References: <20230809220545.1308228-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Copy and paste the commit message from Darrick into a comment to explain the seemly odd invalidate_bdev in xfs_shutdown_devices. Signed-off-by: Christoph Hellwig --- fs/xfs/xfs_super.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 4ae3b01ed038c7..c169beb0d8cab3 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -399,6 +399,32 @@ STATIC void xfs_shutdown_devices( struct xfs_mount *mp) { + /* + * Udev is triggered whenever anyone closes a block device or unmounts + * a file systemm on a block device. + * The default udev rules invoke blkid to read the fs super and create + * symlinks to the bdev under /dev/disk. For this, it uses buffered + * reads through the page cache. + * + * xfs_db also uses buffered reads to examine metadata. There is no + * coordination between xfs_db and udev, which means that they can run + * concurrently. Note there is no coordination between the kernel and + * blkid either. + * + * On a system with 64k pages, the page cache can cache the superblock + * and the root inode (and hence the root directory) with the same 64k + * page. If udev spawns blkid after the mkfs and the system is busy + * enough that it is still running when xfs_db starts up, they'll both + * read from the same page in the pagecache. + * + * The unmount writes updated inode metadata to disk directly. The XFS + * buffer cache does not use the bdev pagecache, nor does it invalidate + * the pagecache on umount. If the above scenario occurs, the pagecache + * no longer reflects what's on disk, xfs_db reads the stale metadata, + * and fails to find /a. Most of the time this succeeds because closing + * a bdev invalidates the page cache, but when processes race, everyone + * loses. + */ if (mp->m_logdev_targp && mp->m_logdev_targp != mp->m_ddev_targp) { blkdev_issue_flush(mp->m_logdev_targp->bt_bdev); invalidate_bdev(mp->m_logdev_targp->bt_bdev); -- 2.39.2