22#ifndef _LINUX_FS_H
33#define _LINUX_FS_H
44
5+ #include <linux/fs/super_types.h>
56#include <linux/vfsdebug.h>
67#include <linux/linkage.h>
78#include <linux/wait_bit.h>
1112#include <linux/stat.h>
1213#include <linux/cache.h>
1314#include <linux/list.h>
14- #include <linux/list_lru.h>
1515#include <linux/llist.h>
1616#include <linux/radix-tree.h>
1717#include <linux/xarray.h>
3737#include <linux/uuid.h>
3838#include <linux/errseq.h>
3939#include <linux/ioprio.h>
40- #include <linux/fs_dirent.h>
4140#include <linux/build_bug.h>
4241#include <linux/stddef.h>
4342#include <linux/mount.h>
5251#include <asm/byteorder.h>
5352#include <uapi/linux/fs.h>
5453
55- struct backing_dev_info ;
5654struct bdi_writeback ;
5755struct bio ;
5856struct io_comp_batch ;
59- struct export_operations ;
6057struct fiemap_extent_info ;
6158struct hd_geometry ;
6259struct iovec ;
@@ -70,12 +67,8 @@ struct vfsmount;
7067struct cred ;
7168struct swap_info_struct ;
7269struct seq_file ;
73- struct workqueue_struct ;
7470struct iov_iter ;
75- struct fscrypt_operations ;
76- struct fsverity_operations ;
7771struct fsnotify_mark_connector ;
78- struct fsnotify_sb_info ;
7972struct fs_context ;
8073struct fs_parameter_spec ;
8174struct file_kattr ;
@@ -298,11 +291,6 @@ struct iattr {
298291 struct file * ia_file ;
299292};
300293
301- /*
302- * Includes for diskquotas.
303- */
304- #include <linux/quota.h>
305-
306294/*
307295 * Maximum number of layers of fs stack. Needs to be limited to
308296 * prevent kernel stack overflow
@@ -1347,49 +1335,6 @@ extern void f_delown(struct file *filp);
13471335extern pid_t f_getown (struct file * filp );
13481336extern int send_sigurg (struct file * file );
13491337
1350- /*
1351- * sb->s_flags. Note that these mirror the equivalent MS_* flags where
1352- * represented in both.
1353- */
1354- #define SB_RDONLY BIT(0) /* Mount read-only */
1355- #define SB_NOSUID BIT(1) /* Ignore suid and sgid bits */
1356- #define SB_NODEV BIT(2) /* Disallow access to device special files */
1357- #define SB_NOEXEC BIT(3) /* Disallow program execution */
1358- #define SB_SYNCHRONOUS BIT(4) /* Writes are synced at once */
1359- #define SB_MANDLOCK BIT(6) /* Allow mandatory locks on an FS */
1360- #define SB_DIRSYNC BIT(7) /* Directory modifications are synchronous */
1361- #define SB_NOATIME BIT(10) /* Do not update access times. */
1362- #define SB_NODIRATIME BIT(11) /* Do not update directory access times */
1363- #define SB_SILENT BIT(15)
1364- #define SB_POSIXACL BIT(16) /* Supports POSIX ACLs */
1365- #define SB_INLINECRYPT BIT(17) /* Use blk-crypto for encrypted files */
1366- #define SB_KERNMOUNT BIT(22) /* this is a kern_mount call */
1367- #define SB_I_VERSION BIT(23) /* Update inode I_version field */
1368- #define SB_LAZYTIME BIT(25) /* Update the on-disk [acm]times lazily */
1369-
1370- /* These sb flags are internal to the kernel */
1371- #define SB_DEAD BIT(21)
1372- #define SB_DYING BIT(24)
1373- #define SB_FORCE BIT(27)
1374- #define SB_NOSEC BIT(28)
1375- #define SB_BORN BIT(29)
1376- #define SB_ACTIVE BIT(30)
1377- #define SB_NOUSER BIT(31)
1378-
1379- /* These flags relate to encoding and casefolding */
1380- #define SB_ENC_STRICT_MODE_FL (1 << 0)
1381- #define SB_ENC_NO_COMPAT_FALLBACK_FL (1 << 1)
1382-
1383- #define sb_has_strict_encoding (sb ) \
1384- (sb->s_encoding_flags & SB_ENC_STRICT_MODE_FL)
1385-
1386- #if IS_ENABLED (CONFIG_UNICODE )
1387- #define sb_no_casefold_compat_fallback (sb ) \
1388- (sb->s_encoding_flags & SB_ENC_NO_COMPAT_FALLBACK_FL)
1389- #else
1390- #define sb_no_casefold_compat_fallback (sb ) (1)
1391- #endif
1392-
13931338/*
13941339 * Umount options
13951340 */
@@ -1400,191 +1345,6 @@ extern int send_sigurg(struct file *file);
14001345#define UMOUNT_NOFOLLOW 0x00000008 /* Don't follow symlink on umount */
14011346#define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */
14021347
1403- /* sb->s_iflags */
1404- #define SB_I_CGROUPWB 0x00000001 /* cgroup-aware writeback enabled */
1405- #define SB_I_NOEXEC 0x00000002 /* Ignore executables on this fs */
1406- #define SB_I_NODEV 0x00000004 /* Ignore devices on this fs */
1407- #define SB_I_STABLE_WRITES 0x00000008 /* don't modify blks until WB is done */
1408-
1409- /* sb->s_iflags to limit user namespace mounts */
1410- #define SB_I_USERNS_VISIBLE 0x00000010 /* fstype already mounted */
1411- #define SB_I_IMA_UNVERIFIABLE_SIGNATURE 0x00000020
1412- #define SB_I_UNTRUSTED_MOUNTER 0x00000040
1413- #define SB_I_EVM_HMAC_UNSUPPORTED 0x00000080
1414-
1415- #define SB_I_SKIP_SYNC 0x00000100 /* Skip superblock at global sync */
1416- #define SB_I_PERSB_BDI 0x00000200 /* has a per-sb bdi */
1417- #define SB_I_TS_EXPIRY_WARNED 0x00000400 /* warned about timestamp range expiry */
1418- #define SB_I_RETIRED 0x00000800 /* superblock shouldn't be reused */
1419- #define SB_I_NOUMASK 0x00001000 /* VFS does not apply umask */
1420- #define SB_I_NOIDMAP 0x00002000 /* No idmapped mounts on this superblock */
1421- #define SB_I_ALLOW_HSM 0x00004000 /* Allow HSM events on this superblock */
1422-
1423- /* Possible states of 'frozen' field */
1424- enum {
1425- SB_UNFROZEN = 0 , /* FS is unfrozen */
1426- SB_FREEZE_WRITE = 1 , /* Writes, dir ops, ioctls frozen */
1427- SB_FREEZE_PAGEFAULT = 2 , /* Page faults stopped as well */
1428- SB_FREEZE_FS = 3 , /* For internal FS use (e.g. to stop
1429- * internal threads if needed) */
1430- SB_FREEZE_COMPLETE = 4 , /* ->freeze_fs finished successfully */
1431- };
1432-
1433- #define SB_FREEZE_LEVELS (SB_FREEZE_COMPLETE - 1)
1434-
1435- struct sb_writers {
1436- unsigned short frozen ; /* Is sb frozen? */
1437- int freeze_kcount ; /* How many kernel freeze requests? */
1438- int freeze_ucount ; /* How many userspace freeze requests? */
1439- const void * freeze_owner ; /* Owner of the freeze */
1440- struct percpu_rw_semaphore rw_sem [SB_FREEZE_LEVELS ];
1441- };
1442-
1443- struct mount ;
1444-
1445- struct super_block {
1446- struct list_head s_list ; /* Keep this first */
1447- dev_t s_dev ; /* search index; _not_ kdev_t */
1448- unsigned char s_blocksize_bits ;
1449- unsigned long s_blocksize ;
1450- loff_t s_maxbytes ; /* Max file size */
1451- struct file_system_type * s_type ;
1452- const struct super_operations * s_op ;
1453- const struct dquot_operations * dq_op ;
1454- const struct quotactl_ops * s_qcop ;
1455- const struct export_operations * s_export_op ;
1456- unsigned long s_flags ;
1457- unsigned long s_iflags ; /* internal SB_I_* flags */
1458- unsigned long s_magic ;
1459- struct dentry * s_root ;
1460- struct rw_semaphore s_umount ;
1461- int s_count ;
1462- atomic_t s_active ;
1463- #ifdef CONFIG_SECURITY
1464- void * s_security ;
1465- #endif
1466- const struct xattr_handler * const * s_xattr ;
1467- #ifdef CONFIG_FS_ENCRYPTION
1468- const struct fscrypt_operations * s_cop ;
1469- struct fscrypt_keyring * s_master_keys ; /* master crypto keys in use */
1470- #endif
1471- #ifdef CONFIG_FS_VERITY
1472- const struct fsverity_operations * s_vop ;
1473- #endif
1474- #if IS_ENABLED (CONFIG_UNICODE )
1475- struct unicode_map * s_encoding ;
1476- __u16 s_encoding_flags ;
1477- #endif
1478- struct hlist_bl_head s_roots ; /* alternate root dentries for NFS */
1479- struct mount * s_mounts ; /* list of mounts; _not_ for fs use */
1480- struct block_device * s_bdev ; /* can go away once we use an accessor for @s_bdev_file */
1481- struct file * s_bdev_file ;
1482- struct backing_dev_info * s_bdi ;
1483- struct mtd_info * s_mtd ;
1484- struct hlist_node s_instances ;
1485- unsigned int s_quota_types ; /* Bitmask of supported quota types */
1486- struct quota_info s_dquot ; /* Diskquota specific options */
1487-
1488- struct sb_writers s_writers ;
1489-
1490- /*
1491- * Keep s_fs_info, s_time_gran, s_fsnotify_mask, and
1492- * s_fsnotify_info together for cache efficiency. They are frequently
1493- * accessed and rarely modified.
1494- */
1495- void * s_fs_info ; /* Filesystem private info */
1496-
1497- /* Granularity of c/m/atime in ns (cannot be worse than a second) */
1498- u32 s_time_gran ;
1499- /* Time limits for c/m/atime in seconds */
1500- time64_t s_time_min ;
1501- time64_t s_time_max ;
1502- #ifdef CONFIG_FSNOTIFY
1503- u32 s_fsnotify_mask ;
1504- struct fsnotify_sb_info * s_fsnotify_info ;
1505- #endif
1506-
1507- /*
1508- * q: why are s_id and s_sysfs_name not the same? both are human
1509- * readable strings that identify the filesystem
1510- * a: s_id is allowed to change at runtime; it's used in log messages,
1511- * and we want to when a device starts out as single device (s_id is dev
1512- * name) but then a device is hot added and we have to switch to
1513- * identifying it by UUID
1514- * but s_sysfs_name is a handle for programmatic access, and can't
1515- * change at runtime
1516- */
1517- char s_id [32 ]; /* Informational name */
1518- uuid_t s_uuid ; /* UUID */
1519- u8 s_uuid_len ; /* Default 16, possibly smaller for weird filesystems */
1520-
1521- /* if set, fs shows up under sysfs at /sys/fs/$FSTYP/s_sysfs_name */
1522- char s_sysfs_name [UUID_STRING_LEN + 1 ];
1523-
1524- unsigned int s_max_links ;
1525- unsigned int s_d_flags ; /* default d_flags for dentries */
1526-
1527- /*
1528- * The next field is for VFS *only*. No filesystems have any business
1529- * even looking at it. You had been warned.
1530- */
1531- struct mutex s_vfs_rename_mutex ; /* Kludge */
1532-
1533- /*
1534- * Filesystem subtype. If non-empty the filesystem type field
1535- * in /proc/mounts will be "type.subtype"
1536- */
1537- const char * s_subtype ;
1538-
1539- const struct dentry_operations * __s_d_op ; /* default d_op for dentries */
1540-
1541- struct shrinker * s_shrink ; /* per-sb shrinker handle */
1542-
1543- /* Number of inodes with nlink == 0 but still referenced */
1544- atomic_long_t s_remove_count ;
1545-
1546- /* Read-only state of the superblock is being changed */
1547- int s_readonly_remount ;
1548-
1549- /* per-sb errseq_t for reporting writeback errors via syncfs */
1550- errseq_t s_wb_err ;
1551-
1552- /* AIO completions deferred from interrupt context */
1553- struct workqueue_struct * s_dio_done_wq ;
1554- struct hlist_head s_pins ;
1555-
1556- /*
1557- * Owning user namespace and default context in which to
1558- * interpret filesystem uids, gids, quotas, device nodes,
1559- * xattrs and security labels.
1560- */
1561- struct user_namespace * s_user_ns ;
1562-
1563- /*
1564- * The list_lru structure is essentially just a pointer to a table
1565- * of per-node lru lists, each of which has its own spinlock.
1566- * There is no need to put them into separate cachelines.
1567- */
1568- struct list_lru s_dentry_lru ;
1569- struct list_lru s_inode_lru ;
1570- struct rcu_head rcu ;
1571- struct work_struct destroy_work ;
1572-
1573- struct mutex s_sync_lock ; /* sync serialisation lock */
1574-
1575- /*
1576- * Indicates how deep in a filesystem stack this SB is
1577- */
1578- int s_stack_depth ;
1579-
1580- /* s_inode_list_lock protects s_inodes */
1581- spinlock_t s_inode_list_lock ____cacheline_aligned_in_smp ;
1582- struct list_head s_inodes ; /* all inodes */
1583-
1584- spinlock_t s_inode_wblist_lock ;
1585- struct list_head s_inodes_wb ; /* writeback inodes */
1586- } __randomize_layout ;
1587-
15881348static inline struct user_namespace * i_user_ns (const struct inode * inode )
15891349{
15901350 return inode -> i_sb -> s_user_ns ;
@@ -2431,72 +2191,6 @@ extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
24312191 struct file * dst_file , loff_t dst_pos ,
24322192 loff_t len , unsigned int remap_flags );
24332193
2434- /**
2435- * enum freeze_holder - holder of the freeze
2436- * @FREEZE_HOLDER_KERNEL: kernel wants to freeze or thaw filesystem
2437- * @FREEZE_HOLDER_USERSPACE: userspace wants to freeze or thaw filesystem
2438- * @FREEZE_MAY_NEST: whether nesting freeze and thaw requests is allowed
2439- * @FREEZE_EXCL: a freeze that can only be undone by the owner
2440- *
2441- * Indicate who the owner of the freeze or thaw request is and whether
2442- * the freeze needs to be exclusive or can nest.
2443- * Without @FREEZE_MAY_NEST, multiple freeze and thaw requests from the
2444- * same holder aren't allowed. It is however allowed to hold a single
2445- * @FREEZE_HOLDER_USERSPACE and a single @FREEZE_HOLDER_KERNEL freeze at
2446- * the same time. This is relied upon by some filesystems during online
2447- * repair or similar.
2448- */
2449- enum freeze_holder {
2450- FREEZE_HOLDER_KERNEL = (1U << 0 ),
2451- FREEZE_HOLDER_USERSPACE = (1U << 1 ),
2452- FREEZE_MAY_NEST = (1U << 2 ),
2453- FREEZE_EXCL = (1U << 3 ),
2454- };
2455-
2456- struct super_operations {
2457- struct inode * (* alloc_inode )(struct super_block * sb );
2458- void (* destroy_inode )(struct inode * );
2459- void (* free_inode )(struct inode * );
2460-
2461- void (* dirty_inode ) (struct inode * , int flags );
2462- int (* write_inode ) (struct inode * , struct writeback_control * wbc );
2463- int (* drop_inode ) (struct inode * );
2464- void (* evict_inode ) (struct inode * );
2465- void (* put_super ) (struct super_block * );
2466- int (* sync_fs )(struct super_block * sb , int wait );
2467- int (* freeze_super ) (struct super_block * , enum freeze_holder who , const void * owner );
2468- int (* freeze_fs ) (struct super_block * );
2469- int (* thaw_super ) (struct super_block * , enum freeze_holder who , const void * owner );
2470- int (* unfreeze_fs ) (struct super_block * );
2471- int (* statfs ) (struct dentry * , struct kstatfs * );
2472- int (* remount_fs ) (struct super_block * , int * , char * );
2473- void (* umount_begin ) (struct super_block * );
2474-
2475- int (* show_options )(struct seq_file * , struct dentry * );
2476- int (* show_devname )(struct seq_file * , struct dentry * );
2477- int (* show_path )(struct seq_file * , struct dentry * );
2478- int (* show_stats )(struct seq_file * , struct dentry * );
2479- #ifdef CONFIG_QUOTA
2480- ssize_t (* quota_read )(struct super_block * , int , char * , size_t , loff_t );
2481- ssize_t (* quota_write )(struct super_block * , int , const char * , size_t , loff_t );
2482- struct dquot __rcu * * (* get_dquots )(struct inode * );
2483- #endif
2484- long (* nr_cached_objects )(struct super_block * ,
2485- struct shrink_control * );
2486- long (* free_cached_objects )(struct super_block * ,
2487- struct shrink_control * );
2488- /*
2489- * If a filesystem can support graceful removal of a device and
2490- * continue read-write operations, implement this callback.
2491- *
2492- * Return 0 if the filesystem can continue read-write.
2493- * Non-zero return value or no such callback means the fs will be shutdown
2494- * as usual.
2495- */
2496- int (* remove_bdev )(struct super_block * sb , struct block_device * bdev );
2497- void (* shutdown )(struct super_block * sb );
2498- };
2499-
25002194/*
25012195 * Inode flags - they have no relation to superblock flags now
25022196 */
0 commit comments