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.

Merge patch series "fs: start to split up fs.h"

Christian Brauner <brauner@kernel.org> says:

Take first steps to split up fs.h. Add fs/super_types.h and fs/super.h
headers that contain the types and functions associated with super
blocks respectively.

* patches from https://patch.msgid.link/20251104-work-fs-header-v1-0-fb39a2efe39e@kernel.org:
fs: add fs/super.h header
fs: add fs/super_types.h header
fs: rename fs_types.h to fs_dirent.h

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

+578 -531
+1 -1
fs/Makefile
··· 14 14 seq_file.o xattr.o libfs.o fs-writeback.o \ 15 15 pnode.o splice.o sync.o utimes.o d_path.o \ 16 16 stack.o fs_struct.o statfs.o fs_pin.o nsfs.o \ 17 - fs_types.o fs_context.o fs_parser.o fsopen.o init.o \ 17 + fs_dirent.o fs_context.o fs_parser.o fsopen.o init.o \ 18 18 kernel_read_file.o mnt_idmapping.o remap_range.o pidfs.o \ 19 19 file_attr.o 20 20
+1 -1
fs/fs_types.c fs/fs_dirent.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0 2 - #include <linux/fs.h> 2 + #include <linux/fs_dirent.h> 3 3 #include <linux/export.h> 4 4 5 5 /*
+1 -525
include/linux/fs.h
··· 2 2 #ifndef _LINUX_FS_H 3 3 #define _LINUX_FS_H 4 4 5 + #include <linux/fs/super.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_types.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 { ··· 1662 1902 * Snapshotting support. 1663 1903 */ 1664 1904 1665 - /* 1666 - * These are internal functions, please use sb_start_{write,pagefault,intwrite} 1667 - * instead. 1668 - */ 1669 - static inline void __sb_end_write(struct super_block *sb, int level) 1670 - { 1671 - percpu_up_read(sb->s_writers.rw_sem + level-1); 1672 - } 1673 - 1674 - static inline void __sb_start_write(struct super_block *sb, int level) 1675 - { 1676 - percpu_down_read_freezable(sb->s_writers.rw_sem + level - 1, true); 1677 - } 1678 - 1679 - static inline bool __sb_start_write_trylock(struct super_block *sb, int level) 1680 - { 1681 - return percpu_down_read_trylock(sb->s_writers.rw_sem + level - 1); 1682 - } 1683 - 1684 - #define __sb_writers_acquired(sb, lev) \ 1685 - percpu_rwsem_acquire(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_) 1686 - #define __sb_writers_release(sb, lev) \ 1687 - percpu_rwsem_release(&(sb)->s_writers.rw_sem[(lev)-1], _THIS_IP_) 1688 - 1689 - /** 1690 - * __sb_write_started - check if sb freeze level is held 1691 - * @sb: the super we write to 1692 - * @level: the freeze level 1693 - * 1694 - * * > 0 - sb freeze level is held 1695 - * * 0 - sb freeze level is not held 1696 - * * < 0 - !CONFIG_LOCKDEP/LOCK_STATE_UNKNOWN 1697 - */ 1698 - static inline int __sb_write_started(const struct super_block *sb, int level) 1699 - { 1700 - return lockdep_is_held_type(sb->s_writers.rw_sem + level - 1, 1); 1701 - } 1702 - 1703 - /** 1704 - * sb_write_started - check if SB_FREEZE_WRITE is held 1705 - * @sb: the super we write to 1706 - * 1707 - * May be false positive with !CONFIG_LOCKDEP/LOCK_STATE_UNKNOWN. 1708 - */ 1709 - static inline bool sb_write_started(const struct super_block *sb) 1710 - { 1711 - return __sb_write_started(sb, SB_FREEZE_WRITE); 1712 - } 1713 - 1714 - /** 1715 - * sb_write_not_started - check if SB_FREEZE_WRITE is not held 1716 - * @sb: the super we write to 1717 - * 1718 - * May be false positive with !CONFIG_LOCKDEP/LOCK_STATE_UNKNOWN. 1719 - */ 1720 - static inline bool sb_write_not_started(const struct super_block *sb) 1721 - { 1722 - return __sb_write_started(sb, SB_FREEZE_WRITE) <= 0; 1723 - } 1724 - 1725 1905 /** 1726 1906 * file_write_started - check if SB_FREEZE_WRITE is held 1727 1907 * @file: the file we write to ··· 1690 1990 if (!S_ISREG(file_inode(file)->i_mode)) 1691 1991 return true; 1692 1992 return sb_write_not_started(file_inode(file)->i_sb); 1693 - } 1694 - 1695 - /** 1696 - * sb_end_write - drop write access to a superblock 1697 - * @sb: the super we wrote to 1698 - * 1699 - * Decrement number of writers to the filesystem. Wake up possible waiters 1700 - * wanting to freeze the filesystem. 1701 - */ 1702 - static inline void sb_end_write(struct super_block *sb) 1703 - { 1704 - __sb_end_write(sb, SB_FREEZE_WRITE); 1705 - } 1706 - 1707 - /** 1708 - * sb_end_pagefault - drop write access to a superblock from a page fault 1709 - * @sb: the super we wrote to 1710 - * 1711 - * Decrement number of processes handling write page fault to the filesystem. 1712 - * Wake up possible waiters wanting to freeze the filesystem. 1713 - */ 1714 - static inline void sb_end_pagefault(struct super_block *sb) 1715 - { 1716 - __sb_end_write(sb, SB_FREEZE_PAGEFAULT); 1717 - } 1718 - 1719 - /** 1720 - * sb_end_intwrite - drop write access to a superblock for internal fs purposes 1721 - * @sb: the super we wrote to 1722 - * 1723 - * Decrement fs-internal number of writers to the filesystem. Wake up possible 1724 - * waiters wanting to freeze the filesystem. 1725 - */ 1726 - static inline void sb_end_intwrite(struct super_block *sb) 1727 - { 1728 - __sb_end_write(sb, SB_FREEZE_FS); 1729 - } 1730 - 1731 - /** 1732 - * sb_start_write - get write access to a superblock 1733 - * @sb: the super we write to 1734 - * 1735 - * When a process wants to write data or metadata to a file system (i.e. dirty 1736 - * a page or an inode), it should embed the operation in a sb_start_write() - 1737 - * sb_end_write() pair to get exclusion against file system freezing. This 1738 - * function increments number of writers preventing freezing. If the file 1739 - * system is already frozen, the function waits until the file system is 1740 - * thawed. 1741 - * 1742 - * Since freeze protection behaves as a lock, users have to preserve 1743 - * ordering of freeze protection and other filesystem locks. Generally, 1744 - * freeze protection should be the outermost lock. In particular, we have: 1745 - * 1746 - * sb_start_write 1747 - * -> i_rwsem (write path, truncate, directory ops, ...) 1748 - * -> s_umount (freeze_super, thaw_super) 1749 - */ 1750 - static inline void sb_start_write(struct super_block *sb) 1751 - { 1752 - __sb_start_write(sb, SB_FREEZE_WRITE); 1753 - } 1754 - 1755 - static inline bool sb_start_write_trylock(struct super_block *sb) 1756 - { 1757 - return __sb_start_write_trylock(sb, SB_FREEZE_WRITE); 1758 - } 1759 - 1760 - /** 1761 - * sb_start_pagefault - get write access to a superblock from a page fault 1762 - * @sb: the super we write to 1763 - * 1764 - * When a process starts handling write page fault, it should embed the 1765 - * operation into sb_start_pagefault() - sb_end_pagefault() pair to get 1766 - * exclusion against file system freezing. This is needed since the page fault 1767 - * is going to dirty a page. This function increments number of running page 1768 - * faults preventing freezing. If the file system is already frozen, the 1769 - * function waits until the file system is thawed. 1770 - * 1771 - * Since page fault freeze protection behaves as a lock, users have to preserve 1772 - * ordering of freeze protection and other filesystem locks. It is advised to 1773 - * put sb_start_pagefault() close to mmap_lock in lock ordering. Page fault 1774 - * handling code implies lock dependency: 1775 - * 1776 - * mmap_lock 1777 - * -> sb_start_pagefault 1778 - */ 1779 - static inline void sb_start_pagefault(struct super_block *sb) 1780 - { 1781 - __sb_start_write(sb, SB_FREEZE_PAGEFAULT); 1782 - } 1783 - 1784 - /** 1785 - * sb_start_intwrite - get write access to a superblock for internal fs purposes 1786 - * @sb: the super we write to 1787 - * 1788 - * This is the third level of protection against filesystem freezing. It is 1789 - * free for use by a filesystem. The only requirement is that it must rank 1790 - * below sb_start_pagefault. 1791 - * 1792 - * For example filesystem can call sb_start_intwrite() when starting a 1793 - * transaction which somewhat eases handling of freezing for internal sources 1794 - * of filesystem changes (internal fs threads, discarding preallocation on file 1795 - * close, etc.). 1796 - */ 1797 - static inline void sb_start_intwrite(struct super_block *sb) 1798 - { 1799 - __sb_start_write(sb, SB_FREEZE_FS); 1800 - } 1801 - 1802 - static inline bool sb_start_intwrite_trylock(struct super_block *sb) 1803 - { 1804 - return __sb_start_write_trylock(sb, SB_FREEZE_FS); 1805 1993 } 1806 1994 1807 1995 bool inode_owner_or_capable(struct mnt_idmap *idmap, ··· 2019 2431 struct file *dst_file, loff_t dst_pos, 2020 2432 loff_t len, unsigned int remap_flags); 2021 2433 2022 - /** 2023 - * enum freeze_holder - holder of the freeze 2024 - * @FREEZE_HOLDER_KERNEL: kernel wants to freeze or thaw filesystem 2025 - * @FREEZE_HOLDER_USERSPACE: userspace wants to freeze or thaw filesystem 2026 - * @FREEZE_MAY_NEST: whether nesting freeze and thaw requests is allowed 2027 - * @FREEZE_EXCL: a freeze that can only be undone by the owner 2028 - * 2029 - * Indicate who the owner of the freeze or thaw request is and whether 2030 - * the freeze needs to be exclusive or can nest. 2031 - * Without @FREEZE_MAY_NEST, multiple freeze and thaw requests from the 2032 - * same holder aren't allowed. It is however allowed to hold a single 2033 - * @FREEZE_HOLDER_USERSPACE and a single @FREEZE_HOLDER_KERNEL freeze at 2034 - * the same time. This is relied upon by some filesystems during online 2035 - * repair or similar. 2036 - */ 2037 - enum freeze_holder { 2038 - FREEZE_HOLDER_KERNEL = (1U << 0), 2039 - FREEZE_HOLDER_USERSPACE = (1U << 1), 2040 - FREEZE_MAY_NEST = (1U << 2), 2041 - FREEZE_EXCL = (1U << 3), 2042 - }; 2043 - 2044 - struct super_operations { 2045 - struct inode *(*alloc_inode)(struct super_block *sb); 2046 - void (*destroy_inode)(struct inode *); 2047 - void (*free_inode)(struct inode *); 2048 - 2049 - void (*dirty_inode) (struct inode *, int flags); 2050 - int (*write_inode) (struct inode *, struct writeback_control *wbc); 2051 - int (*drop_inode) (struct inode *); 2052 - void (*evict_inode) (struct inode *); 2053 - void (*put_super) (struct super_block *); 2054 - int (*sync_fs)(struct super_block *sb, int wait); 2055 - int (*freeze_super) (struct super_block *, enum freeze_holder who, const void *owner); 2056 - int (*freeze_fs) (struct super_block *); 2057 - int (*thaw_super) (struct super_block *, enum freeze_holder who, const void *owner); 2058 - int (*unfreeze_fs) (struct super_block *); 2059 - int (*statfs) (struct dentry *, struct kstatfs *); 2060 - int (*remount_fs) (struct super_block *, int *, char *); 2061 - void (*umount_begin) (struct super_block *); 2062 - 2063 - int (*show_options)(struct seq_file *, struct dentry *); 2064 - int (*show_devname)(struct seq_file *, struct dentry *); 2065 - int (*show_path)(struct seq_file *, struct dentry *); 2066 - int (*show_stats)(struct seq_file *, struct dentry *); 2067 - #ifdef CONFIG_QUOTA 2068 - ssize_t (*quota_read)(struct super_block *, int, char *, size_t, loff_t); 2069 - ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 2070 - struct dquot __rcu **(*get_dquots)(struct inode *); 2071 - #endif 2072 - long (*nr_cached_objects)(struct super_block *, 2073 - struct shrink_control *); 2074 - long (*free_cached_objects)(struct super_block *, 2075 - struct shrink_control *); 2076 - /* 2077 - * If a filesystem can support graceful removal of a device and 2078 - * continue read-write operations, implement this callback. 2079 - * 2080 - * Return 0 if the filesystem can continue read-write. 2081 - * Non-zero return value or no such callback means the fs will be shutdown 2082 - * as usual. 2083 - */ 2084 - int (*remove_bdev)(struct super_block *sb, struct block_device *bdev); 2085 - void (*shutdown)(struct super_block *sb); 2086 - }; 2087 - 2088 2434 /* 2089 2435 * Inode flags - they have no relation to superblock flags now 2090 2436 */ ··· 2061 2539 */ 2062 2540 #define __IS_FLG(inode, flg) ((inode)->i_sb->s_flags & (flg)) 2063 2541 2064 - static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags & SB_RDONLY; } 2065 2542 #define IS_RDONLY(inode) sb_rdonly((inode)->i_sb) 2066 2543 #define IS_SYNC(inode) (__IS_FLG(inode, SB_SYNCHRONOUS) || \ 2067 2544 ((inode)->i_flags & S_SYNC)) ··· 2294 2773 extern int vfs_statfs(const struct path *, struct kstatfs *); 2295 2774 extern int user_statfs(const char __user *, struct kstatfs *); 2296 2775 extern int fd_statfs(int, struct kstatfs *); 2297 - int freeze_super(struct super_block *super, enum freeze_holder who, 2298 - const void *freeze_owner); 2299 - int thaw_super(struct super_block *super, enum freeze_holder who, 2300 - const void *freeze_owner); 2301 2776 extern __printf(2, 3) 2302 2777 int super_setup_bdi_name(struct super_block *sb, char *fmt, ...); 2303 2778 extern int super_setup_bdi(struct super_block *sb); ··· 2479 2962 2480 2963 #define __getname() kmem_cache_alloc(names_cachep, GFP_KERNEL) 2481 2964 #define __putname(name) kmem_cache_free(names_cachep, (void *)(name)) 2482 - 2483 - extern struct super_block *blockdev_superblock; 2484 - static inline bool sb_is_blkdev_sb(struct super_block *sb) 2485 - { 2486 - return IS_ENABLED(CONFIG_BLOCK) && sb == blockdev_superblock; 2487 - } 2488 2965 2489 2966 void emergency_thaw_all(void); 2490 2967 extern int sync_filesystem(struct super_block *); ··· 2934 3423 extern void inode_sb_list_add(struct inode *inode); 2935 3424 extern void inode_add_lru(struct inode *inode); 2936 3425 2937 - extern int sb_set_blocksize(struct super_block *, int); 2938 - extern int sb_min_blocksize(struct super_block *, int); 2939 - 2940 3426 int generic_file_mmap(struct file *, struct vm_area_struct *); 2941 3427 int generic_file_mmap_prepare(struct vm_area_desc *desc); 2942 3428 int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); ··· 3252 3744 return true; 3253 3745 } 3254 3746 #endif 3255 - 3256 - static inline struct unicode_map *sb_encoding(const struct super_block *sb) 3257 - { 3258 - #if IS_ENABLED(CONFIG_UNICODE) 3259 - return sb->s_encoding; 3260 - #else 3261 - return NULL; 3262 - #endif 3263 - } 3264 - 3265 - static inline bool sb_has_encoding(const struct super_block *sb) 3266 - { 3267 - return !!sb_encoding(sb); 3268 - } 3269 - 3270 - /* 3271 - * Compare if two super blocks have the same encoding and flags 3272 - */ 3273 - static inline bool sb_same_encoding(const struct super_block *sb1, 3274 - const struct super_block *sb2) 3275 - { 3276 - #if IS_ENABLED(CONFIG_UNICODE) 3277 - if (sb1->s_encoding == sb2->s_encoding) 3278 - return true; 3279 - 3280 - return (sb1->s_encoding && sb2->s_encoding && 3281 - (sb1->s_encoding->version == sb2->s_encoding->version) && 3282 - (sb1->s_encoding_flags == sb2->s_encoding_flags)); 3283 - #else 3284 - return true; 3285 - #endif 3286 - } 3287 3747 3288 3748 int may_setattr(struct mnt_idmap *idmap, struct inode *inode, 3289 3749 unsigned int ia_valid);
+233
include/linux/fs/super.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + #ifndef _LINUX_FS_SUPER_H 3 + #define _LINUX_FS_SUPER_H 4 + 5 + #include <linux/fs/super_types.h> 6 + #include <linux/unicode.h> 7 + 8 + /* 9 + * These are internal functions, please use sb_start_{write,pagefault,intwrite} 10 + * instead. 11 + */ 12 + static inline void __sb_end_write(struct super_block *sb, int level) 13 + { 14 + percpu_up_read(sb->s_writers.rw_sem + level - 1); 15 + } 16 + 17 + static inline void __sb_start_write(struct super_block *sb, int level) 18 + { 19 + percpu_down_read_freezable(sb->s_writers.rw_sem + level - 1, true); 20 + } 21 + 22 + static inline bool __sb_start_write_trylock(struct super_block *sb, int level) 23 + { 24 + return percpu_down_read_trylock(sb->s_writers.rw_sem + level - 1); 25 + } 26 + 27 + #define __sb_writers_acquired(sb, lev) \ 28 + percpu_rwsem_acquire(&(sb)->s_writers.rw_sem[(lev) - 1], 1, _THIS_IP_) 29 + #define __sb_writers_release(sb, lev) \ 30 + percpu_rwsem_release(&(sb)->s_writers.rw_sem[(lev) - 1], _THIS_IP_) 31 + 32 + /** 33 + * __sb_write_started - check if sb freeze level is held 34 + * @sb: the super we write to 35 + * @level: the freeze level 36 + * 37 + * * > 0 - sb freeze level is held 38 + * * 0 - sb freeze level is not held 39 + * * < 0 - !CONFIG_LOCKDEP/LOCK_STATE_UNKNOWN 40 + */ 41 + static inline int __sb_write_started(const struct super_block *sb, int level) 42 + { 43 + return lockdep_is_held_type(sb->s_writers.rw_sem + level - 1, 1); 44 + } 45 + 46 + /** 47 + * sb_write_started - check if SB_FREEZE_WRITE is held 48 + * @sb: the super we write to 49 + * 50 + * May be false positive with !CONFIG_LOCKDEP/LOCK_STATE_UNKNOWN. 51 + */ 52 + static inline bool sb_write_started(const struct super_block *sb) 53 + { 54 + return __sb_write_started(sb, SB_FREEZE_WRITE); 55 + } 56 + 57 + /** 58 + * sb_write_not_started - check if SB_FREEZE_WRITE is not held 59 + * @sb: the super we write to 60 + * 61 + * May be false positive with !CONFIG_LOCKDEP/LOCK_STATE_UNKNOWN. 62 + */ 63 + static inline bool sb_write_not_started(const struct super_block *sb) 64 + { 65 + return __sb_write_started(sb, SB_FREEZE_WRITE) <= 0; 66 + } 67 + 68 + /** 69 + * sb_end_write - drop write access to a superblock 70 + * @sb: the super we wrote to 71 + * 72 + * Decrement number of writers to the filesystem. Wake up possible waiters 73 + * wanting to freeze the filesystem. 74 + */ 75 + static inline void sb_end_write(struct super_block *sb) 76 + { 77 + __sb_end_write(sb, SB_FREEZE_WRITE); 78 + } 79 + 80 + /** 81 + * sb_end_pagefault - drop write access to a superblock from a page fault 82 + * @sb: the super we wrote to 83 + * 84 + * Decrement number of processes handling write page fault to the filesystem. 85 + * Wake up possible waiters wanting to freeze the filesystem. 86 + */ 87 + static inline void sb_end_pagefault(struct super_block *sb) 88 + { 89 + __sb_end_write(sb, SB_FREEZE_PAGEFAULT); 90 + } 91 + 92 + /** 93 + * sb_end_intwrite - drop write access to a superblock for internal fs purposes 94 + * @sb: the super we wrote to 95 + * 96 + * Decrement fs-internal number of writers to the filesystem. Wake up possible 97 + * waiters wanting to freeze the filesystem. 98 + */ 99 + static inline void sb_end_intwrite(struct super_block *sb) 100 + { 101 + __sb_end_write(sb, SB_FREEZE_FS); 102 + } 103 + 104 + /** 105 + * sb_start_write - get write access to a superblock 106 + * @sb: the super we write to 107 + * 108 + * When a process wants to write data or metadata to a file system (i.e. dirty 109 + * a page or an inode), it should embed the operation in a sb_start_write() - 110 + * sb_end_write() pair to get exclusion against file system freezing. This 111 + * function increments number of writers preventing freezing. If the file 112 + * system is already frozen, the function waits until the file system is 113 + * thawed. 114 + * 115 + * Since freeze protection behaves as a lock, users have to preserve 116 + * ordering of freeze protection and other filesystem locks. Generally, 117 + * freeze protection should be the outermost lock. In particular, we have: 118 + * 119 + * sb_start_write 120 + * -> i_rwsem (write path, truncate, directory ops, ...) 121 + * -> s_umount (freeze_super, thaw_super) 122 + */ 123 + static inline void sb_start_write(struct super_block *sb) 124 + { 125 + __sb_start_write(sb, SB_FREEZE_WRITE); 126 + } 127 + 128 + static inline bool sb_start_write_trylock(struct super_block *sb) 129 + { 130 + return __sb_start_write_trylock(sb, SB_FREEZE_WRITE); 131 + } 132 + 133 + /** 134 + * sb_start_pagefault - get write access to a superblock from a page fault 135 + * @sb: the super we write to 136 + * 137 + * When a process starts handling write page fault, it should embed the 138 + * operation into sb_start_pagefault() - sb_end_pagefault() pair to get 139 + * exclusion against file system freezing. This is needed since the page fault 140 + * is going to dirty a page. This function increments number of running page 141 + * faults preventing freezing. If the file system is already frozen, the 142 + * function waits until the file system is thawed. 143 + * 144 + * Since page fault freeze protection behaves as a lock, users have to preserve 145 + * ordering of freeze protection and other filesystem locks. It is advised to 146 + * put sb_start_pagefault() close to mmap_lock in lock ordering. Page fault 147 + * handling code implies lock dependency: 148 + * 149 + * mmap_lock 150 + * -> sb_start_pagefault 151 + */ 152 + static inline void sb_start_pagefault(struct super_block *sb) 153 + { 154 + __sb_start_write(sb, SB_FREEZE_PAGEFAULT); 155 + } 156 + 157 + /** 158 + * sb_start_intwrite - get write access to a superblock for internal fs purposes 159 + * @sb: the super we write to 160 + * 161 + * This is the third level of protection against filesystem freezing. It is 162 + * free for use by a filesystem. The only requirement is that it must rank 163 + * below sb_start_pagefault. 164 + * 165 + * For example filesystem can call sb_start_intwrite() when starting a 166 + * transaction which somewhat eases handling of freezing for internal sources 167 + * of filesystem changes (internal fs threads, discarding preallocation on file 168 + * close, etc.). 169 + */ 170 + static inline void sb_start_intwrite(struct super_block *sb) 171 + { 172 + __sb_start_write(sb, SB_FREEZE_FS); 173 + } 174 + 175 + static inline bool sb_start_intwrite_trylock(struct super_block *sb) 176 + { 177 + return __sb_start_write_trylock(sb, SB_FREEZE_FS); 178 + } 179 + 180 + static inline bool sb_rdonly(const struct super_block *sb) 181 + { 182 + return sb->s_flags & SB_RDONLY; 183 + } 184 + 185 + static inline bool sb_is_blkdev_sb(struct super_block *sb) 186 + { 187 + return IS_ENABLED(CONFIG_BLOCK) && sb == blockdev_superblock; 188 + } 189 + 190 + #if IS_ENABLED(CONFIG_UNICODE) 191 + static inline struct unicode_map *sb_encoding(const struct super_block *sb) 192 + { 193 + return sb->s_encoding; 194 + } 195 + 196 + /* Compare if two super blocks have the same encoding and flags */ 197 + static inline bool sb_same_encoding(const struct super_block *sb1, 198 + const struct super_block *sb2) 199 + { 200 + if (sb1->s_encoding == sb2->s_encoding) 201 + return true; 202 + 203 + return (sb1->s_encoding && sb2->s_encoding && 204 + (sb1->s_encoding->version == sb2->s_encoding->version) && 205 + (sb1->s_encoding_flags == sb2->s_encoding_flags)); 206 + } 207 + #else 208 + static inline struct unicode_map *sb_encoding(const struct super_block *sb) 209 + { 210 + return NULL; 211 + } 212 + 213 + static inline bool sb_same_encoding(const struct super_block *sb1, 214 + const struct super_block *sb2) 215 + { 216 + return true; 217 + } 218 + #endif 219 + 220 + static inline bool sb_has_encoding(const struct super_block *sb) 221 + { 222 + return !!sb_encoding(sb); 223 + } 224 + 225 + int sb_set_blocksize(struct super_block *sb, int size); 226 + int sb_min_blocksize(struct super_block *sb, int size); 227 + 228 + int freeze_super(struct super_block *super, enum freeze_holder who, 229 + const void *freeze_owner); 230 + int thaw_super(struct super_block *super, enum freeze_holder who, 231 + const void *freeze_owner); 232 + 233 + #endif /* _LINUX_FS_SUPER_H */
+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 */
+7 -4
include/linux/fs_types.h include/linux/fs_dirent.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _LINUX_FS_TYPES_H 3 - #define _LINUX_FS_TYPES_H 2 + #ifndef _LINUX_FS_DIRENT_H 3 + #define _LINUX_FS_DIRENT_H 4 + 5 + #include <linux/stat.h> 6 + #include <linux/types.h> 4 7 5 8 /* 6 9 * This is a header for the common implementation of dirent ··· 69 66 70 67 /* 71 68 * declarations for helper functions, accompanying implementation 72 - * is in fs/fs_types.c 69 + * is in fs/fs_dirent.c 73 70 */ 74 71 extern unsigned char fs_ftype_to_dtype(unsigned int filetype); 75 72 extern unsigned char fs_umode_to_ftype(umode_t mode); 76 73 extern unsigned char fs_umode_to_dtype(umode_t mode); 77 74 78 - #endif 75 + #endif /* _LINUX_FS_DIRENT_H */