ref: 9fe8815522e8dc1bff0d825f52ababb9fbbab22f
parent: 29b69c630d36e29b9e683f3a2fc96edc60cc579b
author: ngkaho1234 <ngkaho1234@gmail.com>
date: Fri Dec 25 20:26:33 EST 2015
ext4_journal: add jbd_trans_try_revoke_block routine.
--- a/lwext4/ext4_journal.c
+++ b/lwext4/ext4_journal.c
@@ -1222,6 +1222,28 @@
return EOK;
}
+/**@brief Try to add block to be revoked to a transaction.
+ * If @lba still remains in an transaction on checkpoint
+ * queue, add @lba as a revoked block to the transaction.
+ * @param trans transaction
+ * @param lba logical block address
+ * @return standard error code*/
+int jbd_trans_try_revoke_block(struct jbd_trans *trans,
+ ext4_fsblk_t lba)
+{
+ int r = EOK;
+ struct jbd_trans *tmp;
+ struct jbd_journal *journal = trans->journal;
+ TAILQ_FOREACH(tmp, &journal->cp_queue, trans_node) {
+ struct jbd_block_rec *block_rec =
+ jbd_trans_block_rec_lookup(trans, lba);
+ if (block_rec)
+ jbd_trans_revoke_block(trans, lba);
+
+ }
+ return r;
+}
+
/**@brief Free a transaction
* @param journal current journal session
* @param trans transaction
--- a/lwext4/ext4_journal.h
+++ b/lwext4/ext4_journal.h
@@ -62,6 +62,8 @@
struct ext4_block *block);
int jbd_trans_revoke_block(struct jbd_trans *trans,
ext4_fsblk_t lba);
+int jbd_trans_try_revoke_block(struct jbd_trans *trans,
+ ext4_fsblk_t lba);
void jbd_journal_free_trans(struct jbd_journal *journal,
struct jbd_trans *trans,
bool abort);