hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/xfs/xfs_trans.h
....@@ -27,7 +27,7 @@
2727 struct xfs_bui_log_item;
2828 struct xfs_bud_log_item;
2929
30
-typedef struct xfs_log_item {
30
+struct xfs_log_item {
3131 struct list_head li_ail; /* AIL pointers */
3232 struct list_head li_trans; /* transaction list */
3333 xfs_lsn_t li_lsn; /* last on-disk lsn */
....@@ -37,18 +37,14 @@
3737 unsigned long li_flags; /* misc flags */
3838 struct xfs_buf *li_buf; /* real buffer pointer */
3939 struct list_head li_bio_list; /* buffer item list */
40
- void (*li_cb)(struct xfs_buf *,
41
- struct xfs_log_item *);
42
- /* buffer item iodone */
43
- /* callback func */
4440 const struct xfs_item_ops *li_ops; /* function list */
4541
4642 /* delayed logging */
4743 struct list_head li_cil; /* CIL pointers */
4844 struct xfs_log_vec *li_lv; /* active log vector */
4945 struct xfs_log_vec *li_lv_shadow; /* standby vector */
50
- xfs_lsn_t li_seq; /* CIL commit seq */
51
-} xfs_log_item_t;
46
+ xfs_csn_t li_seq; /* CIL commit seq */
47
+};
5248
5349 /*
5450 * li_flags use the (set/test/clear)_bit atomic interfaces because updates can
....@@ -67,16 +63,43 @@
6763 { (1 << XFS_LI_DIRTY), "DIRTY" }
6864
6965 struct xfs_item_ops {
70
- void (*iop_size)(xfs_log_item_t *, int *, int *);
71
- void (*iop_format)(xfs_log_item_t *, struct xfs_log_vec *);
72
- void (*iop_pin)(xfs_log_item_t *);
73
- void (*iop_unpin)(xfs_log_item_t *, int remove);
66
+ unsigned flags;
67
+ void (*iop_size)(struct xfs_log_item *, int *, int *);
68
+ void (*iop_format)(struct xfs_log_item *, struct xfs_log_vec *);
69
+ void (*iop_pin)(struct xfs_log_item *);
70
+ void (*iop_unpin)(struct xfs_log_item *, int remove);
7471 uint (*iop_push)(struct xfs_log_item *, struct list_head *);
75
- void (*iop_unlock)(xfs_log_item_t *);
76
- xfs_lsn_t (*iop_committed)(xfs_log_item_t *, xfs_lsn_t);
77
- void (*iop_committing)(xfs_log_item_t *, xfs_lsn_t);
78
- void (*iop_error)(xfs_log_item_t *, xfs_buf_t *);
72
+ void (*iop_committing)(struct xfs_log_item *lip, xfs_csn_t seq);
73
+ void (*iop_release)(struct xfs_log_item *);
74
+ xfs_lsn_t (*iop_committed)(struct xfs_log_item *, xfs_lsn_t);
75
+ int (*iop_recover)(struct xfs_log_item *lip,
76
+ struct list_head *capture_list);
77
+ bool (*iop_match)(struct xfs_log_item *item, uint64_t id);
78
+ struct xfs_log_item *(*iop_relog)(struct xfs_log_item *intent,
79
+ struct xfs_trans *tp);
7980 };
81
+
82
+/* Is this log item a deferred action intent? */
83
+static inline bool
84
+xlog_item_is_intent(struct xfs_log_item *lip)
85
+{
86
+ return lip->li_ops->iop_recover != NULL &&
87
+ lip->li_ops->iop_match != NULL;
88
+}
89
+
90
+/* Is this a log intent-done item? */
91
+static inline bool
92
+xlog_item_is_intent_done(struct xfs_log_item *lip)
93
+{
94
+ return lip->li_ops->iop_unpin == NULL &&
95
+ lip->li_ops->iop_push == NULL;
96
+}
97
+
98
+/*
99
+ * Release the log item as soon as committed. This is for items just logging
100
+ * intents that never need to be written back in place.
101
+ */
102
+#define XFS_ITEM_RELEASE_WHEN_COMMITTED (1 << 0)
80103
81104 void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item,
82105 int type, const struct xfs_item_ops *ops);
....@@ -162,21 +185,21 @@
162185 struct xfs_trans **tpp);
163186 void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
164187
165
-struct xfs_buf *xfs_trans_get_buf_map(struct xfs_trans *tp,
166
- struct xfs_buftarg *target,
167
- struct xfs_buf_map *map, int nmaps,
168
- uint flags);
188
+int xfs_trans_get_buf_map(struct xfs_trans *tp, struct xfs_buftarg *target,
189
+ struct xfs_buf_map *map, int nmaps, xfs_buf_flags_t flags,
190
+ struct xfs_buf **bpp);
169191
170
-static inline struct xfs_buf *
192
+static inline int
171193 xfs_trans_get_buf(
172194 struct xfs_trans *tp,
173195 struct xfs_buftarg *target,
174196 xfs_daddr_t blkno,
175197 int numblks,
176
- uint flags)
198
+ uint flags,
199
+ struct xfs_buf **bpp)
177200 {
178201 DEFINE_SINGLE_BUF_MAP(map, blkno, numblks);
179
- return xfs_trans_get_buf_map(tp, target, &map, 1, flags);
202
+ return xfs_trans_get_buf_map(tp, target, &map, 1, flags, bpp);
180203 }
181204
182205 int xfs_trans_read_buf_map(struct xfs_mount *mp,
....@@ -203,7 +226,7 @@
203226 flags, bpp, ops);
204227 }
205228
206
-struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int);
229
+struct xfs_buf *xfs_trans_getsb(struct xfs_trans *);
207230
208231 void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *);
209232 void xfs_trans_bjoin(xfs_trans_t *, struct xfs_buf *);
....@@ -220,16 +243,9 @@
220243 void xfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, uint,
221244 uint);
222245 void xfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *);
246
+bool xfs_trans_buf_is_dirty(struct xfs_buf *bp);
223247 void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint);
224248
225
-void xfs_extent_free_init_defer_op(void);
226
-struct xfs_efd_log_item *xfs_trans_get_efd(struct xfs_trans *,
227
- struct xfs_efi_log_item *,
228
- uint);
229
-int xfs_trans_free_extent(struct xfs_trans *,
230
- struct xfs_efd_log_item *, xfs_fsblock_t,
231
- xfs_extlen_t, struct xfs_owner_info *,
232
- bool);
233249 int xfs_trans_commit(struct xfs_trans *);
234250 int xfs_trans_roll(struct xfs_trans **);
235251 int xfs_trans_roll_inode(struct xfs_trans **, struct xfs_inode *);
....@@ -244,40 +260,42 @@
244260
245261 extern kmem_zone_t *xfs_trans_zone;
246262
247
-/* rmap updates */
248
-enum xfs_rmap_intent_type;
263
+static inline struct xfs_log_item *
264
+xfs_trans_item_relog(
265
+ struct xfs_log_item *lip,
266
+ struct xfs_trans *tp)
267
+{
268
+ return lip->li_ops->iop_relog(lip, tp);
269
+}
249270
250
-void xfs_rmap_update_init_defer_op(void);
251
-struct xfs_rud_log_item *xfs_trans_get_rud(struct xfs_trans *tp,
252
- struct xfs_rui_log_item *ruip);
253
-int xfs_trans_log_finish_rmap_update(struct xfs_trans *tp,
254
- struct xfs_rud_log_item *rudp, enum xfs_rmap_intent_type type,
255
- uint64_t owner, int whichfork, xfs_fileoff_t startoff,
256
- xfs_fsblock_t startblock, xfs_filblks_t blockcount,
257
- xfs_exntst_t state, struct xfs_btree_cur **pcur);
271
+static inline void
272
+xfs_trans_set_context(
273
+ struct xfs_trans *tp)
274
+{
275
+ ASSERT(current->journal_info == NULL);
276
+ tp->t_pflags = memalloc_nofs_save();
277
+ current->journal_info = tp;
278
+}
258279
259
-/* refcount updates */
260
-enum xfs_refcount_intent_type;
280
+static inline void
281
+xfs_trans_clear_context(
282
+ struct xfs_trans *tp)
283
+{
284
+ if (current->journal_info == tp) {
285
+ memalloc_nofs_restore(tp->t_pflags);
286
+ current->journal_info = NULL;
287
+ }
288
+}
261289
262
-void xfs_refcount_update_init_defer_op(void);
263
-struct xfs_cud_log_item *xfs_trans_get_cud(struct xfs_trans *tp,
264
- struct xfs_cui_log_item *cuip);
265
-int xfs_trans_log_finish_refcount_update(struct xfs_trans *tp,
266
- struct xfs_cud_log_item *cudp,
267
- enum xfs_refcount_intent_type type, xfs_fsblock_t startblock,
268
- xfs_extlen_t blockcount, xfs_fsblock_t *new_fsb,
269
- xfs_extlen_t *new_len, struct xfs_btree_cur **pcur);
270
-
271
-/* mapping updates */
272
-enum xfs_bmap_intent_type;
273
-
274
-void xfs_bmap_update_init_defer_op(void);
275
-struct xfs_bud_log_item *xfs_trans_get_bud(struct xfs_trans *tp,
276
- struct xfs_bui_log_item *buip);
277
-int xfs_trans_log_finish_bmap_update(struct xfs_trans *tp,
278
- struct xfs_bud_log_item *rudp, enum xfs_bmap_intent_type type,
279
- struct xfs_inode *ip, int whichfork, xfs_fileoff_t startoff,
280
- xfs_fsblock_t startblock, xfs_filblks_t *blockcount,
281
- xfs_exntst_t state);
290
+static inline void
291
+xfs_trans_switch_context(
292
+ struct xfs_trans *old_tp,
293
+ struct xfs_trans *new_tp)
294
+{
295
+ ASSERT(current->journal_info == old_tp);
296
+ new_tp->t_pflags = old_tp->t_pflags;
297
+ old_tp->t_pflags = 0;
298
+ current->journal_info = new_tp;
299
+}
282300
283301 #endif /* __XFS_TRANS_H__ */