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.h100
1 files changed, 73 insertions, 27 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b5b979247863..b224dc468a23 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
@@ -392,8 +395,9 @@ struct inodes_stat_t {
392#include <linux/semaphore.h> 395#include <linux/semaphore.h>
393#include <linux/fiemap.h> 396#include <linux/fiemap.h>
394#include <linux/rculist_bl.h> 397#include <linux/rculist_bl.h>
398#include <linux/shrinker.h>
399#include <linux/atomic.h>
395 400
396#include <asm/atomic.h>
397#include <asm/byteorder.h> 401#include <asm/byteorder.h>
398 402
399struct export_operations; 403struct export_operations;
@@ -777,7 +781,7 @@ struct inode {
777 struct timespec i_ctime; 781 struct timespec i_ctime;
778 blkcnt_t i_blocks; 782 blkcnt_t i_blocks;
779 unsigned short i_bytes; 783 unsigned short i_bytes;
780 struct rw_semaphore i_alloc_sem; 784 atomic_t i_dio_count;
781 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 785 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
782 struct file_lock *i_flock; 786 struct file_lock *i_flock;
783 struct address_space *i_mapping; 787 struct address_space *i_mapping;
@@ -1396,6 +1400,11 @@ struct super_block {
1396 struct list_head s_dentry_lru; /* unused dentry lru */ 1400 struct list_head s_dentry_lru; /* unused dentry lru */
1397 int s_nr_dentry_unused; /* # of dentry on lru */ 1401 int s_nr_dentry_unused; /* # of dentry on lru */
1398 1402
1403 /* s_inode_lru_lock protects s_inode_lru and s_nr_inodes_unused */
1404 spinlock_t s_inode_lru_lock ____cacheline_aligned_in_smp;
1405 struct list_head s_inode_lru; /* unused inode lru */
1406 int s_nr_inodes_unused; /* # of inodes on lru */
1407
1399 struct block_device *s_bdev; 1408 struct block_device *s_bdev;
1400 struct backing_dev_info *s_bdi; 1409 struct backing_dev_info *s_bdi;
1401 struct mtd_info *s_mtd; 1410 struct mtd_info *s_mtd;
@@ -1438,8 +1447,14 @@ struct super_block {
1438 * Saved pool identifier for cleancache (-1 means none) 1447 * Saved pool identifier for cleancache (-1 means none)
1439 */ 1448 */
1440 int cleancache_poolid; 1449 int cleancache_poolid;
1450
1451 struct shrinker s_shrink; /* per-sb shrinker handle */
1441}; 1452};
1442 1453
1454/* superblock cache pruning functions */
1455extern void prune_icache_sb(struct super_block *sb, int nr_to_scan);
1456extern void prune_dcache_sb(struct super_block *sb, int nr_to_scan);
1457
1443extern struct timespec current_fs_time(struct super_block *sb); 1458extern struct timespec current_fs_time(struct super_block *sb);
1444 1459
1445/* 1460/*
@@ -1490,7 +1505,6 @@ extern void dentry_unhash(struct dentry *dentry);
1490/* 1505/*
1491 * VFS file helper functions. 1506 * VFS file helper functions.
1492 */ 1507 */
1493extern int file_permission(struct file *, int);
1494extern void inode_init_owner(struct inode *inode, const struct inode *dir, 1508extern void inode_init_owner(struct inode *inode, const struct inode *dir,
1495 mode_t mode); 1509 mode_t mode);
1496/* 1510/*
@@ -1538,11 +1552,6 @@ struct block_device_operations;
1538#define HAVE_COMPAT_IOCTL 1 1552#define HAVE_COMPAT_IOCTL 1
1539#define HAVE_UNLOCKED_IOCTL 1 1553#define HAVE_UNLOCKED_IOCTL 1
1540 1554
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 { 1555struct file_operations {
1547 struct module *owner; 1556 struct module *owner;
1548 loff_t (*llseek) (struct file *, loff_t, int); 1557 loff_t (*llseek) (struct file *, loff_t, int);
@@ -1558,7 +1567,7 @@ struct file_operations {
1558 int (*open) (struct inode *, struct file *); 1567 int (*open) (struct inode *, struct file *);
1559 int (*flush) (struct file *, fl_owner_t id); 1568 int (*flush) (struct file *, fl_owner_t id);
1560 int (*release) (struct inode *, struct file *); 1569 int (*release) (struct inode *, struct file *);
1561 int (*fsync) (struct file *, int datasync); 1570 int (*fsync) (struct file *, loff_t, loff_t, int datasync);
1562 int (*aio_fsync) (struct kiocb *, int datasync); 1571 int (*aio_fsync) (struct kiocb *, int datasync);
1563 int (*fasync) (int, struct file *, int); 1572 int (*fasync) (int, struct file *, int);
1564 int (*lock) (struct file *, int, struct file_lock *); 1573 int (*lock) (struct file *, int, struct file_lock *);
@@ -1573,13 +1582,11 @@ struct file_operations {
1573 loff_t len); 1582 loff_t len);
1574}; 1583};
1575 1584
1576#define IPERM_FLAG_RCU 0x0001
1577
1578struct inode_operations { 1585struct inode_operations {
1579 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *); 1586 struct dentry * (*lookup) (struct inode *,struct dentry *, struct nameidata *);
1580 void * (*follow_link) (struct dentry *, struct nameidata *); 1587 void * (*follow_link) (struct dentry *, struct nameidata *);
1581 int (*permission) (struct inode *, int, unsigned int); 1588 int (*permission) (struct inode *, int);
1582 int (*check_acl)(struct inode *, int, unsigned int); 1589 int (*check_acl)(struct inode *, int);
1583 1590
1584 int (*readlink) (struct dentry *, char __user *,int); 1591 int (*readlink) (struct dentry *, char __user *,int);
1585 void (*put_link) (struct dentry *, struct nameidata *, void *); 1592 void (*put_link) (struct dentry *, struct nameidata *, void *);
@@ -1645,6 +1652,8 @@ struct super_operations {
1645 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); 1652 ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t);
1646#endif 1653#endif
1647 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); 1654 int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t);
1655 int (*nr_cached_objects)(struct super_block *);
1656 void (*free_cached_objects)(struct super_block *, int);
1648}; 1657};
1649 1658
1650/* 1659/*
@@ -1693,6 +1702,10 @@ struct super_operations {
1693 * set during data writeback, and cleared with a wakeup 1702 * set during data writeback, and cleared with a wakeup
1694 * on the bit address once it is done. 1703 * on the bit address once it is done.
1695 * 1704 *
1705 * I_REFERENCED Marks the inode as recently references on the LRU list.
1706 *
1707 * I_DIO_WAKEUP Never set. Only used as a key for wait_on_bit().
1708 *
1696 * Q: What is the difference between I_WILL_FREE and I_FREEING? 1709 * Q: What is the difference between I_WILL_FREE and I_FREEING?
1697 */ 1710 */
1698#define I_DIRTY_SYNC (1 << 0) 1711#define I_DIRTY_SYNC (1 << 0)
@@ -1706,6 +1719,8 @@ struct super_operations {
1706#define __I_SYNC 7 1719#define __I_SYNC 7
1707#define I_SYNC (1 << __I_SYNC) 1720#define I_SYNC (1 << __I_SYNC)
1708#define I_REFERENCED (1 << 8) 1721#define I_REFERENCED (1 << 8)
1722#define __I_DIO_WAKEUP 9
1723#define I_DIO_WAKEUP (1 << I_DIO_WAKEUP)
1709 1724
1710#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES) 1725#define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
1711 1726
@@ -1816,7 +1831,6 @@ struct file_system_type {
1816 struct lock_class_key i_lock_key; 1831 struct lock_class_key i_lock_key;
1817 struct lock_class_key i_mutex_key; 1832 struct lock_class_key i_mutex_key;
1818 struct lock_class_key i_mutex_dir_key; 1833 struct lock_class_key i_mutex_dir_key;
1819 struct lock_class_key i_alloc_sem_key;
1820}; 1834};
1821 1835
1822extern struct dentry *mount_ns(struct file_system_type *fs_type, int flags, 1836extern struct dentry *mount_ns(struct file_system_type *fs_type, int flags,
@@ -1837,6 +1851,8 @@ void kill_litter_super(struct super_block *sb);
1837void deactivate_super(struct super_block *sb); 1851void deactivate_super(struct super_block *sb);
1838void deactivate_locked_super(struct super_block *sb); 1852void deactivate_locked_super(struct super_block *sb);
1839int set_anon_super(struct super_block *s, void *data); 1853int set_anon_super(struct super_block *s, void *data);
1854int get_anon_bdev(dev_t *);
1855void free_anon_bdev(dev_t);
1840struct super_block *sget(struct file_system_type *type, 1856struct super_block *sget(struct file_system_type *type,
1841 int (*test)(struct super_block *,void *), 1857 int (*test)(struct super_block *,void *),
1842 int (*set)(struct super_block *,void *), 1858 int (*set)(struct super_block *,void *),
@@ -2188,16 +2204,38 @@ extern sector_t bmap(struct inode *, sector_t);
2188#endif 2204#endif
2189extern int notify_change(struct dentry *, struct iattr *); 2205extern int notify_change(struct dentry *, struct iattr *);
2190extern int inode_permission(struct inode *, int); 2206extern int inode_permission(struct inode *, int);
2191extern int generic_permission(struct inode *, int, unsigned int, 2207extern int generic_permission(struct inode *, int);
2192 int (*check_acl)(struct inode *, int, unsigned int));
2193 2208
2194static inline bool execute_ok(struct inode *inode) 2209static inline bool execute_ok(struct inode *inode)
2195{ 2210{
2196 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode); 2211 return (inode->i_mode & S_IXUGO) || S_ISDIR(inode->i_mode);
2197} 2212}
2198 2213
2199extern int get_write_access(struct inode *); 2214/*
2200extern int deny_write_access(struct file *); 2215 * get_write_access() gets write permission for a file.
2216 * put_write_access() releases this write permission.
2217 * This is used for regular files.
2218 * We cannot support write (and maybe mmap read-write shared) accesses and
2219 * MAP_DENYWRITE mmappings simultaneously. The i_writecount field of an inode
2220 * can have the following values:
2221 * 0: no writers, no VM_DENYWRITE mappings
2222 * < 0: (-i_writecount) vm_area_structs with VM_DENYWRITE set exist
2223 * > 0: (i_writecount) users are writing to the file.
2224 *
2225 * Normally we operate on that counter with atomic_{inc,dec} and it's safe
2226 * except for the cases where we don't hold i_writecount yet. Then we need to
2227 * use {get,deny}_write_access() - these functions check the sign and refuse
2228 * to do the change if sign is wrong.
2229 */
2230static inline int get_write_access(struct inode *inode)
2231{
2232 return atomic_inc_unless_negative(&inode->i_writecount) ? 0 : -ETXTBSY;
2233}
2234static inline int deny_write_access(struct file *file)
2235{
2236 struct inode *inode = file->f_path.dentry->d_inode;
2237 return atomic_dec_unless_positive(&inode->i_writecount) ? 0 : -ETXTBSY;
2238}
2201static inline void put_write_access(struct inode * inode) 2239static inline void put_write_access(struct inode * inode)
2202{ 2240{
2203 atomic_dec(&inode->i_writecount); 2241 atomic_dec(&inode->i_writecount);
@@ -2317,7 +2355,8 @@ extern int generic_segment_checks(const struct iovec *iov,
2317/* fs/block_dev.c */ 2355/* fs/block_dev.c */
2318extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov, 2356extern ssize_t blkdev_aio_write(struct kiocb *iocb, const struct iovec *iov,
2319 unsigned long nr_segs, loff_t pos); 2357 unsigned long nr_segs, loff_t pos);
2320extern int blkdev_fsync(struct file *filp, int datasync); 2358extern int blkdev_fsync(struct file *filp, loff_t start, loff_t end,
2359 int datasync);
2321 2360
2322/* fs/splice.c */ 2361/* fs/splice.c */
2323extern ssize_t generic_file_splice_read(struct file *, loff_t *, 2362extern ssize_t generic_file_splice_read(struct file *, loff_t *,
@@ -2368,6 +2407,8 @@ enum {
2368}; 2407};
2369 2408
2370void dio_end_io(struct bio *bio, int error); 2409void dio_end_io(struct bio *bio, int error);
2410void inode_dio_wait(struct inode *inode);
2411void inode_dio_done(struct inode *inode);
2371 2412
2372ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, 2413ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
2373 struct block_device *bdev, const struct iovec *iov, loff_t offset, 2414 struct block_device *bdev, const struct iovec *iov, loff_t offset,
@@ -2375,14 +2416,17 @@ ssize_t __blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode,
2375 dio_submit_t submit_io, int flags); 2416 dio_submit_t submit_io, int flags);
2376 2417
2377static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb, 2418static inline ssize_t blockdev_direct_IO(int rw, struct kiocb *iocb,
2378 struct inode *inode, struct block_device *bdev, const struct iovec *iov, 2419 struct inode *inode, const struct iovec *iov, loff_t offset,
2379 loff_t offset, unsigned long nr_segs, get_block_t get_block, 2420 unsigned long nr_segs, get_block_t get_block)
2380 dio_iodone_t end_io)
2381{ 2421{
2382 return __blockdev_direct_IO(rw, iocb, inode, bdev, iov, offset, 2422 return __blockdev_direct_IO(rw, iocb, inode, inode->i_sb->s_bdev, iov,
2383 nr_segs, get_block, end_io, NULL, 2423 offset, nr_segs, get_block, NULL, NULL,
2384 DIO_LOCKING | DIO_SKIP_HOLES); 2424 DIO_LOCKING | DIO_SKIP_HOLES);
2385} 2425}
2426#else
2427static inline void inode_dio_wait(struct inode *inode)
2428{
2429}
2386#endif 2430#endif
2387 2431
2388extern const struct file_operations generic_ro_fops; 2432extern const struct file_operations generic_ro_fops;
@@ -2432,6 +2476,8 @@ extern struct super_block *get_active_super(struct block_device *bdev);
2432extern struct super_block *user_get_super(dev_t); 2476extern struct super_block *user_get_super(dev_t);
2433extern void drop_super(struct super_block *sb); 2477extern void drop_super(struct super_block *sb);
2434extern void iterate_supers(void (*)(struct super_block *, void *), void *); 2478extern void iterate_supers(void (*)(struct super_block *, void *), void *);
2479extern void iterate_supers_type(struct file_system_type *,
2480 void (*)(struct super_block *, void *), void *);
2435 2481
2436extern int dcache_dir_open(struct inode *, struct file *); 2482extern int dcache_dir_open(struct inode *, struct file *);
2437extern int dcache_dir_close(struct inode *, struct file *); 2483extern int dcache_dir_close(struct inode *, struct file *);
@@ -2444,7 +2490,7 @@ extern int simple_link(struct dentry *, struct inode *, struct dentry *);
2444extern int simple_unlink(struct inode *, struct dentry *); 2490extern int simple_unlink(struct inode *, struct dentry *);
2445extern int simple_rmdir(struct inode *, struct dentry *); 2491extern int simple_rmdir(struct inode *, struct dentry *);
2446extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *); 2492extern int simple_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
2447extern int noop_fsync(struct file *, int); 2493extern int noop_fsync(struct file *, loff_t, loff_t, int);
2448extern int simple_empty(struct dentry *); 2494extern int simple_empty(struct dentry *);
2449extern int simple_readpage(struct file *file, struct page *page); 2495extern int simple_readpage(struct file *file, struct page *page);
2450extern int simple_write_begin(struct file *file, struct address_space *mapping, 2496extern int simple_write_begin(struct file *file, struct address_space *mapping,
@@ -2469,7 +2515,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, 2515extern ssize_t simple_write_to_buffer(void *to, size_t available, loff_t *ppos,
2470 const void __user *from, size_t count); 2516 const void __user *from, size_t count);
2471 2517
2472extern int generic_file_fsync(struct file *, int); 2518extern int generic_file_fsync(struct file *, loff_t, loff_t, int);
2473 2519
2474extern int generic_check_addressable(unsigned, u64); 2520extern int generic_check_addressable(unsigned, u64);
2475 2521