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