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