Skip to contentSkip to conversation

Btrfs: fix double decrease of the writer counter

PATCH In review Miao Xie 2 participants 2 messages Sep 17, 2012 Btrfs file system

lore
Share & tools
lore

Miao Xie

author
#0 lore raw

PATCH 1/1 Btrfs: fix double decrease of the writer counter

In __btrfs_end_transaction(), we have invoked sb_end_intwrite(), but if we need run btrfs_commit_transaction(), we will decrease the writer counter for two times because btrfs_commit_transaction() also invokes sb_end_intwrite(). Fix it.

---
 fs/btrfs/transaction.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/transaction.c +2 -2
index 27c2600..3134fdc 100644
@@ -551,8 +551,6 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 	btrfs_trans_release_metadata(trans, root);
 	trans->block_rsv = NULL;
 
-	sb_end_intwrite(root->fs_info->sb);
-
 	if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) &&
 	    should_end_transaction(trans, root)) {
 		trans->transaction->blocked = 1;
@@ -573,6 +571,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 		}
 	}
 
+	sb_end_intwrite(root->fs_info->sb);
+
 	WARN_ON(cur_trans != info->running_transaction);
 	WARN_ON(atomic_read(&cur_trans->num_writers) < 1);
 	atomic_dec(&cur_trans->num_writers);
Signature · 1 line
1.7.6.5
#1 lore raw
Quoted 5 lines · Miao Xie

In __btrfs_end_transaction(), we have invoked sb_end_intwrite(), but if we need run btrfs_commit_transaction(), we will decrease the writer counter for two times because btrfs_commit_transaction() also invokes sb_end_intwrite(). Fix it.

Already fixed in btrfs-next. Thanks,

Josef

Quoted 33 lines
---
 fs/btrfs/transaction.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/transaction.c +2 -2
index 27c2600..3134fdc 100644
@@ -551,8 +551,6 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 	btrfs_trans_release_metadata(trans, root);
 	trans->block_rsv = NULL;
 
-	sb_end_intwrite(root->fs_info->sb);
-
 	if (lock && !atomic_read(&root->fs_info->open_ioctl_trans) &&
 	    should_end_transaction(trans, root)) {
 		trans->transaction->blocked = 1;
@@ -573,6 +571,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 		}
 	}
 
+	sb_end_intwrite(root->fs_info->sb);
+
 	WARN_ON(cur_trans != info->running_transaction);
 	WARN_ON(atomic_read(&cur_trans->num_writers) < 1);
 	atomic_dec(&cur_trans->num_writers);
Signature · 5 lines
1.7.6.5
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html