Lines Matching refs:trans
59 static void journal_dump_trans(journal_transaction_t *trans EXT2FS_ATTR((unused)), in journal_dump_trans()
63 "flags=0x%x\n", trans, tag, trans->tid, trans->start, in journal_dump_trans()
64 trans->block, trans->end, trans->flags); in journal_dump_trans()
67 static errcode_t journal_commit_trans(journal_transaction_t *trans) in journal_commit_trans() argument
76 JOURNAL_CHECK_TRANS_MAGIC(trans); in journal_commit_trans()
78 if ((trans->flags & J_TRANS_COMMITTED) || in journal_commit_trans()
79 !(trans->flags & J_TRANS_OPEN)) in journal_commit_trans()
82 bh = getblk(trans->journal->j_dev, 0, trans->journal->j_blocksize); in journal_commit_trans()
90 commit->h_sequence = ext2fs_cpu_to_be32(trans->tid); in journal_commit_trans()
91 if (jfs_has_feature_checksum(trans->journal)) { in journal_commit_trans()
95 cbh = getblk(trans->journal->j_dev, 0, in journal_commit_trans()
96 trans->journal->j_blocksize); in journal_commit_trans()
102 for (cblk = trans->start; cblk < trans->block; cblk++) { in journal_commit_trans()
103 err = journal_bmap(trans->journal, cblk, in journal_commit_trans()
135 jbd2_commit_block_csum_set(trans->journal, bh); in journal_commit_trans()
136 err = journal_bmap(trans->journal, trans->block, &bh->b_blocknr); in journal_commit_trans()
140 dbg_printf("Writing commit block at %llu:%llu\n", trans->block, in journal_commit_trans()
147 trans->flags |= J_TRANS_COMMITTED; in journal_commit_trans()
148 trans->flags &= ~J_TRANS_OPEN; in journal_commit_trans()
149 trans->block++; in journal_commit_trans()
151 ext2fs_set_feature_journal_needs_recovery(trans->fs->super); in journal_commit_trans()
152 ext2fs_mark_super_dirty(trans->fs); in journal_commit_trans()
160 static errcode_t journal_add_revoke_to_trans(journal_transaction_t *trans, in journal_add_revoke_to_trans() argument
173 JOURNAL_CHECK_TRANS_MAGIC(trans); in journal_add_revoke_to_trans()
175 if ((trans->flags & J_TRANS_COMMITTED) || in journal_add_revoke_to_trans()
176 !(trans->flags & J_TRANS_OPEN)) in journal_add_revoke_to_trans()
183 if (journal_has_csum_v2or3(trans->journal)) in journal_add_revoke_to_trans()
186 curr_blk = trans->block; in journal_add_revoke_to_trans()
188 bh = getblk(trans->journal->j_dev, curr_blk, in journal_add_revoke_to_trans()
189 trans->journal->j_blocksize); in journal_add_revoke_to_trans()
195 jrb->r_header.h_sequence = ext2fs_cpu_to_be32(trans->tid); in journal_add_revoke_to_trans()
198 if (jfs_has_feature_64bit(trans->journal)) in journal_add_revoke_to_trans()
205 if (offset + sz > trans->journal->j_blocksize - csum_size) { in journal_add_revoke_to_trans()
207 jbd2_revoke_csum_set(trans->journal, bh); in journal_add_revoke_to_trans()
209 err = journal_bmap(trans->journal, curr_blk, in journal_add_revoke_to_trans()
226 ext2fs_blocks_count(trans->journal->j_fs_dev->k_fs->super)) { in journal_add_revoke_to_trans()
231 if (jfs_has_feature_64bit(trans->journal)) in journal_add_revoke_to_trans()
242 jbd2_revoke_csum_set(trans->journal, bh); in journal_add_revoke_to_trans()
244 err = journal_bmap(trans->journal, curr_blk, &bh->b_blocknr); in journal_add_revoke_to_trans()
258 trans->block = curr_blk; in journal_add_revoke_to_trans()
263 static errcode_t journal_add_blocks_to_trans(journal_transaction_t *trans, in journal_add_blocks_to_trans() argument
277 JOURNAL_CHECK_TRANS_MAGIC(trans); in journal_add_blocks_to_trans()
279 if ((trans->flags & J_TRANS_COMMITTED) || in journal_add_blocks_to_trans()
280 !(trans->flags & J_TRANS_OPEN)) in journal_add_blocks_to_trans()
287 if (journal_has_csum_v2or3(trans->journal)) in journal_add_blocks_to_trans()
290 curr_blk = jdb_blk = trans->block; in journal_add_blocks_to_trans()
292 data_bh = getblk(trans->journal->j_dev, curr_blk, in journal_add_blocks_to_trans()
293 trans->journal->j_blocksize); in journal_add_blocks_to_trans()
299 bh = getblk(trans->journal->j_dev, curr_blk, in journal_add_blocks_to_trans()
300 trans->journal->j_blocksize); in journal_add_blocks_to_trans()
308 jdb->h_sequence = ext2fs_cpu_to_be32(trans->tid); in journal_add_blocks_to_trans()
313 j = fread(data_bh->b_data, trans->journal->j_blocksize, 1, fp); in journal_add_blocks_to_trans()
319 tag_bytes = journal_tag_bytes(trans->journal); in journal_add_blocks_to_trans()
323 (char *)jdb_buf + trans->journal->j_blocksize - csum_size) { in journal_add_blocks_to_trans()
324 jbd2_descr_block_csum_set(trans->journal, bh); in journal_add_blocks_to_trans()
325 err = journal_bmap(trans->journal, jdb_blk, in journal_add_blocks_to_trans()
343 ext2fs_blocks_count(trans->journal->j_fs_dev->k_fs->super)) { in journal_add_blocks_to_trans()
355 trans->journal->j_superblock->s_uuid, in journal_add_blocks_to_trans()
356 sizeof(trans->journal->j_superblock->s_uuid)); in journal_add_blocks_to_trans()
365 if (jfs_has_feature_64bit(trans->journal)) in journal_add_blocks_to_trans()
367 jbd2_block_tag_csum_set(trans->journal, jdbt, data_bh, in journal_add_blocks_to_trans()
368 trans->tid); in journal_add_blocks_to_trans()
371 err = journal_bmap(trans->journal, curr_blk, in journal_add_blocks_to_trans()
390 jbd2_descr_block_csum_set(trans->journal, bh); in journal_add_blocks_to_trans()
391 err = journal_bmap(trans->journal, jdb_blk, &bh->b_blocknr); in journal_add_blocks_to_trans()
404 trans->block = curr_blk; in journal_add_blocks_to_trans()
437 journal_transaction_t *trans, in journal_open_trans() argument
440 trans->fs = journal->j_fs_dev->k_fs; in journal_open_trans()
441 trans->journal = journal; in journal_open_trans()
442 trans->flags = J_TRANS_OPEN; in journal_open_trans()
446 trans->tid = journal->j_tail_sequence; in journal_open_trans()
447 trans->start = journal->j_first; in journal_open_trans()
450 trans->tid = journal->j_transaction_sequence; in journal_open_trans()
451 trans->start = journal->j_head; in journal_open_trans()
454 trans->block = trans->start; in journal_open_trans()
455 if (trans->start + blocks > journal->j_last) in journal_open_trans()
457 trans->end = trans->block + blocks; in journal_open_trans()
458 journal_dump_trans(trans, "new transaction"); in journal_open_trans()
460 trans->magic = J_TRANS_MAGIC; in journal_open_trans()
464 static errcode_t journal_close_trans(journal_transaction_t *trans) in journal_close_trans() argument
468 JOURNAL_CHECK_TRANS_MAGIC(trans); in journal_close_trans()
470 if (!(trans->flags & J_TRANS_COMMITTED)) in journal_close_trans()
473 journal = trans->journal; in journal_close_trans()
476 journal->j_tail_sequence = trans->tid; in journal_close_trans()
477 journal->j_tail = trans->start; in journal_close_trans()
478 journal->j_superblock->s_start = ext2fs_cpu_to_be32(trans->start); in journal_close_trans()
482 journal->j_head = trans->end + 1; in journal_close_trans()
483 journal->j_transaction_sequence = trans->tid + 1; in journal_close_trans()
485 trans->magic = 0; in journal_close_trans()
488 if (!ext2fs_has_feature_journal_needs_recovery(trans->fs->super)) { in journal_close_trans()
489 ext2fs_set_feature_journal_needs_recovery(trans->fs->super); in journal_close_trans()
490 ext2fs_mark_super_dirty(trans->fs); in journal_close_trans()
503 journal_transaction_t trans; in journal_write() local
512 err = journal_open_trans(journal, &trans, blocks); in journal_write()
516 err = journal_add_blocks_to_trans(&trans, block_list, block_len, fp); in journal_write()
520 err = journal_add_revoke_to_trans(&trans, revoke_list, revoke_len); in journal_write()
525 err = journal_commit_trans(&trans); in journal_write()
530 err = journal_close_trans(&trans); in journal_write()