]> git.ipfire.org Git - people/ms/linux.git/blame - fs/xfs/xfs_trans_priv.h
Merge branch 'for-6.0/dax' into libnvdimm-fixes
[people/ms/linux.git] / fs / xfs / xfs_trans_priv.h
CommitLineData
0b61f8a4 1// SPDX-License-Identifier: GPL-2.0
1da177e4 2/*
7b718769
NS
3 * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
1da177e4
LT
5 */
6#ifndef __XFS_TRANS_PRIV_H__
7#define __XFS_TRANS_PRIV_H__
8
8eda8721 9struct xlog;
1da177e4 10struct xfs_log_item;
1da177e4
LT
11struct xfs_mount;
12struct xfs_trans;
0e57f6a3
DC
13struct xfs_ail;
14struct xfs_log_vec;
1da177e4 15
d386b32b
DC
16
17void xfs_trans_init(struct xfs_mount *);
e98c414f
CH
18void xfs_trans_add_item(struct xfs_trans *, struct xfs_log_item *);
19void xfs_trans_del_item(struct xfs_log_item *);
71e330b5 20void xfs_trans_unreserve_and_mod_sb(struct xfs_trans *tp);
1da177e4 21
16924853
DC
22void xfs_trans_committed_bulk(struct xfs_ail *ailp,
23 struct list_head *lv_chain,
d15cbf2f 24 xfs_lsn_t commit_lsn, bool aborted);
1da177e4 25/*
27d8d5fe
DC
26 * AIL traversal cursor.
27 *
28 * Rather than using a generation number for detecting changes in the ail, use
29 * a cursor that is protected by the ail lock. The aild cursor exists in the
30 * struct xfs_ail, but other traversals can declare it on the stack and link it
31 * to the ail list.
32 *
33 * When an object is deleted from or moved int the AIL, the cursor list is
34 * searched to see if the object is a designated cursor item. If it is, it is
35 * deleted from the cursor so that the next time the cursor is used traversal
36 * will return to the start.
37 *
38 * This means a traversal colliding with a removal will cause a restart of the
39 * list scan, rather than any insertion or deletion anywhere in the list. The
40 * low bit of the item pointer is set if the cursor has been invalidated so
41 * that we can tell the difference between invalidation and reaching the end
42 * of the list to trigger traversal restarts.
1da177e4 43 */
27d8d5fe 44struct xfs_ail_cursor {
af3e4022 45 struct list_head list;
27d8d5fe
DC
46 struct xfs_log_item *item;
47};
1da177e4 48
249a8c11 49/*
27d8d5fe
DC
50 * Private AIL structures.
51 *
52 * Eventually we need to drive the locking in here as well.
249a8c11 53 */
82fa9012 54struct xfs_ail {
8eda8721 55 struct xlog *ail_log;
57e80956
MW
56 struct task_struct *ail_task;
57 struct list_head ail_head;
58 xfs_lsn_t ail_target;
59 xfs_lsn_t ail_target_prev;
60 struct list_head ail_cursors;
61 spinlock_t ail_lock;
62 xfs_lsn_t ail_last_pushed_lsn;
63 int ail_log_flush;
64 struct list_head ail_buf_list;
65 wait_queue_head_t ail_empty;
82fa9012
DC
66};
67
27d8d5fe
DC
68/*
69 * From xfs_trans_ail.c
70 */
e6059949 71void xfs_trans_ail_update_bulk(struct xfs_ail *ailp,
1d8c95a3 72 struct xfs_ail_cursor *cur,
e6059949 73 struct xfs_log_item **log_items, int nr_items,
57e80956 74 xfs_lsn_t lsn) __releases(ailp->ail_lock);
8d1d4083
JL
75/*
76 * Return a pointer to the first item in the AIL. If the AIL is empty, then
77 * return NULL.
78 */
79static inline struct xfs_log_item *
80xfs_ail_min(
81 struct xfs_ail *ailp)
82{
57e80956 83 return list_first_entry_or_null(&ailp->ail_head, struct xfs_log_item,
8d1d4083
JL
84 li_ail);
85}
86
e6059949
DC
87static inline void
88xfs_trans_ail_update(
89 struct xfs_ail *ailp,
90 struct xfs_log_item *lip,
57e80956 91 xfs_lsn_t lsn) __releases(ailp->ail_lock)
e6059949 92{
1d8c95a3 93 xfs_trans_ail_update_bulk(ailp, NULL, &lip, 1, lsn);
e6059949
DC
94}
95
86a37174
DW
96void xfs_trans_ail_insert(struct xfs_ail *ailp, struct xfs_log_item *lip,
97 xfs_lsn_t lsn);
98
8eb807bd
DC
99xfs_lsn_t xfs_ail_delete_one(struct xfs_ail *ailp, struct xfs_log_item *lip);
100void xfs_ail_update_finish(struct xfs_ail *ailp, xfs_lsn_t old_lsn)
4165994a 101 __releases(ailp->ail_lock);
849274c1 102void xfs_trans_ail_delete(struct xfs_log_item *lip, int shutdown_type);
9552e7f2 103
fd074841
DC
104void xfs_ail_push(struct xfs_ail *, xfs_lsn_t);
105void xfs_ail_push_all(struct xfs_ail *);
211e4d43 106void xfs_ail_push_all_sync(struct xfs_ail *);
1c304625 107struct xfs_log_item *xfs_ail_min(struct xfs_ail *ailp);
fd074841
DC
108xfs_lsn_t xfs_ail_min_lsn(struct xfs_ail *ailp);
109
1d8c95a3 110struct xfs_log_item * xfs_trans_ail_cursor_first(struct xfs_ail *ailp,
5b00f14f
DC
111 struct xfs_ail_cursor *cur,
112 xfs_lsn_t lsn);
1d8c95a3
DC
113struct xfs_log_item * xfs_trans_ail_cursor_last(struct xfs_ail *ailp,
114 struct xfs_ail_cursor *cur,
115 xfs_lsn_t lsn);
116struct xfs_log_item * xfs_trans_ail_cursor_next(struct xfs_ail *ailp,
27d8d5fe 117 struct xfs_ail_cursor *cur);
e4a1e29c 118void xfs_trans_ail_cursor_done(struct xfs_ail_cursor *cur);
27d8d5fe 119
7b2e2a31
DC
120#if BITS_PER_LONG != 64
121static inline void
122xfs_trans_ail_copy_lsn(
123 struct xfs_ail *ailp,
124 xfs_lsn_t *dst,
125 xfs_lsn_t *src)
126{
127 ASSERT(sizeof(xfs_lsn_t) == 8); /* don't lock if it shrinks */
57e80956 128 spin_lock(&ailp->ail_lock);
7b2e2a31 129 *dst = *src;
57e80956 130 spin_unlock(&ailp->ail_lock);
7b2e2a31
DC
131}
132#else
133static inline void
134xfs_trans_ail_copy_lsn(
135 struct xfs_ail *ailp,
136 xfs_lsn_t *dst,
137 xfs_lsn_t *src)
138{
139 ASSERT(sizeof(xfs_lsn_t) == 8);
140 *dst = *src;
141}
142#endif
d3a304b6
CM
143
144static inline void
145xfs_clear_li_failed(
146 struct xfs_log_item *lip)
147{
148 struct xfs_buf *bp = lip->li_buf;
149
22525c17 150 ASSERT(test_bit(XFS_LI_IN_AIL, &lip->li_flags));
57e80956 151 lockdep_assert_held(&lip->li_ailp->ail_lock);
d3a304b6 152
22525c17 153 if (test_and_clear_bit(XFS_LI_FAILED, &lip->li_flags)) {
d3a304b6
CM
154 lip->li_buf = NULL;
155 xfs_buf_rele(bp);
156 }
157}
158
159static inline void
160xfs_set_li_failed(
161 struct xfs_log_item *lip,
162 struct xfs_buf *bp)
163{
57e80956 164 lockdep_assert_held(&lip->li_ailp->ail_lock);
d3a304b6 165
22525c17 166 if (!test_and_set_bit(XFS_LI_FAILED, &lip->li_flags)) {
d3a304b6 167 xfs_buf_hold(bp);
d3a304b6
CM
168 lip->li_buf = bp;
169 }
170}
171
1da177e4 172#endif /* __XFS_TRANS_PRIV_H__ */