diff options
Diffstat (limited to 'include/linux/fs.h')
-rw-r--r-- | include/linux/fs.h | 166 |
1 files changed, 40 insertions, 126 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 4f0b3bf5983c..d33beadd9a43 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -44,7 +44,7 @@ extern int get_max_files(void); | |||
44 | struct inodes_stat_t { | 44 | struct inodes_stat_t { |
45 | int nr_inodes; | 45 | int nr_inodes; |
46 | int nr_unused; | 46 | int nr_unused; |
47 | int dummy[5]; | 47 | int dummy[5]; /* padding for sysctl ABI compatibility */ |
48 | }; | 48 | }; |
49 | extern struct inodes_stat_t inodes_stat; | 49 | extern struct inodes_stat_t inodes_stat; |
50 | 50 | ||
@@ -283,11 +283,14 @@ extern int dir_notify_enable; | |||
283 | #include <linux/init.h> | 283 | #include <linux/init.h> |
284 | #include <linux/pid.h> | 284 | #include <linux/pid.h> |
285 | #include <linux/mutex.h> | 285 | #include <linux/mutex.h> |
286 | #include <linux/sysctl.h> | ||
287 | #include <linux/capability.h> | ||
286 | 288 | ||
287 | #include <asm/atomic.h> | 289 | #include <asm/atomic.h> |
288 | #include <asm/semaphore.h> | 290 | #include <asm/semaphore.h> |
289 | #include <asm/byteorder.h> | 291 | #include <asm/byteorder.h> |
290 | 292 | ||
293 | struct export_operations; | ||
291 | struct hd_geometry; | 294 | struct hd_geometry; |
292 | struct iovec; | 295 | struct iovec; |
293 | struct nameidata; | 296 | struct nameidata; |
@@ -694,20 +697,26 @@ struct fown_struct { | |||
694 | * Track a single file's readahead state | 697 | * Track a single file's readahead state |
695 | */ | 698 | */ |
696 | struct file_ra_state { | 699 | struct file_ra_state { |
697 | unsigned long start; /* Current window */ | 700 | pgoff_t start; /* where readahead started */ |
698 | unsigned long size; | 701 | unsigned long size; /* # of readahead pages */ |
699 | unsigned long flags; /* ra flags RA_FLAG_xxx*/ | 702 | unsigned long async_size; /* do asynchronous readahead when |
700 | unsigned long cache_hit; /* cache hit count*/ | 703 | there are only # of pages ahead */ |
701 | unsigned long prev_index; /* Cache last read() position */ | 704 | |
702 | unsigned long ahead_start; /* Ahead window */ | ||
703 | unsigned long ahead_size; | ||
704 | unsigned long ra_pages; /* Maximum readahead window */ | 705 | unsigned long ra_pages; /* Maximum readahead window */ |
705 | unsigned long mmap_hit; /* Cache hit stat for mmap accesses */ | 706 | unsigned long mmap_hit; /* Cache hit stat for mmap accesses */ |
706 | unsigned long mmap_miss; /* Cache miss stat for mmap accesses */ | 707 | unsigned long mmap_miss; /* Cache miss stat for mmap accesses */ |
708 | unsigned long prev_index; /* Cache last read() position */ | ||
707 | unsigned int prev_offset; /* Offset where last read() ended in a page */ | 709 | unsigned int prev_offset; /* Offset where last read() ended in a page */ |
708 | }; | 710 | }; |
709 | #define RA_FLAG_MISS 0x01 /* a cache miss occured against this file */ | 711 | |
710 | #define RA_FLAG_INCACHE 0x02 /* file is already in cache */ | 712 | /* |
713 | * Check if @index falls in the readahead windows. | ||
714 | */ | ||
715 | static inline int ra_has_index(struct file_ra_state *ra, pgoff_t index) | ||
716 | { | ||
717 | return (index >= ra->start && | ||
718 | index < ra->start + ra->size); | ||
719 | } | ||
711 | 720 | ||
712 | struct file { | 721 | struct file { |
713 | /* | 722 | /* |
@@ -820,6 +829,10 @@ struct file_lock { | |||
820 | union { | 829 | union { |
821 | struct nfs_lock_info nfs_fl; | 830 | struct nfs_lock_info nfs_fl; |
822 | struct nfs4_lock_info nfs4_fl; | 831 | struct nfs4_lock_info nfs4_fl; |
832 | struct { | ||
833 | struct list_head link; /* link in AFS vnode's pending_locks list */ | ||
834 | int state; /* state of grant or error if -ve */ | ||
835 | } afs; | ||
823 | } fl_u; | 836 | } fl_u; |
824 | }; | 837 | }; |
825 | 838 | ||
@@ -855,7 +868,7 @@ extern void locks_init_lock(struct file_lock *); | |||
855 | extern void locks_copy_lock(struct file_lock *, struct file_lock *); | 868 | extern void locks_copy_lock(struct file_lock *, struct file_lock *); |
856 | extern void locks_remove_posix(struct file *, fl_owner_t); | 869 | extern void locks_remove_posix(struct file *, fl_owner_t); |
857 | extern void locks_remove_flock(struct file *); | 870 | extern void locks_remove_flock(struct file *); |
858 | extern int posix_test_lock(struct file *, struct file_lock *); | 871 | extern void posix_test_lock(struct file *, struct file_lock *); |
859 | extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *); | 872 | extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *); |
860 | extern int posix_lock_file_wait(struct file *, struct file_lock *); | 873 | extern int posix_lock_file_wait(struct file *, struct file_lock *); |
861 | extern int posix_unblock_lock(struct file *, struct file_lock *); | 874 | extern int posix_unblock_lock(struct file *, struct file_lock *); |
@@ -866,6 +879,7 @@ extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl); | |||
866 | extern int __break_lease(struct inode *inode, unsigned int flags); | 879 | extern int __break_lease(struct inode *inode, unsigned int flags); |
867 | extern void lease_get_mtime(struct inode *, struct timespec *time); | 880 | extern void lease_get_mtime(struct inode *, struct timespec *time); |
868 | extern int setlease(struct file *, long, struct file_lock **); | 881 | extern int setlease(struct file *, long, struct file_lock **); |
882 | extern int vfs_setlease(struct file *, long, struct file_lock **); | ||
869 | extern int lease_modify(struct file_lock **, int); | 883 | extern int lease_modify(struct file_lock **, int); |
870 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); | 884 | extern int lock_may_read(struct inode *, loff_t start, unsigned long count); |
871 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); | 885 | extern int lock_may_write(struct inode *, loff_t start, unsigned long count); |
@@ -984,6 +998,9 @@ enum { | |||
984 | #define put_fs_excl() atomic_dec(¤t->fs_excl) | 998 | #define put_fs_excl() atomic_dec(¤t->fs_excl) |
985 | #define has_fs_excl() atomic_read(¤t->fs_excl) | 999 | #define has_fs_excl() atomic_read(¤t->fs_excl) |
986 | 1000 | ||
1001 | #define is_owner_or_cap(inode) \ | ||
1002 | ((current->fsuid == (inode)->i_uid) || capable(CAP_FOWNER)) | ||
1003 | |||
987 | /* not quite ready to be deprecated, but... */ | 1004 | /* not quite ready to be deprecated, but... */ |
988 | extern void lock_super(struct super_block *); | 1005 | extern void lock_super(struct super_block *); |
989 | extern void unlock_super(struct super_block *); | 1006 | extern void unlock_super(struct super_block *); |
@@ -1112,6 +1129,7 @@ struct file_operations { | |||
1112 | int (*flock) (struct file *, int, struct file_lock *); | 1129 | int (*flock) (struct file *, int, struct file_lock *); |
1113 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); | 1130 | ssize_t (*splice_write)(struct pipe_inode_info *, struct file *, loff_t *, size_t, unsigned int); |
1114 | ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); | 1131 | ssize_t (*splice_read)(struct file *, loff_t *, struct pipe_inode_info *, size_t, unsigned int); |
1132 | int (*setlease)(struct file *, long, struct file_lock **); | ||
1115 | }; | 1133 | }; |
1116 | 1134 | ||
1117 | struct inode_operations { | 1135 | struct inode_operations { |
@@ -1137,6 +1155,8 @@ struct inode_operations { | |||
1137 | ssize_t (*listxattr) (struct dentry *, char *, size_t); | 1155 | ssize_t (*listxattr) (struct dentry *, char *, size_t); |
1138 | int (*removexattr) (struct dentry *, const char *); | 1156 | int (*removexattr) (struct dentry *, const char *); |
1139 | void (*truncate_range)(struct inode *, loff_t, loff_t); | 1157 | void (*truncate_range)(struct inode *, loff_t, loff_t); |
1158 | long (*fallocate)(struct inode *inode, int mode, loff_t offset, | ||
1159 | loff_t len); | ||
1140 | }; | 1160 | }; |
1141 | 1161 | ||
1142 | struct seq_file; | 1162 | struct seq_file; |
@@ -1273,119 +1293,6 @@ static inline void file_accessed(struct file *file) | |||
1273 | 1293 | ||
1274 | int sync_inode(struct inode *inode, struct writeback_control *wbc); | 1294 | int sync_inode(struct inode *inode, struct writeback_control *wbc); |
1275 | 1295 | ||
1276 | /** | ||
1277 | * struct export_operations - for nfsd to communicate with file systems | ||
1278 | * @decode_fh: decode a file handle fragment and return a &struct dentry | ||
1279 | * @encode_fh: encode a file handle fragment from a dentry | ||
1280 | * @get_name: find the name for a given inode in a given directory | ||
1281 | * @get_parent: find the parent of a given directory | ||
1282 | * @get_dentry: find a dentry for the inode given a file handle sub-fragment | ||
1283 | * @find_exported_dentry: | ||
1284 | * set by the exporting module to a standard helper function. | ||
1285 | * | ||
1286 | * Description: | ||
1287 | * The export_operations structure provides a means for nfsd to communicate | ||
1288 | * with a particular exported file system - particularly enabling nfsd and | ||
1289 | * the filesystem to co-operate when dealing with file handles. | ||
1290 | * | ||
1291 | * export_operations contains two basic operation for dealing with file | ||
1292 | * handles, decode_fh() and encode_fh(), and allows for some other | ||
1293 | * operations to be defined which standard helper routines use to get | ||
1294 | * specific information from the filesystem. | ||
1295 | * | ||
1296 | * nfsd encodes information use to determine which filesystem a filehandle | ||
1297 | * applies to in the initial part of the file handle. The remainder, termed | ||
1298 | * a file handle fragment, is controlled completely by the filesystem. The | ||
1299 | * standard helper routines assume that this fragment will contain one or | ||
1300 | * two sub-fragments, one which identifies the file, and one which may be | ||
1301 | * used to identify the (a) directory containing the file. | ||
1302 | * | ||
1303 | * In some situations, nfsd needs to get a dentry which is connected into a | ||
1304 | * specific part of the file tree. To allow for this, it passes the | ||
1305 | * function acceptable() together with a @context which can be used to see | ||
1306 | * if the dentry is acceptable. As there can be multiple dentrys for a | ||
1307 | * given file, the filesystem should check each one for acceptability before | ||
1308 | * looking for the next. As soon as an acceptable one is found, it should | ||
1309 | * be returned. | ||
1310 | * | ||
1311 | * decode_fh: | ||
1312 | * @decode_fh is given a &struct super_block (@sb), a file handle fragment | ||
1313 | * (@fh, @fh_len) and an acceptability testing function (@acceptable, | ||
1314 | * @context). It should return a &struct dentry which refers to the same | ||
1315 | * file that the file handle fragment refers to, and which passes the | ||
1316 | * acceptability test. If it cannot, it should return a %NULL pointer if | ||
1317 | * the file was found but no acceptable &dentries were available, or a | ||
1318 | * %ERR_PTR error code indicating why it couldn't be found (e.g. %ENOENT or | ||
1319 | * %ENOMEM). | ||
1320 | * | ||
1321 | * encode_fh: | ||
1322 | * @encode_fh should store in the file handle fragment @fh (using at most | ||
1323 | * @max_len bytes) information that can be used by @decode_fh to recover the | ||
1324 | * file refered to by the &struct dentry @de. If the @connectable flag is | ||
1325 | * set, the encode_fh() should store sufficient information so that a good | ||
1326 | * attempt can be made to find not only the file but also it's place in the | ||
1327 | * filesystem. This typically means storing a reference to de->d_parent in | ||
1328 | * the filehandle fragment. encode_fh() should return the number of bytes | ||
1329 | * stored or a negative error code such as %-ENOSPC | ||
1330 | * | ||
1331 | * get_name: | ||
1332 | * @get_name should find a name for the given @child in the given @parent | ||
1333 | * directory. The name should be stored in the @name (with the | ||
1334 | * understanding that it is already pointing to a a %NAME_MAX+1 sized | ||
1335 | * buffer. get_name() should return %0 on success, a negative error code | ||
1336 | * or error. @get_name will be called without @parent->i_mutex held. | ||
1337 | * | ||
1338 | * get_parent: | ||
1339 | * @get_parent should find the parent directory for the given @child which | ||
1340 | * is also a directory. In the event that it cannot be found, or storage | ||
1341 | * space cannot be allocated, a %ERR_PTR should be returned. | ||
1342 | * | ||
1343 | * get_dentry: | ||
1344 | * Given a &super_block (@sb) and a pointer to a file-system specific inode | ||
1345 | * identifier, possibly an inode number, (@inump) get_dentry() should find | ||
1346 | * the identified inode and return a dentry for that inode. Any suitable | ||
1347 | * dentry can be returned including, if necessary, a new dentry created with | ||
1348 | * d_alloc_root. The caller can then find any other extant dentrys by | ||
1349 | * following the d_alias links. If a new dentry was created using | ||
1350 | * d_alloc_root, DCACHE_NFSD_DISCONNECTED should be set, and the dentry | ||
1351 | * should be d_rehash()ed. | ||
1352 | * | ||
1353 | * If the inode cannot be found, either a %NULL pointer or an %ERR_PTR code | ||
1354 | * can be returned. The @inump will be whatever was passed to | ||
1355 | * nfsd_find_fh_dentry() in either the @obj or @parent parameters. | ||
1356 | * | ||
1357 | * Locking rules: | ||
1358 | * get_parent is called with child->d_inode->i_mutex down | ||
1359 | * get_name is not (which is possibly inconsistent) | ||
1360 | */ | ||
1361 | |||
1362 | struct export_operations { | ||
1363 | struct dentry *(*decode_fh)(struct super_block *sb, __u32 *fh, int fh_len, int fh_type, | ||
1364 | int (*acceptable)(void *context, struct dentry *de), | ||
1365 | void *context); | ||
1366 | int (*encode_fh)(struct dentry *de, __u32 *fh, int *max_len, | ||
1367 | int connectable); | ||
1368 | |||
1369 | /* the following are only called from the filesystem itself */ | ||
1370 | int (*get_name)(struct dentry *parent, char *name, | ||
1371 | struct dentry *child); | ||
1372 | struct dentry * (*get_parent)(struct dentry *child); | ||
1373 | struct dentry * (*get_dentry)(struct super_block *sb, void *inump); | ||
1374 | |||
1375 | /* This is set by the exporting module to a standard helper */ | ||
1376 | struct dentry * (*find_exported_dentry)( | ||
1377 | struct super_block *sb, void *obj, void *parent, | ||
1378 | int (*acceptable)(void *context, struct dentry *de), | ||
1379 | void *context); | ||
1380 | |||
1381 | |||
1382 | }; | ||
1383 | |||
1384 | extern struct dentry * | ||
1385 | find_exported_dentry(struct super_block *sb, void *obj, void *parent, | ||
1386 | int (*acceptable)(void *context, struct dentry *de), | ||
1387 | void *context); | ||
1388 | |||
1389 | struct file_system_type { | 1296 | struct file_system_type { |
1390 | const char *name; | 1297 | const char *name; |
1391 | int fs_flags; | 1298 | int fs_flags; |
@@ -1522,7 +1429,7 @@ extern void putname(const char *name); | |||
1522 | 1429 | ||
1523 | #ifdef CONFIG_BLOCK | 1430 | #ifdef CONFIG_BLOCK |
1524 | extern int register_blkdev(unsigned int, const char *); | 1431 | extern int register_blkdev(unsigned int, const char *); |
1525 | extern int unregister_blkdev(unsigned int, const char *); | 1432 | extern void unregister_blkdev(unsigned int, const char *); |
1526 | extern struct block_device *bdget(dev_t); | 1433 | extern struct block_device *bdget(dev_t); |
1527 | extern void bd_set_size(struct block_device *, loff_t size); | 1434 | extern void bd_set_size(struct block_device *, loff_t size); |
1528 | extern void bd_forget(struct inode *inode); | 1435 | extern void bd_forget(struct inode *inode); |
@@ -1562,7 +1469,7 @@ extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *); | |||
1562 | extern int register_chrdev_region(dev_t, unsigned, const char *); | 1469 | extern int register_chrdev_region(dev_t, unsigned, const char *); |
1563 | extern int register_chrdev(unsigned int, const char *, | 1470 | extern int register_chrdev(unsigned int, const char *, |
1564 | const struct file_operations *); | 1471 | const struct file_operations *); |
1565 | extern int unregister_chrdev(unsigned int, const char *); | 1472 | extern void unregister_chrdev(unsigned int, const char *); |
1566 | extern void unregister_chrdev_region(dev_t, unsigned); | 1473 | extern void unregister_chrdev_region(dev_t, unsigned); |
1567 | extern int chrdev_open(struct inode *, struct file *); | 1474 | extern int chrdev_open(struct inode *, struct file *); |
1568 | extern void chrdev_show(struct seq_file *,off_t); | 1475 | extern void chrdev_show(struct seq_file *,off_t); |
@@ -1610,6 +1517,9 @@ extern int __invalidate_device(struct block_device *); | |||
1610 | extern int invalidate_partition(struct gendisk *, int); | 1517 | extern int invalidate_partition(struct gendisk *, int); |
1611 | #endif | 1518 | #endif |
1612 | extern int invalidate_inodes(struct super_block *); | 1519 | extern int invalidate_inodes(struct super_block *); |
1520 | unsigned long __invalidate_mapping_pages(struct address_space *mapping, | ||
1521 | pgoff_t start, pgoff_t end, | ||
1522 | bool be_atomic); | ||
1613 | unsigned long invalidate_mapping_pages(struct address_space *mapping, | 1523 | unsigned long invalidate_mapping_pages(struct address_space *mapping, |
1614 | pgoff_t start, pgoff_t end); | 1524 | pgoff_t start, pgoff_t end); |
1615 | 1525 | ||
@@ -2043,5 +1953,9 @@ static inline void free_secdata(void *secdata) | |||
2043 | { } | 1953 | { } |
2044 | #endif /* CONFIG_SECURITY */ | 1954 | #endif /* CONFIG_SECURITY */ |
2045 | 1955 | ||
1956 | int proc_nr_files(ctl_table *table, int write, struct file *filp, | ||
1957 | void __user *buffer, size_t *lenp, loff_t *ppos); | ||
1958 | |||
1959 | |||
2046 | #endif /* __KERNEL__ */ | 1960 | #endif /* __KERNEL__ */ |
2047 | #endif /* _LINUX_FS_H */ | 1961 | #endif /* _LINUX_FS_H */ |