aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r--include/linux/fs.h77
1 files changed, 49 insertions, 28 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 805bf22898cf..33322702c910 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -74,6 +74,8 @@ extern struct inodes_stat_t inodes_stat;
74extern int leases_enable, lease_break_time; 74extern int leases_enable, lease_break_time;
75extern int sysctl_protected_symlinks; 75extern int sysctl_protected_symlinks;
76extern int sysctl_protected_hardlinks; 76extern int sysctl_protected_hardlinks;
77extern int sysctl_protected_fifos;
78extern int sysctl_protected_regular;
77 79
78typedef __kernel_rwf_t rwf_t; 80typedef __kernel_rwf_t rwf_t;
79 81
@@ -148,12 +150,18 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
148/* Has write method(s) */ 150/* Has write method(s) */
149#define FMODE_CAN_WRITE ((__force fmode_t)0x40000) 151#define FMODE_CAN_WRITE ((__force fmode_t)0x40000)
150 152
153#define FMODE_OPENED ((__force fmode_t)0x80000)
154#define FMODE_CREATED ((__force fmode_t)0x100000)
155
151/* File was opened by fanotify and shouldn't generate fanotify events */ 156/* File was opened by fanotify and shouldn't generate fanotify events */
152#define FMODE_NONOTIFY ((__force fmode_t)0x4000000) 157#define FMODE_NONOTIFY ((__force fmode_t)0x4000000)
153 158
154/* File is capable of returning -EAGAIN if I/O will block */ 159/* File is capable of returning -EAGAIN if I/O will block */
155#define FMODE_NOWAIT ((__force fmode_t)0x8000000) 160#define FMODE_NOWAIT ((__force fmode_t)0x8000000)
156 161
162/* File does not contribute to nr_files count */
163#define FMODE_NOACCOUNT ((__force fmode_t)0x20000000)
164
157/* 165/*
158 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector 166 * Flag for rw_copy_check_uvector and compat_rw_copy_check_uvector
159 * that indicates that they should check the contents of the iovec are 167 * that indicates that they should check the contents of the iovec are
@@ -176,7 +184,6 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset,
176#define ATTR_ATIME_SET (1 << 7) 184#define ATTR_ATIME_SET (1 << 7)
177#define ATTR_MTIME_SET (1 << 8) 185#define ATTR_MTIME_SET (1 << 8)
178#define ATTR_FORCE (1 << 9) /* Not a change, but a change it */ 186#define ATTR_FORCE (1 << 9) /* Not a change, but a change it */
179#define ATTR_ATTR_FLAG (1 << 10)
180#define ATTR_KILL_SUID (1 << 11) 187#define ATTR_KILL_SUID (1 << 11)
181#define ATTR_KILL_SGID (1 << 12) 188#define ATTR_KILL_SGID (1 << 12)
182#define ATTR_FILE (1 << 13) 189#define ATTR_FILE (1 << 13)
@@ -275,6 +282,7 @@ struct writeback_control;
275 282
276/* 283/*
277 * Write life time hint values. 284 * Write life time hint values.
285 * Stored in struct inode as u8.
278 */ 286 */
279enum rw_hint { 287enum rw_hint {
280 WRITE_LIFE_NOT_SET = 0, 288 WRITE_LIFE_NOT_SET = 0,
@@ -341,6 +349,10 @@ struct address_space_operations {
341 /* Set a page dirty. Return true if this dirtied it */ 349 /* Set a page dirty. Return true if this dirtied it */
342 int (*set_page_dirty)(struct page *page); 350 int (*set_page_dirty)(struct page *page);
343 351
352 /*
353 * Reads in the requested pages. Unlike ->readpage(), this is
354 * PURELY used for read-ahead!.
355 */
344 int (*readpages)(struct file *filp, struct address_space *mapping, 356 int (*readpages)(struct file *filp, struct address_space *mapping,
345 struct list_head *pages, unsigned nr_pages); 357 struct list_head *pages, unsigned nr_pages);
346 358
@@ -609,8 +621,8 @@ struct inode {
609 struct timespec64 i_ctime; 621 struct timespec64 i_ctime;
610 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ 622 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
611 unsigned short i_bytes; 623 unsigned short i_bytes;
612 unsigned int i_blkbits; 624 u8 i_blkbits;
613 enum rw_hint i_write_hint; 625 u8 i_write_hint;
614 blkcnt_t i_blocks; 626 blkcnt_t i_blocks;
615 627
616#ifdef __NEED_I_SIZE_ORDERED 628#ifdef __NEED_I_SIZE_ORDERED
@@ -685,6 +697,17 @@ static inline int inode_unhashed(struct inode *inode)
685} 697}
686 698
687/* 699/*
700 * __mark_inode_dirty expects inodes to be hashed. Since we don't
701 * want special inodes in the fileset inode space, we make them
702 * appear hashed, but do not put on any lists. hlist_del()
703 * will work fine and require no locking.
704 */
705static inline void inode_fake_hash(struct inode *inode)
706{
707 hlist_add_fake(&inode->i_hash);
708}
709
710/*
688 * inode->i_mutex nesting subclasses for the lock validator: 711 * inode->i_mutex nesting subclasses for the lock validator:
689 * 712 *
690 * 0: the object of the current VFS operation 713 * 0: the object of the current VFS operation
@@ -1049,17 +1072,7 @@ struct file_lock_context {
1049 1072
1050extern void send_sigio(struct fown_struct *fown, int fd, int band); 1073extern void send_sigio(struct fown_struct *fown, int fd, int band);
1051 1074
1052/* 1075#define locks_inode(f) file_inode(f)
1053 * Return the inode to use for locking
1054 *
1055 * For overlayfs this should be the overlay inode, not the real inode returned
1056 * by file_inode(). For any other fs file_inode(filp) and locks_inode(filp) are
1057 * equal.
1058 */
1059static inline struct inode *locks_inode(const struct file *f)
1060{
1061 return f->f_path.dentry->d_inode;
1062}
1063 1076
1064#ifdef CONFIG_FILE_LOCKING 1077#ifdef CONFIG_FILE_LOCKING
1065extern int fcntl_getlk(struct file *, unsigned int, struct flock *); 1078extern int fcntl_getlk(struct file *, unsigned int, struct flock *);
@@ -1244,7 +1257,7 @@ static inline struct inode *file_inode(const struct file *f)
1244 1257
1245static inline struct dentry *file_dentry(const struct file *file) 1258static inline struct dentry *file_dentry(const struct file *file)
1246{ 1259{
1247 return d_real(file->f_path.dentry, file_inode(file), 0, 0); 1260 return d_real(file->f_path.dentry, file_inode(file));
1248} 1261}
1249 1262
1250static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl) 1263static inline int locks_lock_file_wait(struct file *filp, struct file_lock *fl)
@@ -1300,7 +1313,6 @@ extern int send_sigurg(struct fown_struct *fown);
1300 1313
1301/* These sb flags are internal to the kernel */ 1314/* These sb flags are internal to the kernel */
1302#define SB_SUBMOUNT (1<<26) 1315#define SB_SUBMOUNT (1<<26)
1303#define SB_NOREMOTELOCK (1<<27)
1304#define SB_NOSEC (1<<28) 1316#define SB_NOSEC (1<<28)
1305#define SB_BORN (1<<29) 1317#define SB_BORN (1<<29)
1306#define SB_ACTIVE (1<<30) 1318#define SB_ACTIVE (1<<30)
@@ -1629,6 +1641,8 @@ int vfs_mkobj(struct dentry *, umode_t,
1629 int (*f)(struct dentry *, umode_t, void *), 1641 int (*f)(struct dentry *, umode_t, void *),
1630 void *); 1642 void *);
1631 1643
1644extern long vfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
1645
1632/* 1646/*
1633 * VFS file helper functions. 1647 * VFS file helper functions.
1634 */ 1648 */
@@ -1747,7 +1761,7 @@ struct file_operations {
1747 loff_t, size_t, unsigned int); 1761 loff_t, size_t, unsigned int);
1748 int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, 1762 int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t,
1749 u64); 1763 u64);
1750 ssize_t (*dedupe_file_range)(struct file *, u64, u64, struct file *, 1764 int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t,
1751 u64); 1765 u64);
1752} __randomize_layout; 1766} __randomize_layout;
1753 1767
@@ -1776,7 +1790,7 @@ struct inode_operations {
1776 int (*update_time)(struct inode *, struct timespec64 *, int); 1790 int (*update_time)(struct inode *, struct timespec64 *, int);
1777 int (*atomic_open)(struct inode *, struct dentry *, 1791 int (*atomic_open)(struct inode *, struct dentry *,
1778 struct file *, unsigned open_flag, 1792 struct file *, unsigned open_flag,
1779 umode_t create_mode, int *opened); 1793 umode_t create_mode);
1780 int (*tmpfile) (struct inode *, struct dentry *, umode_t); 1794 int (*tmpfile) (struct inode *, struct dentry *, umode_t);
1781 int (*set_acl)(struct inode *, struct posix_acl *, int); 1795 int (*set_acl)(struct inode *, struct posix_acl *, int);
1782} ____cacheline_aligned; 1796} ____cacheline_aligned;
@@ -1820,6 +1834,10 @@ extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
1820 loff_t len, bool *is_same); 1834 loff_t len, bool *is_same);
1821extern int vfs_dedupe_file_range(struct file *file, 1835extern int vfs_dedupe_file_range(struct file *file,
1822 struct file_dedupe_range *same); 1836 struct file_dedupe_range *same);
1837extern int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
1838 struct file *dst_file, loff_t dst_pos,
1839 u64 len);
1840
1823 1841
1824struct super_operations { 1842struct super_operations {
1825 struct inode *(*alloc_inode)(struct super_block *sb); 1843 struct inode *(*alloc_inode)(struct super_block *sb);
@@ -2014,6 +2032,8 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
2014 * I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper 2032 * I_OVL_INUSE Used by overlayfs to get exclusive ownership on upper
2015 * and work dirs among overlayfs mounts. 2033 * and work dirs among overlayfs mounts.
2016 * 2034 *
2035 * I_CREATING New object's inode in the middle of setting up.
2036 *
2017 * Q: What is the difference between I_WILL_FREE and I_FREEING? 2037 * Q: What is the difference between I_WILL_FREE and I_FREEING?
2018 */ 2038 */
2019#define I_DIRTY_SYNC (1 << 0) 2039#define I_DIRTY_SYNC (1 << 0)
@@ -2034,7 +2054,8 @@ static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp)
2034#define __I_DIRTY_TIME_EXPIRED 12 2054#define __I_DIRTY_TIME_EXPIRED 12
2035#define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED) 2055#define I_DIRTY_TIME_EXPIRED (1 << __I_DIRTY_TIME_EXPIRED)
2036#define I_WB_SWITCH (1 << 13) 2056#define I_WB_SWITCH (1 << 13)
2037#define I_OVL_INUSE (1 << 14) 2057#define I_OVL_INUSE (1 << 14)
2058#define I_CREATING (1 << 15)
2038 2059
2039#define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC) 2060#define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
2040#define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES) 2061#define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES)
@@ -2075,6 +2096,7 @@ enum file_time_flags {
2075 S_VERSION = 8, 2096 S_VERSION = 8,
2076}; 2097};
2077 2098
2099extern bool atime_needs_update(const struct path *, struct inode *);
2078extern void touch_atime(const struct path *); 2100extern void touch_atime(const struct path *);
2079static inline void file_accessed(struct file *file) 2101static inline void file_accessed(struct file *file)
2080{ 2102{
@@ -2420,7 +2442,12 @@ extern struct file *filp_open(const char *, int, umode_t);
2420extern struct file *file_open_root(struct dentry *, struct vfsmount *, 2442extern struct file *file_open_root(struct dentry *, struct vfsmount *,
2421 const char *, int, umode_t); 2443 const char *, int, umode_t);
2422extern struct file * dentry_open(const struct path *, int, const struct cred *); 2444extern struct file * dentry_open(const struct path *, int, const struct cred *);
2423extern struct file *filp_clone_open(struct file *); 2445extern struct file * open_with_fake_path(const struct path *, int,
2446 struct inode*, const struct cred *);
2447static inline struct file *file_clone_open(struct file *file)
2448{
2449 return dentry_open(&file->f_path, file->f_flags, file->f_cred);
2450}
2424extern int filp_close(struct file *, fl_owner_t id); 2451extern int filp_close(struct file *, fl_owner_t id);
2425 2452
2426extern struct filename *getname_flags(const char __user *, int, int *); 2453extern struct filename *getname_flags(const char __user *, int, int *);
@@ -2428,13 +2455,8 @@ extern struct filename *getname(const char __user *);
2428extern struct filename *getname_kernel(const char *); 2455extern struct filename *getname_kernel(const char *);
2429extern void putname(struct filename *name); 2456extern void putname(struct filename *name);
2430 2457
2431enum {
2432 FILE_CREATED = 1,
2433 FILE_OPENED = 2
2434};
2435extern int finish_open(struct file *file, struct dentry *dentry, 2458extern int finish_open(struct file *file, struct dentry *dentry,
2436 int (*open)(struct inode *, struct file *), 2459 int (*open)(struct inode *, struct file *));
2437 int *opened);
2438extern int finish_no_open(struct file *file, struct dentry *dentry); 2460extern int finish_no_open(struct file *file, struct dentry *dentry);
2439 2461
2440/* fs/ioctl.c */ 2462/* fs/ioctl.c */
@@ -2622,8 +2644,6 @@ static inline int filemap_fdatawait(struct address_space *mapping)
2622 2644
2623extern bool filemap_range_has_page(struct address_space *, loff_t lstart, 2645extern bool filemap_range_has_page(struct address_space *, loff_t lstart,
2624 loff_t lend); 2646 loff_t lend);
2625extern int __must_check file_fdatawait_range(struct file *file, loff_t lstart,
2626 loff_t lend);
2627extern int filemap_write_and_wait(struct address_space *mapping); 2647extern int filemap_write_and_wait(struct address_space *mapping);
2628extern int filemap_write_and_wait_range(struct address_space *mapping, 2648extern int filemap_write_and_wait_range(struct address_space *mapping,
2629 loff_t lstart, loff_t lend); 2649 loff_t lstart, loff_t lend);
@@ -2918,6 +2938,7 @@ extern void lockdep_annotate_inode_mutex_key(struct inode *inode);
2918static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { }; 2938static inline void lockdep_annotate_inode_mutex_key(struct inode *inode) { };
2919#endif 2939#endif
2920extern void unlock_new_inode(struct inode *); 2940extern void unlock_new_inode(struct inode *);
2941extern void discard_new_inode(struct inode *);
2921extern unsigned int get_next_ino(void); 2942extern unsigned int get_next_ino(void);
2922extern void evict_inodes(struct super_block *sb); 2943extern void evict_inodes(struct super_block *sb);
2923 2944