Btrfs: crash recovery fixes
[linux-2.6-block.git] / fs / btrfs / disk-io.c
index 7081729d5b161dd8bc0e450589d3ae2286c417c7..d1bf5bc1bc14b29bcfaccd442b5c88a4a4f44c90 100644 (file)
@@ -270,14 +270,6 @@ fail:
        return NULL;
 }
 
-int dirty_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
-                    struct buffer_head *buf)
-{
-       WARN_ON(atomic_read(&buf->b_count) == 0);
-       mark_buffer_dirty(buf);
-       return 0;
-}
-
 int clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
                     struct buffer_head *buf)
 {
@@ -621,6 +613,20 @@ int close_ctree(struct btrfs_root *root)
        return 0;
 }
 
+void btrfs_mark_buffer_dirty(struct buffer_head *bh)
+{
+       struct btrfs_root *root = BTRFS_I(bh->b_page->mapping->host)->root;
+       u64 transid = btrfs_header_generation(btrfs_buffer_header(bh));
+       WARN_ON(!atomic_read(&bh->b_count));
+       if (transid != root->fs_info->generation) {
+               printk(KERN_CRIT "transid mismatch buffer %llu, found %Lu running %Lu\n",
+                       (unsigned long long)bh->b_blocknr,
+                       transid, root->fs_info->generation);
+               WARN_ON(1);
+       }
+       mark_buffer_dirty(bh);
+}
+
 void btrfs_block_release(struct btrfs_root *root, struct buffer_head *buf)
 {
        brelse(buf);