]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - fs/btrfs/fs.h
btrfs: add and use helpers for reading and writing fs_info->generation
[thirdparty/linux.git] / fs / btrfs / fs.h
index 2bd9bedc70958067f6579bee1cc341a648d17ac9..d04b729cbdf3353970e066b5b02a8fd118b9a82c 100644 (file)
@@ -416,6 +416,12 @@ struct btrfs_fs_info {
 
        struct btrfs_block_rsv empty_block_rsv;
 
+       /*
+        * Updated while holding the lock 'trans_lock'. Due to the life cycle of
+        * a transaction, it can be directly read while holding a transaction
+        * handle, everywhere else must be read with btrfs_get_fs_generation().
+        * Should always be updated using btrfs_set_fs_generation().
+        */
        u64 generation;
        u64 last_trans_committed;
        /*
@@ -817,6 +823,16 @@ struct btrfs_fs_info {
 #endif
 };
 
+static inline u64 btrfs_get_fs_generation(const struct btrfs_fs_info *fs_info)
+{
+       return READ_ONCE(fs_info->generation);
+}
+
+static inline void btrfs_set_fs_generation(struct btrfs_fs_info *fs_info, u64 gen)
+{
+       WRITE_ONCE(fs_info->generation, gen);
+}
+
 static inline void btrfs_set_last_root_drop_gen(struct btrfs_fs_info *fs_info,
                                                u64 gen)
 {