From patchwork Tue Oct 24 13:01:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434425 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1D33314A84 for ; Tue, 24 Oct 2023 13:06:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="djcYZ/B9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C351C433C8; Tue, 24 Oct 2023 13:06:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152772; bh=V47he2npVP8GSLfUCdp40Hooxnm7f2iCuON82HbGixg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=djcYZ/B9tG5aP2HrQ9TxPeD98nS9EIu9x6HAJDn6EijTyHVeZ0ulpR+czsJtZrQQE djbSHAsMGEX30+Rkt6viWaFMg5sI0N8y6RrrALXinZS8Nq/fj+4vaMCiNm/6PlCP8j gCJme+um+M840a5NJIOpLIWIVjJ1OUJHYmS/fzYqUlP4F7Z5aONUWX5B81SOUk6Rfg HEQ2Pw1/Id49JU/6AZWlWTBTHFtzpGksDWbEN3AAzmc4R9cRIFJ6FFWuTgIVEsif/5 CQ33QcqQMv6cr4dEDCiLnhXD731U9HBUrMPqKVQ0hZ37QcGLGz5UQsC/0lmhjxeis1 y+hVXGIZMpB7w== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:07 +0200 Subject: [PATCH v2 01/10] fs: massage locking helpers Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-1-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=7882; i=brauner@kernel.org; h=from:subject:message-id; bh=V47he2npVP8GSLfUCdp40Hooxnm7f2iCuON82HbGixg=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3RgOSA741jgZiY2wQMWGnqLGSJMrvU8T3s7L+npfdH0 lDeOHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABM5fYbhf9jLCSv9BWvnZjvO/vzjsa j4t6mLWl/sq+5ZpvkvrfsVzzdGhtVS64uWh0ZrOazhXHVqf9Hi919XGGtrurnlXfp2y0XsKBMA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Multiple people have balked at the the fact that super_lock{_shared,_excluse}() return booleans and even if they return false hold s_umount. So let's change them to only hold s_umount when true is returned and change the code accordingly. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- fs/super.c | 105 +++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 61 insertions(+), 44 deletions(-) diff --git a/fs/super.c b/fs/super.c index c7b452e12e4c..9cf3ee50cecd 100644 --- a/fs/super.c +++ b/fs/super.c @@ -105,8 +105,9 @@ static inline bool wait_born(struct super_block *sb) * * The caller must have acquired a temporary reference on @sb->s_count. * - * Return: This returns true if SB_BORN was set, false if SB_DYING was - * set. The function acquires s_umount and returns with it held. + * Return: The function returns true if SB_BORN was set and with + * s_umount held. The function returns false if SB_DYING was + * set and without s_umount held. */ static __must_check bool super_lock(struct super_block *sb, bool excl) { @@ -121,8 +122,10 @@ static __must_check bool super_lock(struct super_block *sb, bool excl) * @sb->s_root is NULL and @sb->s_active is 0. No one needs to * grab a reference to this. Tell them so. */ - if (sb->s_flags & SB_DYING) + if (sb->s_flags & SB_DYING) { + super_unlock(sb, excl); return false; + } /* Has called ->get_tree() successfully. */ if (sb->s_flags & SB_BORN) @@ -140,13 +143,13 @@ static __must_check bool super_lock(struct super_block *sb, bool excl) goto relock; } -/* wait and acquire read-side of @sb->s_umount */ +/* wait and try to acquire read-side of @sb->s_umount */ static inline bool super_lock_shared(struct super_block *sb) { return super_lock(sb, false); } -/* wait and acquire write-side of @sb->s_umount */ +/* wait and try to acquire write-side of @sb->s_umount */ static inline bool super_lock_excl(struct super_block *sb) { return super_lock(sb, true); @@ -532,16 +535,18 @@ EXPORT_SYMBOL(deactivate_super); */ static int grab_super(struct super_block *s) __releases(sb_lock) { - bool born; + bool locked; s->s_count++; spin_unlock(&sb_lock); - born = super_lock_excl(s); - if (born && atomic_inc_not_zero(&s->s_active)) { - put_super(s); - return 1; + locked = super_lock_excl(s); + if (locked) { + if (atomic_inc_not_zero(&s->s_active)) { + put_super(s); + return 1; + } + super_unlock_excl(s); } - super_unlock_excl(s); put_super(s); return 0; } @@ -572,7 +577,6 @@ static inline bool wait_dead(struct super_block *sb) */ static bool grab_super_dead(struct super_block *sb) { - sb->s_count++; if (grab_super(sb)) { put_super(sb); @@ -958,15 +962,17 @@ void iterate_supers(void (*f)(struct super_block *, void *), void *arg) spin_lock(&sb_lock); list_for_each_entry(sb, &super_blocks, s_list) { - bool born; + bool locked; sb->s_count++; spin_unlock(&sb_lock); - born = super_lock_shared(sb); - if (born && sb->s_root) - f(sb, arg); - super_unlock_shared(sb); + locked = super_lock_shared(sb); + if (locked) { + if (sb->s_root) + f(sb, arg); + super_unlock_shared(sb); + } spin_lock(&sb_lock); if (p) @@ -994,15 +1000,17 @@ void iterate_supers_type(struct file_system_type *type, spin_lock(&sb_lock); hlist_for_each_entry(sb, &type->fs_supers, s_instances) { - bool born; + bool locked; sb->s_count++; spin_unlock(&sb_lock); - born = super_lock_shared(sb); - if (born && sb->s_root) - f(sb, arg); - super_unlock_shared(sb); + locked = super_lock_shared(sb); + if (locked) { + if (sb->s_root) + f(sb, arg); + super_unlock_shared(sb); + } spin_lock(&sb_lock); if (p) @@ -1051,15 +1059,17 @@ struct super_block *user_get_super(dev_t dev, bool excl) spin_lock(&sb_lock); list_for_each_entry(sb, &super_blocks, s_list) { if (sb->s_dev == dev) { - bool born; + bool locked; sb->s_count++; spin_unlock(&sb_lock); /* still alive? */ - born = super_lock(sb, excl); - if (born && sb->s_root) - return sb; - super_unlock(sb, excl); + locked = super_lock(sb, excl); + if (locked) { + if (sb->s_root) + return sb; + super_unlock(sb, excl); + } /* nope, got unmounted */ spin_lock(&sb_lock); __put_super(sb); @@ -1170,9 +1180,9 @@ int reconfigure_super(struct fs_context *fc) static void do_emergency_remount_callback(struct super_block *sb) { - bool born = super_lock_excl(sb); + bool locked = super_lock_excl(sb); - if (born && sb->s_root && sb->s_bdev && !sb_rdonly(sb)) { + if (locked && sb->s_root && sb->s_bdev && !sb_rdonly(sb)) { struct fs_context *fc; fc = fs_context_for_reconfigure(sb->s_root, @@ -1183,7 +1193,8 @@ static void do_emergency_remount_callback(struct super_block *sb) put_fs_context(fc); } } - super_unlock_excl(sb); + if (locked) + super_unlock_excl(sb); } static void do_emergency_remount(struct work_struct *work) @@ -1206,16 +1217,17 @@ void emergency_remount(void) static void do_thaw_all_callback(struct super_block *sb) { - bool born = super_lock_excl(sb); + bool locked = super_lock_excl(sb); - if (born && sb->s_root) { + if (locked && sb->s_root) { if (IS_ENABLED(CONFIG_BLOCK)) while (sb->s_bdev && !thaw_bdev(sb->s_bdev)) pr_warn("Emergency Thaw on %pg\n", sb->s_bdev); thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE); - } else { - super_unlock_excl(sb); + return; } + if (locked) + super_unlock_excl(sb); } static void do_thaw_all(struct work_struct *work) @@ -1429,7 +1441,7 @@ static struct super_block *bdev_super_lock_shared(struct block_device *bdev) __releases(&bdev->bd_holder_lock) { struct super_block *sb = bdev->bd_holder; - bool born; + bool locked; lockdep_assert_held(&bdev->bd_holder_lock); lockdep_assert_not_held(&sb->s_umount); @@ -1441,9 +1453,8 @@ static struct super_block *bdev_super_lock_shared(struct block_device *bdev) spin_unlock(&sb_lock); mutex_unlock(&bdev->bd_holder_lock); - born = super_lock_shared(sb); - if (!born || !sb->s_root || !(sb->s_flags & SB_ACTIVE)) { - super_unlock_shared(sb); + locked = super_lock_shared(sb); + if (!locked || !sb->s_root || !(sb->s_flags & SB_ACTIVE)) { put_super(sb); return NULL; } @@ -1959,9 +1970,11 @@ int freeze_super(struct super_block *sb, enum freeze_holder who) { int ret; + if (!super_lock_excl(sb)) { + WARN_ON_ONCE("Dying superblock while freezing!"); + return -EINVAL; + } atomic_inc(&sb->s_active); - if (!super_lock_excl(sb)) - WARN(1, "Dying superblock while freezing!"); retry: if (sb->s_writers.frozen == SB_FREEZE_COMPLETE) { @@ -2009,8 +2022,10 @@ int freeze_super(struct super_block *sb, enum freeze_holder who) /* Release s_umount to preserve sb_start_write -> s_umount ordering */ super_unlock_excl(sb); sb_wait_write(sb, SB_FREEZE_WRITE); - if (!super_lock_excl(sb)) - WARN(1, "Dying superblock while freezing!"); + if (!super_lock_excl(sb)) { + WARN_ON_ONCE("Dying superblock while freezing!"); + return -EINVAL; + } /* Now we go and block page faults... */ sb->s_writers.frozen = SB_FREEZE_PAGEFAULT; @@ -2128,8 +2143,10 @@ static int thaw_super_locked(struct super_block *sb, enum freeze_holder who) */ int thaw_super(struct super_block *sb, enum freeze_holder who) { - if (!super_lock_excl(sb)) - WARN(1, "Dying superblock while thawing!"); + if (!super_lock_excl(sb)) { + WARN_ON_ONCE("Dying superblock while thawing!"); + return -EINVAL; + } return thaw_super_locked(sb, who); } EXPORT_SYMBOL(thaw_super); From patchwork Tue Oct 24 13:01:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434426 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAEE22940B for ; Tue, 24 Oct 2023 13:06:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CJEVdqSq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E009C433CA; Tue, 24 Oct 2023 13:06:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152774; bh=EwFj3PRIGaPqamDxqJaccMckl8OKeAeT8WVjpWKp7zU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CJEVdqSq2Cg/5JBWv7i2SoGmMeNkh9tlXAXiM4We2r7t+GZB8ysnQGZL4kIvBWGF3 r0osNGMQuSvQ9NF9m8mw7xe71bKX5yXleV79a8g4iVl9+8gXcowVQaLs+uhbu1PtR3 rmqB8m6q6nf5H9C/MTupsu0PL5b5aMqH2n1JlG3m3ikJ9hxnXtNEwr4SH+6x7ez7QE BlL2uXfYCeVkU3D3W5E2tXQBoypzKdCLG6z9irhQUiHbdqDcy11ihk33sbjRYtUjO6 /WoTIiBefTuiCMTwQIJh8PVTufnVkgB5QDSRhobSFow/kYRbfMkHIRaraDXdnTq5ZP KMrFIgefMHZww== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:08 +0200 Subject: [PATCH v2 02/10] bdev: rename freeze and thaw helpers Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-2-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=6803; i=brauner@kernel.org; h=from:subject:message-id; bh=EwFj3PRIGaPqamDxqJaccMckl8OKeAeT8WVjpWKp7zU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3TImze/93KOj28iS+70qNVzfye7rbI3qV/CK3/zyUaW 2QZfO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACYiVczIcKozIuSEbUrjQ+uuXz2fmf U6ZS8z8084qfjEu6/31XtdIYb/Sfa5QpM+HStneceRHrn0bHIkE8PHjswpgdOdcqZ4rPzMAQA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 We have bdev_mark_dead() etc and we're going to move block device freezing to holder ops in the next patch. Make the naming consistent: * freeze_bdev() -> bdev_freeze() * thaw_bdev() -> bdev_thaw() Also document the return code. Link: https://lore.kernel.org/r/20230927-vfs-super-freeze-v1-1-ecc36d9ab4d9@kernel.org Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- block/bdev.c | 22 +++++++++++++--------- drivers/md/dm.c | 4 ++-- fs/ext4/ioctl.c | 4 ++-- fs/f2fs/file.c | 4 ++-- fs/super.c | 4 ++-- fs/xfs/xfs_fsops.c | 4 ++-- include/linux/blkdev.h | 4 ++-- 7 files changed, 25 insertions(+), 21 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 2018d250e131..d674ad381c52 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -207,18 +207,20 @@ int sync_blockdev_range(struct block_device *bdev, loff_t lstart, loff_t lend) EXPORT_SYMBOL(sync_blockdev_range); /** - * freeze_bdev - lock a filesystem and force it into a consistent state + * bdev_freeze - lock a filesystem and force it into a consistent state * @bdev: blockdevice to lock * * If a superblock is found on this device, we take the s_umount semaphore * on it to make sure nobody unmounts until the snapshot creation is done. * The reference counter (bd_fsfreeze_count) guarantees that only the last * unfreeze process can unfreeze the frozen filesystem actually when multiple - * freeze requests arrive simultaneously. It counts up in freeze_bdev() and - * count down in thaw_bdev(). When it becomes 0, thaw_bdev() will unfreeze + * freeze requests arrive simultaneously. It counts up in bdev_freeze() and + * count down in bdev_thaw(). When it becomes 0, thaw_bdev() will unfreeze * actually. + * + * Return: On success zero is returned, negative error code on failure. */ -int freeze_bdev(struct block_device *bdev) +int bdev_freeze(struct block_device *bdev) { struct super_block *sb; int error = 0; @@ -248,15 +250,17 @@ int freeze_bdev(struct block_device *bdev) mutex_unlock(&bdev->bd_fsfreeze_mutex); return error; } -EXPORT_SYMBOL(freeze_bdev); +EXPORT_SYMBOL(bdev_freeze); /** - * thaw_bdev - unlock filesystem + * bdev_thaw - unlock filesystem * @bdev: blockdevice to unlock * - * Unlocks the filesystem and marks it writeable again after freeze_bdev(). + * Unlocks the filesystem and marks it writeable again after bdev_freeze(). + * + * Return: On success zero is returned, negative error code on failure. */ -int thaw_bdev(struct block_device *bdev) +int bdev_thaw(struct block_device *bdev) { struct super_block *sb; int error = -EINVAL; @@ -285,7 +289,7 @@ int thaw_bdev(struct block_device *bdev) mutex_unlock(&bdev->bd_fsfreeze_mutex); return error; } -EXPORT_SYMBOL(thaw_bdev); +EXPORT_SYMBOL(bdev_thaw); /* * pseudo-fs diff --git a/drivers/md/dm.c b/drivers/md/dm.c index f7212e8fc27f..c14dc6db0810 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -2650,7 +2650,7 @@ static int lock_fs(struct mapped_device *md) WARN_ON(test_bit(DMF_FROZEN, &md->flags)); - r = freeze_bdev(md->disk->part0); + r = bdev_freeze(md->disk->part0); if (!r) set_bit(DMF_FROZEN, &md->flags); return r; @@ -2660,7 +2660,7 @@ static void unlock_fs(struct mapped_device *md) { if (!test_bit(DMF_FROZEN, &md->flags)) return; - thaw_bdev(md->disk->part0); + bdev_thaw(md->disk->part0); clear_bit(DMF_FROZEN, &md->flags); } diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 0bfe2ce589e2..c1390219c945 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -810,11 +810,11 @@ int ext4_force_shutdown(struct super_block *sb, u32 flags) switch (flags) { case EXT4_GOING_FLAGS_DEFAULT: - ret = freeze_bdev(sb->s_bdev); + ret = bdev_freeze(sb->s_bdev); if (ret) return ret; set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); - thaw_bdev(sb->s_bdev); + bdev_thaw(sb->s_bdev); break; case EXT4_GOING_FLAGS_LOGFLUSH: set_bit(EXT4_FLAGS_SHUTDOWN, &sbi->s_ext4_flags); diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index ca5904129b16..c22aeb9ffb61 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -2239,11 +2239,11 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg) switch (in) { case F2FS_GOING_DOWN_FULLSYNC: - ret = freeze_bdev(sb->s_bdev); + ret = bdev_freeze(sb->s_bdev); if (ret) goto out; f2fs_stop_checkpoint(sbi, false, STOP_CP_REASON_SHUTDOWN); - thaw_bdev(sb->s_bdev); + bdev_thaw(sb->s_bdev); break; case F2FS_GOING_DOWN_METASYNC: /* do checkpoint only */ diff --git a/fs/super.c b/fs/super.c index 9cf3ee50cecd..b224182f2440 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1221,7 +1221,7 @@ static void do_thaw_all_callback(struct super_block *sb) if (locked && sb->s_root) { if (IS_ENABLED(CONFIG_BLOCK)) - while (sb->s_bdev && !thaw_bdev(sb->s_bdev)) + while (sb->s_bdev && !bdev_thaw(sb->s_bdev)) pr_warn("Emergency Thaw on %pg\n", sb->s_bdev); thaw_super_locked(sb, FREEZE_HOLDER_USERSPACE); return; @@ -1529,7 +1529,7 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, /* * Until SB_BORN flag is set, there can be no active superblock * references and thus no filesystem freezing. get_active_super() will - * just loop waiting for SB_BORN so even freeze_bdev() cannot proceed. + * just loop waiting for SB_BORN so even bdev_freeze() cannot proceed. * * It is enough to check bdev was not frozen before we set s_bdev. */ diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index 7cb75cb6b8e9..57076a25f17d 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -482,9 +482,9 @@ xfs_fs_goingdown( { switch (inflags) { case XFS_FSOP_GOING_FLAGS_DEFAULT: { - if (!freeze_bdev(mp->m_super->s_bdev)) { + if (!bdev_freeze(mp->m_super->s_bdev)) { xfs_force_shutdown(mp, SHUTDOWN_FORCE_UMOUNT); - thaw_bdev(mp->m_super->s_bdev); + bdev_thaw(mp->m_super->s_bdev); } break; } diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 51fa7ffdee83..7a3da7f44afb 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1541,8 +1541,8 @@ static inline int early_lookup_bdev(const char *pathname, dev_t *dev) } #endif /* CONFIG_BLOCK */ -int freeze_bdev(struct block_device *bdev); -int thaw_bdev(struct block_device *bdev); +int bdev_freeze(struct block_device *bdev); +int bdev_thaw(struct block_device *bdev); struct io_comp_batch { struct request *req_list; From patchwork Tue Oct 24 13:01:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434427 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D0142940B for ; Tue, 24 Oct 2023 13:06:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="jIGoq9MI" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA854C433CC; Tue, 24 Oct 2023 13:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152776; bh=TkCowelFDovyrB2g0BMhnKJEz3rlU5FTsJL2UGhCl5Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jIGoq9MIC4leT2G63MnFVWZ9loVJbGqYMdnOoW5Uir54hV5cPug3/ys6Mrnlv5szV T2Z/E6aLWIWot4/veBbiMVj6gOyg5oL9FUWdvCe/yYPk1QwVC6HK2EHJ/U7FvSFHE8 6Hn2pZN2xlvv0GeWcsE2AfvSv1wYAQEu+1GdF5zWvxT1hA7r+/MjGenrdP0QlUv/VT kWUDLJQL1n/fuzR6lzVsBlh4jkXf5GqPWENhoWHQNuoguQqCbDpYK93GgBvlu6wYnO RCSU+H73rRMX/hR9LVHEYBhul0uA1qJqUyWAOriwAzv7j9ztfCernw3mza0P4cB1VB PWIa6tS6CHysg== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:09 +0200 Subject: [PATCH v2 03/10] bdev: surface the error from sync_blockdev() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-3-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=810; i=brauner@kernel.org; h=from:subject:message-id; bh=TkCowelFDovyrB2g0BMhnKJEz3rlU5FTsJL2UGhCl5Y=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3TIeql4u0Klfkd4+ZrE6eazLTfclf6kp75zTijrT74S QZMTHaUsDGJcDLJiiiwO7Sbhcst5KjYbZWrAzGFlAhnCwMUpABNZcpbhf4atlnp2w4njAUGvdc3mvA s+p1I+IWntnRsPDToVMu7I9DP80/e7n7s/yrSaie1MiCjrxv8Os5pnqWjM2hsgXrM+/NMOHgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 When freeze_super() is called, sync_filesystem() will be called which calls sync_blockdev() and already surfaces any errors. Do the same for block devices that aren't owned by a superblock and also for filesystems that don't call sync_blockdev() internally but implicitly rely on bdev_freeze() to do it. Signed-off-by: Christian Brauner Reviewed-by: Darrick J. Wong Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- block/bdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bdev.c b/block/bdev.c index d674ad381c52..a3e2af580a73 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -245,7 +245,7 @@ int bdev_freeze(struct block_device *bdev) bdev->bd_fsfreeze_sb = sb; sync: - sync_blockdev(bdev); + error = sync_blockdev(bdev); done: mutex_unlock(&bdev->bd_fsfreeze_mutex); return error; From patchwork Tue Oct 24 13:01:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434428 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FABA29429 for ; Tue, 24 Oct 2023 13:06:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j+a0k5qj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CC24C433CA; Tue, 24 Oct 2023 13:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152777; bh=WFm2ZXpOXnQSHZ4vtEzrtFrRM4tT4/LzuHBZCyjYdVw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=j+a0k5qju3jFMPZVId4TKWjo6/VBMxuAxr0VyJSavzmKmrvxjFLMfv5Gm93omZx49 zr/XF9zuArAEIefs5WZNd4ZiqY8GV0F1s3n1yxGrv+mxk1krPKAf8MdeVqhEVCDXLI 7+qvLQxSHdIu5TmB2enEtVTZVgCOGdaBja6JyoM+caT+DKwBiNMCbphT87Ipz6zin8 RB6v4yxcNJy36y60pWYEpjdAdU5ud9HP7JQAKIcxq5DH0lMZ9+Viw3DZXaOd86QYa9 /TXbwTNR2j3bwE6jqr/G7NN/lnEnBHAb+fe+MONArmKZfsBwFyY4pcN8h4G68GOoo7 c1bSz+nPp9iuA== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:10 +0200 Subject: [PATCH v2 04/10] bdev: add freeze and thaw holder operations Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-4-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=1093; i=brauner@kernel.org; h=from:subject:message-id; bh=WFm2ZXpOXnQSHZ4vtEzrtFrRM4tT4/LzuHBZCyjYdVw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3S47hkwQyVu6ZL9gep5b5hMXwmc3PNh449nq3uD/Xc/ teqr6yhlYRDjYpAVU2RxaDcJl1vOU7HZKFMDZg4rE8gQBi5OAZjIwVOMDGerjSzjdMRlDO95X4v/lr babd7C7PpDy7fNaX7Hdapu+SOGv/Jz3SfxSy9PbjR6bnS1u4ZdcbPMkRfZf/KXtZU/8otbxQcA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Add block device freeze and thaw holder operations. Follow-up patches will implement block device freeze and thaw based on stuct blk_holder_ops. Link: https://lore.kernel.org/r/20230927-vfs-super-freeze-v1-2-ecc36d9ab4d9@kernel.org Reviewed-by: "Darrick J. Wong" Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- include/linux/blkdev.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 7a3da7f44afb..1bc776335ff8 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1468,6 +1468,16 @@ struct blk_holder_ops { * Sync the file system mounted on the block device. */ void (*sync)(struct block_device *bdev); + + /* + * Freeze the file system mounted on the block device. + */ + int (*freeze)(struct block_device *bdev); + + /* + * Thaw the file system mounted on the block device. + */ + int (*thaw)(struct block_device *bdev); }; extern const struct blk_holder_ops fs_holder_ops; From patchwork Tue Oct 24 13:01:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434429 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C90B828E05 for ; Tue, 24 Oct 2023 13:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eoKOqmwq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33854C433C7; Tue, 24 Oct 2023 13:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152779; bh=ICCkjU3mGoRTP3El9nlcGoQ+U811rHa4m5XE8dELokY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=eoKOqmwqcL/ws2becLnBth9qbLpcvmP/rQL46ZMm0WSDmXGPxdfueuDJBhox/TZNq cU0DgBOD4H+BXe0IYrZfY1XHN2Mzq8XVw8EuntwZ4Fi7TGaXtzssDZ+Hv16Ha6k+cW O7F5XWp+t+/BOPHYz4rnUscAYxIqchdMGit/u4qaOHD1vviT8XZSWYVAeQohhwq7VY rsJOAO5kw7fTYiCdWCt6VADr95eosqw0b3O2Sk1Q3CowhVPLhX0rhjyU92z35z58AU iBh334TrOgomTYIFh4yvRYVX9d8hIV8+p5D9NUaMNLWqUrgHz43Qsq3vMAJFBE79gD 0Wl+t1nrX9aFQ== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:11 +0200 Subject: [PATCH v2 05/10] bdev: implement freeze and thaw holder operations Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-5-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=8644; i=brauner@kernel.org; h=from:subject:message-id; bh=ICCkjU3mGoRTP3El9nlcGoQ+U811rHa4m5XE8dELokY=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3TQeVC537zNsslPT4jvp3OU8cvkWVtncKi/vWw+Wzfe wii0o5SFQYyLQVZMkcWh3SRcbjlPxWajTA2YOaxMIEMYuDgFYCLGExkZzmskbb+erqtWvpDXYXLpZG vlb5Ui977lz76VfEVj9/b/3YwMX/bKFb56nOe74Wpxd+WKPu3tKqeDeZxlLU0TL65IN1XjBgA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 The old method of implementing block device freeze and thaw operations required us to rely on get_active_super() to walk the list of all superblocks on the system to find any superblock that might use the block device. This is wasteful and not very pleasant overall. Now that we can finally go straight from block device to owning superblock things become way simpler. Link: https://lore.kernel.org/r/20230927-vfs-super-freeze-v1-3-ecc36d9ab4d9@kernel.org Signed-off-by: Christian Brauner Reviewed-by: Darrick J. Wong Reviewed-by: Darrick J. Wong Signed-off-by: Christian Brauner Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- block/bdev.c | 62 +++++++++++------------ fs/super.c | 124 ++++++++++++++++++++++++++++++++++++---------- include/linux/blk_types.h | 2 +- 3 files changed, 128 insertions(+), 60 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index a3e2af580a73..9deacd346192 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -222,31 +222,24 @@ EXPORT_SYMBOL(sync_blockdev_range); */ int bdev_freeze(struct block_device *bdev) { - struct super_block *sb; int error = 0; mutex_lock(&bdev->bd_fsfreeze_mutex); - if (++bdev->bd_fsfreeze_count > 1) - goto done; - - sb = get_active_super(bdev); - if (!sb) - goto sync; - if (sb->s_op->freeze_super) - error = sb->s_op->freeze_super(sb, FREEZE_HOLDER_USERSPACE); - else - error = freeze_super(sb, FREEZE_HOLDER_USERSPACE); - deactivate_super(sb); - if (error) { - bdev->bd_fsfreeze_count--; - goto done; + if (atomic_inc_return(&bdev->bd_fsfreeze_count) > 1) { + mutex_unlock(&bdev->bd_fsfreeze_mutex); + return 0; + } + + mutex_lock(&bdev->bd_holder_lock); + if (bdev->bd_holder_ops && bdev->bd_holder_ops->freeze) { + error = bdev->bd_holder_ops->freeze(bdev); + lockdep_assert_not_held(&bdev->bd_holder_lock); + } else { + mutex_unlock(&bdev->bd_holder_lock); + error = sync_blockdev(bdev); } - bdev->bd_fsfreeze_sb = sb; -sync: - error = sync_blockdev(bdev); -done: mutex_unlock(&bdev->bd_fsfreeze_mutex); return error; } @@ -262,29 +255,30 @@ EXPORT_SYMBOL(bdev_freeze); */ int bdev_thaw(struct block_device *bdev) { - struct super_block *sb; - int error = -EINVAL; + int error = -EINVAL, nr_freeze; mutex_lock(&bdev->bd_fsfreeze_mutex); - if (!bdev->bd_fsfreeze_count) + + /* + * If this returns < 0 it means that @bd_fsfreeze_count was + * already 0 and no decrement was performed. + */ + nr_freeze = atomic_dec_if_positive(&bdev->bd_fsfreeze_count); + if (nr_freeze < 0) goto out; error = 0; - if (--bdev->bd_fsfreeze_count > 0) + if (nr_freeze > 0) goto out; - sb = bdev->bd_fsfreeze_sb; - if (!sb) - goto out; + mutex_lock(&bdev->bd_holder_lock); + if (bdev->bd_holder_ops && bdev->bd_holder_ops->thaw) { + error = bdev->bd_holder_ops->thaw(bdev); + lockdep_assert_not_held(&bdev->bd_holder_lock); + } else { + mutex_unlock(&bdev->bd_holder_lock); + } - if (sb->s_op->thaw_super) - error = sb->s_op->thaw_super(sb, FREEZE_HOLDER_USERSPACE); - else - error = thaw_super(sb, FREEZE_HOLDER_USERSPACE); - if (error) - bdev->bd_fsfreeze_count++; - else - bdev->bd_fsfreeze_sb = NULL; out: mutex_unlock(&bdev->bd_fsfreeze_mutex); return error; diff --git a/fs/super.c b/fs/super.c index b224182f2440..ee0795ce09c7 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1430,14 +1430,8 @@ struct super_block *sget_dev(struct fs_context *fc, dev_t dev) EXPORT_SYMBOL(sget_dev); #ifdef CONFIG_BLOCK -/* - * Lock the superblock that is holder of the bdev. Returns the superblock - * pointer if we successfully locked the superblock and it is alive. Otherwise - * we return NULL and just unlock bdev->bd_holder_lock. - * - * The function must be called with bdev->bd_holder_lock and releases it. - */ -static struct super_block *bdev_super_lock_shared(struct block_device *bdev) + +static struct super_block *bdev_super_lock(struct block_device *bdev, bool excl) __releases(&bdev->bd_holder_lock) { struct super_block *sb = bdev->bd_holder; @@ -1451,18 +1445,37 @@ static struct super_block *bdev_super_lock_shared(struct block_device *bdev) spin_lock(&sb_lock); sb->s_count++; spin_unlock(&sb_lock); + mutex_unlock(&bdev->bd_holder_lock); - locked = super_lock_shared(sb); - if (!locked || !sb->s_root || !(sb->s_flags & SB_ACTIVE)) { - put_super(sb); + locked = super_lock(sb, excl); + put_super(sb); + if (!locked) + return NULL; + + return sb; +} + +/* + * Lock the superblock that is holder of the bdev. Returns the superblock + * pointer if we successfully locked the superblock and it is alive. Otherwise + * we return NULL and just unlock bdev->bd_holder_lock. + * + * The function must be called with bdev->bd_holder_lock and releases it. + */ +static struct super_block *bdev_super_lock_shared(struct block_device *bdev) +{ + struct super_block *sb; + + sb = bdev_super_lock(bdev, false); + if (!sb) + return NULL; + + if (!sb->s_root || !(sb->s_flags & SB_ACTIVE)) { + super_unlock_shared(sb); return NULL; } - /* - * The superblock is active and we hold s_umount, we can drop our - * temporary reference now. - */ - put_super(sb); + return sb; } @@ -1495,9 +1508,76 @@ static void fs_bdev_sync(struct block_device *bdev) super_unlock_shared(sb); } +static struct super_block *get_bdev_super(struct block_device *bdev) +{ + bool active = false; + struct super_block *sb; + + sb = bdev_super_lock(bdev, true); + if (sb) { + active = atomic_inc_not_zero(&sb->s_active); + super_unlock_excl(sb); + } + if (!active) + return NULL; + return sb; +} + +static int fs_bdev_freeze(struct block_device *bdev) +{ + struct super_block *sb; + int error = 0; + + lockdep_assert_held(&bdev->bd_fsfreeze_mutex); + + if (WARN_ON_ONCE(unlikely(!bdev->bd_holder))) + return -EINVAL; + + sb = get_bdev_super(bdev); + if (!sb) + return -EINVAL; + + if (sb->s_op->freeze_super) + error = sb->s_op->freeze_super(sb, FREEZE_HOLDER_USERSPACE); + else + error = freeze_super(sb, FREEZE_HOLDER_USERSPACE); + if (error) + atomic_dec(&bdev->bd_fsfreeze_count); + if (!error) + error = sync_blockdev(bdev); + deactivate_super(sb); + return error; +} + +static int fs_bdev_thaw(struct block_device *bdev) +{ + struct super_block *sb; + int error; + + lockdep_assert_held(&bdev->bd_fsfreeze_mutex); + + if (WARN_ON_ONCE(unlikely(!bdev->bd_holder))) + return -EINVAL; + + sb = get_bdev_super(bdev); + if (WARN_ON_ONCE(!sb)) + return -EINVAL; + + if (sb->s_op->thaw_super) + error = sb->s_op->thaw_super(sb, FREEZE_HOLDER_USERSPACE); + else + error = thaw_super(sb, FREEZE_HOLDER_USERSPACE); + if (error) + atomic_inc(&bdev->bd_fsfreeze_count); + deactivate_super(sb); + return error; +} + const struct blk_holder_ops fs_holder_ops = { .mark_dead = fs_bdev_mark_dead, .sync = fs_bdev_sync, + .freeze = fs_bdev_freeze, + .thaw = fs_bdev_thaw, }; EXPORT_SYMBOL_GPL(fs_holder_ops); @@ -1527,15 +1607,10 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, } /* - * Until SB_BORN flag is set, there can be no active superblock - * references and thus no filesystem freezing. get_active_super() will - * just loop waiting for SB_BORN so even bdev_freeze() cannot proceed. - * - * It is enough to check bdev was not frozen before we set s_bdev. + * It is enough to check bdev was not frozen before we set + * s_bdev as freezing will wait until SB_BORN is set. */ - mutex_lock(&bdev->bd_fsfreeze_mutex); - if (bdev->bd_fsfreeze_count > 0) { - mutex_unlock(&bdev->bd_fsfreeze_mutex); + if (atomic_read(&bdev->bd_fsfreeze_count) > 0) { if (fc) warnf(fc, "%pg: Can't mount, blockdev is frozen", bdev); bdev_release(bdev_handle); @@ -1548,7 +1623,6 @@ int setup_bdev_super(struct super_block *sb, int sb_flags, if (bdev_stable_writes(bdev)) sb->s_iflags |= SB_I_STABLE_WRITES; spin_unlock(&sb_lock); - mutex_unlock(&bdev->bd_fsfreeze_mutex); snprintf(sb->s_id, sizeof(sb->s_id), "%pg", bdev); shrinker_debugfs_rename(&sb->s_shrink, "sb-%s:%s", sb->s_type->name, diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index d5c5e59ddbd2..88e1848b0869 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -57,7 +57,7 @@ struct block_device { const struct blk_holder_ops *bd_holder_ops; struct mutex bd_holder_lock; /* The counter of freeze processes */ - int bd_fsfreeze_count; + atomic_t bd_fsfreeze_count; int bd_holders; struct kobject *bd_holder_dir; From patchwork Tue Oct 24 13:01:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434430 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2AC7628E1F for ; Tue, 24 Oct 2023 13:06:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Lth0PrhP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C99BAC433C8; Tue, 24 Oct 2023 13:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152781; bh=643g/XQmiQ2NFZJoNrdzUgTSzFzhse2eqaFJWyzKez0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Lth0PrhPgetTg3jzGv/vHMSXqUZ27rscanDi2qsSZrD/LmyCo/zG1ULE+sVryDsPi GopUxzhi81fdVZtgkzS+pNC3Dy1dbVdu0G2MKqLFNuQ7d+vV7t6S0ux8UznPuK84KN hX/BFCsb1HfNDYz132L3CpA7GYoaWuHc5SF2TEWzG9ELpcw6Dp0gVS/de5HqWPVNrO Hq3jsyj4yi8t+D2at5KI6jdgBVnUYgk/s+5l+GswaGywbDXKKdwzlRE63E1FbcL5YA mqUdbr5IIaES0rMN9OlEmYBleLTNx+G5OaumpLxA5PhuhhyI2P3MS0ZlmfzU0GklSk dSETsh94GL9TQ== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:12 +0200 Subject: [PATCH v2 06/10] fs: remove get_active_super() Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-6-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=2266; i=brauner@kernel.org; h=from:subject:message-id; bh=643g/XQmiQ2NFZJoNrdzUgTSzFzhse2eqaFJWyzKez0=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3TULF6cWbFywoT0BysdSu5snjNrZklE5cb/5zl3S0+7 4Zd1oaOUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BWAiSeIM/4zWvzaMX2AVucB54urdM0 ufTdyU96Nz+aTJclVGLwuSmZoYGZZ8eluxUqNLf1Z+6MaOo31ieuxvlfdpn1vpf3OhdM7rRH4A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 This function is now unused so remove it. One less function that uses the global superblock list. Link: https://lore.kernel.org/r/20230927-vfs-super-freeze-v1-4-ecc36d9ab4d9@kernel.org Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- fs/super.c | 28 ---------------------------- include/linux/fs.h | 1 - 2 files changed, 29 deletions(-) diff --git a/fs/super.c b/fs/super.c index ee0795ce09c7..c9658ddb53f7 100644 --- a/fs/super.c +++ b/fs/super.c @@ -1024,34 +1024,6 @@ void iterate_supers_type(struct file_system_type *type, EXPORT_SYMBOL(iterate_supers_type); -/** - * get_active_super - get an active reference to 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. Returns the superblock with an active - * reference or %NULL if none was found. - */ -struct super_block *get_active_super(struct block_device *bdev) -{ - struct super_block *sb; - - if (!bdev) - return NULL; - - spin_lock(&sb_lock); - list_for_each_entry(sb, &super_blocks, s_list) { - if (sb->s_bdev == bdev) { - if (!grab_super(sb)) - return NULL; - super_unlock_excl(sb); - return sb; - } - } - spin_unlock(&sb_lock); - return NULL; -} - struct super_block *user_get_super(dev_t dev, bool excl) { struct super_block *sb; diff --git a/include/linux/fs.h b/include/linux/fs.h index 03afc8b6f2af..5174e821d451 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3053,7 +3053,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_active_super(struct block_device *bdev); extern void drop_super(struct super_block *sb); extern void drop_super_exclusive(struct super_block *sb); extern void iterate_supers(void (*)(struct super_block *, void *), void *); From patchwork Tue Oct 24 13:01:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434431 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CEF8229410 for ; Tue, 24 Oct 2023 13:06:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NSHHBKlP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76EEAC433C7; Tue, 24 Oct 2023 13:06:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152782; bh=A2F7xcCPQijS5nHDzQ+tLk6QIWnmUFSEgNKGFeyRhaw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NSHHBKlPJsDEt4IatYffF/lhq0ZUKai75TiZICyt5hQAgaCBasobzvagHul6pNUgD t8d4+uQbpbvxV61uX6rL6pMReq7zD1ikx19xPonZdSy/gil/x27VCDesZ3Z9Dn+r9c Vi8ZVakQH+/URWW0KopDfDaWWl2UX7MInKixsMZXyZIFQ5gYA2HZFadUVL5Iujk8ji Z/PL+AJvyOQFCTKgKxhsFhxuzs43rxCB8UNv+xbtDux+jOB8oz69u16Ys3gDY2/4VE LROf5/QrqH884gfhPJPypL9GW5nxsYDHIIWELMcE+2Q1CRcI3/EDwb8/JjrC6JPfYB bn6TDnk0Tf+jQ== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:13 +0200 Subject: [PATCH v2 07/10] super: remove bd_fsfreeze_sb Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-7-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=1359; i=brauner@kernel.org; h=from:subject:message-id; bh=A2F7xcCPQijS5nHDzQ+tLk6QIWnmUFSEgNKGFeyRhaw=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3S87XLkbrS4YXrRq137n2x7uzns4iohwQnzA/u3nrCw WLiktqOUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BWAiQiKMDA9vP7NIZImsKXELnWhxPC phQdylTu/FBb7q81KkTP/V7Gf4Z3/UctHJLWXPbumV5Lj3n5JsuiA6SzFX/WOD+LLrWQKr2AE= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Remove bd_fsfreeze_sb as it's now unused and can be removed. Also move bd_fsfreeze_count down to not have it weirdly placed in the middle of the holder fields. Link: https://lore.kernel.org/r/20230927-vfs-super-freeze-v1-5-ecc36d9ab4d9@kernel.org Reviewed-by: "Darrick J. Wong" Reviewed-by: Jan Kara Suggested-by: Jan Kara Suggested-by: Christoph Hellwig Signed-off-by: Christian Brauner --- include/linux/blk_types.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 88e1848b0869..749203277fee 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -56,14 +56,11 @@ struct block_device { void * bd_holder; const struct blk_holder_ops *bd_holder_ops; struct mutex bd_holder_lock; - /* The counter of freeze processes */ - atomic_t bd_fsfreeze_count; int bd_holders; struct kobject *bd_holder_dir; - /* Mutex for freeze */ - struct mutex bd_fsfreeze_mutex; - struct super_block *bd_fsfreeze_sb; + atomic_t bd_fsfreeze_count; /* number of freeze requests */ + struct mutex bd_fsfreeze_mutex; /* serialize freeze/thaw */ struct partition_meta_info *bd_meta_info; #ifdef CONFIG_FAIL_MAKE_REQUEST From patchwork Tue Oct 24 13:01:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434432 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C85D929CE2 for ; Tue, 24 Oct 2023 13:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ufNUgpUi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3851CC433C7; Tue, 24 Oct 2023 13:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152784; bh=16J0W4NcQ8UbgHZxida2I/GQkpCT537jEIeeQZxI09c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ufNUgpUi7qzIFl+Os9IZ0dmIHpcSaIGG8kUK4lEuZdKSMS5mYvdhdIc8AR5gI9i19 0n3E+YqcncPBQU4wSAffI2n6+uqm7UbDJ40ioshlVb9TQ+uCtT9fDF/UWs+zIl8net 9Gx4GrTO2/p2bwHFR7DCLciKCmDbLGuKQBi72JnfmdkqPtRXUeWjiAQbCYlIZ2ACEI hYFaE8xZv37Jjrph0cBCauygJYkJj32kr5bkzznLjktvbcrEBIFmvaCz8v25HW8H4p YA+mwLONc/Z0xfIM5voG12SneH4KJ8GeXFjvIxwMLtMm05R4QquBFH8pY7D7XC1ypP 6ePjSXfEqQlHg== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:14 +0200 Subject: [PATCH v2 08/10] fs: remove unused helper Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-8-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=3498; i=brauner@kernel.org; h=from:subject:message-id; bh=16J0W4NcQ8UbgHZxida2I/GQkpCT537jEIeeQZxI09c=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3T8Vrr3U+ytngOGXhv2OrV/XfVedfayE84G9n82zAoL Cfia01HKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRu2WMDG3M8+YZTqj49vDR94OxxT oGqdcytvxdV1wwiTOl/2HXxTMM/zOucjwSneXw1ex3wr8NCXs2HzD0Pn+h6vS+Y1/6GZufi/MAAA== X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 The grab_super() helper is now only used by grab_super_dead(). Merge the two helpers into one. Link: https://lore.kernel.org/r/20230927-vfs-super-freeze-v1-6-ecc36d9ab4d9@kernel.org Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Reviewed-by: Jan Kara Signed-off-by: Christian Brauner --- fs/super.c | 54 ++++++++++++++---------------------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/fs/super.c b/fs/super.c index c9658ddb53f7..b26b302f870d 100644 --- a/fs/super.c +++ b/fs/super.c @@ -520,37 +520,6 @@ void deactivate_super(struct super_block *s) EXPORT_SYMBOL(deactivate_super); -/** - * grab_super - acquire an active reference - * @s: reference we are trying to make active - * - * Tries to acquire an active reference. grab_super() is used when we - * had just found a superblock in super_blocks or fs_type->fs_supers - * and want to turn it into a full-blown active reference. grab_super() - * is called with sb_lock held and drops it. Returns 1 in case of - * success, 0 if we had failed (superblock contents was already dead or - * dying when grab_super() had been called). Note that this is only - * called for superblocks not in rundown mode (== ones still on ->fs_supers - * of their type), so increment of ->s_count is OK here. - */ -static int grab_super(struct super_block *s) __releases(sb_lock) -{ - bool locked; - - s->s_count++; - spin_unlock(&sb_lock); - locked = super_lock_excl(s); - if (locked) { - if (atomic_inc_not_zero(&s->s_active)) { - put_super(s); - return 1; - } - super_unlock_excl(s); - } - put_super(s); - return 0; -} - static inline bool wait_dead(struct super_block *sb) { unsigned int flags; @@ -564,7 +533,7 @@ static inline bool wait_dead(struct super_block *sb) } /** - * grab_super_dead - acquire an active reference to a superblock + * grab_super - acquire an active reference to a superblock * @sb: superblock to acquire * * Acquire a temporary reference on a superblock and try to trade it for @@ -575,16 +544,21 @@ static inline bool wait_dead(struct super_block *sb) * Return: This returns true if an active reference could be acquired, * false if not. */ -static bool grab_super_dead(struct super_block *sb) +static bool grab_super(struct super_block *sb) { + bool locked; + sb->s_count++; - if (grab_super(sb)) { - put_super(sb); - lockdep_assert_held(&sb->s_umount); - return true; + spin_unlock(&sb_lock); + locked = super_lock_excl(sb); + if (locked) { + if (atomic_inc_not_zero(&sb->s_active)) { + put_super(sb); + return true; + } + super_unlock_excl(sb); } wait_var_event(&sb->s_flags, wait_dead(sb)); - lockdep_assert_not_held(&sb->s_umount); put_super(sb); return false; } @@ -835,7 +809,7 @@ struct super_block *sget_fc(struct fs_context *fc, warnfc(fc, "reusing existing filesystem in another namespace not allowed"); return ERR_PTR(-EBUSY); } - if (!grab_super_dead(old)) + if (!grab_super(old)) goto retry; destroy_unused_super(s); return old; @@ -879,7 +853,7 @@ struct super_block *sget(struct file_system_type *type, destroy_unused_super(s); return ERR_PTR(-EBUSY); } - if (!grab_super_dead(old)) + if (!grab_super(old)) goto retry; destroy_unused_super(s); return old; From patchwork Tue Oct 24 13:01:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434433 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 34F542AB34 for ; Tue, 24 Oct 2023 13:06:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E+1R7stM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2CD5C433CB; Tue, 24 Oct 2023 13:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152786; bh=FXSCh7bJ1nHc2Do09YWhMLAgS/mi2LTs07xOv53L2gs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=E+1R7stMd+tLAzqSHC3ooOpBu2a0JtLDTKoyxGBBMAPdjAQcBv8Gibh1CHzMAw9Yk FLAjTtPnE+Xa3Hg01z5+W3NndUi7i2rary/W0o1ItnqRJLVAV0mz29mpgekUavuz9V S8y6NVh0gFNSzIMQVY9YAKen7ppK0cP9OI6poWoFkbDcue4Vm0umGWpn3yRzGRcrlA Jgk+CvVRJM5ilUh2THXNzBjGY9VxIImPiHvH3c0HN77ljiCHNfvJ6wIaAg4RBthuLI PUPZX4Z0LhPrbyQQ7/vGw8j9jppIL6mmWXWGHOBr6hZxmlqSqEQ1+ozYsFIITtfiwg BykERz3pK0rGg== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:15 +0200 Subject: [PATCH v2 09/10] porting: document block device freeze and thaw changes Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-9-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=1175; i=brauner@kernel.org; h=from:subject:message-id; bh=FXSCh7bJ1nHc2Do09YWhMLAgS/mi2LTs07xOv53L2gs=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3TcknLrcoV/cPX21d9jDTW2b0yIfHs+2enuujdhXloP 5z7f0VHKwiDGxSArpsji0G4SLrecp2KzUaYGzBxWJpAhDFycAjCRZ68ZGe4f/sM7/bf65La+JyHFwd 0JgW1fc1fPXND6uO1l4eF3k7Yw/DOP3b7Kfu4Fp/JWL8upPFtsxJN05WfOmsFqFXhnYuD3dj4A X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Link: https://lore.kernel.org/r/20230927-vfs-super-freeze-v1-7-ecc36d9ab4d9@kernel.org Signed-off-by: Christian Brauner Reviewed-by: Darrick J. Wong Reviewed-by: Jan Kara --- Documentation/filesystems/porting.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst index d69f59700a23..78fc854c9e41 100644 --- a/Documentation/filesystems/porting.rst +++ b/Documentation/filesystems/porting.rst @@ -1052,3 +1052,15 @@ kill_anon_super(), or kill_block_super() helpers. Lock ordering has been changed so that s_umount ranks above open_mutex again. All places where s_umount was taken under open_mutex have been fixed up. + +--- + +**recommended** + +Block device freezing and thawing have been moved to holder operations. + +Before this change, get_active_super() would only be able to find the +superblock of the main block device, i.e., the one stored in sb->s_bdev. Block +device freezing now works for any block device owned by a given superblock, not +just the main block device. The get_active_super() helper is gone, so are +bd_fsfreeze_sb, and bd_fsfreeze_mutex. From patchwork Tue Oct 24 13:01:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Brauner X-Patchwork-Id: 13434434 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD64A2AB34 for ; Tue, 24 Oct 2023 13:06:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="chMjXc5d" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 797B0C433C7; Tue, 24 Oct 2023 13:06:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1698152787; bh=MkC7wweWEr/Q8U6sMQJlPfRF4r0D9Znipc25YUVbu/g=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=chMjXc5dWDcQ/dETq+4LXmcMPoe/JYnzifV9cbuLC9z4O35uFgX+o3AU7dWVgoEKR 3BP9doFFk386Vsfp6iSPpV8XLI0x6iqq6F0KstQ3TJe9jVcMdhYnjzW617DMQVz1tz 278QUUoDpTl72T6bVGfs9BNV92tEp6e5xsIRiWwH80QTnN8e2YP3LlJ4DwO9ke2tWH GfUiqu5VLoiat9mU5YA9HAl00SmJCYNQu1Id1wJH/oJaE0rSnftk+3Wu/P5dphVLBO DpZK9Wncy1XsG9XKzzrM6CWcPKccaDOPBJLoIMVUBRlxVSa8K+1wwEMwt3Q7N+nt4A yu4l8ruH2jq2w== From: Christian Brauner Date: Tue, 24 Oct 2023 15:01:16 +0200 Subject: [PATCH v2 10/10] blkdev: comment fs_holder_ops Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20231024-vfs-super-freeze-v2-10-599c19f4faac@kernel.org> References: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> In-Reply-To: <20231024-vfs-super-freeze-v2-0-599c19f4faac@kernel.org> To: Jan Kara , Christoph Hellwig , "Darrick J. Wong" Cc: linux-fsdevel@vger.kernel.org, Christian Brauner X-Mailer: b4 0.13-dev-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=738; i=brauner@kernel.org; h=from:subject:message-id; bh=MkC7wweWEr/Q8U6sMQJlPfRF4r0D9Znipc25YUVbu/g=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMaSaH3TcOoXLkcf8xrPYFu/qb3/+i13Z3MLOti/zJtv9jU4c d7VSO0pZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACbSeJnhf/KRLSxmWhy//JqVK/xl3l dxfFmy6LzCD7VN95yiz6i962T4n26v0KR0NI+NO7iHsdIkcualtCu3u37F8POXHZO/UrCLHwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Add a comment to @fs_holder_ops that @holder must point to a superblock. Signed-off-by: Christian Brauner Reviewed-by: Darrick J. Wong Reviewed-by: Jan Kara Reviewed-by: Christoph Hellwig --- include/linux/blkdev.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 1bc776335ff8..abf71cce785c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1480,6 +1480,11 @@ struct blk_holder_ops { int (*thaw)(struct block_device *bdev); }; +/* + * For filesystems using @fs_holder_ops, the @holder argument passed to + * helpers used to open and claim block devices via + * bd_prepare_to_claim() must point to a superblock. + */ extern const struct blk_holder_ops fs_holder_ops; /*