~ubuntu-branches/debian/experimental/linux-tools/experimental

« back to all changes in this revision

Viewing changes to include/linux/fs.h

  • Committer: Package Import Robot
  • Author(s): Ben Hutchings
  • Date: 2014-02-02 16:57:49 UTC
  • mfrom: (1.1.10) (0.1.21 sid)
  • Revision ID: package-import@ubuntu.com-20140202165749-tw94o9t1t0a8txk6
Tags: 3.13-1~exp2
Merge changes from sid up to 3.12.6-3

Show diffs side-by-side

added added

removed removed

Lines of Context:
623
623
 * 0: the object of the current VFS operation
624
624
 * 1: parent
625
625
 * 2: child/target
626
 
 * 3: quota file
 
626
 * 3: xattr
 
627
 * 4: second non-directory
 
628
 * The last is for certain operations (such as rename) which lock two
 
629
 * non-directories at once.
627
630
 *
628
631
 * The locking order between these classes is
629
 
 * parent -> child -> normal -> xattr -> quota
 
632
 * parent -> child -> normal -> xattr -> second non-directory
630
633
 */
631
634
enum inode_i_mutex_lock_class
632
635
{
634
637
        I_MUTEX_PARENT,
635
638
        I_MUTEX_CHILD,
636
639
        I_MUTEX_XATTR,
637
 
        I_MUTEX_QUOTA
 
640
        I_MUTEX_NONDIR2
638
641
};
639
642
 
 
643
void lock_two_nondirectories(struct inode *, struct inode*);
 
644
void unlock_two_nondirectories(struct inode *, struct inode*);
 
645
 
640
646
/*
641
647
 * NOTE: in a 32bit arch with a preemptable kernel and
642
648
 * an UP compile the i_size_read/write must be atomic
764
770
#define FILE_MNT_WRITE_RELEASED 2
765
771
 
766
772
struct file {
767
 
        /*
768
 
         * fu_list becomes invalid after file_free is called and queued via
769
 
         * fu_rcuhead for RCU freeing
770
 
         */
771
773
        union {
772
 
                struct list_head        fu_list;
773
774
                struct llist_node       fu_llist;
774
775
                struct rcu_head         fu_rcuhead;
775
776
        } f_u;
783
784
         * Must not be taken from IRQ context.
784
785
         */
785
786
        spinlock_t              f_lock;
786
 
#ifdef CONFIG_SMP
787
 
        int                     f_sb_list_cpu;
788
 
#endif
789
787
        atomic_long_t           f_count;
790
788
        unsigned int            f_flags;
791
789
        fmode_t                 f_mode;
882
880
 
883
881
#define FL_POSIX        1
884
882
#define FL_FLOCK        2
 
883
#define FL_DELEG        4       /* NFSv4 delegation */
885
884
#define FL_ACCESS       8       /* not trying to lock, just looking */
886
885
#define FL_EXISTS       16      /* when unlocking, test for existence */
887
886
#define FL_LEASE        32      /* lease held on this file */
1023
1022
extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct file_lock *);
1024
1023
extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
1025
1024
extern int flock_lock_file_wait(struct file *filp, struct file_lock *fl);
1026
 
extern int __break_lease(struct inode *inode, unsigned int flags);
 
1025
extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type);
1027
1026
extern void lease_get_mtime(struct inode *, struct timespec *time);
1028
1027
extern int generic_setlease(struct file *, long, struct file_lock **);
1029
1028
extern int vfs_setlease(struct file *, long, struct file_lock **);
1132
1131
        return -ENOLCK;
1133
1132
}
1134
1133
 
1135
 
static inline int __break_lease(struct inode *inode, unsigned int mode)
 
1134
static inline int __break_lease(struct inode *inode, unsigned int mode, unsigned int type)
1136
1135
{
1137
1136
        return 0;
1138
1137
}
1264
1263
 
1265
1264
        struct list_head        s_inodes;       /* all inodes */
