| .. | .. |
|---|
| 27 | 27 | struct xfs_bui_log_item; |
|---|
| 28 | 28 | struct xfs_bud_log_item; |
|---|
| 29 | 29 | |
|---|
| 30 | | -typedef struct xfs_log_item { |
|---|
| 30 | +struct xfs_log_item { |
|---|
| 31 | 31 | struct list_head li_ail; /* AIL pointers */ |
|---|
| 32 | 32 | struct list_head li_trans; /* transaction list */ |
|---|
| 33 | 33 | xfs_lsn_t li_lsn; /* last on-disk lsn */ |
|---|
| .. | .. |
|---|
| 37 | 37 | unsigned long li_flags; /* misc flags */ |
|---|
| 38 | 38 | struct xfs_buf *li_buf; /* real buffer pointer */ |
|---|
| 39 | 39 | 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 */ |
|---|
| 44 | 40 | const struct xfs_item_ops *li_ops; /* function list */ |
|---|
| 45 | 41 | |
|---|
| 46 | 42 | /* delayed logging */ |
|---|
| 47 | 43 | struct list_head li_cil; /* CIL pointers */ |
|---|
| 48 | 44 | struct xfs_log_vec *li_lv; /* active log vector */ |
|---|
| 49 | 45 | 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 | +}; |
|---|
| 52 | 48 | |
|---|
| 53 | 49 | /* |
|---|
| 54 | 50 | * li_flags use the (set/test/clear)_bit atomic interfaces because updates can |
|---|
| .. | .. |
|---|
| 67 | 63 | { (1 << XFS_LI_DIRTY), "DIRTY" } |
|---|
| 68 | 64 | |
|---|
| 69 | 65 | 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); |
|---|
| 74 | 71 | 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); |
|---|
| 79 | 80 | }; |
|---|
| 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) |
|---|
| 80 | 103 | |
|---|
| 81 | 104 | void xfs_log_item_init(struct xfs_mount *mp, struct xfs_log_item *item, |
|---|
| 82 | 105 | int type, const struct xfs_item_ops *ops); |
|---|
| .. | .. |
|---|
| 162 | 185 | struct xfs_trans **tpp); |
|---|
| 163 | 186 | void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t); |
|---|
| 164 | 187 | |
|---|
| 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); |
|---|
| 169 | 191 | |
|---|
| 170 | | -static inline struct xfs_buf * |
|---|
| 192 | +static inline int |
|---|
| 171 | 193 | xfs_trans_get_buf( |
|---|
| 172 | 194 | struct xfs_trans *tp, |
|---|
| 173 | 195 | struct xfs_buftarg *target, |
|---|
| 174 | 196 | xfs_daddr_t blkno, |
|---|
| 175 | 197 | int numblks, |
|---|
| 176 | | - uint flags) |
|---|
| 198 | + uint flags, |
|---|
| 199 | + struct xfs_buf **bpp) |
|---|
| 177 | 200 | { |
|---|
| 178 | 201 | 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); |
|---|
| 180 | 203 | } |
|---|
| 181 | 204 | |
|---|
| 182 | 205 | int xfs_trans_read_buf_map(struct xfs_mount *mp, |
|---|
| .. | .. |
|---|
| 203 | 226 | flags, bpp, ops); |
|---|
| 204 | 227 | } |
|---|
| 205 | 228 | |
|---|
| 206 | | -struct xfs_buf *xfs_trans_getsb(xfs_trans_t *, struct xfs_mount *, int); |
|---|
| 229 | +struct xfs_buf *xfs_trans_getsb(struct xfs_trans *); |
|---|
| 207 | 230 | |
|---|
| 208 | 231 | void xfs_trans_brelse(xfs_trans_t *, struct xfs_buf *); |
|---|
| 209 | 232 | void xfs_trans_bjoin(xfs_trans_t *, struct xfs_buf *); |
|---|
| .. | .. |
|---|
| 220 | 243 | void xfs_trans_log_buf(struct xfs_trans *, struct xfs_buf *, uint, |
|---|
| 221 | 244 | uint); |
|---|
| 222 | 245 | void xfs_trans_dirty_buf(struct xfs_trans *, struct xfs_buf *); |
|---|
| 246 | +bool xfs_trans_buf_is_dirty(struct xfs_buf *bp); |
|---|
| 223 | 247 | void xfs_trans_log_inode(xfs_trans_t *, struct xfs_inode *, uint); |
|---|
| 224 | 248 | |
|---|
| 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); |
|---|
| 233 | 249 | int xfs_trans_commit(struct xfs_trans *); |
|---|
| 234 | 250 | int xfs_trans_roll(struct xfs_trans **); |
|---|
| 235 | 251 | int xfs_trans_roll_inode(struct xfs_trans **, struct xfs_inode *); |
|---|
| .. | .. |
|---|
| 244 | 260 | |
|---|
| 245 | 261 | extern kmem_zone_t *xfs_trans_zone; |
|---|
| 246 | 262 | |
|---|
| 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 | +} |
|---|
| 249 | 270 | |
|---|
| 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 | +} |
|---|
| 258 | 279 | |
|---|
| 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 | +} |
|---|
| 261 | 289 | |
|---|
| 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 | +} |
|---|
| 282 | 300 | |
|---|
| 283 | 301 | #endif /* __XFS_TRANS_H__ */ |
|---|