]> git.sesse.net Git - bcachefs-tools-debian/blob - libbcachefs/fs.h
Update bcachefs sources to d4b7ef921a bcachefs: Refactoring
[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            v;
11
12         struct mutex            ei_update_lock;
13         u64                     ei_journal_seq;
14
15         atomic_long_t           ei_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                     ei_size;
22         u32                     ei_flags;
23
24         atomic_long_t           ei_sectors_dirty_count;
25         atomic64_t              ei_sectors;
26
27         struct bch_hash_info    ei_str_hash;
28
29         unsigned long           ei_last_dirtied;
30 };
31
32 #define to_bch_ei(_inode)                                       \
33         container_of_or_null(_inode, struct bch_inode_info, v)
34
35 static inline struct bch_inode_info *file_bch_inode(struct file *file)
36 {
37         return to_bch_ei(file_inode(file));
38 }
39
40 static inline u8 mode_to_type(umode_t mode)
41 {
42         return (mode >> 12) & 15;
43 }
44
45 static inline unsigned nlink_bias(umode_t mode)
46 {
47         return S_ISDIR(mode) ? 2 : 1;
48 }
49
50 struct bch_inode_unpacked;
51
52 #ifndef NO_BCACHEFS_FS
53
54 /* returns 0 if we want to do the update, or error is passed up */
55 typedef int (*inode_set_fn)(struct bch_inode_info *,
56                             struct bch_inode_unpacked *, void *);
57
58 int __must_check __bch2_write_inode(struct bch_fs *, struct bch_inode_info *,
59                                     inode_set_fn, void *);
60 int __must_check bch2_write_inode(struct bch_fs *,
61                                   struct bch_inode_info *);
62
63 void bch2_vfs_exit(void);
64 int bch2_vfs_init(void);
65
66 #else
67
68 static inline void bch2_vfs_exit(void) {}
69 static inline int bch2_vfs_init(void) { return 0; }
70
71 #endif /* NO_BCACHEFS_FS */
72
73 #endif /* _BCACHEFS_FS_H */