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.h118
1 files changed, 80 insertions, 38 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b5b979247863..5f523eb9bb8d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -32,7 +32,9 @@
32#define SEEK_SET 0 /* seek relative to beginning of file */ 32#define SEEK_SET 0 /* seek relative to beginning of file */
33#define SEEK_CUR 1 /* seek relative to current file position */ 33#define SEEK_CUR 1 /* seek relative to current file position */
34#define SEEK_END 2 /* seek relative to end of file */ 34#define SEEK_END 2 /* seek relative to end of file */
35#define SEEK_MAX SEEK_END 35#define SEEK_DATA 3 /* seek to the next data */
36#define SEEK_HOLE 4 /* seek to the next hole */
37#define SEEK_MAX SEEK_HOLE
36 38
37struct fstrim_range { 39struct fstrim_range {
38 __u64 start; 40 __u64 start;
@@ -63,6 +65,7 @@ struct inodes_stat_t {
63#define MAY_ACCESS 16 65#define MAY_ACCESS 16
64#define MAY_OPEN 32 66#define MAY_OPEN 32
65#define MAY_CHDIR 64 67#define MAY_CHDIR 64
68#define MAY_NOT_BLOCK 128 /* called from RCU mode, don't block */
66 69
67/* 70/*
68 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond 71 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond
@@ -376,7 +379,6 @@ struct inodes_stat_t {
376 379
377#include <linux/linkage.h> 380#include <linux/linkage.h>
378#include <linux/wait.h> 381#include <linux/wait.h>
379#include <linux/types.h>
380#include <linux/kdev_t.h> 382#include <linux/kdev_t.h>
381#include <linux/dcache.h> 383#include <linux/dcache.h>
382#include <linux/path.h> 384#include <linux/path.h>
@@ -392,8 +394,9 @@ struct inodes_stat_t {
392#include <linux/semaphore.h> 394#include <linux/semaphore.h>
393#include <linux/fiemap.h> 395#include <linux/fiemap.h>
394#include <linux/rculist_bl.h> 396#include <linux/rculist_bl.h>
397#include <linux/shrinker.h>
398#include <linux/atomic.h>
395 399
396#include <asm/atomic.h>
397#include <asm/byteorder.h> 400#include <asm/byteorder.h>
398 401
399struct export_operations; 402struct export_operations;
@@ -777,7 +780,7 @@ struct inode {
777 struct timespec i_ctime; 780 struct timespec i_ctime;
778 blkcnt_t i_blocks; 781 blkcnt_t i_blocks;
779 unsigned short i_bytes; 782 unsigned short i_bytes;
780 struct rw_semaphore i_alloc_sem; 783 atomic_t i_dio_count;
781 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 784 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
782 struct file_lock *i_flock; 785 struct file_lock *i_flock;
783 struct address_space *i_mapping; 786 struct address_space *i_mapping;
@@ -1069,12 +1072,12 @@ struct file_lock_operations {
1069}; 1072};
1070 1073
1071struct lock_manager_operations { 1074struct lock_manager_operations {
1072 int (*fl_compare_owner)(struct file_lock *, struct file_lock *); 1075 int (*lm_compare_owner)(struct file_lock *, struct file_lock *);
1073 void (*fl_notify)(struct file_lock *); /* unblock callback */ 1076 void (*lm_notify)(struct file_lock *); /* unblock callback */
1074 int (*fl_grant)(struct file_lock *, struct file_lock *, int); 1077 int (*lm_grant)(struct file_lock *, struct file_lock *, int);
1075 void (*fl_release_private)(struct file_lock *); 1078 void (*lm_release_private)(struct file_lock *);
1076 void (*fl_break)(struct file_lock *); 1079 void (*lm_break)(struct file_lock *);
1077 int (*fl_change)(struct file_lock **, int); 1080 int (*lm_change)(struct file_lock **, int);
1078}; 1081};
1079 1082
1080struct lock_manager { 1083struct lock_manager {
@@ -1396,6 +1399,11 @@ struct super_block {
1396 struct list_head s_dentry_lru; /* unused dentry lru */ 1399 struct list_head s_dentry_lru; /* unused dentry lru */
1397 int s_nr_dentry_unused; /* # of dentry on lru */ 1400 int s_nr_dentry_unused; /* # of dentry on lru */
1398 1401
1402 /* s_inode_lru_lock protects s_inode_lru and s_nr_inodes_unused */
1403 spinlock_t s_inode_lru_lock ____cacheline_aligned_in_smp;
1404 struct list_head s_inode_lru; /* unused inode lru */
1405 int s_nr_inodes_unused; /* # of inodes on lru */
1406
1399 struct block_device *s_bdev; 1407 struct block_device *s_bdev;
1400 struct backing_dev_info *s_bdi; 1408 struct backing_dev_info *s_bdi;
1401 struct mtd_info *s_mtd; 1409 struct mtd_info *s_mtd;
@@ -1438,8 +1446,14 @@ struct super_block {
1438 * Saved pool identifier for cleancache (-1 means none) 1446 * Saved pool identifier for cleancache (-1 means none)
1439 */ 1447 */
1440 int cleancache_poolid; 1448 int cleancache_poolid;
1449
1450 struct shrinker s_shrink; /* per-sb shrinker handle */
1441}; 1451};
1442 1452
1453/* superblock cache pruning functions */
1454extern void prune_icache_sb(struct super_block *sb, int nr_to_scan);
1455extern void prune_dcache_sb(struct super_block *sb, int nr_to_scan);
1456
1443extern struct timespec current_fs_time(struct super_block *sb); 1457extern struct timespec current_fs_time(struct super_block *sb);
1444 1458
1445/* 1459/*
@@ -1454,10 +1468,6 @@ enum {
1454#define vfs_check_frozen(sb, level) \ 1468#define vfs_check_frozen(sb, level) \
1455 wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level))) 1469 wait_event((sb)->s_wait_unfrozen, ((sb)->s_frozen < (level)))
1456 1470
1457#define get_fs_excl() atomic_inc(&current->fs_excl)
1458#define put_fs_excl() atomic_dec(&current->fs_excl)
1459#define has_fs_excl() atomic_read(&current->fs_excl)
1460
1461/* 1471/*
1462 * until VFS tracks user namespaces for inodes, just make all files 1472 * until VFS tracks user namespaces for inodes, just make all files
1463 * belong to init_user_ns 1473 * belong to init_user_ns
@@ -1490,7 +1500,6 @@ extern void dentry_unhash(struct dentry *dentry);
1490/* 1500/*
1491 * VFS file helper functions. 1501 * VFS file helper functions.
1492 */ 1502 */
1493extern int file_permission(struct file *, int);
1494extern void inode_init_owner(struct inode *inode, const struct inode *dir, 1503extern void inode_init_owner(struct inode *inode, const struct inode *dir,
1495 mode_t mode); 1504 mode_t mode);
1496/* 1505/*
@@ -1538,11 +1547,6 @@ struct block_device_operations;
1538#define HAVE_COMPAT_IOCTL 1 1547#define HAVE_COMPAT_IOCTL 1
1539#define HAVE_UNLOCKED_IOCTL 1 1548#define HAVE_UNLOCKED_IOCTL 1
1540 1549
1541/*
1542 * NOTE:
1543 * all file operations except setlease can be called without
1544 * the big kernel lock held in all filesystems.
1545 */
1546struct file_operations { 1550struct file_operations {
1547 struct module *owner; 1551 struct module *owner;
1548 loff_t (*llseek) (struct file *, loff_t, int); 1552 loff_t (*llseek) (struct file *, loff_t, int);
@@ -1558,7 +1562,7 @@ struct file_operations {
1558 int (*open) (struct inode *, struct file *); 1562 int (*open) (struct inode *, struct file *);
1559 int (*flush) (struct file *, fl_owner_t id); 1563 int (*flush) (struct file *, fl_owner_t id);
1560 int (*release) (struct inode *, struct file *); 1564 int (*release) (struct inode *, struct file *);
1561 int (*fsync) (struct file *, int datasync); 1565 int (*fsync) (struct file *, loff_t, loff_t, int datasync);
1562 int (*aio_fsync) (struct kiocb *, int datasync); 1566 int (*aio_fsync) (struct kiocb *, int datasync);
1563 int (*fasync) (int, struct file *, int); 1567 int (*fasync) (int, struct file *, int);
1564 int (*lock) (struct file *, int, struct file_lock *); 1568 int (*lock) (struct file *, int, struct file_lock *);
@@ -1573,13 +1577,11 @@ struct file_operations {
1573 loff_t len); 1577 loff_t len);
1574}; 1578};
1575 1579
1576#define IPERM_FLAG_RCU 0x0001
1577
1578struct inode_operations { 1580struct inode_operations {
1579 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *); 1581 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
1580 void * (*follow_link) (struct dentry *, struct nameidata *); 1582 void * (*follow_link) (struct dentry *, struct nameidata *);
1581 int (*permission) (struct inode *, int, unsigned int); 1583 int (*permission) (struct inode *, int);
1582 int (*check_acl)(struct inode *, int, unsigned int); 1584 struct posix_acl * (*get_acl)(struct inode *, int);
1583 1585
1584 int (*readlink) (struct dentry *, char __user *,int); 1586 int (*readlink) (struct dentry *, char __user *,int);
1585 void (*put_link) (struct dentry *, struct nameidata *, void *); 1587 void (*put_link) (struct dentry *, struct nameidata *, void *);
@@ -1645,6 +1647,8 @@ struct super_operations {
1645 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 1647 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
1646#endif 1648#endif
1647 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); 1649 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
1650 int (*nr_cached_objects)(struct super_block *);
1651 void (*free_cached_objects)(struct super_block *, int);
1648}; 1652};
1649 1653
1650/* 1654/*
@@ -1693,6 +1697,10 @@ struct super_operations {
1693 * set during data writeback, and cleared with a wakeup 1697 * set during data writeback, and cleared with a wakeup
1694 * on the bit address once it is done. 1698 * on the bit address once it is done.
1695 * 1699 *
1700 * I_REFERENCED Marks the inode as recently references on the LRU list.
1701 *
1702 * I_DIO_WAKEUP Never set. Only used as a key for wait_on_bit().
1703 *
1696 * Q: What is the difference between I_WILL_FREE and I_FREEING? 1704 * Q: What is the difference between I_WILL_FREE and I_FREEING?
1697 */ 1705 */
1698#define I_DIRTY_SYNC (1 << 0) 1706#define I_DIRTY_SYNC (1 << 0)
@@ -1706,6 +1714,8 @@ struct super_operations {
1706#define __I_SYNC 7 1714#define __I_SYNC 7
1707#define I_SYNC (1 << __I_SYNC) 1715#define I_SYNC (1 << __I_SYNC)
1708#define I_REFERENCED (1 << 8) 1716#define I_REFERENCED (1 << 8)
1717#define __I_DIO_WAKEUP 9
1718#define I_DIO_WAKEUP (1 << I_DIO_WAKEUP)
1709 1719
1710#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) 1720#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
1711 1721
@@ -1816,7 +1826,6 @@ struct file_system_type {
1816 struct lock_class_key i_lock_key; 1826 struct lock_class_key i_lock_key;
1817 struct lock_class_key i_mutex_key; 1827 struct lock_class_key i_mutex_key;
1818 struct lock_class_key i_mutex_dir_key; 1828 struct lock_class_key i_mutex_dir_key;
1819 struct lock_class_key i_alloc_sem_key;
1820}; 1829};
1821 1830
1822extern struct dentry *mount_ns(struct file_system_type *fs_type, int flags, 1831extern struct dentry *mount_ns(struct file_system_type *fs_type, int flags,
@@ -1837,6 +1846,8 @@ void kill_litter_super(struct super_block *sb);
1837void deactivate_super(struct super_block *sb); 1846void deactivate_super(struct super_block *sb);
1838void deactivate_locked_super(struct super_block *sb); 1847void deactivate_locked_super(struct super_block *sb);
1839int set_anon_super(struct super_block *s, void *data); 1848int set_anon_super(struct super_block *s, void *data);
1849int get_anon_bdev(dev_t *);
1850void free_anon_bdev(dev_t);
1840struct super_block *sget(struct file_system_type *type, 1851struct super_block *sget(struct file_system_type *type,
1841 int (*test)(struct super_block *,void *), 1852 int (*test)(struct super_block *,void *),
1842 int (*set)(struct super_block *,void *), 1853 int (*set)(struct super_block *,void *),
@@ -1869,6 +1880,7 @@ extern int register_filesystem(struct file_system_type *);
1869extern int unregister_filesystem(struct file_system_type *); 1880extern int unregister_filesystem(struct file_system_type *);
1870extern struct vfsmount *kern_mount_data(struct file_system_type *, void *data); 1881extern struct vfsmount *kern_mount_data(struct file_system_type *, void *data);
1871#define kern_mount(type) kern_mount_data(type, NULL) 1882#define kern_mount(type) kern_mount_data(type, NULL)
1883extern void kern_unmount(struct vfsmount *mnt);
1872extern int may_umount_tree(struct vfsmount *); 1884extern int may_umount_tree(struct vfsmount *);
1873extern int may_umount(struct vfsmount *); 1885extern int may_umount(struct vfsmount *);
1874extern long do_mount(char *, char *, char *, unsigned long, void *); 1886extern long do_mount(char *, char *, char *, unsigned long, void *);
@@ -2188,16 +2200,38 @@ extern sector_t bmap(struct inode *, sector_t);
2188#endif 2200#endif
2189extern int notify_change(struct dentry *, struct iattr *); 2201extern int notify_change(struct dentry *, struct iattr *);
2190extern int inode_permission(struct inode *, int); 2202extern int inode_permission(struct inode *, int);
2191extern int generic_permission(struct inode *, int, unsigned int, 2203extern int generic_permission(struct inode *, int);
2192 int (*check_acl)(struct inode *, int, unsigned int));
2193 2204
2194static inline bool execute_ok(struct inode *inode) 2205static inline bool execute_ok(struct inode *inode)
2195{ 2206{
2196 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode); 2207 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
2197} 2208}
2198 2209
2199extern int get_write_access(struct inode *); 2210/*
2200extern int deny_write_access(struct file *); 2211 * get_write_access() gets write permission for a file.
2212 * put_write_access() releases this write permission.
2213 * This is used for regular files.
2214 * We cannot support write (and maybe mmap read-write shared) accesses and
2215 * MAP_DENYWRITE mmappings simultaneously. The i_writecount field of an inode
2216 * can have the following values:
2217 * 0: no writers, no VM_DENYWRITE mappings
2218 * < 0: (-i_writecount) vm_area_structs with VM_DENYWRITE set exist
2219 * > 0: (i_writecount) users are writing to the file.
2220 *
2221 * Normally we operate on that counter with atomic_{inc,dec} and it's safe
2222 * except for the cases where we don't hold i_writecount yet. Then we need to
2223 * use {get,deny}_write_access() - these functions check the sign and refuse
2224 * to do the change if sign is wrong.
2225 */
2226static inline int get_write_access(struct inode *inode)
2227{
2228 return atomic_inc_unless_negative(&inode->i_writecount) ? 0 : -ETXTBSY;
2229}
2230static inline int deny_write_access(struct file *file)
2231{
2232 struct inode *inode = file->f_path.dentry->d_inode;
2233 return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY;
2234}
2201static inline void put_write_access(struct inode * inode) 2235static inline void put_write_access(struct inode * inode)
2202{ 2236{
2203 atomic_dec(&inode->i_writecount); 2237 atomic_dec(&inode->i_writecount);
@@ -2317,7 +2351,8 @@ extern int generic_segment_checks(const struct iovec *iov,
2317/* fs/block_dev.c */ 2351/* fs/block_dev.c */
2318extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, 2352extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
2319 unsigned long nr_segs, loff_t pos); 2353 unsigned long nr_segs, loff_t pos);
2320extern int blkdev_fsync(struct file *filp, int datasync); 2354extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
2355 int datasync);
2321 2356
2322/* fs/splice.c */ 2357/* fs/splice.c */
2323extern ssize_t generic_file_splice_read(struct file *, loff_t *, 2358extern ssize_t generic_file_splice_read(struct file *, loff_t *,
@@ -2368,6 +2403,8 @@ enum {
2368}; 2403};
2369 2404
2370void dio_end_io(struct bio *bio, int error); 2405void dio_end_io(struct bio *bio, int error);
2406void inode_dio_wait(struct inode *inode);
2407void inode_dio_done(struct inode *inode);
2371 2408
2372ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, 2409ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
2373 struct block_device *bdev, const struct iovec *iov, loff_t offset, 2410 struct block_device *bdev, const struct iovec *iov, loff_t offset,
@@ -2375,14 +2412,17 @@ ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
2375 dio_submit_t submit_io, int flags); 2412 dio_submit_t submit_io, int flags);
2376 2413
2377static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb, 2414static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
2378 struct inode *inode, struct block_device *bdev, const struct iovec *iov, 2415 struct inode *inode, const struct iovec *iov, loff_t offset,
2379 loff_t offset, unsigned long nr_segs, get_block_t get_block, 2416 unsigned long nr_segs, get_block_t get_block)
2380 dio_iodone_t end_io)
2381{ 2417{
2382 return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset, 2418 return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
2383 nr_segs, get_block, end_io, NULL, 2419 offset, nr_segs, get_block, NULL, NULL,
2384 DIO_LOCKING | DIO_SKIP_HOLES); 2420 DIO_LOCKING | DIO_SKIP_HOLES);
2385} 2421}
2422#else
2423static inline void inode_dio_wait(struct inode *inode)
2424{
2425}
2386#endif 2426#endif
2387 2427
2388extern const struct file_operations generic_ro_fops; 2428extern const struct file_operations generic_ro_fops;
@@ -2432,6 +2472,8 @@ extern struct super_block *get_active_super(struct block_device *bdev);
2432extern struct super_block *user_get_super(dev_t); 2472extern struct super_block *user_get_super(dev_t);
2433extern void drop_super(struct super_block *sb); 2473extern void drop_super(struct super_block *sb);
2434extern void iterate_supers(void (*)(struct super_block *, void *), void *); 2474extern void iterate_supers(void (*)(struct super_block *, void *), void *);
2475extern void iterate_supers_type(struct file_system_type *,
2476 void (*)(struct super_block *, void *), void *);
2435 2477
2436extern int dcache_dir_open(struct inode *, struct file *); 2478extern int dcache_dir_open(struct inode *, struct file *);
2437extern int dcache_dir_close(struct inode *, struct file *); 2479extern int dcache_dir_close(struct inode *, struct file *);
@@ -2444,7 +2486,7 @@ extern int simple_link(struct dentry *, struct inode *, struct dentry *);
2444extern int simple_unlink(struct inode *, struct dentry *); 2486extern int simple_unlink(struct inode *, struct dentry *);
2445extern int simple_rmdir(struct inode *, struct dentry *); 2487extern int simple_rmdir(struct inode *, struct dentry *);
2446extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); 2488extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
2447extern int noop_fsync(struct file *, int); 2489extern int noop_fsync(struct file *, loff_t, loff_t, int);
2448extern int simple_empty(struct dentry *); 2490extern int simple_empty(struct dentry *);
2449extern int simple_readpage(struct file *file, struct page *page); 2491extern int simple_readpage(struct file *file, struct page *page);
2450extern int simple_write_begin(struct file *file, struct address_space *mapping, 2492extern int simple_write_begin(struct file *file, struct address_space *mapping,
@@ -2469,7 +2511,7 @@ extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
2469extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos, 2511extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos,
2470 const void __user *from, size_t count); 2512 const void __user *from, size_t count);
2471 2513
2472extern int generic_file_fsync(struct file *, int); 2514extern int generic_file_fsync(struct file *, loff_t, loff_t, int);
2473 2515
2474extern int generic_check_addressable(unsigned, u64); 2516extern int generic_check_addressable(unsigned, u64);
2475 2517