Blame view

fs/btrfs/tree-log.h 2.78 KB
9888c3402   David Sterba   btrfs: replace GP...
1
  /* SPDX-License-Identifier: GPL-2.0 */
e02119d5a   Chris Mason   Btrfs: Add a writ...
2
3
  /*
   * Copyright (C) 2008 Oracle.  All rights reserved.
e02119d5a   Chris Mason   Btrfs: Add a writ...
4
   */
9888c3402   David Sterba   btrfs: replace GP...
5
6
  #ifndef BTRFS_TREE_LOG_H
  #define BTRFS_TREE_LOG_H
e02119d5a   Chris Mason   Btrfs: Add a writ...
7

995946dd2   Miao Xie   Btrfs: use helper...
8
9
  #include "ctree.h"
  #include "transaction.h"
257c62e1b   Chris Mason   Btrfs: avoid tree...
10
11
  /* return value for btrfs_log_dentry_safe that means we don't need to log it at all */
  #define BTRFS_NO_LOG_SYNC 256
8b050d350   Miao Xie   Btrfs: fix skippe...
12
13
  struct btrfs_log_ctx {
  	int log_ret;
d1433debe   Miao Xie   Btrfs: just wait ...
14
  	int log_transid;
2f2ff0ee5   Filipe Manana   Btrfs: fix metada...
15
  	bool log_new_dentries;
75b463d2b   Filipe Manana   btrfs: do not com...
16
  	bool logging_new_name;
28a235931   Filipe Manana   Btrfs: fix lockde...
17
  	struct inode *inode;
8b050d350   Miao Xie   Btrfs: fix skippe...
18
  	struct list_head list;
487781796   Filipe Manana   btrfs: make fast ...
19
20
  	/* Only used for fast fsyncs. */
  	struct list_head ordered_extents;
8b050d350   Miao Xie   Btrfs: fix skippe...
21
  };
28a235931   Filipe Manana   Btrfs: fix lockde...
22
23
  static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx,
  				      struct inode *inode)
8b050d350   Miao Xie   Btrfs: fix skippe...
24
25
  {
  	ctx->log_ret = 0;
d1433debe   Miao Xie   Btrfs: just wait ...
26
  	ctx->log_transid = 0;
2f2ff0ee5   Filipe Manana   Btrfs: fix metada...
27
  	ctx->log_new_dentries = false;
75b463d2b   Filipe Manana   btrfs: do not com...
28
  	ctx->logging_new_name = false;
28a235931   Filipe Manana   Btrfs: fix lockde...
29
  	ctx->inode = inode;
8b050d350   Miao Xie   Btrfs: fix skippe...
30
  	INIT_LIST_HEAD(&ctx->list);
487781796   Filipe Manana   btrfs: make fast ...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
  	INIT_LIST_HEAD(&ctx->ordered_extents);
  }
  
  static inline void btrfs_release_log_ctx_extents(struct btrfs_log_ctx *ctx)
  {
  	struct btrfs_ordered_extent *ordered;
  	struct btrfs_ordered_extent *tmp;
  
  	ASSERT(inode_is_locked(ctx->inode));
  
  	list_for_each_entry_safe(ordered, tmp, &ctx->ordered_extents, log_list) {
  		list_del_init(&ordered->log_list);
  		btrfs_put_ordered_extent(ordered);
  	}
8b050d350   Miao Xie   Btrfs: fix skippe...
45
  }
907877664   David Sterba   btrfs: get fs_inf...
46
  static inline void btrfs_set_log_full_commit(struct btrfs_trans_handle *trans)
995946dd2   Miao Xie   Btrfs: use helper...
47
  {
907877664   David Sterba   btrfs: get fs_inf...
48
  	WRITE_ONCE(trans->fs_info->last_trans_log_full_commit, trans->transid);
995946dd2   Miao Xie   Btrfs: use helper...
49
  }
4884b8e8e   David Sterba   btrfs: get fs_inf...
50
  static inline int btrfs_need_log_full_commit(struct btrfs_trans_handle *trans)
995946dd2   Miao Xie   Btrfs: use helper...
51
  {
4884b8e8e   David Sterba   btrfs: get fs_inf...
52
  	return READ_ONCE(trans->fs_info->last_trans_log_full_commit) ==
995946dd2   Miao Xie   Btrfs: use helper...
53
54
  		trans->transid;
  }
e02119d5a   Chris Mason   Btrfs: Add a writ...
55
  int btrfs_sync_log(struct btrfs_trans_handle *trans,
8b050d350   Miao Xie   Btrfs: fix skippe...
56
  		   struct btrfs_root *root, struct btrfs_log_ctx *ctx);
e02119d5a   Chris Mason   Btrfs: Add a writ...
57
  int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root);
4a500fd17   Yan, Zheng   Btrfs: Metadata E...
58
59
  int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans,
  			     struct btrfs_fs_info *fs_info);
e02119d5a   Chris Mason   Btrfs: Add a writ...
60
61
  int btrfs_recover_log_trees(struct btrfs_root *tree_root);
  int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans,
e5b84f7a2   Nikolay Borisov   btrfs: Remove roo...
62
  			  struct dentry *dentry,
8b050d350   Miao Xie   Btrfs: fix skippe...
63
  			  struct btrfs_log_ctx *ctx);
e02119d5a   Chris Mason   Btrfs: Add a writ...
64
65
66
  int btrfs_del_dir_entries_in_log(struct btrfs_trans_handle *trans,
  				 struct btrfs_root *root,
  				 const char *name, int name_len,
49f34d1f9   Nikolay Borisov   btrfs: Make btrfs...
67
  				 struct btrfs_inode *dir, u64 index);
e02119d5a   Chris Mason   Btrfs: Add a writ...
68
69
70
  int btrfs_del_inode_ref_in_log(struct btrfs_trans_handle *trans,
  			       struct btrfs_root *root,
  			       const char *name, int name_len,
a491abb2e   Nikolay Borisov   btrfs: Make btrfs...
71
  			       struct btrfs_inode *inode, u64 dirid);
143bede52   Jeff Mahoney   btrfs: return voi...
72
  void btrfs_end_log_trans(struct btrfs_root *root);
45128b08f   zhong jiang   btrfs: change btr...
73
  void btrfs_pin_log_trans(struct btrfs_root *root);
12fcfd22f   Chris Mason   Btrfs: tree loggi...
74
  void btrfs_record_unlink_dir(struct btrfs_trans_handle *trans,
4176bdbf2   Nikolay Borisov   btrfs: Make btrfs...
75
  			     struct btrfs_inode *dir, struct btrfs_inode *inode,
12fcfd22f   Chris Mason   Btrfs: tree loggi...
76
  			     int for_rename);
1ec9a1ae1   Filipe Manana   Btrfs: fix unrepl...
77
  void btrfs_record_snapshot_destroy(struct btrfs_trans_handle *trans,
436635571   Nikolay Borisov   btrfs: Make btrfs...
78
  				   struct btrfs_inode *dir);
75b463d2b   Filipe Manana   btrfs: do not com...
79
  void btrfs_log_new_name(struct btrfs_trans_handle *trans,
9ca5fbfbb   Nikolay Borisov   btrfs: Make btrfs...
80
  			struct btrfs_inode *inode, struct btrfs_inode *old_dir,
75b463d2b   Filipe Manana   btrfs: do not com...
81
  			struct dentry *parent);
9888c3402   David Sterba   btrfs: replace GP...
82

e02119d5a   Chris Mason   Btrfs: Add a writ...
83
  #endif