X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?p=pandora-kernel.git;a=blobdiff_plain;f=include%2Flinux%2Ffs.h;h=0c4df261af7e6a32d5b5c80633fa6a643e2d6285;hp=7a049fd2aa4cca0860f9dd51f7a317d7fe3b58d5;hb=80c2861672bbf000f6af838656959ee937e4ee4d;hpb=34116645d912f65d7eb4508a1db3c9d0e45facb1 diff --git a/include/linux/fs.h b/include/linux/fs.h index 7a049fd2aa4c..0c4df261af7e 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -768,14 +768,25 @@ struct inode { /* Stat data, not accessed from path walking */ unsigned long i_ino; - unsigned int i_nlink; + /* + * Filesystems may only read i_nlink directly. They shall use the + * following functions for modification: + * + * (set|clear|inc|drop)_nlink + * inode_(inc|dec)_link_count + */ + union { + const unsigned int i_nlink; + unsigned int __i_nlink; + }; dev_t i_rdev; - loff_t i_size; struct timespec i_atime; struct timespec i_mtime; struct timespec i_ctime; - unsigned int i_blkbits; + spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ + unsigned short i_bytes; blkcnt_t i_blocks; + loff_t i_size; #ifdef __NEED_I_SIZE_ORDERED seqcount_t i_size_seqcount; @@ -783,7 +794,6 @@ struct inode { /* Misc */ unsigned long i_state; - spinlock_t i_lock; /* i_blocks, i_bytes, maybe i_size */ struct mutex i_mutex; unsigned long dirtied_when; /* jiffies of first dirtying */ @@ -797,9 +807,10 @@ struct inode { struct rcu_head i_rcu; }; atomic_t i_count; + unsigned int i_blkbits; u64 i_version; - unsigned short i_bytes; atomic_t i_dio_count; + atomic_t i_writecount; const struct file_operations *i_fop; /* former ->i_op->default_file_ops */ struct file_lock *i_flock; struct address_space i_data; @@ -823,7 +834,6 @@ struct inode { #ifdef CONFIG_IMA atomic_t i_readcount; /* struct files open RO */ #endif - atomic_t i_writecount; void *i_private; /* fs or device private pointer */ }; @@ -1754,6 +1764,19 @@ static inline void mark_inode_dirty_sync(struct inode *inode) __mark_inode_dirty(inode, I_DIRTY_SYNC); } +/** + * set_nlink - directly set an inode's link count + * @inode: inode + * @nlink: new nlink (should be non-zero) + * + * This is a low-level filesystem helper to replace any + * direct filesystem manipulation of i_nlink. + */ +static inline void set_nlink(struct inode *inode, unsigned int nlink) +{ + inode->__i_nlink = nlink; +} + /** * inc_nlink - directly increment an inode's link count * @inode: inode @@ -1764,7 +1787,7 @@ static inline void mark_inode_dirty_sync(struct inode *inode) */ static inline void inc_nlink(struct inode *inode) { - inode->i_nlink++; + inode->__i_nlink++; } static inline void inode_inc_link_count(struct inode *inode) @@ -1786,7 +1809,7 @@ static inline void inode_inc_link_count(struct inode *inode) */ static inline void drop_nlink(struct inode *inode) { - inode->i_nlink--; + inode->__i_nlink--; } /** @@ -1799,7 +1822,7 @@ static inline void drop_nlink(struct inode *inode) */ static inline void clear_nlink(struct inode *inode) { - inode->i_nlink = 0; + inode->__i_nlink = 0; } static inline void inode_dec_link_count(struct inode *inode)