transaction.h 607 B

123456789101112131415161718192021222324252627
  1. #ifndef __TRANSACTION__
  2. #define __TRANSACTION__
  3. struct btrfs_trans_handle {
  4. u64 transid;
  5. unsigned long blocks_reserved;
  6. unsigned long blocks_used;
  7. };
  8. static inline struct btrfs_trans_handle *
  9. btrfs_start_transaction(struct btrfs_root *root, int num_blocks)
  10. {
  11. struct btrfs_trans_handle *h = kmalloc(sizeof(*h), GFP_NOFS);
  12. h->transid = root->root_key.offset;
  13. h->blocks_reserved = num_blocks;
  14. h->blocks_used = 0;
  15. return h;
  16. }
  17. static inline void btrfs_free_transaction(struct btrfs_root *root,
  18. struct btrfs_trans_handle *handle)
  19. {
  20. memset(handle, 0, sizeof(*handle));
  21. kfree(handle);
  22. }
  23. #endif