]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcache/fs.h
aec6159b58ffdf158acd63b51af10de2da62a53a
[bcachefs-tools-debian] / libbcache / 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 /* returns 0 if we want to do the update, or error is passed up */
45 typedef int (*inode_set_fn)(struct bch_inode_info *,
46                             struct bch_inode_unpacked *, void *);
47
48 int __must_check __bch_write_inode(struct cache_set *, struct bch_inode_info *,
49                                    inode_set_fn, void *);
50 int __must_check bch_write_inode(struct cache_set *,
51                                  struct bch_inode_info *);
52
53 void bch_fs_exit(void);
54 int bch_fs_init(void);
55
56 #endif /* _BCACHE_FS_H */