It is only used as a convenience function in the ext2fs.h header, so move it
there as an inline function. This enforces strict use of the externally
visible libdiskfs transaction API (diskfs_journal_start_transaction, etc.)
rather than relying on internal journal locks, improving encapsulation.
---
 ext2fs/ext2fs.h  | 15 ++++++++++++++-
 ext2fs/journal.c | 16 ----------------
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/ext2fs/ext2fs.h b/ext2fs/ext2fs.h
index 5bf20e645..9282e5417 100644
--- a/ext2fs/ext2fs.h
+++ b/ext2fs/ext2fs.h
@@ -352,7 +352,6 @@ extern struct journal *ext2_journal;
 error_t
 journal_dirty_block (diskfs_transaction_t * txn, block_t fs_blocknr);
 
-void journal_notify_block_changed (block_t block);
 
 void ext2_orphan_drop_ram_link (struct node *np);
 
@@ -531,6 +530,20 @@ extern void sync_global (int wait);
 extern void alloc_sync (struct node *np);
 
 #if defined(__USE_EXTERN_INLINES) || defined(EXT2FS_DEFINE_EI)
+EXT2FS_EI void
+journal_notify_block_changed (block_t block)
+{
+  if (!ext2_journal)
+    return;
+
+  diskfs_transaction_t *txn = diskfs_journal_start_transaction ();
+  error_t err = journal_dirty_block (txn, block);
+  if (err)
+    JRNL_LOG_WARN ("Didn't manage to add a dirty block %u to the journal. 
(%s).",
+                  block, strerror (err));
+  diskfs_journal_stop_transaction (txn);
+}
+
 /* Marks the global block BLOCK as being modified, and returns true if we
    think it may have been clean before (but we may not be sure).  Note that
    this isn't enough to cause the block to be synced; you must call
diff --git a/ext2fs/journal.c b/ext2fs/journal.c
index 9eccabe20..fcd90f05e 100644
--- a/ext2fs/journal.c
+++ b/ext2fs/journal.c
@@ -2743,22 +2743,6 @@ journal_store_read (block_t start_block, size_t length, 
void **buf,
   return err;
 }
 
-void
-journal_notify_block_changed (block_t block)
-{
-  if (!ext2_journal)
-    return;
-
-  JOURNAL_LOCK (ext2_journal);
-  diskfs_transaction_t *txn =
-    journal_join_transaction_locked (ext2_journal);
-  if (journal_dirty_block_locked (txn, block))
-    JRNL_LOG_WARN ("Didn't manage to add a dirty block %u to the journal.",
-                  block);
-  diskfs_journal_stop_transaction_locked (ext2_journal, txn);
-  JOURNAL_UNLOCK (ext2_journal);
-}
-
 void
 diskfs_journal_shutdown (void)
 {
-- 
2.55.0


Reply via email to