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.h80
1 files changed, 55 insertions, 25 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h
index ba98668a1826..0c4df261af7e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -58,14 +58,15 @@ struct inodes_stat_t {
58 58
59#define NR_FILE 8192 /* this can well be larger on a larger system */ 59#define NR_FILE 8192 /* this can well be larger on a larger system */
60 60
61#define MAY_EXEC 1 61#define MAY_EXEC 0x00000001
62#define MAY_WRITE 2 62#define MAY_WRITE 0x00000002
63#define MAY_READ 4 63#define MAY_READ 0x00000004
64#define MAY_APPEND 8 64#define MAY_APPEND 0x00000008
65#define MAY_ACCESS 16 65#define MAY_ACCESS 0x00000010
66#define MAY_OPEN 32 66#define MAY_OPEN 0x00000020
67#define MAY_CHDIR 64 67#define MAY_CHDIR 0x00000040
68#define MAY_NOT_BLOCK 128 /* called from RCU mode, don't block */ 68/* called from RCU mode, don't block */
69#define MAY_NOT_BLOCK 0x00000080
69 70
70/* 71/*
71 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond 72 * flags in file.f_mode. Note that FMODE_READ and FMODE_WRITE must correspond
@@ -767,14 +768,25 @@ struct inode {
767 768
768 /* Stat data, not accessed from path walking */ 769 /* Stat data, not accessed from path walking */
769 unsigned long i_ino; 770 unsigned long i_ino;
770 unsigned int i_nlink; 771 /*
772 * Filesystems may only read i_nlink directly. They shall use the
773 * following functions for modification:
774 *
775 * (set|clear|inc|drop)_nlink
776 * inode_(inc|dec)_link_count
777 */
778 union {
779 const unsigned int i_nlink;
780 unsigned int __i_nlink;
781 };
771 dev_t i_rdev; 782 dev_t i_rdev;
772 loff_t i_size;
773 struct timespec i_atime; 783 struct timespec i_atime;
774 struct timespec i_mtime; 784 struct timespec i_mtime;
775 struct timespec i_ctime; 785 struct timespec i_ctime;
776 unsigned int i_blkbits; 786 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
787 unsigned short i_bytes;
777 blkcnt_t i_blocks; 788 blkcnt_t i_blocks;
789 loff_t i_size;
778 790
779#ifdef __NEED_I_SIZE_ORDERED 791#ifdef __NEED_I_SIZE_ORDERED
780 seqcount_t i_size_seqcount; 792 seqcount_t i_size_seqcount;
@@ -782,7 +794,6 @@ struct inode {
782 794
783 /* Misc */ 795 /* Misc */
784 unsigned long i_state; 796 unsigned long i_state;
785 spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */
786 struct mutex i_mutex; 797 struct mutex i_mutex;
787 798
788 unsigned long dirtied_when; /* jiffies of first dirtying */ 799 unsigned long dirtied_when; /* jiffies of first dirtying */
@@ -796,9 +807,10 @@ struct inode {
796 struct rcu_head i_rcu; 807 struct rcu_head i_rcu;
797 }; 808 };
798 atomic_t i_count; 809 atomic_t i_count;
810 unsigned int i_blkbits;
799 u64 i_version; 811 u64 i_version;
800 unsigned short i_bytes;
801 atomic_t i_dio_count; 812 atomic_t i_dio_count;
813 atomic_t i_writecount;
802 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ 814 const struct file_operations *i_fop; /* former ->i_op->default_file_ops */
803 struct file_lock *i_flock; 815 struct file_lock *i_flock;
804 struct address_space i_data; 816 struct address_space i_data;
@@ -822,7 +834,6 @@ struct inode {
822#ifdef CONFIG_IMA 834#ifdef CONFIG_IMA
823 atomic_t i_readcount; /* struct files open RO */ 835 atomic_t i_readcount; /* struct files open RO */
824#endif 836#endif
825 atomic_t i_writecount;
826 void *i_private; /* fs or device private pointer */ 837 void *i_private; /* fs or device private pointer */
827}; 838};
828 839
@@ -963,7 +974,12 @@ struct file {
963#define f_dentry f_path.dentry 974#define f_dentry f_path.dentry
964#define f_vfsmnt f_path.mnt 975#define f_vfsmnt f_path.mnt
965 const struct file_operations *f_op; 976 const struct file_operations *f_op;
966 spinlock_t f_lock; /* f_ep_links, f_flags, no IRQ */ 977
978 /*
979 * Protects f_ep_links, f_flags, f_pos vs i_size in lseek SEEK_CUR.
980 * Must not be taken from IRQ context.
981 */
982 spinlock_t f_lock;
967#ifdef CONFIG_SMP 983#ifdef CONFIG_SMP
968 int f_sb_list_cpu; 984 int f_sb_list_cpu;
969#endif 985#endif
@@ -1627,9 +1643,10 @@ struct inode_operations {
1627struct seq_file; 1643struct seq_file;
1628 1644
1629ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, 1645ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
1630 unsigned long nr_segs, unsigned long fast_segs, 1646 unsigned long nr_segs, unsigned long fast_segs,
1631 struct iovec *fast_pointer, 1647 struct iovec *fast_pointer,
1632 struct iovec **ret_pointer); 1648 struct iovec **ret_pointer,
1649 int check_access);
1633 1650
1634extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); 1651extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
1635extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); 1652extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *);
@@ -1748,6 +1765,19 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
1748} 1765}
1749 1766
1750/** 1767/**
1768 * set_nlink - directly set an inode's link count
1769 * @inode: inode
1770 * @nlink: new nlink (should be non-zero)
1771 *
1772 * This is a low-level filesystem helper to replace any
1773 * direct filesystem manipulation of i_nlink.
1774 */
1775static inline void set_nlink(struct inode *inode, unsigned int nlink)
1776{
1777 inode->__i_nlink = nlink;
1778}
1779
1780/**
1751 * inc_nlink - directly increment an inode's link count 1781 * inc_nlink - directly increment an inode's link count
1752 * @inode: inode 1782 * @inode: inode
1753 * 1783 *
@@ -1757,7 +1787,7 @@ static inline void mark_inode_dirty_sync(struct inode *inode)
1757 */ 1787 */
1758static inline void inc_nlink(struct inode *inode) 1788static inline void inc_nlink(struct inode *inode)
1759{ 1789{
1760 inode->i_nlink++; 1790 inode->__i_nlink++;
1761} 1791}
1762 1792
1763static inline void inode_inc_link_count(struct inode *inode) 1793static inline void inode_inc_link_count(struct inode *inode)
@@ -1779,7 +1809,7 @@ static inline void inode_inc_link_count(struct inode *inode)
1779 */ 1809 */
1780static inline void drop_nlink(struct inode *inode) 1810static inline void drop_nlink(struct inode *inode)
1781{ 1811{
1782 inode->i_nlink--; 1812 inode->__i_nlink--;
1783} 1813}
1784 1814
1785/** 1815/**
@@ -1792,7 +1822,7 @@ static inline void drop_nlink(struct inode *inode)
1792 */ 1822 */
1793static inline void clear_nlink(struct inode *inode) 1823static inline void clear_nlink(struct inode *inode)
1794{ 1824{
1795 inode->i_nlink = 0; 1825 inode->__i_nlink = 0;
1796} 1826}
1797 1827
1798static inline void inode_dec_link_count(struct inode *inode) 1828static inline void inode_dec_link_count(struct inode *inode)
@@ -2401,8 +2431,8 @@ file_ra_state_init(struct file_ra_state *ra, struct address_space *mapping);
2401extern loff_t noop_llseek(struct file *file, loff_t offset, int origin); 2431extern loff_t noop_llseek(struct file *file, loff_t offset, int origin);
2402extern loff_t no_llseek(struct file *file, loff_t offset, int origin); 2432extern loff_t no_llseek(struct file *file, loff_t offset, int origin);
2403extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin); 2433extern loff_t generic_file_llseek(struct file *file, loff_t offset, int origin);
2404extern loff_t generic_file_llseek_unlocked(struct file *file, loff_t offset, 2434extern loff_t generic_file_llseek_size(struct file *file, loff_t offset,
2405 int origin); 2435 int origin, loff_t maxsize);
2406extern int generic_file_open(struct inode * inode, struct file * filp); 2436extern int generic_file_open(struct inode * inode, struct file * filp);
2407extern int nonseekable_open(struct inode * inode, struct file * filp); 2437extern int nonseekable_open(struct inode * inode, struct file * filp);
2408 2438
@@ -2628,8 +2658,8 @@ static const struct file_operations __fops = { \
2628 .llseek = generic_file_llseek, \ 2658 .llseek = generic_file_llseek, \
2629}; 2659};
2630 2660
2631static inline void __attribute__((format(printf, 1, 2))) 2661static inline __printf(1, 2)
2632__simple_attr_check_format(const char *fmt, ...) 2662void __simple_attr_check_format(const char *fmt, ...)
2633{ 2663{
2634 /* don't do anything, just let the compiler check the arguments; */ 2664 /* don't do anything, just let the compiler check the arguments; */
2635} 2665}