1266
1265
        struct hlist_bl_head    s_anon;         /* anonymous dentries for (nfs) exporting */
1267
 
#ifdef CONFIG_SMP
1268
 
        struct list_head __percpu *s_files;
1269
 
#else
1270
 
        struct list_head        s_files;
1271
 
#endif
1272
1266
        struct list_head        s_mounts;       /* list of mounts; _not_ for fs use */
1273
1267
        struct block_device     *s_bdev;
1274
1268
        struct backing_dev_info *s_bdi;
1330
1324
         */
1331
1325
        struct list_lru         s_dentry_lru ____cacheline_aligned_in_smp;
1332
1326
        struct list_lru         s_inode_lru ____cacheline_aligned_in_smp;
 
1327
        struct rcu_head         rcu;
1333
1328
};
1334
1329
 
1335
1330
extern struct timespec current_fs_time(struct super_block *sb);
1458
1453
extern int vfs_mkdir(struct inode *, struct dentry *, umode_t);
1459
1454
extern int vfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
1460
1455
extern int vfs_symlink(struct inode *, struct dentry *, const char *);
1461
 
extern int vfs_link(struct dentry *, struct inode *, struct dentry *);
 
1456
extern int vfs_link(struct dentry *, struct inode *, struct dentry *, struct inode **);
1462
1457
extern int vfs_rmdir(struct inode *, struct dentry *);
1463
 
extern int vfs_unlink(struct inode *, struct dentry *);
1464
 
extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
 
1458
extern int vfs_unlink(struct inode *, struct dentry *, struct inode **);
 
1459
extern int vfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *, struct inode **);
1465
1460
 
1466
1461
/*
1467
1462
 * VFS dentry helper functions.
1875
1870
        (((fops) && try_module_get((fops)->owner) ? (fops) : NULL))
1876
1871
#define fops_put(fops) \
1877
1872
        do { if (fops) module_put((fops)->owner); } while(0)
 
1873
/*
 
1874
 * This one is to be used *ONLY* from ->open() instances.
 
1875
 * fops must be non-NULL, pinned down *and* module dependencies
 
1876
 * should be sufficient to pin the caller down as well.
 
1877
 */
 
1878
#define replace_fops(f, fops) \
 
1879
        do {    \
 
1880
                struct file *__file = (f); \
 
1881
                fops_put(__file->f_op); \
 
1882
                BUG_ON(!(__file->f_op = (fops))); \
 
1883
        } while(0)
1878
1884
 
1879
1885
extern int register_filesystem(struct file_system_type *);
1880
1886
extern int unregister_filesystem(struct file_system_type *);
1899
1905
 
1900
1906
extern int current_umask(void);
1901
1907
 
 
1908
extern void ihold(struct inode * inode);
 
1909
extern void iput(struct inode *);
 
1910
 
1902
1911
/* /sys/fs */
1903
1912
extern struct kobject *fs_kobj;
1904
1913
 
1955
1964
static inline int break_lease(struct inode *inode, unsigned int mode)
1956
1965
{
1957
1966
        if (inode->i_flock)
1958
 
                return __break_lease(inode, mode);
1959
 
        return 0;
1960
 
}
 
1967
                return __break_lease(inode, mode, FL_LEASE);
 
1968
        return 0;
 
1969
}
 
1970
 
 
1971
static inline int break_deleg(struct inode *inode, unsigned int mode)
 
1972
{
 
1973
        if (inode->i_flock)
 
1974
                return __break_lease(inode, mode, FL_DELEG);
 
1975
        return 0;
 
1976
}
 
1977
 
 
1978
static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode)
 
1979
{
 
1980
        int ret;
 
1981
 
 
1982
        ret = break_deleg(inode, O_WRONLY|O_NONBLOCK);
 
1983
        if (ret == -EWOULDBLOCK && delegated_inode) {
 
1984
                *delegated_inode = inode;
 
1985
                ihold(inode);
 
1986
        }
 
1987
        return ret;
 
1988
}
 
