]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/fs.h
Update bcachefs sources to 02ae70070a bcachefs: Allocate new btree roots lazily
[bcachefs-tools-debian] / libbcachefs / fs.h
1 #ifndef _BCACHEFS_FS_H
2 #define _BCACHEFS_FS_H
3
4 #include "opts.h"
5 #include "str_hash.h"
6 #include "quota_types.h"
7
8 #include <linux/seqlock.h>
9 #include <linux/stat.h>
10
11 struct bch_inode_info {
12         struct inode            v;
13
14         struct mutex            ei_update_lock;
15         u64                     ei_journal_seq;
16         unsigned long           ei_last_dirtied;
17         struct bch_qid          ei_qid;
18
19         struct bch_hash_info    ei_str_hash;
20
21         /* copy of inode in btree: */
22         struct bch_inode_unpacked ei_inode;
23 };
24
25 #define to_bch_ei(_inode)                                       \
26         container_of_or_null(_inode, struct bch_inode_info, v)
27
28 static inline struct bch_inode_info *file_bch_inode(struct file *file)
29 {
30         return to_bch_ei(file_inode(file));
31 }
32
33 static inline u8 mode_to_type(umode_t mode)
34 {
35         return (mode >> 12) & 15;
36 }
37
38 static inline unsigned nlink_bias(umode_t mode)
39 {
40         return S_ISDIR(mode) ? 2 : 1;
41 }
42
43 struct bch_inode_unpacked;
44
45 #ifndef NO_BCACHEFS_FS
46
47 /* returns 0 if we want to do the update, or error is passed up */
48 typedef int (*inode_set_fn)(struct bch_inode_info *,
49                             struct bch_inode_unpacked *, void *);
50
51 int __must_check __bch2_write_inode(struct bch_fs *, struct bch_inode_info *,
52                                     inode_set_fn, void *);
53 int __must_check bch2_write_inode(struct bch_fs *,
54                                   struct bch_inode_info *);
55
56 void bch2_vfs_exit(void);
57 int bch2_vfs_init(void);
58
59 #else
60
61 static inline void bch2_vfs_exit(void) {}
62 static inline int bch2_vfs_init(void) { return 0; }
63
64 #endif /* NO_BCACHEFS_FS */
65
66 #endif /* _BCACHEFS_FS_H */