Skip to contentSkip to conversation

Patch "btrfs: Fix transaction abort during failure in btrfs_rm_dev_item" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Feb 1, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

btrfs: Fix transaction abort during failure in btrfs_rm_dev_item

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
btrfs-fix-transaction-abort-during-failure-in-btrfs_rm_dev_item.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From foo@baz Thu Feb 1 13:45:42 CET 2018

From: Nikolay Borisov <[email protected]>
Date: Mon, 23 Oct 2017 09:58:46 +0300
Subject: btrfs: Fix transaction abort during failure in btrfs_rm_dev_item

From: Nikolay Borisov <[email protected]>

[ Upstream commit 5e9f2ad5b2904a7e81df6d9a3dbef29478952eac ]

btrfs_rm_dev_item calls several function under an active transaction, however it fails to abort it if an error happens. Fix this by adding explicit btrfs_abort_transaction/btrfs_end_transaction calls.

---
 fs/btrfs/volumes.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
fs/btrfs/volumes.c +12 -8
@@ -1765,20 +1765,24 @@ static int btrfs_rm_dev_item(struct btrf
 	key.offset = device->devid;
 
 	ret = btrfs_search_slot(trans, root, &key, path, -1, 1);
-	if (ret < 0)
-		goto out;
-
-	if (ret > 0) {
-		ret = -ENOENT;
+	if (ret) {
+		if (ret > 0)
+			ret = -ENOENT;
+		btrfs_abort_transaction(trans, ret);
+		btrfs_end_transaction(trans);
 		goto out;
 	}
 
 	ret = btrfs_del_item(trans, root, path);
-	if (ret)
-		goto out;
+	if (ret) {
+		btrfs_abort_transaction(trans, ret);
+		btrfs_end_transaction(trans);
+	}
+
 out:
 	btrfs_free_path(path);
-	btrfs_commit_transaction(trans);
+	if (!ret)
+		ret = btrfs_commit_transaction(trans);
 	return ret;
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/btrfs-fix-transaction-abort-during-failure-in-btrfs_rm_dev_item.patch