1989
 
 
1990
static inline int break_deleg_wait(struct inode **delegated_inode)
 
1991
{
 
1992
        int ret;
 
1993
 
 
1994
        ret = break_deleg(*delegated_inode, O_WRONLY);
 
1995
        iput(*delegated_inode);
 
1996
        *delegated_inode = NULL;
 
1997
        return ret;
 
1998
}
 
1999
 
1961
2000
#else /* !CONFIG_FILE_LOCKING */
1962
2001
static inline int locks_mandatory_locked(struct inode *inode)
1963
2002
{
1997
2036
        return 0;
1998
2037
}
1999
2038
 
 
2039
static inline int break_deleg(struct inode *inode, unsigned int mode)
 
2040
{
 
2041
        return 0;
 
2042
}
 
2043
 
 
2044
static inline int try_break_deleg(struct inode *inode, struct inode **delegated_inode)
 
2045
{
 
2046
        return 0;
 
2047
}
 
2048
 
 
2049
static inline int break_deleg_wait(struct inode **delegated_inode)
 
2050
{
 
2051
        BUG();
 
2052
        return 0;
 
2053
}
 
2054
 
2000
2055
#endif /* CONFIG_FILE_LOCKING */
2001
2056
 
2002
2057
/* fs/open.c */
2223
2278
#ifdef CONFIG_BLOCK
2224
2279
extern sector_t bmap(struct inode *, sector_t);
2225
2280
#endif
2226
 
extern int notify_change(struct dentry *, struct iattr *);
 
2281
extern int notify_change(struct dentry *, struct iattr *, struct inode **);
2227
2282
extern int inode_permission(struct inode *, int);
2228
2283
extern int generic_permission(struct inode *, int);
2229
2284
 
2292
2347
        if (file)
2293
2348
                atomic_inc(&file_inode(file)->i_writecount);
2294
2349
}
 
2350
static inline bool inode_is_open_for_write(const struct inode *inode)
 
2351
{
 
2352
        return atomic_read(&inode->i_writecount) > 0;
 
2353
}
 
2354
 
2295
2355
#ifdef CONFIG_IMA
2296
2356
static inline void i_readcount_dec(struct inode *inode)
2297
2357
{
2332
2392
extern int inode_init_always(struct super_block *, struct inode *);
2333
2393
extern void inode_init_once(struct inode *);
2334
2394
extern void address_space_init_once(struct address_space *mapping);
2335
 
extern void ihold(struct inode * inode);
2336
 
extern void iput(struct inode *);
2337
2395
extern struct inode * igrab(struct inode *);
2338
2396
extern ino_t iunique(struct super_block *, ino_t);
2339
2397
extern int inode_needs_sync(struct inode *inode);
2502
2560
                int nofs);
2503
2561
extern int page_symlink(struct inode *inode, const char *symname, int len);
2504
2562
extern const struct inode_operations page_symlink_inode_operations;
 
2563
extern void kfree_put_link(struct dentry *, struct nameidata *, void *);
2505
2564
extern int generic_readlink(struct dentry *, char __user *, int);
2506
2565
extern void generic_fillattr(struct inode *, struct kstat *);
 
2566
int vfs_getattr_nosec(struct path *path, struct kstat *stat);
2507
2567
extern int vfs_getattr(struct path *, struct kstat *);
2508
2568
void __inode_add_bytes(struct inode *inode, loff_t bytes);
2509
2569
void inode_add_bytes(struct inode *inode, loff_t bytes);
2562
2622
extern int simple_write_end(struct file *file, struct address_space *mapping,
2563
2623
                        loff_t pos, unsigned len, unsigned copied,
2564
2624
                        struct page *page, void *fsdata);
 
2625
extern int always_delete_dentry(const struct dentry *);
 
2626
extern struct inode *alloc_anon_inode(struct super_block *);
 
2627
extern const struct dentry_operations simple_dentry_operations;
2565
2628
 
2566
2629
extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags);
2567
2630
extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *);