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