Blame view
fs/btrfs/tree-log.h
2.78 KB
9888c3402
|
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
e02119d5a
|
2 3 |
/* * Copyright (C) 2008 Oracle. All rights reserved. |
e02119d5a
|
4 |
*/ |
9888c3402
|
5 6 |
#ifndef BTRFS_TREE_LOG_H #define BTRFS_TREE_LOG_H |
e02119d5a
|
7 |
|
995946dd2
|
8 9 |
#include "ctree.h" #include "transaction.h" |
257c62e1b
|
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
|
12 13 |
struct btrfs_log_ctx { int log_ret; |
d1433debe
|
14 |
int log_transid; |
2f2ff0ee5
|
15 |
bool log_new_dentries; |
75b463d2b
|
16 |
bool logging_new_name; |
28a235931
|
17 |
struct inode *inode; |
8b050d350
|
18 |
struct list_head list; |
487781796
|
19 20 |
/* Only used for fast fsyncs. */ struct list_head ordered_extents; |
8b050d350
|
21 |
}; |
28a235931
|
22 23 |
static inline void btrfs_init_log_ctx(struct btrfs_log_ctx *ctx, struct inode *inode) |
8b050d350
|
24 25 |
{ ctx->log_ret = 0; |
d1433debe
|
26 |
ctx->log_transid = 0; |
2f2ff0ee5
|
27 |
ctx->log_new_dentries = false; |
75b463d2b
|
28 |
ctx->logging_new_name = false; |
28a235931
|
29 |
ctx->inode = inode; |
8b050d350
|
30 |
INIT_LIST_HEAD(&ctx->list); |
487781796
|
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
|
45 |
} |
907877664
|
46 |
static inline void btrfs_set_log_full_commit(struct btrfs_trans_handle *trans) |
995946dd2
|
47 |
{ |
907877664
|
48 |
WRITE_ONCE(trans->fs_info->last_trans_log_full_commit, trans->transid); |
995946dd2
|
49 |
} |
4884b8e8e
|
50 |
static inline int btrfs_need_log_full_commit(struct btrfs_trans_handle *trans) |
995946dd2
|
51 |
{ |
4884b8e8e
|
52 |
return READ_ONCE(trans->fs_info->last_trans_log_full_commit) == |
995946dd2
|
53 54 |
trans->transid; } |
e02119d5a
|
55 |
int btrfs_sync_log(struct btrfs_trans_handle *trans, |
8b050d350
|
56 |
struct btrfs_root *root, struct btrfs_log_ctx *ctx); |
e02119d5a
|
57 |
int btrfs_free_log(struct btrfs_trans_handle *trans, struct btrfs_root *root); |
4a500fd17
|
58 59 |
int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info); |
e02119d5a
|
60 61 |
int btrfs_recover_log_trees(struct btrfs_root *tree_root); int btrfs_log_dentry_safe(struct btrfs_trans_handle *trans, |
e5b84f7a2
|
62 |
struct dentry *dentry, |
8b050d350
|
63 |
struct btrfs_log_ctx *ctx); |
e02119d5a
|
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
|
67 |
struct btrfs_inode *dir, u64 index); |
e02119d5a
|
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
|
71 |
struct btrfs_inode *inode, u64 dirid); |
143bede52
|
72 |
void btrfs_end_log_trans(struct btrfs_root *root); |
45128b08f
|
73 |
void btrfs_pin_log_trans(struct btrfs_root *root); |
12fcfd22f
|
74 |
void btrfs_record_unlink_dir(struct btrfs_trans_handle *trans, |
4176bdbf2
|
75 |
struct btrfs_inode *dir, struct btrfs_inode *inode, |
12fcfd22f
|
76 |
int for_rename); |
1ec9a1ae1
|
77 |
void btrfs_record_snapshot_destroy(struct btrfs_trans_handle *trans, |
436635571
|
78 |
struct btrfs_inode *dir); |
75b463d2b
|
79 |
void btrfs_log_new_name(struct btrfs_trans_handle *trans, |
9ca5fbfbb
|
80 |
struct btrfs_inode *inode, struct btrfs_inode *old_dir, |
75b463d2b
|
81 |
struct dentry *parent); |
9888c3402
|
82 |
|
e02119d5a
|
83 |
#endif |