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.h166
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);
44struct inodes_stat_t { 44struct 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};
49extern struct inodes_stat_t inodes_stat; 49extern 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
293struct export_operations;
291struct hd_geometry; 294struct hd_geometry;
292struct iovec; 295struct iovec;
293struct nameidata; 296struct 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 */
696struct file_ra_state { 699struct 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 */
715static 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
712struct file { 721struct 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 *);
855extern void locks_copy_lock(struct file_lock *, struct file_lock *); 868extern void locks_copy_lock(struct file_lock *, struct file_lock *);
856extern void locks_remove_posix(struct file *, fl_owner_t); 869extern void locks_remove_posix(struct file *, fl_owner_t);
857extern void locks_remove_flock(struct file *); 870extern void locks_remove_flock(struct file *);
858extern int posix_test_lock(struct file *, struct file_lock *); 871extern void posix_test_lock(struct file *, struct file_lock *);
859extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *); 872extern int posix_lock_file(struct file *, struct file_lock *, struct file_lock *);
860extern int posix_lock_file_wait(struct file *, struct file_lock *); 873extern int posix_lock_file_wait(struct file *, struct file_lock *);
861extern int posix_unblock_lock(struct file *, struct file_lock *); 874extern 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);
866extern int __break_lease(struct inode *inode, unsigned int flags); 879extern int __break_lease(struct inode *inode, unsigned int flags);
867extern void lease_get_mtime(struct inode *, struct timespec *time); 880extern void lease_get_mtime(struct inode *, struct timespec *time);
868extern int setlease(struct file *, long, struct file_lock **); 881extern int setlease(struct file *, long, struct file_lock **);
882extern int vfs_setlease(struct file *, long, struct file_lock **);
869extern int lease_modify(struct file_lock **, int); 883extern int lease_modify(struct file_lock **, int);
870extern int lock_may_read(struct inode *, loff_t start, unsigned long count); 884extern int lock_may_read(struct inode *, loff_t start, unsigned long count);
871extern int lock_may_write(struct inode *, loff_t start, unsigned long count); 885extern int lock_may_write(struct inode *, loff_t start, unsigned long count);
@@ -984,6 +998,9 @@ enum {
984#define put_fs_excl() atomic_dec(&current->fs_excl) 998#define put_fs_excl() atomic_dec(&current->fs_excl)
985#define has_fs_excl() atomic_read(&current->fs_excl) 999#define has_fs_excl() atomic_read(&current->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... */
988extern void lock_super(struct super_block *); 1005extern void lock_super(struct super_block *);
989extern void unlock_super(struct super_block *); 1006extern 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
1117struct inode_operations { 1135struct 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
1142struct seq_file; 1162struct seq_file;
@@ -1273,119 +1293,6 @@ static inline void file_accessed(struct file *file)
1273 1293
1274int sync_inode(struct inode *inode, struct writeback_control *wbc); 1294int 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
1362struct 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
1384extern struct dentry *
1385find_exported_dentry(struct super_block *sb, void *obj, void *parent,
1386 int (*acceptable)(void *context, struct dentry *de),
1387 void *context);
1388
1389struct file_system_type { 1296struct 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
1524extern int register_blkdev(unsigned int, const char *); 1431extern int register_blkdev(unsigned int, const char *);
1525extern int unregister_blkdev(unsigned int, const char *); 1432extern void unregister_blkdev(unsigned int, const char *);
1526extern struct block_device *bdget(dev_t); 1433extern struct block_device *bdget(dev_t);
1527extern void bd_set_size(struct block_device *, loff_t size); 1434extern void bd_set_size(struct block_device *, loff_t size);
1528extern void bd_forget(struct inode *inode); 1435extern void bd_forget(struct inode *inode);
@@ -1562,7 +1469,7 @@ extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
1562extern int register_chrdev_region(dev_t, unsigned, const char *); 1469extern int register_chrdev_region(dev_t, unsigned, const char *);
1563extern int register_chrdev(unsigned int, const char *, 1470extern int register_chrdev(unsigned int, const char *,
1564 const struct file_operations *); 1471 const struct file_operations *);
1565extern int unregister_chrdev(unsigned int, const char *); 1472extern void unregister_chrdev(unsigned int, const char *);
1566extern void unregister_chrdev_region(dev_t, unsigned); 1473extern void unregister_chrdev_region(dev_t, unsigned);
1567extern int chrdev_open(struct inode *, struct file *); 1474extern int chrdev_open(struct inode *, struct file *);
1568extern void chrdev_show(struct seq_file *,off_t); 1475extern void chrdev_show(struct seq_file *,off_t);
@@ -1610,6 +1517,9 @@ extern int __invalidate_device(struct block_device *);
1610extern int invalidate_partition(struct gendisk *, int); 1517extern int invalidate_partition(struct gendisk *, int);
1611#endif 1518#endif
1612extern int invalidate_inodes(struct super_block *); 1519extern int invalidate_inodes(struct super_block *);
1520unsigned long __invalidate_mapping_pages(struct address_space *mapping,
1521 pgoff_t start, pgoff_t end,
1522 bool be_atomic);
1613unsigned long invalidate_mapping_pages(struct address_space *mapping, 1523unsigned 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
1956int 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 */