]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/fs.h
update bcache sources
[bcachefs-tools-debian] / libbcachefs / fs.h
1 #ifndef _BCACHE_FS_H
2 #define _BCACHE_FS_H
3
4 #include "str_hash.h"
5
6 #include <linux/seqlock.h>
7
8 struct bch_inode_info {
9         struct inode            vfs_inode;
10
11         struct mutex            update_lock;
12         u64                     journal_seq;
13
14         atomic_long_t           i_size_dirty_count;
15
16         /*
17          * these are updated whenever we update the inode in the btree - for
18          * e.g. fsync
19          */
20         u64                     i_size;
21         u32                     i_flags;
22
23         atomic_long_t           i_sectors_dirty_count;
24         atomic64_t              i_sectors;
25
26         struct bch_hash_info    str_hash;
27 };
28
29 #define to_bch_ei(_inode)                                       \
30         container_of(_inode, struct bch_inode_info, vfs_inode)
31
32 static inline u8 mode_to_type(umode_t mode)
33 {
34         return (mode >> 12) & 15;
35 }
36
37 static inline unsigned nlink_bias(umode_t mode)
38 {
39         return S_ISDIR(mode) ? 2 : 1;
40 }
41
42 struct bch_inode_unpacked;
43
44 #ifndef NO_BCACHE_FS
45
46 /* returns 0 if we want to do the update, or error is passed up */
47 typedef int (*inode_set_fn)(struct bch_inode_info *,
48                             struct bch_inode_unpacked *, void *);
49
50 int __must_check __bch2_write_inode(struct bch_fs *, struct bch_inode_info *,
51                                     inode_set_fn, void *);
52 int __must_check bch2_write_inode(struct bch_fs *,
53                                   struct bch_inode_info *);
54
55 void bch2_vfs_exit(void);
56 int bch2_vfs_init(void);
57
58 #else
59
60 static inline void bch2_vfs_exit(void) {}
61 static inline int bch2_vfs_init(void) { return 0; }
62
63 #endif
64
65 #endif /* _BCACHE_FS_H */