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

fs: add fs/super_types.h header

Split out super block associated structures into a separate header.

Link: https://patch.msgid.link/20251104-work-fs-header-v1-2-fb39a2efe39e@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

+336 -307
+1 -307
include/linux/fs.h
··· 2 2 #ifndef _LINUX_FS_H 3 3 #define _LINUX_FS_H 4 4 5 + #include <linux/fs/super_types.h> 5 6 #include <linux/vfsdebug.h> 6 7 #include <linux/linkage.h> 7 8 #include <linux/wait_bit.h> ··· 12 11 #include <linux/stat.h> 13 12 #include <linux/cache.h> 14 13 #include <linux/list.h> 15 - #include <linux/list_lru.h> 16 14 #include <linux/llist.h> 17 15 #include <linux/radix-tree.h> 18 16 #include <linux/xarray.h> ··· 37 37 #include <linux/uuid.h> 38 38 #include <linux/errseq.h> 39 39 #include <linux/ioprio.h> 40 - #include <linux/fs_dirent.h> 41 40 #include <linux/build_bug.h> 42 41 #include <linux/stddef.h> 43 42 #include <linux/mount.h> ··· 51 52 #include <asm/byteorder.h> 52 53 #include <uapi/linux/fs.h> 53 54 54 - struct backing_dev_info; 55 55 struct bdi_writeback; 56 56 struct bio; 57 57 struct io_comp_batch; 58 - struct export_operations; 59 58 struct fiemap_extent_info; 60 59 struct hd_geometry; 61 60 struct iovec; ··· 67 70 struct cred; 68 71 struct swap_info_struct; 69 72 struct seq_file; 70 - struct workqueue_struct; 71 73 struct iov_iter; 72 - struct fscrypt_operations; 73 - struct fsverity_operations; 74 74 struct fsnotify_mark_connector; 75 - struct fsnotify_sb_info; 76 75 struct fs_context; 77 76 struct fs_parameter_spec; 78 77 struct file_kattr; ··· 290 297 */ 291 298 struct file *ia_file; 292 299 }; 293 - 294 - /* 295 - * Includes for diskquotas. 296 - */ 297 - #include <linux/quota.h> 298 300 299 301 /* 300 302 * Maximum number of layers of fs stack. Needs to be limited to ··· 1336 1348 extern int send_sigurg(struct file *file); 1337 1349 1338 1350 /* 1339 - * sb->s_flags. Note that these mirror the equivalent MS_* flags where 1340 - * represented in both. 1341 - */ 1342 - #define SB_RDONLY BIT(0) /* Mount read-only */ 1343 - #define SB_NOSUID BIT(1) /* Ignore suid and sgid bits */ 1344 - #define SB_NODEV BIT(2) /* Disallow access to device special files */ 1345 - #define SB_NOEXEC BIT(3) /* Disallow program execution */ 1346 - #define SB_SYNCHRONOUS BIT(4) /* Writes are synced at once */ 1347 - #define SB_MANDLOCK BIT(6) /* Allow mandatory locks on an FS */ 1348 - #define SB_DIRSYNC BIT(7) /* Directory modifications are synchronous */ 1349 - #define SB_NOATIME BIT(10) /* Do not update access times. */ 1350 - #define SB_NODIRATIME BIT(11) /* Do not update directory access times */ 1351 - #define SB_SILENT BIT(15) 1352 - #define SB_POSIXACL BIT(16) /* Supports POSIX ACLs */ 1353 - #define SB_INLINECRYPT BIT(17) /* Use blk-crypto for encrypted files */ 1354 - #define SB_KERNMOUNT BIT(22) /* this is a kern_mount call */ 1355 - #define SB_I_VERSION BIT(23) /* Update inode I_version field */ 1356 - #define SB_LAZYTIME BIT(25) /* Update the on-disk [acm]times lazily */ 1357 - 1358 - /* These sb flags are internal to the kernel */ 1359 - #define SB_DEAD BIT(21) 1360 - #define SB_DYING BIT(24) 1361 - #define SB_FORCE BIT(27) 1362 - #define SB_NOSEC BIT(28) 1363 - #define SB_BORN BIT(29) 1364 - #define SB_ACTIVE BIT(30) 1365 - #define SB_NOUSER BIT(31) 1366 - 1367 - /* These flags relate to encoding and casefolding */ 1368 - #define SB_ENC_STRICT_MODE_FL (1 << 0) 1369 - #define SB_ENC_NO_COMPAT_FALLBACK_FL (1 << 1) 1370 - 1371 - #define sb_has_strict_encoding(sb) \ 1372 - (sb->s_encoding_flags & SB_ENC_STRICT_MODE_FL) 1373 - 1374 - #if IS_ENABLED(CONFIG_UNICODE) 1375 - #define sb_no_casefold_compat_fallback(sb) \ 1376 - (sb->s_encoding_flags & SB_ENC_NO_COMPAT_FALLBACK_FL) 1377 - #else 1378 - #define sb_no_casefold_compat_fallback(sb) (1) 1379 - #endif 1380 - 1381 - /* 1382 1351 * Umount options 1383 1352 */ 1384 1353 ··· 1344 1399 #define MNT_EXPIRE 0x00000004 /* Mark for expiry */ 1345 1400 #define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */ 1346 1401 #define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */ 1347 - 1348 - /* sb->s_iflags */ 1349 - #define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */ 1350 - #define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */ 1351 - #define SB_I_NODEV 0x00000004 /* Ignore devices on this fs */ 1352 - #define SB_I_STABLE_WRITES 0x00000008 /* don't modify blks until WB is done */ 1353 - 1354 - /* sb->s_iflags to limit user namespace mounts */ 1355 - #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ 1356 - #define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020 1357 - #define SB_I_UNTRUSTED_MOUNTER 0x00000040 1358 - #define SB_I_EVM_HMAC_UNSUPPORTED 0x00000080 1359 - 1360 - #define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */ 1361 - #define SB_I_PERSB_BDI 0x00000200 /* has a per-sb bdi */ 1362 - #define SB_I_TS_EXPIRY_WARNED 0x00000400 /* warned about timestamp range expiry */ 1363 - #define SB_I_RETIRED 0x00000800 /* superblock shouldn't be reused */ 1364 - #define SB_I_NOUMASK 0x00001000 /* VFS does not apply umask */ 1365 - #define SB_I_NOIDMAP 0x00002000 /* No idmapped mounts on this superblock */ 1366 - #define SB_I_ALLOW_HSM 0x00004000 /* Allow HSM events on this superblock */ 1367 - 1368 - /* Possible states of 'frozen' field */ 1369 - enum { 1370 - SB_UNFROZEN = 0, /* FS is unfrozen */ 1371 - SB_FREEZE_WRITE = 1, /* Writes, dir ops, ioctls frozen */ 1372 - SB_FREEZE_PAGEFAULT = 2, /* Page faults stopped as well */ 1373 - SB_FREEZE_FS = 3, /* For internal FS use (e.g. to stop 1374 - * internal threads if needed) */ 1375 - SB_FREEZE_COMPLETE = 4, /* ->freeze_fs finished successfully */ 1376 - }; 1377 - 1378 - #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1) 1379 - 1380 - struct sb_writers { 1381 - unsigned short frozen; /* Is sb frozen? */ 1382 - int freeze_kcount; /* How many kernel freeze requests? */ 1383 - int freeze_ucount; /* How many userspace freeze requests? */ 1384 - const void *freeze_owner; /* Owner of the freeze */ 1385 - struct percpu_rw_semaphore rw_sem[SB_FREEZE_LEVELS]; 1386 - }; 1387 - 1388 - struct mount; 1389 - 1390 - struct super_block { 1391 - struct list_head s_list; /* Keep this first */ 1392 - dev_t s_dev; /* search index; _not_ kdev_t */ 1393 - unsigned char s_blocksize_bits; 1394 - unsigned long s_blocksize; 1395 - loff_t s_maxbytes; /* Max file size */ 1396 - struct file_system_type *s_type; 1397 - const struct super_operations *s_op; 1398 - const struct dquot_operations *dq_op; 1399 - const struct quotactl_ops *s_qcop; 1400 - const struct export_operations *s_export_op; 1401 - unsigned long s_flags; 1402 - unsigned long s_iflags; /* internal SB_I_* flags */ 1403 - unsigned long s_magic; 1404 - struct dentry *s_root; 1405 - struct rw_semaphore s_umount; 1406 - int s_count; 1407 - atomic_t s_active; 1408 - #ifdef CONFIG_SECURITY 1409 - void *s_security; 1410 - #endif 1411 - const struct xattr_handler * const *s_xattr; 1412 - #ifdef CONFIG_FS_ENCRYPTION 1413 - const struct fscrypt_operations *s_cop; 1414 - struct fscrypt_keyring *s_master_keys; /* master crypto keys in use */ 1415 - #endif 1416 - #ifdef CONFIG_FS_VERITY 1417 - const struct fsverity_operations *s_vop; 1418 - #endif 1419 - #if IS_ENABLED(CONFIG_UNICODE) 1420 - struct unicode_map *s_encoding; 1421 - __u16 s_encoding_flags; 1422 - #endif 1423 - struct hlist_bl_head s_roots; /* alternate root dentries for NFS */ 1424 - struct mount *s_mounts; /* list of mounts; _not_ for fs use */ 1425 - struct block_device *s_bdev; /* can go away once we use an accessor for @s_bdev_file */ 1426 - struct file *s_bdev_file; 1427 - struct backing_dev_info *s_bdi; 1428 - struct mtd_info *s_mtd; 1429 - struct hlist_node s_instances; 1430 - unsigned int s_quota_types; /* Bitmask of supported quota types */ 1431 - struct quota_info s_dquot; /* Diskquota specific options */ 1432 - 1433 - struct sb_writers s_writers; 1434 - 1435 - /* 1436 - * Keep s_fs_info, s_time_gran, s_fsnotify_mask, and 1437 - * s_fsnotify_info together for cache efficiency. They are frequently 1438 - * accessed and rarely modified. 1439 - */ 1440 - void *s_fs_info; /* Filesystem private info */ 1441 - 1442 - /* Granularity of c/m/atime in ns (cannot be worse than a second) */ 1443 - u32 s_time_gran; 1444 - /* Time limits for c/m/atime in seconds */ 1445 - time64_t s_time_min; 1446 - time64_t s_time_max; 1447 - #ifdef CONFIG_FSNOTIFY 1448 - u32 s_fsnotify_mask; 1449 - struct fsnotify_sb_info *s_fsnotify_info; 1450 - #endif 1451 - 1452 - /* 1453 - * q: why are s_id and s_sysfs_name not the same? both are human 1454 - * readable strings that identify the filesystem 1455 - * a: s_id is allowed to change at runtime; it's used in log messages, 1456 - * and we want to when a device starts out as single device (s_id is dev 1457 - * name) but then a device is hot added and we have to switch to 1458 - * identifying it by UUID 1459 - * but s_sysfs_name is a handle for programmatic access, and can't 1460 - * change at runtime 1461 - */ 1462 - char s_id[32]; /* Informational name */ 1463 - uuid_t s_uuid; /* UUID */ 1464 - u8 s_uuid_len; /* Default 16, possibly smaller for weird filesystems */ 1465 - 1466 - /* if set, fs shows up under sysfs at /sys/fs/$FSTYP/s_sysfs_name */ 1467 - char s_sysfs_name[UUID_STRING_LEN + 1]; 1468 - 1469 - unsigned int s_max_links; 1470 - unsigned int s_d_flags; /* default d_flags for dentries */ 1471 - 1472 - /* 1473 - * The next field is for VFS *only*. No filesystems have any business 1474 - * even looking at it. You had been warned. 1475 - */ 1476 - struct mutex s_vfs_rename_mutex; /* Kludge */ 1477 - 1478 - /* 1479 - * Filesystem subtype. If non-empty the filesystem type field 1480 - * in /proc/mounts will be "type.subtype" 1481 - */ 1482 - const char *s_subtype; 1483 - 1484 - const struct dentry_operations *__s_d_op; /* default d_op for dentries */ 1485 - 1486 - struct shrinker *s_shrink; /* per-sb shrinker handle */ 1487 - 1488 - /* Number of inodes with nlink == 0 but still referenced */ 1489 - atomic_long_t s_remove_count; 1490 - 1491 - /* Read-only state of the superblock is being changed */ 1492 - int s_readonly_remount; 1493 - 1494 - /* per-sb errseq_t for reporting writeback errors via syncfs */ 1495 - errseq_t s_wb_err; 1496 - 1497 - /* AIO completions deferred from interrupt context */ 1498 - struct workqueue_struct *s_dio_done_wq; 1499 - struct hlist_head s_pins; 1500 - 1501 - /* 1502 - * Owning user namespace and default context in which to 1503 - * interpret filesystem uids, gids, quotas, device nodes, 1504 - * xattrs and security labels. 1505 - */ 1506 - struct user_namespace *s_user_ns; 1507 - 1508 - /* 1509 - * The list_lru structure is essentially just a pointer to a table 1510 - * of per-node lru lists, each of which has its own spinlock. 1511 - * There is no need to put them into separate cachelines. 1512 - */ 1513 - struct list_lru s_dentry_lru; 1514 - struct list_lru s_inode_lru; 1515 - struct rcu_head rcu; 1516 - struct work_struct destroy_work; 1517 - 1518 - struct mutex s_sync_lock; /* sync serialisation lock */ 1519 - 1520 - /* 1521 - * Indicates how deep in a filesystem stack this SB is 1522 - */ 1523 - int s_stack_depth; 1524 - 1525 - /* s_inode_list_lock protects s_inodes */ 1526 - spinlock_t s_inode_list_lock ____cacheline_aligned_in_smp; 1527 - struct list_head s_inodes; /* all inodes */ 1528 - 1529 - spinlock_t s_inode_wblist_lock; 1530 - struct list_head s_inodes_wb; /* writeback inodes */ 1531 - } __randomize_layout; 1532 1402 1533 1403 static inline struct user_namespace *i_user_ns(const struct inode *inode) 1534 1404 { ··· 2190 2430 extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, 2191 2431 struct file *dst_file, loff_t dst_pos, 2192 2432 loff_t len, unsigned int remap_flags); 2193 - 2194 - /** 2195 - * enum freeze_holder - holder of the freeze 2196 - * @FREEZE_HOLDER_KERNEL: kernel wants to freeze or thaw filesystem 2197 - * @FREEZE_HOLDER_USERSPACE: userspace wants to freeze or thaw filesystem 2198 - * @FREEZE_MAY_NEST: whether nesting freeze and thaw requests is allowed 2199 - * @FREEZE_EXCL: a freeze that can only be undone by the owner 2200 - * 2201 - * Indicate who the owner of the freeze or thaw request is and whether 2202 - * the freeze needs to be exclusive or can nest. 2203 - * Without @FREEZE_MAY_NEST, multiple freeze and thaw requests from the 2204 - * same holder aren't allowed. It is however allowed to hold a single 2205 - * @FREEZE_HOLDER_USERSPACE and a single @FREEZE_HOLDER_KERNEL freeze at 2206 - * the same time. This is relied upon by some filesystems during online 2207 - * repair or similar. 2208 - */ 2209 - enum freeze_holder { 2210 - FREEZE_HOLDER_KERNEL = (1U << 0), 2211 - FREEZE_HOLDER_USERSPACE = (1U << 1), 2212 - FREEZE_MAY_NEST = (1U << 2), 2213 - FREEZE_EXCL = (1U << 3), 2214 - }; 2215 - 2216 - struct super_operations { 2217 - struct inode *(*alloc_inode)(struct super_block *sb); 2218 - void (*destroy_inode)(struct inode *); 2219 - void (*free_inode)(struct inode *); 2220 - 2221 - void (*dirty_inode) (struct inode *, int flags); 2222 - int (*write_inode) (struct inode *, struct writeback_control *wbc); 2223 - int (*drop_inode) (struct inode *); 2224 - void (*evict_inode) (struct inode *); 2225 - void (*put_super) (struct super_block *); 2226 - int (*sync_fs)(struct super_block *sb, int wait); 2227 - int (*freeze_super) (struct super_block *, enum freeze_holder who, const void *owner); 2228 - int (*freeze_fs) (struct super_block *); 2229 - int (*thaw_super) (struct super_block *, enum freeze_holder who, const void *owner); 2230 - int (*unfreeze_fs) (struct super_block *); 2231 - int (*statfs) (struct dentry *, struct kstatfs *); 2232 - int (*remount_fs) (struct super_block *, int *, char *); 2233 - void (*umount_begin) (struct super_block *); 2234 - 2235 - int (*show_options)(struct seq_file *, struct dentry *); 2236 - int (*show_devname)(struct seq_file *, struct dentry *); 2237 - int (*show_path)(struct seq_file *, struct dentry *); 2238 - int (*show_stats)(struct seq_file *, struct dentry *); 2239 - #ifdef CONFIG_QUOTA 2240 - ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); 2241 - ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 2242 - struct dquot __rcu **(*get_dquots)(struct inode *); 2243 - #endif 2244 - long (*nr_cached_objects)(struct super_block *, 2245 - struct shrink_control *); 2246 - long (*free_cached_objects)(struct super_block *, 2247 - struct shrink_control *); 2248 - /* 2249 - * If a filesystem can support graceful removal of a device and 2250 - * continue read-write operations, implement this callback. 2251 - * 2252 - * Return 0 if the filesystem can continue read-write. 2253 - * Non-zero return value or no such callback means the fs will be shutdown 2254 - * as usual. 2255 - */ 2256 - int (*remove_bdev)(struct super_block *sb, struct block_device *bdev); 2257 - void (*shutdown)(struct super_block *sb); 2258 - }; 2259 2433 2260 2434 /* 2261 2435 * Inode flags - they have no relation to superblock flags now
+335
include/linux/fs/super_types.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_FS_SUPER_TYPES_H 3 + #define _LINUX_FS_SUPER_TYPES_H 4 + 5 + #include <linux/fs_dirent.h> 6 + #include <linux/errseq.h> 7 + #include <linux/list_lru.h> 8 + #include <linux/list.h> 9 + #include <linux/list_bl.h> 10 + #include <linux/llist.h> 11 + #include <linux/uidgid.h> 12 + #include <linux/uuid.h> 13 + #include <linux/percpu-rwsem.h> 14 + #include <linux/workqueue_types.h> 15 + #include <linux/quota.h> 16 + 17 + struct backing_dev_info; 18 + struct block_device; 19 + struct dentry; 20 + struct dentry_operations; 21 + struct dquot_operations; 22 + struct export_operations; 23 + struct file; 24 + struct file_system_type; 25 + struct fscrypt_operations; 26 + struct fsnotify_sb_info; 27 + struct fsverity_operations; 28 + struct kstatfs; 29 + struct mount; 30 + struct mtd_info; 31 + struct quotactl_ops; 32 + struct shrinker; 33 + struct unicode_map; 34 + struct user_namespace; 35 + struct workqueue_struct; 36 + struct writeback_control; 37 + struct xattr_handler; 38 + 39 + extern struct super_block *blockdev_superblock; 40 + 41 + /* Possible states of 'frozen' field */ 42 + enum { 43 + SB_UNFROZEN = 0, /* FS is unfrozen */ 44 + SB_FREEZE_WRITE = 1, /* Writes, dir ops, ioctls frozen */ 45 + SB_FREEZE_PAGEFAULT = 2, /* Page faults stopped as well */ 46 + SB_FREEZE_FS = 3, /* For internal FS use (e.g. to stop internal threads if needed) */ 47 + SB_FREEZE_COMPLETE = 4, /* ->freeze_fs finished successfully */ 48 + }; 49 + 50 + #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1) 51 + 52 + struct sb_writers { 53 + unsigned short frozen; /* Is sb frozen? */ 54 + int freeze_kcount; /* How many kernel freeze requests? */ 55 + int freeze_ucount; /* How many userspace freeze requests? */ 56 + const void *freeze_owner; /* Owner of the freeze */ 57 + struct percpu_rw_semaphore rw_sem[SB_FREEZE_LEVELS]; 58 + }; 59 + 60 + /** 61 + * enum freeze_holder - holder of the freeze 62 + * @FREEZE_HOLDER_KERNEL: kernel wants to freeze or thaw filesystem 63 + * @FREEZE_HOLDER_USERSPACE: userspace wants to freeze or thaw filesystem 64 + * @FREEZE_MAY_NEST: whether nesting freeze and thaw requests is allowed 65 + * @FREEZE_EXCL: a freeze that can only be undone by the owner 66 + * 67 + * Indicate who the owner of the freeze or thaw request is and whether 68 + * the freeze needs to be exclusive or can nest. 69 + * Without @FREEZE_MAY_NEST, multiple freeze and thaw requests from the 70 + * same holder aren't allowed. It is however allowed to hold a single 71 + * @FREEZE_HOLDER_USERSPACE and a single @FREEZE_HOLDER_KERNEL freeze at 72 + * the same time. This is relied upon by some filesystems during online 73 + * repair or similar. 74 + */ 75 + enum freeze_holder { 76 + FREEZE_HOLDER_KERNEL = (1U << 0), 77 + FREEZE_HOLDER_USERSPACE = (1U << 1), 78 + FREEZE_MAY_NEST = (1U << 2), 79 + FREEZE_EXCL = (1U << 3), 80 + }; 81 + 82 + struct super_operations { 83 + struct inode *(*alloc_inode)(struct super_block *sb); 84 + void (*destroy_inode)(struct inode *inode); 85 + void (*free_inode)(struct inode *inode); 86 + void (*dirty_inode)(struct inode *inode, int flags); 87 + int (*write_inode)(struct inode *inode, struct writeback_control *wbc); 88 + int (*drop_inode)(struct inode *inode); 89 + void (*evict_inode)(struct inode *inode); 90 + void (*put_super)(struct super_block *sb); 91 + int (*sync_fs)(struct super_block *sb, int wait); 92 + int (*freeze_super)(struct super_block *sb, enum freeze_holder who, 93 + const void *owner); 94 + int (*freeze_fs)(struct super_block *sb); 95 + int (*thaw_super)(struct super_block *sb, enum freeze_holder who, 96 + const void *owner); 97 + int (*unfreeze_fs)(struct super_block *sb); 98 + int (*statfs)(struct dentry *dentry, struct kstatfs *kstatfs); 99 + int (*remount_fs) (struct super_block *, int *, char *); 100 + void (*umount_begin)(struct super_block *sb); 101 + 102 + int (*show_options)(struct seq_file *seq, struct dentry *dentry); 103 + int (*show_devname)(struct seq_file *seq, struct dentry *dentry); 104 + int (*show_path)(struct seq_file *seq, struct dentry *dentry); 105 + int (*show_stats)(struct seq_file *seq, struct dentry *dentry); 106 + #ifdef CONFIG_QUOTA 107 + ssize_t (*quota_read)(struct super_block *sb, int type, char *data, 108 + size_t len, loff_t off); 109 + ssize_t (*quota_write)(struct super_block *sb, int type, 110 + const char *data, size_t len, loff_t off); 111 + struct dquot __rcu **(*get_dquots)(struct inode *inode); 112 + #endif 113 + long (*nr_cached_objects)(struct super_block *sb, 114 + struct shrink_control *sc); 115 + long (*free_cached_objects)(struct super_block *sb, 116 + struct shrink_control *sc); 117 + /* 118 + * If a filesystem can support graceful removal of a device and 119 + * continue read-write operations, implement this callback. 120 + * 121 + * Return 0 if the filesystem can continue read-write. 122 + * Non-zero return value or no such callback means the fs will be shutdown 123 + * as usual. 124 + */ 125 + int (*remove_bdev)(struct super_block *sb, struct block_device *bdev); 126 + void (*shutdown)(struct super_block *sb); 127 + }; 128 + 129 + struct super_block { 130 + struct list_head s_list; /* Keep this first */ 131 + dev_t s_dev; /* search index; _not_ kdev_t */ 132 + unsigned char s_blocksize_bits; 133 + unsigned long s_blocksize; 134 + loff_t s_maxbytes; /* Max file size */ 135 + struct file_system_type *s_type; 136 + const struct super_operations *s_op; 137 + const struct dquot_operations *dq_op; 138 + const struct quotactl_ops *s_qcop; 139 + const struct export_operations *s_export_op; 140 + unsigned long s_flags; 141 + unsigned long s_iflags; /* internal SB_I_* flags */ 142 + unsigned long s_magic; 143 + struct dentry *s_root; 144 + struct rw_semaphore s_umount; 145 + int s_count; 146 + atomic_t s_active; 147 + #ifdef CONFIG_SECURITY 148 + void *s_security; 149 + #endif 150 + const struct xattr_handler *const *s_xattr; 151 + #ifdef CONFIG_FS_ENCRYPTION 152 + const struct fscrypt_operations *s_cop; 153 + struct fscrypt_keyring *s_master_keys; /* master crypto keys in use */ 154 + #endif 155 + #ifdef CONFIG_FS_VERITY 156 + const struct fsverity_operations *s_vop; 157 + #endif 158 + #if IS_ENABLED(CONFIG_UNICODE) 159 + struct unicode_map *s_encoding; 160 + __u16 s_encoding_flags; 161 + #endif 162 + struct hlist_bl_head s_roots; /* alternate root dentries for NFS */ 163 + struct mount *s_mounts; /* list of mounts; _not_ for fs use */ 164 + struct block_device *s_bdev; /* can go away once we use an accessor for @s_bdev_file */ 165 + struct file *s_bdev_file; 166 + struct backing_dev_info *s_bdi; 167 + struct mtd_info *s_mtd; 168 + struct hlist_node s_instances; 169 + unsigned int s_quota_types; /* Bitmask of supported quota types */ 170 + struct quota_info s_dquot; /* Diskquota specific options */ 171 + 172 + struct sb_writers s_writers; 173 + 174 + /* 175 + * Keep s_fs_info, s_time_gran, s_fsnotify_mask, and 176 + * s_fsnotify_info together for cache efficiency. They are frequently 177 + * accessed and rarely modified. 178 + */ 179 + void *s_fs_info; /* Filesystem private info */ 180 + 181 + /* Granularity of c/m/atime in ns (cannot be worse than a second) */ 182 + u32 s_time_gran; 183 + /* Time limits for c/m/atime in seconds */ 184 + time64_t s_time_min; 185 + time64_t s_time_max; 186 + #ifdef CONFIG_FSNOTIFY 187 + u32 s_fsnotify_mask; 188 + struct fsnotify_sb_info *s_fsnotify_info; 189 + #endif 190 + 191 + /* 192 + * q: why are s_id and s_sysfs_name not the same? both are human 193 + * readable strings that identify the filesystem 194 + * a: s_id is allowed to change at runtime; it's used in log messages, 195 + * and we want to when a device starts out as single device (s_id is dev 196 + * name) but then a device is hot added and we have to switch to 197 + * identifying it by UUID 198 + * but s_sysfs_name is a handle for programmatic access, and can't 199 + * change at runtime 200 + */ 201 + char s_id[32]; /* Informational name */ 202 + uuid_t s_uuid; /* UUID */ 203 + u8 s_uuid_len; /* Default 16, possibly smaller for weird filesystems */ 204 + 205 + /* if set, fs shows up under sysfs at /sys/fs/$FSTYP/s_sysfs_name */ 206 + char s_sysfs_name[UUID_STRING_LEN + 1]; 207 + 208 + unsigned int s_max_links; 209 + unsigned int s_d_flags; /* default d_flags for dentries */ 210 + 211 + /* 212 + * The next field is for VFS *only*. No filesystems have any business 213 + * even looking at it. You had been warned. 214 + */ 215 + struct mutex s_vfs_rename_mutex; /* Kludge */ 216 + 217 + /* 218 + * Filesystem subtype. If non-empty the filesystem type field 219 + * in /proc/mounts will be "type.subtype" 220 + */ 221 + const char *s_subtype; 222 + 223 + const struct dentry_operations *__s_d_op; /* default d_op for dentries */ 224 + 225 + struct shrinker *s_shrink; /* per-sb shrinker handle */ 226 + 227 + /* Number of inodes with nlink == 0 but still referenced */ 228 + atomic_long_t s_remove_count; 229 + 230 + /* Read-only state of the superblock is being changed */ 231 + int s_readonly_remount; 232 + 233 + /* per-sb errseq_t for reporting writeback errors via syncfs */ 234 + errseq_t s_wb_err; 235 + 236 + /* AIO completions deferred from interrupt context */ 237 + struct workqueue_struct *s_dio_done_wq; 238 + struct hlist_head s_pins; 239 + 240 + /* 241 + * Owning user namespace and default context in which to 242 + * interpret filesystem uids, gids, quotas, device nodes, 243 + * xattrs and security labels. 244 + */ 245 + struct user_namespace *s_user_ns; 246 + 247 + /* 248 + * The list_lru structure is essentially just a pointer to a table 249 + * of per-node lru lists, each of which has its own spinlock. 250 + * There is no need to put them into separate cachelines. 251 + */ 252 + struct list_lru s_dentry_lru; 253 + struct list_lru s_inode_lru; 254 + struct rcu_head rcu; 255 + struct work_struct destroy_work; 256 + 257 + struct mutex s_sync_lock; /* sync serialisation lock */ 258 + 259 + /* 260 + * Indicates how deep in a filesystem stack this SB is 261 + */ 262 + int s_stack_depth; 263 + 264 + /* s_inode_list_lock protects s_inodes */ 265 + spinlock_t s_inode_list_lock ____cacheline_aligned_in_smp; 266 + struct list_head s_inodes; /* all inodes */ 267 + 268 + spinlock_t s_inode_wblist_lock; 269 + struct list_head s_inodes_wb; /* writeback inodes */ 270 + } __randomize_layout; 271 + 272 + /* 273 + * sb->s_flags. Note that these mirror the equivalent MS_* flags where 274 + * represented in both. 275 + */ 276 + #define SB_RDONLY BIT(0) /* Mount read-only */ 277 + #define SB_NOSUID BIT(1) /* Ignore suid and sgid bits */ 278 + #define SB_NODEV BIT(2) /* Disallow access to device special files */ 279 + #define SB_NOEXEC BIT(3) /* Disallow program execution */ 280 + #define SB_SYNCHRONOUS BIT(4) /* Writes are synced at once */ 281 + #define SB_MANDLOCK BIT(6) /* Allow mandatory locks on an FS */ 282 + #define SB_DIRSYNC BIT(7) /* Directory modifications are synchronous */ 283 + #define SB_NOATIME BIT(10) /* Do not update access times. */ 284 + #define SB_NODIRATIME BIT(11) /* Do not update directory access times */ 285 + #define SB_SILENT BIT(15) 286 + #define SB_POSIXACL BIT(16) /* Supports POSIX ACLs */ 287 + #define SB_INLINECRYPT BIT(17) /* Use blk-crypto for encrypted files */ 288 + #define SB_KERNMOUNT BIT(22) /* this is a kern_mount call */ 289 + #define SB_I_VERSION BIT(23) /* Update inode I_version field */ 290 + #define SB_LAZYTIME BIT(25) /* Update the on-disk [acm]times lazily */ 291 + 292 + /* These sb flags are internal to the kernel */ 293 + #define SB_DEAD BIT(21) 294 + #define SB_DYING BIT(24) 295 + #define SB_FORCE BIT(27) 296 + #define SB_NOSEC BIT(28) 297 + #define SB_BORN BIT(29) 298 + #define SB_ACTIVE BIT(30) 299 + #define SB_NOUSER BIT(31) 300 + 301 + /* These flags relate to encoding and casefolding */ 302 + #define SB_ENC_STRICT_MODE_FL (1 << 0) 303 + #define SB_ENC_NO_COMPAT_FALLBACK_FL (1 << 1) 304 + 305 + #define sb_has_strict_encoding(sb) \ 306 + (sb->s_encoding_flags & SB_ENC_STRICT_MODE_FL) 307 + 308 + #if IS_ENABLED(CONFIG_UNICODE) 309 + #define sb_no_casefold_compat_fallback(sb) \ 310 + (sb->s_encoding_flags & SB_ENC_NO_COMPAT_FALLBACK_FL) 311 + #else 312 + #define sb_no_casefold_compat_fallback(sb) (1) 313 + #endif 314 + 315 + /* sb->s_iflags */ 316 + #define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */ 317 + #define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */ 318 + #define SB_I_NODEV 0x00000004 /* Ignore devices on this fs */ 319 + #define SB_I_STABLE_WRITES 0x00000008 /* don't modify blks until WB is done */ 320 + 321 + /* sb->s_iflags to limit user namespace mounts */ 322 + #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */ 323 + #define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020 324 + #define SB_I_UNTRUSTED_MOUNTER 0x00000040 325 + #define SB_I_EVM_HMAC_UNSUPPORTED 0x00000080 326 + 327 + #define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */ 328 + #define SB_I_PERSB_BDI 0x00000200 /* has a per-sb bdi */ 329 + #define SB_I_TS_EXPIRY_WARNED 0x00000400 /* warned about timestamp range expiry */ 330 + #define SB_I_RETIRED 0x00000800 /* superblock shouldn't be reused */ 331 + #define SB_I_NOUMASK 0x00001000 /* VFS does not apply umask */ 332 + #define SB_I_NOIDMAP 0x00002000 /* No idmapped mounts on this superblock */ 333 + #define SB_I_ALLOW_HSM 0x00004000 /* Allow HSM events on this superblock */ 334 + 335 + #endif /* _LINUX_FS_SUPER_TYPES_H */