Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fs: add a method to shut down the file system

Add a new ->shutdown super operation that can be used to tell the file
system to shut down, and call it from newly created holder ops when the
block device under a file system shuts down.

This only covers the main block device for "simple" file systems using
get_tree_bdev / mount_bdev. File systems their own get_tree method
or opening additional devices will need to set up their own
blk_holder_ops.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Acked-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Link: https://lore.kernel.org/r/20230601094459.1350643-12-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Christoph Hellwig and committed by
Jens Axboe
87efb390 f55e017c

+20 -2
+19 -2
fs/super.c
··· 1206 1206 EXPORT_SYMBOL(get_tree_keyed); 1207 1207 1208 1208 #ifdef CONFIG_BLOCK 1209 + static void fs_mark_dead(struct block_device *bdev) 1210 + { 1211 + struct super_block *sb; 1212 + 1213 + sb = get_super(bdev); 1214 + if (!sb) 1215 + return; 1216 + 1217 + if (sb->s_op->shutdown) 1218 + sb->s_op->shutdown(sb); 1219 + drop_super(sb); 1220 + } 1221 + 1222 + static const struct blk_holder_ops fs_holder_ops = { 1223 + .mark_dead = fs_mark_dead, 1224 + }; 1209 1225 1210 1226 static int set_bdev_super(struct super_block *s, void *data) 1211 1227 { ··· 1264 1248 if (!fc->source) 1265 1249 return invalf(fc, "No source specified"); 1266 1250 1267 - bdev = blkdev_get_by_path(fc->source, mode, fc->fs_type, NULL); 1251 + bdev = blkdev_get_by_path(fc->source, mode, fc->fs_type, 1252 + &fs_holder_ops); 1268 1253 if (IS_ERR(bdev)) { 1269 1254 errorf(fc, "%s: Can't open blockdev", fc->source); 1270 1255 return PTR_ERR(bdev); ··· 1350 1333 if (!(flags & SB_RDONLY)) 1351 1334 mode |= FMODE_WRITE; 1352 1335 1353 - bdev = blkdev_get_by_path(dev_name, mode, fs_type, NULL); 1336 + bdev = blkdev_get_by_path(dev_name, mode, fs_type, &fs_holder_ops); 1354 1337 if (IS_ERR(bdev)) 1355 1338 return ERR_CAST(bdev); 1356 1339
+1
include/linux/fs.h
··· 1932 1932 struct shrink_control *); 1933 1933 long (*free_cached_objects)(struct super_block *, 1934 1934 struct shrink_control *); 1935 + void (*shutdown)(struct super_block *sb); 1935 1936 }; 1936 1937 1937 1938 /*