From patchwork Fri Aug 11 10:08:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350499 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7715C07E8F for ; Fri, 11 Aug 2023 10:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235516AbjHKKIs (ORCPT ); Fri, 11 Aug 2023 06:08:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235435AbjHKKIk (ORCPT ); Fri, 11 Aug 2023 06:08:40 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 742B7E3; Fri, 11 Aug 2023 03:08:40 -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=zjW5l1wDCFCu1pt1F8sv0aM8FWD26mmo/JL5KKCdSVc=; b=FLY/bEYIE/O6+NT+S/Mq95/r4q KbdDpVEX1AzOR9mg158RJ8u4nVDaKwzZDPKqlYXpv1hJVBbp+ooEeVpKTD3W8Ptb9V1swX1/QmLQL mxQ0J3YSDFdQaVriWRdeIezdUaanTl1C7etOiswe+fwADJXvujqc1cuQXNKNQJvm9qPjEhKrQwFuP dz906g0PSLyFYc8WzsAsuEQlwYNzsGRv5pEdx5YMF8412opsklTpUEDBglBQqKh5lYahvgmrDjBf5 F3dqgOGPFWbTjsVb8VNlt+o5xySVp3R9xnW/b8uWriDFl38D/MBVtQRXF5d9Rp4cpDl1aHzue8e2o M+saUX9A==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4L-00A5Yk-2W; Fri, 11 Aug 2023 10:08:34 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 01/17] FOLD: reverts part of "fs: use the super_block as holder when mounting file systems" Date: Fri, 11 Aug 2023 12:08:12 +0200 Message-Id: <20230811100828.1897174-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The btrfs hunk should be dropped because the prerequisite btrfs changes were dropped from the branch. Signed-off-by: Christoph Hellwig --- fs/btrfs/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index d58ace4c1d2962..f1dd172d8d5bd7 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -69,6 +69,8 @@ static const struct super_operations btrfs_super_ops; * requested by subvol=/path. That way the callchain is straightforward and we * don't have to play tricks with the mount options and recursive calls to * btrfs_mount. + * + * The new btrfs_root_fs_type also servers as a tag for the bdev_holder. */ static struct file_system_type btrfs_fs_type; static struct file_system_type btrfs_root_fs_type; @@ -1513,7 +1515,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s", fs_type->name, s->s_id); - fs_info->bdev_holder = s; + btrfs_sb(s)->bdev_holder = fs_type; error = btrfs_fill_super(s, fs_devices, data); } if (!error) From patchwork Fri Aug 11 10:08:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350500 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82028C04A94 for ; Fri, 11 Aug 2023 10:09:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235575AbjHKKJX (ORCPT ); Fri, 11 Aug 2023 06:09:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235539AbjHKKI7 (ORCPT ); Fri, 11 Aug 2023 06:08:59 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CF6530D6; Fri, 11 Aug 2023 03:08:46 -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=r6gDfPhaoM7J2iRzTUUAmIosaWN5Ed601e9pLnuJfEs=; b=hNapXvvsvvDvwITKXZVGSZpgwU +YuvGQVrbtALKKwhEmdUw594Ky8bDr2cjaMhvr9qb/ab5q+T5wKfH/D9a/3VO+BhBq9d2am/FVHNL oxCs1BCWMRerkWr0GPYQhvdLKmp64gYyOaCtS8AS8KdbAIOHTItUFBCaGPKDCB+v3zJDYwbryzXP+ 357veeDbEeDL8ZRhha8cEyyd2QmC64GLcYxJ1KiHUog0/NbqgmIBPKi9qOuumVITMM7J5ShAAIKyU N88uYpPY1geqwBvYovpFWWNXq1qfgM5VDdAfNx9LRRzuLvfReG0JJSfZl4nq1FoKfhdAH7ew7ncHB e7uQRRAQ==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4O-00A5Zk-2H; Fri, 11 Aug 2023 10:08:37 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 02/17] btrfs: always open the device read-only in btrfs_scan_one_device Date: Fri, 11 Aug 2023 12:08:13 +0200 Message-Id: <20230811100828.1897174-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org btrfs_scan_one_device opens the block device only to read the super block. Instead of passing a blk_mode_t argument to sometimes open it for writing, just hard code BLK_OPEN_READ as it will never write to the device or hand the block_device out to someone else. Signed-off-by: Christoph Hellwig Reviewed-by: Christian Brauner --- fs/btrfs/super.c | 15 +++++++-------- fs/btrfs/volumes.c | 4 ++-- fs/btrfs/volumes.h | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index f1dd172d8d5bd7..b318bddefd5236 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -849,7 +849,7 @@ int btrfs_parse_options(struct btrfs_fs_info *info, char *options, * All other options will be parsed on much later in the mount process and * only when we need to allocate a new super block. */ -static int btrfs_parse_device_options(const char *options, blk_mode_t flags) +static int btrfs_parse_device_options(const char *options) { substring_t args[MAX_OPT_ARGS]; char *device_name, *opts, *orig, *p; @@ -883,7 +883,7 @@ static int btrfs_parse_device_options(const char *options, blk_mode_t flags) error = -ENOMEM; goto out; } - device = btrfs_scan_one_device(device_name, flags); + device = btrfs_scan_one_device(device_name); kfree(device_name); if (IS_ERR(device)) { error = PTR_ERR(device); @@ -1440,7 +1440,6 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, struct btrfs_fs_devices *fs_devices = NULL; struct btrfs_fs_info *fs_info = NULL; void *new_sec_opts = NULL; - blk_mode_t mode = sb_open_mode(flags); int error = 0; if (data) { @@ -1472,13 +1471,13 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, } mutex_lock(&uuid_mutex); - error = btrfs_parse_device_options(data, mode); + error = btrfs_parse_device_options(data); if (error) { mutex_unlock(&uuid_mutex); goto error_fs_info; } - device = btrfs_scan_one_device(device_name, mode); + device = btrfs_scan_one_device(device_name); if (IS_ERR(device)) { mutex_unlock(&uuid_mutex); error = PTR_ERR(device); @@ -1488,7 +1487,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, fs_devices = device->fs_devices; fs_info->fs_devices = fs_devices; - error = btrfs_open_devices(fs_devices, mode, fs_type); + error = btrfs_open_devices(fs_devices, sb_open_mode(flags), fs_type); mutex_unlock(&uuid_mutex); if (error) goto error_fs_info; @@ -2190,7 +2189,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, switch (cmd) { case BTRFS_IOC_SCAN_DEV: mutex_lock(&uuid_mutex); - device = btrfs_scan_one_device(vol->name, BLK_OPEN_READ); + device = btrfs_scan_one_device(vol->name); ret = PTR_ERR_OR_ZERO(device); mutex_unlock(&uuid_mutex); break; @@ -2204,7 +2203,7 @@ static long btrfs_control_ioctl(struct file *file, unsigned int cmd, break; case BTRFS_IOC_DEVICES_READY: mutex_lock(&uuid_mutex); - device = btrfs_scan_one_device(vol->name, BLK_OPEN_READ); + device = btrfs_scan_one_device(vol->name); if (IS_ERR(device)) { mutex_unlock(&uuid_mutex); ret = PTR_ERR(device); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 73f9ea7672dbda..8246578c70f55b 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1356,7 +1356,7 @@ int btrfs_forget_devices(dev_t devt) * and we are not allowed to call set_blocksize during the scan. The superblock * is read via pagecache */ -struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags) +struct btrfs_device *btrfs_scan_one_device(const char *path) { struct btrfs_super_block *disk_super; bool new_device_added = false; @@ -1384,7 +1384,7 @@ struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags) * values temporarily, as the device paths of the fsid are the only * required information for assembling the volume. */ - bdev = blkdev_get_by_path(path, flags, NULL, NULL); + bdev = blkdev_get_by_path(path, BLK_OPEN_READ, NULL, NULL); if (IS_ERR(bdev)) return ERR_CAST(bdev); diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index b8c51f16ba867f..824161c6dd063e 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -611,7 +611,7 @@ struct btrfs_block_group *btrfs_create_chunk(struct btrfs_trans_handle *trans, void btrfs_mapping_tree_free(struct extent_map_tree *tree); int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, blk_mode_t flags, void *holder); -struct btrfs_device *btrfs_scan_one_device(const char *path, blk_mode_t flags); +struct btrfs_device *btrfs_scan_one_device(const char *path); int btrfs_forget_devices(dev_t devt); void btrfs_close_devices(struct btrfs_fs_devices *fs_devices); void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices); From patchwork Fri Aug 11 10:08:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350501 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E04A1C04FE1 for ; Fri, 11 Aug 2023 10:09:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235545AbjHKKJZ (ORCPT ); Fri, 11 Aug 2023 06:09:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235446AbjHKKJC (ORCPT ); Fri, 11 Aug 2023 06:09:02 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55A1C30E2; Fri, 11 Aug 2023 03:08:47 -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=K/QBcOv4fTIU7nBesYdEWMXMlgsg7gJvNa3bCA3VzKs=; b=K2FtvqOc6v9BOz4kx+Q9nAQX35 JA+FvvCyWF1N2GvLJ+tzYrLvjKzUxvBrw0YbLQK4cyDETzmkA8nS2pYTbU1l2LDHA1seMmpnhxYis YTGlfc/QmhyMJzSXTpMlFoJZxbLcohrsqte1tENFcJHDIdg/Eh8vxiqgyRCy65u6iSRu4I/8vsdh+ UM28ssSRN4XuB2Z9kkibHdnWbS23rWBTtFmdjpz5b1exGl4liCAFQRwqSG3mQEYCE1RtbyhadZcI0 sz0iQIkvuy1iVgGEABv0nHkoZk6vTKBqO441yl7JkYvaIcyHDPfvvYh2L5CvVqdFAzcJyEB5E1Zr3 aAA80+RQ==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4R-00A5aJ-1t; Fri, 11 Aug 2023 10:08:40 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 03/17] btrfs: call btrfs_close_devices from ->kill_sb Date: Fri, 11 Aug 2023 12:08:14 +0200 Message-Id: <20230811100828.1897174-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org blkdev_put must not be called under sb->s_umount to avoid a lock order reversal with disk->open_mutex once call backs from block devices to the file system using the holder ops are supported. Move the call to btrfs_close_devices into btrfs_free_fs_info so that it is closed from ->kill_sb (which is also called from the mount failure handling path unlike ->put_super) as well as when an fs_info is freed because an existing superblock already exists. Signed-off-by: Christoph Hellwig Reviewed-by: Christian Brauner --- fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/super.c | 7 ++----- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 7513388b0567be..3788b55638392e 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1243,6 +1243,8 @@ static void free_global_roots(struct btrfs_fs_info *fs_info) void btrfs_free_fs_info(struct btrfs_fs_info *fs_info) { + if (fs_info->fs_devices) + btrfs_close_devices(fs_info->fs_devices); percpu_counter_destroy(&fs_info->dirty_metadata_bytes); percpu_counter_destroy(&fs_info->delalloc_bytes); percpu_counter_destroy(&fs_info->ordered_bytes); @@ -3554,7 +3556,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device iput(fs_info->btree_inode); fail: - btrfs_close_devices(fs_info->fs_devices); ASSERT(ret < 0); return ret; } @@ -4408,7 +4409,6 @@ void __cold close_ctree(struct btrfs_fs_info *fs_info) #endif btrfs_mapping_tree_free(&fs_info->mapping_tree); - btrfs_close_devices(fs_info->fs_devices); } void btrfs_mark_buffer_dirty(struct extent_buffer *buf) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index b318bddefd5236..2bbc041ac2e2c5 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1494,7 +1494,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, if (!(flags & SB_RDONLY) && fs_devices->rw_devices == 0) { error = -EACCES; - goto error_close_devices; + goto error_fs_info; } bdev = fs_devices->latest_dev->bdev; @@ -1502,11 +1502,10 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, fs_info); if (IS_ERR(s)) { error = PTR_ERR(s); - goto error_close_devices; + goto error_fs_info; } if (s->s_root) { - btrfs_close_devices(fs_devices); btrfs_free_fs_info(fs_info); if ((flags ^ s->s_flags) & SB_RDONLY) error = -EBUSY; @@ -1527,8 +1526,6 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, return dget(s->s_root); -error_close_devices: - btrfs_close_devices(fs_devices); error_fs_info: btrfs_free_fs_info(fs_info); error_sec_opts: From patchwork Fri Aug 11 10:08:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350502 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F372C04A94 for ; Fri, 11 Aug 2023 10:09:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235711AbjHKKJj (ORCPT ); Fri, 11 Aug 2023 06:09:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231603AbjHKKJY (ORCPT ); Fri, 11 Aug 2023 06:09:24 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFAF435AA; Fri, 11 Aug 2023 03:08:51 -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=G5wFZqrNN2Zky0KlYoq/2FSZYr23+UpMaPMZmuKO/fg=; b=DSJg9AaoLRSDPfwDhpCRuzCfu6 nOHA3s1SGXSJ3nmeelWIHN3XOBOkaunJdKly2KkRdkuMXeTxYABV9gdStlPZsPlc3c3lUxq8B4HLu jST/9KizR8cMMPIIkSDhnh5d0v/5IvJvK46PuMatmJ8JMrg0nLo2jqM2Tx+x09g6X3W152V1Pctya IOISTZkXLuibJspnpmF85zSND/RF7ez/xrO22U4jZBAmESYXcfmCaFDFWtMPJwuqDJQPXmluqSfjP EWEF6NM7+Cs9+wFmayF2TJFndksnAY629lPLXRwJ1hQqk6mCVjkMWzdm8kRv9K4ny+sMmjEr6ofKB mbEvi0rg==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4U-00A5ce-1n; Fri, 11 Aug 2023 10:08:42 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 04/17] btrfs: split btrfs_fs_devices.opened Date: Fri, 11 Aug 2023 12:08:15 +0200 Message-Id: <20230811100828.1897174-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The btrfs_fs_devices.opened member mixes an in use counter for the fs_devices structure that prevents it from being garbage collected with a flag if the underlying devices were actually opened. This not only makes the code hard to follow, but also prevents btrfs from switching to opening the block device only after super block creation. Split it into an in_use counter and an is_open boolean flag instead. Signed-off-by: Christoph Hellwig --- fs/btrfs/volumes.c | 49 ++++++++++++++++++++++++++-------------------- fs/btrfs/volumes.h | 6 ++++-- 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8246578c70f55b..3ac1a3aa8939bc 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -405,7 +405,8 @@ static void free_fs_devices(struct btrfs_fs_devices *fs_devices) { struct btrfs_device *device; - WARN_ON(fs_devices->opened); + WARN_ON_ONCE(fs_devices->in_use); + WARN_ON_ONCE(fs_devices->is_open); while (!list_empty(&fs_devices->devices)) { device = list_entry(fs_devices->devices.next, struct btrfs_device, dev_list); @@ -578,7 +579,7 @@ static int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device continue; if (devt && devt != device->devt) continue; - if (fs_devices->opened) { + if (fs_devices->in_use) { /* for an already deleted device return 0 */ if (devt && ret != 0) ret = -EBUSY; @@ -849,7 +850,7 @@ static noinline struct btrfs_device *device_list_add(const char *path, if (!device) { unsigned int nofs_flag; - if (fs_devices->opened) { + if (fs_devices->in_use) { btrfs_err(NULL, "device %s belongs to fsid %pU, and the fs is already mounted", path, fs_devices->fsid); @@ -913,7 +914,7 @@ static noinline struct btrfs_device *device_list_add(const char *path, * tracking a problem where systems fail mount by subvolume id * when we reject replacement on a mounted FS. */ - if (!fs_devices->opened && found_transid < device->generation) { + if (!fs_devices->in_use && found_transid < device->generation) { /* * That is if the FS is _not_ mounted and if you * are here, that means there is more than one @@ -974,7 +975,7 @@ static noinline struct btrfs_device *device_list_add(const char *path, * it back. We need it to pick the disk with largest generation * (as above). */ - if (!fs_devices->opened) { + if (!fs_devices->in_use) { device->generation = found_transid; fs_devices->latest_generation = max_t(u64, found_transid, fs_devices->latest_generation); @@ -1172,15 +1173,19 @@ static void close_fs_devices(struct btrfs_fs_devices *fs_devices) lockdep_assert_held(&uuid_mutex); - if (--fs_devices->opened > 0) + if (--fs_devices->in_use > 0) return; + if (!fs_devices->is_open) + goto done; + list_for_each_entry_safe(device, tmp, &fs_devices->devices, dev_list) btrfs_close_one_device(device); WARN_ON(fs_devices->open_devices); WARN_ON(fs_devices->rw_devices); - fs_devices->opened = 0; + fs_devices->is_open = false; +done: fs_devices->seeding = false; fs_devices->fs_info = NULL; } @@ -1192,7 +1197,7 @@ void btrfs_close_devices(struct btrfs_fs_devices *fs_devices) mutex_lock(&uuid_mutex); close_fs_devices(fs_devices); - if (!fs_devices->opened) { + if (!fs_devices->in_use) { list_splice_init(&fs_devices->seed_list, &list); /* @@ -1240,7 +1245,7 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices, if (fs_devices->open_devices == 0) return -EINVAL; - fs_devices->opened = 1; + fs_devices->is_open = true; fs_devices->latest_dev = latest_dev; fs_devices->total_rw_bytes = 0; fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR; @@ -1277,16 +1282,14 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, * We also don't need the lock here as this is called during mount and * exclusion is provided by uuid_mutex */ - - if (fs_devices->opened) { - fs_devices->opened++; - ret = 0; - } else { + if (!fs_devices->is_open) { list_sort(NULL, &fs_devices->devices, devid_cmp); ret = open_fs_devices(fs_devices, flags, holder); + if (ret) + return ret; } - - return ret; + fs_devices->in_use++; + return 0; } void btrfs_release_disk_super(struct btrfs_super_block *super) @@ -2242,13 +2245,14 @@ int btrfs_rm_device(struct btrfs_fs_info *fs_info, * This can happen if cur_devices is the private seed devices list. We * cannot call close_fs_devices() here because it expects the uuid_mutex * to be held, but in fact we don't need that for the private - * seed_devices, we can simply decrement cur_devices->opened and then + * seed_devices, we can simply decrement cur_devices->in_use and then * remove it from our list and free the fs_devices. */ if (cur_devices->num_devices == 0) { list_del_init(&cur_devices->seed_list); - ASSERT(cur_devices->opened == 1); - cur_devices->opened--; + ASSERT(cur_devices->in_use == 1); + cur_devices->in_use--; + cur_devices->is_open = false; free_fs_devices(cur_devices); } @@ -2478,7 +2482,8 @@ static struct btrfs_fs_devices *btrfs_init_sprout(struct btrfs_fs_info *fs_info) list_add(&old_devices->fs_list, &fs_uuids); memcpy(seed_devices, fs_devices, sizeof(*seed_devices)); - seed_devices->opened = 1; + seed_devices->in_use = 1; + seed_devices->is_open = true; INIT_LIST_HEAD(&seed_devices->devices); INIT_LIST_HEAD(&seed_devices->alloc_list); mutex_init(&seed_devices->device_list_mutex); @@ -6883,7 +6888,8 @@ static struct btrfs_fs_devices *open_seed_devices(struct btrfs_fs_info *fs_info, return fs_devices; fs_devices->seeding = true; - fs_devices->opened = 1; + fs_devices->in_use = 1; + fs_devices->is_open = true; return fs_devices; } @@ -6900,6 +6906,7 @@ static struct btrfs_fs_devices *open_seed_devices(struct btrfs_fs_info *fs_info, free_fs_devices(fs_devices); return ERR_PTR(ret); } + fs_devices->in_use = 1; if (!fs_devices->seeding) { close_fs_devices(fs_devices); diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 824161c6dd063e..f472d646715e72 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -346,8 +346,10 @@ struct btrfs_fs_devices { struct list_head seed_list; - /* Count fs-devices opened. */ - int opened; + /* Count if fs_device is in used. */ + unsigned int in_use; + /* True if the devices were opened. */ + bool is_open; /* Set when we find or add a device that doesn't have the nonrot flag set. */ bool rotating; From patchwork Fri Aug 11 10:08:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350503 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 34C24C0015E for ; Fri, 11 Aug 2023 10:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233666AbjHKKJl (ORCPT ); Fri, 11 Aug 2023 06:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235400AbjHKKJY (ORCPT ); Fri, 11 Aug 2023 06:09:24 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A929D35B1; Fri, 11 Aug 2023 03:08:52 -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=CTqMdFsl7PwdxJLPZ9AeUTfJH8rvgbp4LcXem5+up44=; b=JuzSeA4L0WAaHf47xKgcSHhzYF MBvsLqD1Apf4wWfDr6ulqFSWmwDaA2wS6tW861F6QUL5172t7tRQISTrXZrgavrUfg09VeHmoT+jQ eez8kjHv9cJz0YlXH4V6/JYc7b+SvMH9mcAvVYXtQijYfAJiVm9lEuhl20zw6IenCWVC8uAKc6Fhl ydln3Zy2uetLfIKgWWfyJSK5SVT3XSeiCb1omD7RIWjBGM48nuq0wVkBk95Y9aTZN6vo/wk9Vmvfc r6MvbRqe5Qc3uP0RFnh6k1ZXnXBWyrQpBBryv2rkYtIYgifNOE/l4PxGmVStxbi3ahmHkrVq1PznT uwS+WMAA==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4X-00A5e3-1P; Fri, 11 Aug 2023 10:08:45 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 05/17] btrfs: open block devices after superblock creation Date: Fri, 11 Aug 2023 12:08:16 +0200 Message-Id: <20230811100828.1897174-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Currently btrfs_mount_root opens the block devices before committing to allocating a super block. That creates problems for restricting the number of writers to a device, and also leads to a unusual and not very helpful holder (the fs_type). Reorganize the code to first check whether the superblock for a particular fsid does already exist and open the block devices only if it doesn't, mirroring the recent changes to the VFS mount helpers. To do this the increment of the in_use counter moves out of btrfs_open_devices and into the only caller in btrfs_mount_root so that it happens before dropping uuid_mutex around the call to sget. Signed-off-by: Christoph Hellwig Acked-by: Christian Brauner --- fs/btrfs/super.c | 40 +++++++++++++++++++++++----------------- fs/btrfs/volumes.c | 15 +++++---------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 2bbc041ac2e2c5..1079a0f541790d 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1434,7 +1434,6 @@ static struct dentry *mount_subvol(const char *subvol_name, u64 subvol_objectid, static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, int flags, const char *device_name, void *data) { - struct block_device *bdev = NULL; struct super_block *s; struct btrfs_device *device = NULL; struct btrfs_fs_devices *fs_devices = NULL; @@ -1486,18 +1485,9 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, fs_devices = device->fs_devices; fs_info->fs_devices = fs_devices; - - error = btrfs_open_devices(fs_devices, sb_open_mode(flags), fs_type); + fs_devices->in_use++; mutex_unlock(&uuid_mutex); - if (error) - goto error_fs_info; - - if (!(flags & SB_RDONLY) && fs_devices->rw_devices == 0) { - error = -EACCES; - goto error_fs_info; - } - bdev = fs_devices->latest_dev->bdev; s = sget(fs_type, btrfs_test_super, btrfs_set_super, flags | SB_NOSEC, fs_info); if (IS_ERR(s)) { @@ -1510,7 +1500,22 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, if ((flags ^ s->s_flags) & SB_RDONLY) error = -EBUSY; } else { - snprintf(s->s_id, sizeof(s->s_id), "%pg", bdev); + struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; + + mutex_lock(&uuid_mutex); + error = btrfs_open_devices(fs_devices, sb_open_mode(flags), + fs_type); + mutex_unlock(&uuid_mutex); + if (error) + goto error_deactivate; + + if (!(flags & SB_RDONLY) && fs_devices->rw_devices == 0) { + error = -EACCES; + goto error_deactivate; + } + + snprintf(s->s_id, sizeof(s->s_id), "%pg", + fs_devices->latest_dev->bdev); shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s", fs_type->name, s->s_id); btrfs_sb(s)->bdev_holder = fs_type; @@ -1518,12 +1523,9 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, } if (!error) error = security_sb_set_mnt_opts(s, new_sec_opts, 0, NULL); + if (error) + goto error_deactivate; security_free_mnt_opts(&new_sec_opts); - if (error) { - deactivate_locked_super(s); - return ERR_PTR(error); - } - return dget(s->s_root); error_fs_info: @@ -1531,6 +1533,10 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, error_sec_opts: security_free_mnt_opts(&new_sec_opts); return ERR_PTR(error); + +error_deactivate: + deactivate_locked_super(s); + goto error_sec_opts; } /* diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 3ac1a3aa8939bc..b909e593c0f1bc 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1272,8 +1272,6 @@ static int devid_cmp(void *priv, const struct list_head *a, int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, blk_mode_t flags, void *holder) { - int ret; - lockdep_assert_held(&uuid_mutex); /* * The device_list_mutex cannot be taken here in case opening the @@ -1282,14 +1280,11 @@ int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, * We also don't need the lock here as this is called during mount and * exclusion is provided by uuid_mutex */ - if (!fs_devices->is_open) { - list_sort(NULL, &fs_devices->devices, devid_cmp); - ret = open_fs_devices(fs_devices, flags, holder); - if (ret) - return ret; - } - fs_devices->in_use++; - return 0; + ASSERT(fs_devices->in_use); + if (fs_devices->is_open) + return 0; + list_sort(NULL, &fs_devices->devices, devid_cmp); + return open_fs_devices(fs_devices, flags, holder); } void btrfs_release_disk_super(struct btrfs_super_block *super) From patchwork Fri Aug 11 10:08:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350504 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCC7CC04A6A for ; Fri, 11 Aug 2023 10:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235624AbjHKKJr (ORCPT ); Fri, 11 Aug 2023 06:09:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235537AbjHKKJe (ORCPT ); Fri, 11 Aug 2023 06:09:34 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 266993A92; Fri, 11 Aug 2023 03:08:55 -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=/3mbalPz9mWKW7oe8+rjeqpDnnAIwNVoPvEAXzlOmEA=; b=Kf0RESes2SiwxcuhMUwkC1tu/v j57mzaPUQPBQ7b7q/sMXcM1MGS5/6YmCDQb61sx4euJkFn2+q0Xoo3oMoMsHwS5hvZmscyu8MmZrR /xHy/ii6KMuk/xo0tgVYh4xLy5Q95qX65RiajMsGHI3FnoIx92eqnLXLR11rYFf54jSV/J4hnjUZC /PoNo3rx7uOSrIBL+rG8hOmVbE5w6SOVONf4lGLv45WAGDA0dSOvWZBVU0NsM09bD1Jo1myLaf47k 1HGTBLAhzumDV20VF//EZRTKnEY3dLY9gBVYtm5b04D0B2bRjyIMZL6GdE41RQKWbD9/jMwMCKq0g WWJcEvwA==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4a-00A5fP-0Y; Fri, 11 Aug 2023 10:08:48 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 06/17] btrfs: use the super_block as holder when mounting file systems Date: Fri, 11 Aug 2023 12:08:17 +0200 Message-Id: <20230811100828.1897174-7-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org The file system type is not a very useful holder as it doesn't allow us to go back to the actual file system instance. Pass the super_block instead which is useful when passed back to the file system driver. This matches what is done for all other block device based file systems. Signed-off-by: Christoph Hellwig Acked-by: Christian Brauner --- fs/btrfs/super.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 1079a0f541790d..0f7c402fb40349 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -69,8 +69,6 @@ static const struct super_operations btrfs_super_ops; * requested by subvol=/path. That way the callchain is straightforward and we * don't have to play tricks with the mount options and recursive calls to * btrfs_mount. - * - * The new btrfs_root_fs_type also servers as a tag for the bdev_holder. */ static struct file_system_type btrfs_fs_type; static struct file_system_type btrfs_root_fs_type; @@ -1503,8 +1501,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; mutex_lock(&uuid_mutex); - error = btrfs_open_devices(fs_devices, sb_open_mode(flags), - fs_type); + error = btrfs_open_devices(fs_devices, sb_open_mode(flags), s); mutex_unlock(&uuid_mutex); if (error) goto error_deactivate; @@ -1518,7 +1515,7 @@ static struct dentry *btrfs_mount_root(struct file_system_type *fs_type, fs_devices->latest_dev->bdev); shrinker_debugfs_rename(&s->s_shrink, "sb-%s:%s", fs_type->name, s->s_id); - btrfs_sb(s)->bdev_holder = fs_type; + btrfs_sb(s)->bdev_holder = s; error = btrfs_fill_super(s, fs_devices, data); } if (!error) From patchwork Fri Aug 11 10:08:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350505 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24BD1C04A6A for ; Fri, 11 Aug 2023 10:09:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235642AbjHKKJw (ORCPT ); Fri, 11 Aug 2023 06:09:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235591AbjHKKJg (ORCPT ); Fri, 11 Aug 2023 06:09:36 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E1853AA7; Fri, 11 Aug 2023 03:08:57 -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=J1DfUQkx1NNyyXVn86c6of42JBP1co1gWfvL2lWWijU=; b=yCMFxsqUkS8OiyVwDn9KEmfc7Z rFmoMcg8GMQPhofEhx9Enm+G5VFxPlImqTw38zlGAcBUDaOX7du9FynQJKS48kVT+H/4yTI7Fcvpw +EOdT0Rg5jhDAmGhxLkZ+Aya7VUX0ZicbvHFVPskzYM/AuWxsQnfkqQ3or878BKOi2vguqi8gGb7F rt6WieY+VVtZTtfxA/4t1vyqgnCKVfrPYHz9R6aOcedyEGbVzYLKE5D3+JZwNy0xUiByaW+ayrmb6 mQ4IeDrjULIinCbVYeRvZw2usWFBmPsNVwDFC/AXNzWjF9TQnR07MCidWipacLPwbEEZgYTHYe60G r02dFoGA==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4d-00A5hH-03; Fri, 11 Aug 2023 10:08:51 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 07/17] nbd: call blk_mark_disk_dead in nbd_clear_sock_ioctl Date: Fri, 11 Aug 2023 12:08:18 +0200 Message-Id: <20230811100828.1897174-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org nbd_clear_sock_ioctl kills the socket and with that the block device. Instead of just invalidating file system buffers, mark the device as dead, which will also invalidate the buffers as part of the proper shutdown sequence. This also includes invalidating partitions if there are any. Signed-off-by: Christoph Hellwig --- drivers/block/nbd.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 8576d696c7a221..42e0159bb258fa 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1434,12 +1434,10 @@ static int nbd_start_device_ioctl(struct nbd_device *nbd) return ret; } -static void nbd_clear_sock_ioctl(struct nbd_device *nbd, - struct block_device *bdev) +static void nbd_clear_sock_ioctl(struct nbd_device *nbd) { + blk_mark_disk_dead(nbd->disk); nbd_clear_sock(nbd); - __invalidate_device(bdev, true); - nbd_bdev_reset(nbd); if (test_and_clear_bit(NBD_RT_HAS_CONFIG_REF, &nbd->config->runtime_flags)) nbd_config_put(nbd); @@ -1465,7 +1463,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd, case NBD_DISCONNECT: return nbd_disconnect(nbd); case NBD_CLEAR_SOCK: - nbd_clear_sock_ioctl(nbd, bdev); + nbd_clear_sock_ioctl(nbd); return 0; case NBD_SET_SOCK: return nbd_add_socket(nbd, arg, false); From patchwork Fri Aug 11 10:08:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350506 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1921C001DB for ; Fri, 11 Aug 2023 10:10:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235688AbjHKKKG (ORCPT ); Fri, 11 Aug 2023 06:10:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235614AbjHKKJi (ORCPT ); Fri, 11 Aug 2023 06:09:38 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 559B63C02; Fri, 11 Aug 2023 03:09:01 -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=S8LxUOl9S56sj1DsOn3uC49nZqQheJn1S7aYKJA11jg=; b=fkOly2mevOW8hIE5cZNxMEgxAl jN6B8K2TnBXJ8+UG2oXVDPYt/7z8mT1oNY7M4UBN1MAmjJbXwiRZfA5EL4bpbIfJImCXkL9e4jf97 hLKjI/XcUu413tNdv9CaTSwn3136xufGGEn1EAcqtjyVSllB6WhXcecnMFuRjgTxymUbahUSnnACC mcmLMnHD0UdZC53BIV5n2+8XL253m6UyyaBJ4052PplSHfakO56gbBkrYSY3NCztQqTDD7Y9XrazO xGva8bUJGNwe5LUFB9yglCgtfhrX09dLKnDW+Kigzy3CMvtM+rajG/g0gD/Wjr2QlkrpkMQmFsm2t +wPdtZTw==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4g-00A5jn-1A; Fri, 11 Aug 2023 10:08:55 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 08/17] block: simplify the disk_force_media_change interface Date: Fri, 11 Aug 2023 12:08:19 +0200 Message-Id: <20230811100828.1897174-9-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Hard code the events to DISK_EVENT_MEDIA_CHANGE as that is the only useful use case, and drop the superfluous return value. Signed-off-by: Christoph Hellwig --- block/disk-events.c | 15 ++++----------- drivers/block/loop.c | 6 +++--- include/linux/blkdev.h | 2 +- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/block/disk-events.c b/block/disk-events.c index 0cfac464e6d120..6189b819b2352e 100644 --- a/block/disk-events.c +++ b/block/disk-events.c @@ -294,25 +294,18 @@ EXPORT_SYMBOL(disk_check_media_change); * @disk: the disk which will raise the event * @events: the events to raise * - * Generate uevents for the disk. If DISK_EVENT_MEDIA_CHANGE is present, - * attempt to free all dentries and inodes and invalidates all block + * Should be called when the media changes for @disk. Generates a uevent + * and attempts to free all dentries and inodes and invalidates all block * device page cache entries in that case. - * - * Returns %true if DISK_EVENT_MEDIA_CHANGE was raised, or %false if not. */ -bool disk_force_media_change(struct gendisk *disk, unsigned int events) +void disk_force_media_change(struct gendisk *disk) { - disk_event_uevent(disk, events); - - if (!(events & DISK_EVENT_MEDIA_CHANGE)) - return false; - + disk_event_uevent(disk, DISK_EVENT_MEDIA_CHANGE); inc_diskseq(disk); if (__invalidate_device(disk->part0, true)) pr_warn("VFS: busy inodes on changed media %s\n", disk->disk_name); set_bit(GD_NEED_PART_SCAN, &disk->state); - return true; } EXPORT_SYMBOL_GPL(disk_force_media_change); diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 37511d2b2caf7d..705a0effa7d890 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -603,7 +603,7 @@ static int loop_change_fd(struct loop_device *lo, struct block_device *bdev, goto out_err; /* and ... switch */ - disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE); + disk_force_media_change(lo->lo_disk); blk_mq_freeze_queue(lo->lo_queue); mapping_set_gfp_mask(old_file->f_mapping, lo->old_gfp_mask); lo->lo_backing_file = file; @@ -1067,7 +1067,7 @@ static int loop_configure(struct loop_device *lo, blk_mode_t mode, /* suppress uevents while reconfiguring the device */ dev_set_uevent_suppress(disk_to_dev(lo->lo_disk), 1); - disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE); + disk_force_media_change(lo->lo_disk); set_disk_ro(lo->lo_disk, (lo->lo_flags & LO_FLAGS_READ_ONLY) != 0); lo->use_dio = lo->lo_flags & LO_FLAGS_DIRECT_IO; @@ -1171,7 +1171,7 @@ static void __loop_clr_fd(struct loop_device *lo, bool release) if (!release) blk_mq_unfreeze_queue(lo->lo_queue); - disk_force_media_change(lo->lo_disk, DISK_EVENT_MEDIA_CHANGE); + disk_force_media_change(lo->lo_disk); if (lo->lo_flags & LO_FLAGS_PARTSCAN) { int err; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 83262702eea71a..c8eab6effc2267 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -750,7 +750,7 @@ static inline int bdev_read_only(struct block_device *bdev) } bool set_capacity_and_notify(struct gendisk *disk, sector_t size); -bool disk_force_media_change(struct gendisk *disk, unsigned int events); +void disk_force_media_change(struct gendisk *disk); void add_disk_randomness(struct gendisk *disk) __latent_entropy; void rand_initialize_disk(struct gendisk *disk); From patchwork Fri Aug 11 10:08:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350507 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0450EC41513 for ; Fri, 11 Aug 2023 10:10:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235750AbjHKKKS (ORCPT ); Fri, 11 Aug 2023 06:10:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233288AbjHKKJl (ORCPT ); Fri, 11 Aug 2023 06:09:41 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D49B3C1E; Fri, 11 Aug 2023 03:09:03 -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=h0y45HSXMdqvAsXX+rWjCQySRpy/tzHE4F4xXnA9hUA=; b=X5N6D2RuIJPEACFdN87bByqqvJ nDb/0S8vM5RMj7KWJFBH9dRSEsy+APYfjAaTiF6M2sAxWoDhHeidLglhhFrGZQwKudhJzKh19bAbd DE+hk+Eip05VhTLNh4lGjQknDZ0/AAiyQ/qHcWLyq5iXy33xKctf765bORgQbXrlvINF4pSJ9VBf5 NOGbB5cuTGjmnp/c7b/YhDRHoi0oXqApTNi5I7eH9V9mk+dChbywou7rWIlB4B3k5JiGaNc4lqRIj qA/FAhDmCNpvgUae10Rjh/aNeh9jff95JVbPEU9KGhX81wE39DgChRpEqCmS7PgLY8tB3rEunaLAA jlXANyXg==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4k-00A5lf-03; Fri, 11 Aug 2023 10:08:58 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 09/17] floppy: call disk_force_media_change when changing the format Date: Fri, 11 Aug 2023 12:08:20 +0200 Message-Id: <20230811100828.1897174-10-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org While changing the format of a floppy isn't strictly speaking a media change, the effects are the same in that the content of the media changes and the diskseq should be increased and uevent should be sent. Switch from calling __invalidate_device to disk_force_media_change to do so. Signed-off-by: Christoph Hellwig --- drivers/block/floppy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 2db9b186b977ac..ea4eb88a2e45f4 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -3255,7 +3255,7 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g, if (!disk || ITYPE(drive_state[cnt].fd_device) != type) continue; - __invalidate_device(disk->part0, true); + disk_force_media_change(disk); } mutex_unlock(&open_lock); } else { From patchwork Fri Aug 11 10:08:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350508 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB461C41513 for ; Fri, 11 Aug 2023 10:10:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234980AbjHKKKg (ORCPT ); Fri, 11 Aug 2023 06:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233965AbjHKKKO (ORCPT ); Fri, 11 Aug 2023 06:10:14 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0E2330EC; Fri, 11 Aug 2023 03:09:20 -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=sF7/TLAdvGX6cavT8VuEoUUpVOqcLET0XfQb1xeL0Nw=; b=UCL+x9QG32FS+rhJbyMhi+/7BI pwDlHyybaxOCwwWqEiFMPVBNHFZeJBqaAwqNejCegVzyecx6tc9ySNjKWcO4z9faDK62iUZdEAG92 O0byl8R9U9DO/sDMANpqYnIOjofkj88tIwTlBiw5GOiz58QuvPsWSQaw4+K4EEER553egvEWGz6yj C5tYAvvdB/qekhXR9UmRdfHPWIZUTA/Y6zwP1PKTJ3GVc6U/3wIdpUMiUKzBK001ICAg5yJnDlp8v dS7G9KViqIPcJSoosia71E04M94EtuD+UgLsefFdXt07ze6NRePr4uaLkbHud4BpYeZGm6OT48+gn oYBYUFPw==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4n-00A5mu-2B; Fri, 11 Aug 2023 10:09:02 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 10/17] amiflop: don't call fsync_bdev in FDFMTBEG Date: Fri, 11 Aug 2023 12:08:21 +0200 Message-Id: <20230811100828.1897174-11-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org FDFMTBEG is used by fdformat to calibrate before formatting a disk. Neither the atari nor PC floppy driver sync data, which also seems a bit pointless for a disk hat is about to get formatted. Signed-off-by: Christoph Hellwig --- drivers/block/amiflop.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index e460c9799d9f35..2b98114a9fe092 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1547,7 +1547,6 @@ static int fd_locked_ioctl(struct block_device *bdev, blk_mode_t mode, rel_fdc(); return -EBUSY; } - fsync_bdev(bdev); if (fd_motor_on(drive) == 0) { rel_fdc(); return -ENODEV; From patchwork Fri Aug 11 10:08:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350510 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ACFEFC05051 for ; Fri, 11 Aug 2023 10:10:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbjHKKKj (ORCPT ); Fri, 11 Aug 2023 06:10:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235630AbjHKKKW (ORCPT ); Fri, 11 Aug 2023 06:10:22 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D280130F8; Fri, 11 Aug 2023 03:09:32 -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=XS+CdlPa8tKa487hp4Qha77KSBNKRcJ6rt1gq/j585k=; b=y6q/GXfKNrc73CmPgU/0v1vaSD SgeQHi6ZEDzl4EF/bA0PYph5ooOTx19V22p8u0lTU84Qnt5NuMAcM6YjznaBMV174hVHA4hQg7pvS GHJz+iVCNNxrK1ELvgpjMTWO7ukfMaMmfSt+ABJ5kI8KP3zABhHMV4zpj9lNfhC1Hgh+x3yHH3Vet 0F9ZWA/AKMM3KO77xZeTiszWznPsWQFQZ8sIobkGxhNMwlwOZB5QaJe9+UAjHlcXuw1lhztJDbWGn BhkcIlhZanc68c/eFzRo5+TlVzk+CdHgc8yK4+Fw8onNsG5QR6iq7LD1Ij9KZCUDUy70FxtE5hj6i Ii5UDasg==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4q-00A5o2-2G; Fri, 11 Aug 2023 10:09:05 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 11/17] dasd: also call __invalidate_device when setting the device offline Date: Fri, 11 Aug 2023 12:08:22 +0200 Message-Id: <20230811100828.1897174-12-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Don't just write out the data, but also invalidate all caches when setting the device offline. Stop canceling the offlining when writeback fails as there is no way to recover from that anyway. Signed-off-by: Christoph Hellwig --- drivers/s390/block/dasd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index edcbf77852c31f..675b38ad00dc9e 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -3627,9 +3627,8 @@ int dasd_generic_set_offline(struct ccw_device *cdev) * empty */ if (device->block) { - rc = fsync_bdev(device->block->bdev); - if (rc != 0) - goto interrupted; + fsync_bdev(device->block->bdev); + __invalidate_device(device->block->bdev, true); } dasd_schedule_device_bh(device); rc = wait_event_interruptible(shutdown_waitq, From patchwork Fri Aug 11 10:08:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350509 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1419C04FE1 for ; Fri, 11 Aug 2023 10:10:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235768AbjHKKKh (ORCPT ); Fri, 11 Aug 2023 06:10:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjHKKKX (ORCPT ); Fri, 11 Aug 2023 06:10:23 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36554448B; Fri, 11 Aug 2023 03:09:33 -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=Y0aq5oBkHJsvXg0ECqI6wIhwCUIqs6QSxIJwZB5Tg0o=; b=FjkKB5xIPgNLh//E/xqOQFA45R VSP+UeoBUaF9btYuhIjqqy0u83JMqFCgg2weFALy38TtLThLceZzvbP2t1wBtMyf+55MYxNQ8Eveb AwIwn3qFWLzfz1VCe4o3ExmAAqa/gCJXcK2iawdvzkOzL6+sj9fCAgBnQD2KMMOakDHVl8WlKE5n4 KhykANnyuCdYsCm/vVwFGpBxVvS0hBxd6gSfLKBj2S7UCxjoiJoJHJDO3t7lYe7SEhgS8mpQ/HW2k UUQ7EeGntgFYboYtc1SGDh4rcpg9343vfuLbK4jJQtSTD0mWNyfKSD59b14AYGOcMBMmiV5pe6Ps/ 34ePRnBw==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4t-00A5p2-20; Fri, 11 Aug 2023 10:09:08 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 12/17] block: drop the "busy inodes on changed media" log message Date: Fri, 11 Aug 2023 12:08:23 +0200 Message-Id: <20230811100828.1897174-13-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This message isn't exactly helpful, and file systems already print way more useful messages when shut down while active. Signed-off-by: Christoph Hellwig --- block/disk-events.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/block/disk-events.c b/block/disk-events.c index 6189b819b2352e..6b858d3504772c 100644 --- a/block/disk-events.c +++ b/block/disk-events.c @@ -281,9 +281,7 @@ bool disk_check_media_change(struct gendisk *disk) if (!(events & DISK_EVENT_MEDIA_CHANGE)) return false; - if (__invalidate_device(disk->part0, true)) - pr_warn("VFS: busy inodes on changed media %s\n", - disk->disk_name); + __invalidate_device(disk->part0, true); set_bit(GD_NEED_PART_SCAN, &disk->state); return true; } @@ -302,9 +300,7 @@ void disk_force_media_change(struct gendisk *disk) { disk_event_uevent(disk, DISK_EVENT_MEDIA_CHANGE); inc_diskseq(disk); - if (__invalidate_device(disk->part0, true)) - pr_warn("VFS: busy inodes on changed media %s\n", - disk->disk_name); + __invalidate_device(disk->part0, true); set_bit(GD_NEED_PART_SCAN, &disk->state); } EXPORT_SYMBOL_GPL(disk_force_media_change); From patchwork Fri Aug 11 10:08:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350511 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AB7BC41513 for ; Fri, 11 Aug 2023 10:10:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235540AbjHKKKl (ORCPT ); Fri, 11 Aug 2023 06:10:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234232AbjHKKK1 (ORCPT ); Fri, 11 Aug 2023 06:10:27 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7724358B; Fri, 11 Aug 2023 03:09:36 -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=+8xr8Uhs6dKUcdwdPIFHHTcFEebNaXGmRTj5PR71d4Y=; b=X5IwFNopQ+BITsDb7BAJK37Ih+ Jjl45uX9ftcnsd2BKUz7laOS2LsrzQ9eMC66blIe172pZE0faykKkz4x5679T8o7GvCkdu7i/0ZGP oM6Evvv2Eywjm0Gxn5veNmDx+2JQ380ATpG6CeZ28s2UBbcKophCJdH9kkQRlbSdPO7jHiKsORDWk FQtyAAevuv7vwh+DYeO/IefDMMSSk/xX//PP1IpHTGKczbi/4sMG3ic1CbkfkHPvxjUzoj4WJEnrJ EO5NTy4eNtS1xWxnRgibKR5Vsnxi08yezeHccikg3zdOJrur4qaWlzD4SJ+Ux3C+lmdc51b+g0s3F Nkdvl/mA==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4w-00A5q3-26; Fri, 11 Aug 2023 10:09:11 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 13/17] block: consolidate __invalidate_device and fsync_bdev Date: Fri, 11 Aug 2023 12:08:24 +0200 Message-Id: <20230811100828.1897174-14-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org We currently have two interfaces that take a block_devices and the find a mounted file systems to flush or invaldidate data on it. Both are a bit problematic because they only work for the "main" block devices that is used as s_dev for the super_block, and because they don't call into the file system at all. Merge the two into a new bdev_mark_dead helper that does both the syncing and invalidation and which is properly documented. This is in preparation of merging the functionality into the ->mark_dead holder operation so that it will work on additional block devices used by a file systems and give us a single entry point for invalidation of dead devices or media. Note that a single standalone fsync_bdev call for an obscure ioctl remains for now, but that one will also be deal with in a bit. Signed-off-by: Christoph Hellwig --- block/bdev.c | 33 ++++++++++++++++++++++++++++----- block/disk-events.c | 4 ++-- block/genhd.c | 3 +-- block/partitions/core.c | 5 +---- drivers/s390/block/dasd.c | 6 ++---- fs/super.c | 4 ++-- include/linux/blkdev.h | 2 +- 7 files changed, 37 insertions(+), 20 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 979e28a46b988e..b9ca947bd5e405 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -221,7 +221,6 @@ int fsync_bdev(struct block_device *bdev) } return sync_blockdev(bdev); } -EXPORT_SYMBOL(fsync_bdev); /** * freeze_bdev - lock a filesystem and force it into a consistent state @@ -960,12 +959,27 @@ int lookup_bdev(const char *pathname, dev_t *dev) } EXPORT_SYMBOL(lookup_bdev); -int __invalidate_device(struct block_device *bdev, bool kill_dirty) +/** + * bdev_mark_dead - mark a block device as dead + * @bdev: block device to operate on + * @surprise: indicate a surprise removal + * + * Tell the file system that this devices or media is dead. If @surprise is set + * to %true the device or media is already gone, if not we are preparing for an + * orderly removal. + * + * This syncs out all dirty data and writes back inodes and then invalidates any + * cached data in the inodes on the file system, the inodes themselves and the + * block device mapping. + */ +void bdev_mark_dead(struct block_device *bdev, bool surprise) { struct super_block *sb = get_super(bdev); int res = 0; if (sb) { + if (!surprise) + sync_filesystem(sb); /* * no need to lock the super, get_super holds the * read mutex so the filesystem cannot go away @@ -973,13 +987,22 @@ int __invalidate_device(struct block_device *bdev, bool kill_dirty) * hold). */ shrink_dcache_sb(sb); - res = invalidate_inodes(sb, kill_dirty); + res = invalidate_inodes(sb, true); drop_super(sb); + } else { + if (!surprise) + sync_blockdev(bdev); } invalidate_bdev(bdev); - return res; } -EXPORT_SYMBOL(__invalidate_device); +#ifdef CONFIG_DASD +/* + * Drivers should not use this directly, but the DASD driver has historically + * had a shutdown to offline mode that doesn't actually remove the gendisk + * that otherwise looks a lot like a safe device removal. + */ +EXPORT_SYMBOL_GPL(bdev_mark_dead); +#endif void sync_bdevs(bool wait) { diff --git a/block/disk-events.c b/block/disk-events.c index 6b858d3504772c..422db8292d0997 100644 --- a/block/disk-events.c +++ b/block/disk-events.c @@ -281,7 +281,7 @@ bool disk_check_media_change(struct gendisk *disk) if (!(events & DISK_EVENT_MEDIA_CHANGE)) return false; - __invalidate_device(disk->part0, true); + bdev_mark_dead(disk->part0, true); set_bit(GD_NEED_PART_SCAN, &disk->state); return true; } @@ -300,7 +300,7 @@ void disk_force_media_change(struct gendisk *disk) { disk_event_uevent(disk, DISK_EVENT_MEDIA_CHANGE); inc_diskseq(disk); - __invalidate_device(disk->part0, true); + bdev_mark_dead(disk->part0, true); set_bit(GD_NEED_PART_SCAN, &disk->state); } EXPORT_SYMBOL_GPL(disk_force_media_change); diff --git a/block/genhd.c b/block/genhd.c index 3d287b32d50dfd..afc2cb09eb94b9 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -647,8 +647,7 @@ void del_gendisk(struct gendisk *disk) mutex_lock(&disk->open_mutex); xa_for_each(&disk->part_tbl, idx, part) { remove_inode_hash(part->bd_inode); - fsync_bdev(part); - __invalidate_device(part, true); + bdev_mark_dead(part, false); } mutex_unlock(&disk->open_mutex); diff --git a/block/partitions/core.c b/block/partitions/core.c index 13a7341299a913..e137a87f4db0d3 100644 --- a/block/partitions/core.c +++ b/block/partitions/core.c @@ -281,10 +281,7 @@ static void delete_partition(struct block_device *part) * looked up any more even when openers still hold references. */ remove_inode_hash(part->bd_inode); - - fsync_bdev(part); - __invalidate_device(part, true); - + bdev_mark_dead(part, false); drop_partition(part); } diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c index 675b38ad00dc9e..1f642be840c3ef 100644 --- a/drivers/s390/block/dasd.c +++ b/drivers/s390/block/dasd.c @@ -3626,10 +3626,8 @@ int dasd_generic_set_offline(struct ccw_device *cdev) * so sync bdev first and then wait for our queues to become * empty */ - if (device->block) { - fsync_bdev(device->block->bdev); - __invalidate_device(device->block->bdev, true); - } + if (device->block) + bdev_mark_dead(device->block->bdev, false); dasd_schedule_device_bh(device); rc = wait_event_interruptible(shutdown_waitq, _wait_for_empty_queues(device)); diff --git a/fs/super.c b/fs/super.c index 71fe297a7e90a9..bbce0fdebf7e52 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1359,7 +1359,7 @@ int get_tree_bdev(struct fs_context *fc, /* * We drop s_umount here because we need to open the bdev and * bdev->open_mutex ranks above s_umount (blkdev_put() -> - * __invalidate_device()). It is safe because we have active sb + * bdev_mark_dead()). It is safe because we have active sb * reference and SB_BORN is not set yet. */ up_write(&s->s_umount); @@ -1411,7 +1411,7 @@ struct dentry *mount_bdev(struct file_system_type *fs_type, /* * We drop s_umount here because we need to open the bdev and * bdev->open_mutex ranks above s_umount (blkdev_put() -> - * __invalidate_device()). It is safe because we have active sb + * bdev_mark_dead()). It is safe because we have active sb * reference and SB_BORN is not set yet. */ up_write(&s->s_umount); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index c8eab6effc2267..6721595b9f9741 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -751,6 +751,7 @@ static inline int bdev_read_only(struct block_device *bdev) bool set_capacity_and_notify(struct gendisk *disk, sector_t size); void disk_force_media_change(struct gendisk *disk); +void bdev_mark_dead(struct block_device *bdev, bool surprise); void add_disk_randomness(struct gendisk *disk) __latent_entropy; void rand_initialize_disk(struct gendisk *disk); @@ -809,7 +810,6 @@ int __register_blkdev(unsigned int major, const char *name, void unregister_blkdev(unsigned int major, const char *name); bool disk_check_media_change(struct gendisk *disk); -int __invalidate_device(struct block_device *bdev, bool kill_dirty); void set_capacity(struct gendisk *disk, sector_t size); #ifdef CONFIG_BLOCK_HOLDER_DEPRECATED From patchwork Fri Aug 11 10:08:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350512 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DAC86C001DB for ; Fri, 11 Aug 2023 10:10:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235588AbjHKKKu (ORCPT ); Fri, 11 Aug 2023 06:10:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235648AbjHKKK1 (ORCPT ); Fri, 11 Aug 2023 06:10:27 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B465E3593; Fri, 11 Aug 2023 03:09:37 -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=A5NrYQQ+iDMl8ZujZTgThEgOwqRi6PntDgVI1EiuCVQ=; b=sfWTgv2BPWYvzMM/4il9y74Drn EHJp9clvtdEHtpYQjRzvEt9SAR3ejMLE116/CrVtxPVVX4j81JwwyU6hY7YK1TIBx3ebMSMOCSBb9 RUxA9sjtCVeiw1QTdIy4VqMdApdC4657OyxiNyenzMOxg6jc7L2IsBOr1xgS/En+7D6gemUIEVkCX gDtUxh+7FW6q9H1hdenUSP7mACWFvzfVQbX+yLJkxJyfV5nQqAKmbeBTLQJgxt+EnLnU2rCxE769S IU8r4+8REAtchqaTjbaKmjDZsJ/Q+pNqWE4qWSEA63JPeLQW2oIIAzeooxj2G++rfBkCGB9sw4Q4S YnAVAUOw==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP4z-00A5rB-1r; Fri, 11 Aug 2023 10:09:14 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 14/17] block: call into the file system for bdev_mark_dead Date: Fri, 11 Aug 2023 12:08:25 +0200 Message-Id: <20230811100828.1897174-15-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org Combine the newly merged bdev_mark_dead helper with the existing mark_dead holder operation so that all operations that invalidate a device that is dead or being removed now go through the holder ops. This allows file systems to explicitly shutdown either ASAP (for a surprise removal) or after writing back data (for an orderly removal), and do so not only for the main device. Signed-off-by: Christoph Hellwig --- block/bdev.c | 30 +++++++++------------------- block/genhd.c | 44 +++++++++++++++++++++++------------------- fs/super.c | 8 ++++++-- include/linux/blkdev.h | 2 +- 4 files changed, 40 insertions(+), 44 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index b9ca947bd5e405..658d5dd62cac0a 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -968,31 +968,19 @@ EXPORT_SYMBOL(lookup_bdev); * to %true the device or media is already gone, if not we are preparing for an * orderly removal. * - * This syncs out all dirty data and writes back inodes and then invalidates any - * cached data in the inodes on the file system, the inodes themselves and the - * block device mapping. + * This calls into the file system, which then typicall syncs out all dirty data + * and writes back inodes and then invalidates any cached data in the inodes on + * the file system. In addition we also invalidate the block device mapping. */ void bdev_mark_dead(struct block_device *bdev, bool surprise) { - struct super_block *sb = get_super(bdev); - int res = 0; + mutex_lock(&bdev->bd_holder_lock); + if (bdev->bd_holder_ops && bdev->bd_holder_ops->mark_dead) + bdev->bd_holder_ops->mark_dead(bdev, surprise); + else + sync_blockdev(bdev); + mutex_unlock(&bdev->bd_holder_lock); - if (sb) { - if (!surprise) - sync_filesystem(sb); - /* - * no need to lock the super, get_super holds the - * read mutex so the filesystem cannot go away - * under us (->put_super runs with the write lock - * hold). - */ - shrink_dcache_sb(sb); - res = invalidate_inodes(sb, true); - drop_super(sb); - } else { - if (!surprise) - sync_blockdev(bdev); - } invalidate_bdev(bdev); } #ifdef CONFIG_DASD diff --git a/block/genhd.c b/block/genhd.c index afc2cb09eb94b9..cc32a0c704eb84 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -554,7 +554,7 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk, } EXPORT_SYMBOL(device_add_disk); -static void blk_report_disk_dead(struct gendisk *disk) +static void blk_report_disk_dead(struct gendisk *disk, bool surprise) { struct block_device *bdev; unsigned long idx; @@ -565,10 +565,7 @@ static void blk_report_disk_dead(struct gendisk *disk) continue; rcu_read_unlock(); - mutex_lock(&bdev->bd_holder_lock); - if (bdev->bd_holder_ops && bdev->bd_holder_ops->mark_dead) - bdev->bd_holder_ops->mark_dead(bdev); - mutex_unlock(&bdev->bd_holder_lock); + bdev_mark_dead(bdev, surprise); put_device(&bdev->bd_device); rcu_read_lock(); @@ -576,14 +573,7 @@ static void blk_report_disk_dead(struct gendisk *disk) rcu_read_unlock(); } -/** - * blk_mark_disk_dead - mark a disk as dead - * @disk: disk to mark as dead - * - * Mark as disk as dead (e.g. surprise removed) and don't accept any new I/O - * to this disk. - */ -void blk_mark_disk_dead(struct gendisk *disk) +static void __blk_mark_disk_dead(struct gendisk *disk) { /* * Fail any new I/O. @@ -603,8 +593,19 @@ void blk_mark_disk_dead(struct gendisk *disk) * Prevent new I/O from crossing bio_queue_enter(). */ blk_queue_start_drain(disk->queue); +} - blk_report_disk_dead(disk); +/** + * blk_mark_disk_dead - mark a disk as dead + * @disk: disk to mark as dead + * + * Mark as disk as dead (e.g. surprise removed) and don't accept any new I/O + * to this disk. + */ +void blk_mark_disk_dead(struct gendisk *disk) +{ + __blk_mark_disk_dead(disk); + blk_report_disk_dead(disk, true); } EXPORT_SYMBOL_GPL(blk_mark_disk_dead); @@ -641,17 +642,20 @@ void del_gendisk(struct gendisk *disk) disk_del_events(disk); /* - * Prevent new openers by unlinked the bdev inode, and write out - * dirty data before marking the disk dead and stopping all I/O. + * Prevent new openers by unlinked the bdev inode. */ mutex_lock(&disk->open_mutex); - xa_for_each(&disk->part_tbl, idx, part) { + xa_for_each(&disk->part_tbl, idx, part) remove_inode_hash(part->bd_inode); - bdev_mark_dead(part, false); - } mutex_unlock(&disk->open_mutex); - blk_mark_disk_dead(disk); + /* + * Tell the file system to write back all dirty data and shut down if + * it hasn't been notified earlier. + */ + if (!test_bit(GD_DEAD, &disk->state)) + blk_report_disk_dead(disk, false); + __blk_mark_disk_dead(disk); /* * Drop all partitions now that the disk is marked dead. diff --git a/fs/super.c b/fs/super.c index bbce0fdebf7e52..94d41040584f7b 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1228,7 +1228,7 @@ static bool lock_active_super(struct super_block *sb) return true; } -static void fs_mark_dead(struct block_device *bdev) +static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise) { struct super_block *sb = bdev->bd_holder; @@ -1238,6 +1238,10 @@ static void fs_mark_dead(struct block_device *bdev) if (!lock_active_super(sb)) return; + if (!surprise) + sync_filesystem(sb); + shrink_dcache_sb(sb); + invalidate_inodes(sb, true); if (sb->s_op->shutdown) sb->s_op->shutdown(sb); @@ -1245,7 +1249,7 @@ static void fs_mark_dead(struct block_device *bdev) } const struct blk_holder_ops fs_holder_ops = { - .mark_dead = fs_mark_dead, + .mark_dead = fs_bdev_mark_dead, }; EXPORT_SYMBOL_GPL(fs_holder_ops); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 6721595b9f9741..cdd03c612d3957 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1461,7 +1461,7 @@ void blkdev_show(struct seq_file *seqf, off_t offset); #endif struct blk_holder_ops { - void (*mark_dead)(struct block_device *bdev); + void (*mark_dead)(struct block_device *bdev, bool surprise); }; extern const struct blk_holder_ops fs_holder_ops; From patchwork Fri Aug 11 10:08:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350513 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 747A0C41513 for ; Fri, 11 Aug 2023 10:10:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235627AbjHKKKw (ORCPT ); Fri, 11 Aug 2023 06:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235606AbjHKKK3 (ORCPT ); Fri, 11 Aug 2023 06:10:29 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC36135A2; Fri, 11 Aug 2023 03:09:40 -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=9yuZPRRL/ewc+JozXfI5eRa3tyH81wiISTS4rS7GMcU=; b=2/Wahet/Y/OHfF09ISjohM82rq GjyGfQpYQdVF5upjim+IxKYqzit/TZaED5StXGuAeRHLHO7ILQ4YTOIDaLu6kOZDbVULgJKI65xCK BK7rk2gnpvb9QhrBS+PpwqhbFryAFJgMuHvRmat8AeQkLiCnegfVFW0TfPWhd0nGxbXycXSCWIBwj k6dofYme8Jorw+PVoEH4pffGm8vb7Ej3bdeLLV8IKFBqyiT5NJINWeWirzH/4VVJMqEneceCJufMM yUypVCK6aLvP7xayAGW8PXP5i0Dsv2abDaHYq54XuqOVFc0zRf3WZtaERA3y0rq6Kt103tMChpzNF YUvN4U7w==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP52-00A5sO-1J; Fri, 11 Aug 2023 10:09:16 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 15/17] block: call into the file system for ioctl BLKFLSBUF Date: Fri, 11 Aug 2023 12:08:26 +0200 Message-Id: <20230811100828.1897174-16-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org BLKFLSBUF is a historic ioctl that is called on a file handle to a block device and syncs either the file system mounted on that block device if there is one, or otherwise the just the data on the block device. Replace the get_super based syncing with a holder operation to remove the last usage of get_super, and to also support syncing the file system if the block device is not the main block device stored in s_dev. Signed-off-by: Christoph Hellwig --- block/bdev.c | 16 ---------------- block/ioctl.c | 9 ++++++++- fs/super.c | 13 +++++++++++++ include/linux/blkdev.h | 7 +++++-- 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 658d5dd62cac0a..2a035be7f3ee90 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -206,22 +206,6 @@ int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend) } EXPORT_SYMBOL(sync_blockdev_range); -/* - * Write out and wait upon all dirty data associated with this - * device. Filesystem data as well as the underlying block - * device. Takes the superblock lock. - */ -int fsync_bdev(struct block_device *bdev) -{ - struct super_block *sb = get_super(bdev); - if (sb) { - int res = sync_filesystem(sb); - drop_super(sb); - return res; - } - return sync_blockdev(bdev); -} - /** * freeze_bdev - lock a filesystem and force it into a consistent state * @bdev: blockdevice to lock diff --git a/block/ioctl.c b/block/ioctl.c index 3be11941fb2ddc..648670ddb164a0 100644 --- a/block/ioctl.c +++ b/block/ioctl.c @@ -364,7 +364,14 @@ static int blkdev_flushbuf(struct block_device *bdev, unsigned cmd, { if (!capable(CAP_SYS_ADMIN)) return -EACCES; - fsync_bdev(bdev); + + mutex_lock(&bdev->bd_holder_lock); + if (bdev->bd_holder_ops && bdev->bd_holder_ops->sync) + bdev->bd_holder_ops->sync(bdev); + else + sync_blockdev(bdev); + mutex_unlock(&bdev->bd_holder_lock); + invalidate_bdev(bdev); return 0; } diff --git a/fs/super.c b/fs/super.c index 94d41040584f7b..714dbae58b5e8e 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1248,8 +1248,21 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise) up_read(&sb->s_umount); } +static void fs_bdev_sync(struct block_device *bdev) +{ + struct super_block *sb = bdev->bd_holder; + + lockdep_assert_held(&bdev->bd_holder_lock); + + if (!lock_active_super(sb)) + return; + sync_filesystem(sb); + up_read(&sb->s_umount); +} + const struct blk_holder_ops fs_holder_ops = { .mark_dead = fs_bdev_mark_dead, + .sync = fs_bdev_sync, }; EXPORT_SYMBOL_GPL(fs_holder_ops); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index cdd03c612d3957..fa462d48ee9640 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1462,6 +1462,11 @@ void blkdev_show(struct seq_file *seqf, off_t offset); struct blk_holder_ops { void (*mark_dead)(struct block_device *bdev, bool surprise); + + /* + * Sync the file system mounted on the block device. + */ + void (*sync)(struct block_device *bdev); }; extern const struct blk_holder_ops fs_holder_ops; @@ -1524,8 +1529,6 @@ static inline int early_lookup_bdev(const char *pathname, dev_t *dev) } #endif /* CONFIG_BLOCK */ -int fsync_bdev(struct block_device *bdev); - int freeze_bdev(struct block_device *bdev); int thaw_bdev(struct block_device *bdev); From patchwork Fri Aug 11 10:08:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350514 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8190FC001DB for ; Fri, 11 Aug 2023 10:11:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235658AbjHKKLA (ORCPT ); Fri, 11 Aug 2023 06:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235659AbjHKKK3 (ORCPT ); Fri, 11 Aug 2023 06:10:29 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 329F835A9; Fri, 11 Aug 2023 03:09:43 -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=FTSIEgUybviHzlYdK9QZpWvtnyUm2/Yw6t7t+195RbU=; b=DHgQwyDJFKuZfEj0aczO0zgWUA IxGXygEcWVaJT3P4880ccMLLdVQ9HYI3u6Stmh3O0R05FG4olVGK6AQXnq6lJqu0vMpQdG3SXG33k kwFmJcooSX0d23Dy7shGkCujG1i2A/QM2D3vp2PG5NCQO+jP8Vpa7vLkF3Q6XXzdPZIBTX8oz6fmp OTWTZvr1hY9zyoAeOQ9NgyEKN5pTi7NSq6+DWVl4Z8Imc7Z9TekL0XUR74wfnqiUHBO6m9MKge8Pb +6lUymIPqXX+P0/3w+PQbJOCEeJiERGTyw6HvepoFvhefKyjxB39D3KG6+fbSgBWgob/64MMV/Ynh 59OmrZsw==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP55-00A5tR-15; Fri, 11 Aug 2023 10:09:19 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 16/17] fs: remove get_super Date: Fri, 11 Aug 2023 12:08:27 +0200 Message-Id: <20230811100828.1897174-17-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org get_super is unused now, remove it. Signed-off-by: Christoph Hellwig Reviewed-by: Christian Brauner --- fs/super.c | 37 ------------------------------------- include/linux/fs.h | 1 - 2 files changed, 38 deletions(-) diff --git a/fs/super.c b/fs/super.c index 714dbae58b5e8e..d3d27ff009d5f6 100644 --- a/fs/super.c +++ b/fs/super.c @@ -808,43 +808,6 @@ void iterate_supers_type(struct file_system_type *type, EXPORT_SYMBOL(iterate_supers_type); -/** - * get_super - get the superblock of a device - * @bdev: device to get the superblock for - * - * Scans the superblock list and finds the superblock of the file system - * mounted on the device given. %NULL is returned if no match is found. - */ -struct super_block *get_super(struct block_device *bdev) -{ - struct super_block *sb; - - if (!bdev) - return NULL; - - spin_lock(&sb_lock); -rescan: - list_for_each_entry(sb, &super_blocks, s_list) { - if (hlist_unhashed(&sb->s_instances)) - continue; - if (sb->s_bdev == bdev) { - sb->s_count++; - spin_unlock(&sb_lock); - down_read(&sb->s_umount); - /* still alive? */ - if (sb->s_root && (sb->s_flags & SB_BORN)) - return sb; - up_read(&sb->s_umount); - /* nope, got unmounted */ - spin_lock(&sb_lock); - __put_super(sb); - goto rescan; - } - } - spin_unlock(&sb_lock); - return NULL; -} - /** * get_active_super - get an active reference to the superblock of a device * @bdev: device to get the superblock for diff --git a/include/linux/fs.h b/include/linux/fs.h index 6867512907d6e5..14b5777a24a0b2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2913,7 +2913,6 @@ extern int vfs_readlink(struct dentry *, char __user *, int); extern struct file_system_type *get_filesystem(struct file_system_type *fs); extern void put_filesystem(struct file_system_type *fs); extern struct file_system_type *get_fs_type(const char *name); -extern struct super_block *get_super(struct block_device *); extern struct super_block *get_active_super(struct block_device *bdev); extern void drop_super(struct super_block *sb); extern void drop_super_exclusive(struct super_block *sb); From patchwork Fri Aug 11 10:08:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13350515 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A69DEC0015E for ; Fri, 11 Aug 2023 10:11:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235675AbjHKKLB (ORCPT ); Fri, 11 Aug 2023 06:11:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235670AbjHKKKb (ORCPT ); Fri, 11 Aug 2023 06:10:31 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDD7935BC; Fri, 11 Aug 2023 03:09:46 -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=TfXf3rA/PGmh51lRw9XZCTKP64O/GfZ4zbLGJbB3SHI=; b=MNGF7jGfwxDH36Qic3Fz1xl09l GmgK5zJuj3hVSNHhedykMUuZSoP5/NOMHSjgzzZbc/q87WJKW4TQEU1te8Ja+pUBnNkvgDLQXP6Dm wVT7B6DnAN39z1QOUst8ysCKadJ4AIxRloZbpCKZosjSYZp/yOy9XcdJE6BCB8la+DkR4M+tVfWQt 1VU98T2wUocyuCNOM/6EUJYZMRRvHejA9zEZxxY+k1FfSwfuO2YKjdaG/h8I1j21BJLakfqLBJTew lEnypaUD2w3NshOUPzTBxRXs/dKY0lHyTMTLAyTcJd2WQEMAE2nMywgmpJXDJ1H5CR0qQzltoLuzS YsoZ5aqQ==; Received: from [88.128.92.63] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qUP58-00A5v0-0n; Fri, 11 Aug 2023 10:09:22 +0000 From: Christoph Hellwig To: Al Viro , Christian Brauner Cc: Jens Axboe , Denis Efremov , Josef Bacik , Stefan Haberland , Jan Hoeppner , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , "Darrick J . Wong" , Chris Mason , David Sterba , linux-block@vger.kernel.org, nbd@other.debian.org, linux-s390@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH 17/17] fs: simplify invalidate_inodes Date: Fri, 11 Aug 2023 12:08:28 +0200 Message-Id: <20230811100828.1897174-18-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230811100828.1897174-1-hch@lst.de> References: <20230811100828.1897174-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 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org kill_dirty has always been true for a long time, so hard code it and remove the unused return value. Signed-off-by: Christoph Hellwig Reviewed-by: Christian Brauner --- fs/inode.c | 16 ++-------------- fs/internal.h | 2 +- fs/super.c | 2 +- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 8fefb69e1f84a9..fd67ca46415d50 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -754,14 +754,10 @@ EXPORT_SYMBOL_GPL(evict_inodes); * @sb: superblock to operate on * @kill_dirty: flag to guide handling of dirty inodes * - * Attempts to free all inodes for a given superblock. If there were any - * busy inodes return a non-zero value, else zero. - * If @kill_dirty is set, discard dirty inodes too, otherwise treat - * them as busy. + * Attempts to free all inodes (including dirty inodes) for a given superblock. */ -int invalidate_inodes(struct super_block *sb, bool kill_dirty) +void invalidate_inodes(struct super_block *sb) { - int busy = 0; struct inode *inode, *next; LIST_HEAD(dispose); @@ -773,14 +769,8 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty) spin_unlock(&inode->i_lock); continue; } - if (inode->i_state & I_DIRTY_ALL && !kill_dirty) { - spin_unlock(&inode->i_lock); - busy = 1; - continue; - } if (atomic_read(&inode->i_count)) { spin_unlock(&inode->i_lock); - busy = 1; continue; } @@ -798,8 +788,6 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty) spin_unlock(&sb->s_inode_list_lock); dispose_list(&dispose); - - return busy; } /* diff --git a/fs/internal.h b/fs/internal.h index f7a3dc11102647..b94290f61714a0 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -201,7 +201,7 @@ void lock_two_inodes(struct inode *inode1, struct inode *inode2, * fs-writeback.c */ extern long get_nr_dirty_inodes(void); -extern int invalidate_inodes(struct super_block *, bool); +void invalidate_inodes(struct super_block *sb); /* * dcache.c diff --git a/fs/super.c b/fs/super.c index d3d27ff009d5f6..500c5308f2c8a0 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1204,7 +1204,7 @@ static void fs_bdev_mark_dead(struct block_device *bdev, bool surprise) if (!surprise) sync_filesystem(sb); shrink_dcache_sb(sb); - invalidate_inodes(sb, true); + invalidate_inodes(sb); if (sb->s_op->shutdown) sb->s_op->shutdown(sb);