Commit f880fe6e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by David Sterba
Browse files

btrfs: don't hold an extra reference for redirtied buffers



When btrfs_redirty_list_add redirties a buffer, it also acquires
an extra reference that is released on transaction commit.  But
this is not required as buffers that are dirty or under writeback
are never freed (look for calls to extent_buffer_under_io())).

Remove the extra reference and the infrastructure used to drop it
again.

History behind redirty logic:

In the first place, it used releasing_list to hold all the
to-be-released extent buffers, and decided which buffers to re-dirty at
the commit time. Then, in a later version, the behaviour got changed to
re-dirty a necessary buffer and add re-dirtied one to the list in
btrfs_free_tree_block(). In short, the list was there mostly for the
patch series' historical reason.

Reviewed-by: default avatarNaohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
[ add Naohiro's comment regarding history ]
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent f18cc978
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -5073,8 +5073,6 @@ void btrfs_cleanup_one_transaction(struct btrfs_transaction *cur_trans,
				     EXTENT_DIRTY);
	btrfs_destroy_pinned_extent(fs_info, &cur_trans->pinned_extents);

	btrfs_free_redirty_list(cur_trans);

	cur_trans->state =TRANS_STATE_COMPLETED;
	wake_up(&cur_trans->commit_wait);
}
+0 −1
Original line number Diff line number Diff line
@@ -3557,7 +3557,6 @@ __alloc_extent_buffer(struct btrfs_fs_info *fs_info, u64 start,
	init_rwsem(&eb->lock);

	btrfs_leak_debug_add_eb(eb);
	INIT_LIST_HEAD(&eb->release_list);

	spin_lock_init(&eb->refs_lock);
	atomic_set(&eb->refs, 1);
+0 −1
Original line number Diff line number Diff line
@@ -89,7 +89,6 @@ struct extent_buffer {
	struct rw_semaphore lock;

	struct page *pages[INLINE_EXTENT_BUFFER_PAGES];
	struct list_head release_list;
#ifdef CONFIG_BTRFS_DEBUG
	struct list_head leak_list;
#endif
+0 −9
Original line number Diff line number Diff line
@@ -374,8 +374,6 @@ static noinline int join_transaction(struct btrfs_fs_info *fs_info,
	spin_lock_init(&cur_trans->dirty_bgs_lock);
	INIT_LIST_HEAD(&cur_trans->deleted_bgs);
	spin_lock_init(&cur_trans->dropped_roots_lock);
	INIT_LIST_HEAD(&cur_trans->releasing_ebs);
	spin_lock_init(&cur_trans->releasing_ebs_lock);
	list_add_tail(&cur_trans->list, &fs_info->trans_list);
	extent_io_tree_init(fs_info, &cur_trans->dirty_pages,
			IO_TREE_TRANS_DIRTY_PAGES);
@@ -2482,13 +2480,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
		goto scrub_continue;
	}

	/*
	 * At this point, we should have written all the tree blocks allocated
	 * in this transaction. So it's now safe to free the redirtyied extent
	 * buffers.
	 */
	btrfs_free_redirty_list(cur_trans);

	ret = write_all_supers(fs_info, 0);
	/*
	 * the super is written, we can safely allow the tree-loggers
+0 −3
Original line number Diff line number Diff line
@@ -94,9 +94,6 @@ struct btrfs_transaction {
	 */
	atomic_t pending_ordered;
	wait_queue_head_t pending_wait;

	spinlock_t releasing_ebs_lock;
	struct list_head releasing_ebs;
};

enum {
Loading