Skip to contentSkip to conversation

btrfs: transaction: Commit transaction more frequently for BPF

PATCH In review Qu Wenruo 4 participants 8 messages Aug 15, 2019 – Aug 20, 2019 Btrfs file system

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH v2 1/1 btrfs: transaction: Commit transaction more frequently for BPF

Btrfs has btrfs_end_transaction_throttle() which could try to commit transaction when needed.

However under most cases btrfs_end_transaction_throttle() won't really commit transaction, due to the hard timing requirement.

Now introduce a new error injection point, btrfs_need_trans_pressure(), to allow btrfs_should_end_transaction() to return 1 and btrfs_end_transaction_throttle() to fallback to btrfs_commit_transaction().

With such more aggressive transaction commit, we can dig deeper into cases like snapshot drop.
Now each reference drop of btrfs_drop_snapshot() will lead to a transaction commit, allowing dm-logwrites to catch more details, other than one big transaction dropping everything.

---
Changelog:
v2:
- Add comment to explain why this function is needed

---
 fs/btrfs/transaction.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
fs/btrfs/transaction.c +18 -0
index 3f6811cdf803..8c5471b01d03 100644
@@ -10,6 +10,7 @@
 #include <linux/pagemap.h>
 #include <linux/blkdev.h>
 #include <linux/uuid.h>
+#include <linux/error-injection.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"
@@ -749,10 +750,25 @@ void btrfs_throttle(struct btrfs_fs_info *fs_info)
 	wait_current_trans(fs_info);
 }
 
+/*
+ * This function is to allow BPF to override the return value so that we can
+ * make btrfs to commit transaction more aggressively.
+ *
+ * It's a debug only feature, mainly used with dm-log-writes to catch more details
+ * of transient operations like balance and subvolume drop.
+ */
+static noinline bool btrfs_need_trans_pressure(struct btrfs_trans_handle *trans)
+{
+	return false;
+}
+ALLOW_ERROR_INJECTION(btrfs_need_trans_pressure, TRUE);
+
 static int should_end_transaction(struct btrfs_trans_handle *trans)
 {
 	struct btrfs_fs_info *fs_info = trans->fs_info;
 
+	if (btrfs_need_trans_pressure(trans))
+		return 1;
 	if (btrfs_check_space_for_delayed_refs(fs_info))
 		return 1;
 
@@ -813,6 +829,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
 	btrfs_trans_release_chunk_metadata(trans);
 
+	if (throttle && btrfs_need_trans_pressure(trans))
+		return btrfs_commit_transaction(trans);
 	if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
 		if (throttle)
 			return btrfs_commit_transaction(trans);
Signature · 1 line
2.22.0
#1 lore raw
Quoted 40 lines · Qu Wenruo

Btrfs has btrfs_end_transaction_throttle() which could try to commit transaction when needed.

However under most cases btrfs_end_transaction_throttle() won't really commit transaction, due to the hard timing requirement.

Now introduce a new error injection point, btrfs_need_trans_pressure(), to allow btrfs_should_end_transaction() to return 1 and btrfs_end_transaction_throttle() to fallback to btrfs_commit_transaction().

With such more aggressive transaction commit, we can dig deeper into cases like snapshot drop.
Now each reference drop of btrfs_drop_snapshot() will lead to a transaction commit, allowing dm-logwrites to catch more details, other than one big transaction dropping everything.

---
Changelog:
v2:
- Add comment to explain why this function is needed

---
 fs/btrfs/transaction.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
fs/btrfs/transaction.c +1 -0
index 3f6811cdf803..8c5471b01d03 100644
@@ -10,6 +10,7 @@
 #include <linux/pagemap.h>
 #include <linux/blkdev.h>
 #include <linux/uuid.h>
+#include <linux/error-injection.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 758

Quoted 9 lines
fs/btrfs/transaction.c +6 -0
@@ -749,10 +750,25 @@ void btrfs_throttle(struct btrfs_fs_info *fs_info)
        wait_current_trans(fs_info);
 }
 
+/*
+ * This function is to allow BPF to override the return value so that we can
+ * make btrfs to commit transaction more aggressively.
+ *
+ * It's a debug only feature, mainly used with dm-log-writes to catch more details
+ * of transient operations like balance and subvolume drop.

Transient? I think you mean long running operations that can span multiple transactions.

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 764

Quoted 6 lines
fs/btrfs/transaction.c +6 -0
+ */
+static noinline bool btrfs_need_trans_pressure(struct btrfs_trans_handle *trans)
+{
+       return false;
+}
+ALLOW_ERROR_INJECTION(btrfs_need_trans_pressure, TRUE);

So, I'm not sure if it's really a good idea to have such specific things like this.
Has this proven useful already? I.e., have you already found any bug using this?

I often add such similar things myself for testing and debugging, but because they are so specific, or ugly or verbose, I keep them to myself.

Allowing the return value of should_end_transaction() to be overridden, using the same approach, would be more generic for example.

Thanks.

Quoted 22 lines
fs/btrfs/transaction.c +5 -1
+
 static int should_end_transaction(struct btrfs_trans_handle *trans)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
 
+       if (btrfs_need_trans_pressure(trans))
+               return 1;
        if (btrfs_check_space_for_delayed_refs(fs_info))
                return 1;
 
@@ -813,6 +829,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
        btrfs_trans_release_chunk_metadata(trans);
 
+       if (throttle && btrfs_need_trans_pressure(trans))
+               return btrfs_commit_transaction(trans);
        if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
                if (throttle)
                        return btrfs_commit_transaction(trans);
--

2.22.0

Signature · 3 lines
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”
#2 lore raw
Quoted 44 lines · Filipe Manana
Quoted 43 lines · Qu Wenruo

Btrfs has btrfs_end_transaction_throttle() which could try to commit transaction when needed.

However under most cases btrfs_end_transaction_throttle() won't really commit transaction, due to the hard timing requirement.

Now introduce a new error injection point, btrfs_need_trans_pressure(), to allow btrfs_should_end_transaction() to return 1 and btrfs_end_transaction_throttle() to fallback to btrfs_commit_transaction().

With such more aggressive transaction commit, we can dig deeper into cases like snapshot drop.
Now each reference drop of btrfs_drop_snapshot() will lead to a transaction commit, allowing dm-logwrites to catch more details, other than one big transaction dropping everything.

---
Changelog:
v2:
- Add comment to explain why this function is needed

---
 fs/btrfs/transaction.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
fs/btrfs/transaction.c +1 -0
index 3f6811cdf803..8c5471b01d03 100644
@@ -10,6 +10,7 @@
 #include <linux/pagemap.h>
 #include <linux/blkdev.h>
 #include <linux/uuid.h>
+#include <linux/error-injection.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"
@@ -749,10 +750,25 @@ void btrfs_throttle(struct btrfs_fs_info *fs_info)
        wait_current_trans(fs_info);
 }
 
Quoted 9 lines

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 758

Quoted 6 lines
fs/btrfs/transaction.c +6 -0
+/*
+ * This function is to allow BPF to override the return value so that we can
+ * make btrfs to commit transaction more aggressively.
+ *
+ * It's a debug only feature, mainly used with dm-log-writes to catch more details
+ * of transient operations like balance and subvolume drop.

Transient? I think you mean long running operations that can span multiple transactions.

Nope, really transient details.

E.g catching subvolume dropping for each drop_progress update. While under most one transaction can contain multiple drop_progress update or even the whole tree just get dropped in one transaction.

Quoted 11 lines

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 764

Quoted 7 lines
fs/btrfs/transaction.c +6 -0
+ */
+static noinline bool btrfs_need_trans_pressure(struct btrfs_trans_handle *trans)
+{
+       return false;
+}
+ALLOW_ERROR_INJECTION(btrfs_need_trans_pressure, TRUE);

So, I'm not sure if it's really a good idea to have such specific things like this.
Has this proven useful already? I.e., have you already found any bug using this?

Not exactly.
I have observed a case where btrfs check gives false alert on missing a backref of a dropped tree.

Originally planned to use this feature to catch the exact update, but the problem is, with this pressure, we need an extra ioctl to wait the full subvolume drop to finish.

Or we will get the fs unmounted before we really go to DROP_REFERENCE phase, thus dm-log-writes gets nothing interesting.

Thanks,
Qu

Quoted 35 lines

I often add such similar things myself for testing and debugging, but because they are so specific, or ugly or verbose, I keep them to myself.

Allowing the return value of should_end_transaction() to be overridden, using the same approach, would be more generic for example.

Thanks.

Quoted 22 lines
fs/btrfs/transaction.c +5 -1
+
 static int should_end_transaction(struct btrfs_trans_handle *trans)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
 
+       if (btrfs_need_trans_pressure(trans))
+               return 1;
        if (btrfs_check_space_for_delayed_refs(fs_info))
                return 1;
 
@@ -813,6 +829,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
        btrfs_trans_release_chunk_metadata(trans);
 
+       if (throttle && btrfs_need_trans_pressure(trans))
+               return btrfs_commit_transaction(trans);
        if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
                if (throttle)
                        return btrfs_commit_transaction(trans);
--

2.22.0

#3 lore raw
Quoted 76 lines · Qu Wenruo
Quoted 44 lines · Filipe Manana
Quoted 43 lines · Qu Wenruo

Btrfs has btrfs_end_transaction_throttle() which could try to commit transaction when needed.

However under most cases btrfs_end_transaction_throttle() won't really commit transaction, due to the hard timing requirement.

Now introduce a new error injection point, btrfs_need_trans_pressure(), to allow btrfs_should_end_transaction() to return 1 and btrfs_end_transaction_throttle() to fallback to btrfs_commit_transaction().

With such more aggressive transaction commit, we can dig deeper into cases like snapshot drop.
Now each reference drop of btrfs_drop_snapshot() will lead to a transaction commit, allowing dm-logwrites to catch more details, other than one big transaction dropping everything.

---
Changelog:
v2:
- Add comment to explain why this function is needed

---
 fs/btrfs/transaction.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
fs/btrfs/transaction.c +1 -0
index 3f6811cdf803..8c5471b01d03 100644
@@ -10,6 +10,7 @@
 #include <linux/pagemap.h>
 #include <linux/blkdev.h>
 #include <linux/uuid.h>
+#include <linux/error-injection.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"
@@ -749,10 +750,25 @@ void btrfs_throttle(struct btrfs_fs_info *fs_info)
        wait_current_trans(fs_info);
 }
 
Quoted 9 lines

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 758

Quoted 6 lines
fs/btrfs/transaction.c +6 -0
+/*
+ * This function is to allow BPF to override the return value so that we can
+ * make btrfs to commit transaction more aggressively.
+ *
+ * It's a debug only feature, mainly used with dm-log-writes to catch more details
+ * of transient operations like balance and subvolume drop.

Transient? I think you mean long running operations that can span multiple transactions.

Nope, really transient details.

E.g catching subvolume dropping for each drop_progress update. While under most one transaction can contain multiple drop_progress update or even the whole tree just get dropped in one transaction.

Quoted 11 lines

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 764

Quoted 7 lines
fs/btrfs/transaction.c +6 -0
+ */
+static noinline bool btrfs_need_trans_pressure(struct btrfs_trans_handle *trans)
+{
+       return false;
+}
+ALLOW_ERROR_INJECTION(btrfs_need_trans_pressure, TRUE);

So, I'm not sure if it's really a good idea to have such specific things like this.
Has this proven useful already? I.e., have you already found any bug using this?

Quoted 3 lines

Not exactly.
I have observed a case where btrfs check gives false alert on missing a backref of a dropped tree.

Wasn't this fixed by Josef in
https://github.com/kdave/btrfs-progs/commit/42a1aaeec47bc34ae4a923e3e8b2e55b59c01711
?
That's normal, the first phase of dropping a tree removes the references in the extent tree, and then only in the second phase we drop the leafs/nodes that pointed to the extent.

Quoted 4 lines

Originally planned to use this feature to catch the exact update, but the problem is, with this pressure, we need an extra ioctl to wait the full subvolume drop to finish.

That, the ioctl to wait (or better, poll) for subvolume removal to complete (either all subvolumes or just a specific one), would be useful.

Thanks.

Quoted 43 lines

Or we will get the fs unmounted before we really go to DROP_REFERENCE phase, thus dm-log-writes gets nothing interesting.

Thanks,
Qu

Quoted 35 lines

I often add such similar things myself for testing and debugging, but because they are so specific, or ugly or verbose, I keep them to myself.

Allowing the return value of should_end_transaction() to be overridden, using the same approach, would be more generic for example.

Thanks.

Quoted 22 lines
fs/btrfs/transaction.c +5 -1
+
 static int should_end_transaction(struct btrfs_trans_handle *trans)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
 
+       if (btrfs_need_trans_pressure(trans))
+               return 1;
        if (btrfs_check_space_for_delayed_refs(fs_info))
                return 1;
 
@@ -813,6 +829,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
        btrfs_trans_release_chunk_metadata(trans);
 
+       if (throttle && btrfs_need_trans_pressure(trans))
+               return btrfs_commit_transaction(trans);
        if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
                if (throttle)
                        return btrfs_commit_transaction(trans);
--

2.22.0

Signature · 3 lines
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”
#4 lore raw
Quoted 77 lines · Filipe Manana
Quoted 76 lines · Qu Wenruo
Quoted 44 lines · Filipe Manana
Quoted 43 lines · Qu Wenruo

Btrfs has btrfs_end_transaction_throttle() which could try to commit transaction when needed.

However under most cases btrfs_end_transaction_throttle() won't really commit transaction, due to the hard timing requirement.

Now introduce a new error injection point, btrfs_need_trans_pressure(), to allow btrfs_should_end_transaction() to return 1 and btrfs_end_transaction_throttle() to fallback to btrfs_commit_transaction().

With such more aggressive transaction commit, we can dig deeper into cases like snapshot drop.
Now each reference drop of btrfs_drop_snapshot() will lead to a transaction commit, allowing dm-logwrites to catch more details, other than one big transaction dropping everything.

---
Changelog:
v2:
- Add comment to explain why this function is needed

---
 fs/btrfs/transaction.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
fs/btrfs/transaction.c +1 -0
index 3f6811cdf803..8c5471b01d03 100644
@@ -10,6 +10,7 @@
 #include <linux/pagemap.h>
 #include <linux/blkdev.h>
 #include <linux/uuid.h>
+#include <linux/error-injection.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"
@@ -749,10 +750,25 @@ void btrfs_throttle(struct btrfs_fs_info *fs_info)
        wait_current_trans(fs_info);
 }
 
Quoted 9 lines

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 758

Quoted 6 lines
fs/btrfs/transaction.c +6 -0
+/*
+ * This function is to allow BPF to override the return value so that we can
+ * make btrfs to commit transaction more aggressively.
+ *
+ * It's a debug only feature, mainly used with dm-log-writes to catch more details
+ * of transient operations like balance and subvolume drop.

Transient? I think you mean long running operations that can span multiple transactions.

Nope, really transient details.

E.g catching subvolume dropping for each drop_progress update. While under most one transaction can contain multiple drop_progress update or even the whole tree just get dropped in one transaction.

Quoted 11 lines

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 764

Quoted 7 lines
fs/btrfs/transaction.c +6 -0
+ */
+static noinline bool btrfs_need_trans_pressure(struct btrfs_trans_handle *trans)
+{
+       return false;
+}
+ALLOW_ERROR_INJECTION(btrfs_need_trans_pressure, TRUE);

So, I'm not sure if it's really a good idea to have such specific things like this.
Has this proven useful already? I.e., have you already found any bug using this?

Quoted 7 lines
Quoted 3 lines

Not exactly.
I have observed a case where btrfs check gives false alert on missing a backref of a dropped tree.

Wasn't this fixed by Josef in
https://github.com/kdave/btrfs-progs/commit/42a1aaeec47bc34ae4a923e3e8b2e55b59c01711
?

Oh...

Quoted 3 lines

That's normal, the first phase of dropping a tree removes the references in the extent tree, and then only in the second phase we drop the leafs/nodes that pointed to the extent.

Yes, that's just a false alert from btrfs check, so it is nothing related to kernel.

Quoted 9 lines
Quoted 5 lines

Originally planned to use this feature to catch the exact update, but the problem is, with this pressure, we need an extra ioctl to wait the full subvolume drop to finish.

That, the ioctl to wait (or better, poll) for subvolume removal to complete (either all subvolumes or just a specific one), would be useful.

OK, would work on that feature.

Thanks,
Qu

Quoted 48 lines

Thanks.

Quoted 43 lines

Or we will get the fs unmounted before we really go to DROP_REFERENCE phase, thus dm-log-writes gets nothing interesting.

Thanks,
Qu

Quoted 35 lines

I often add such similar things myself for testing and debugging, but because they are so specific, or ugly or verbose, I keep them to myself.

Allowing the return value of should_end_transaction() to be overridden, using the same approach, would be more generic for example.

Thanks.

Quoted 22 lines
fs/btrfs/transaction.c +5 -1
+
 static int should_end_transaction(struct btrfs_trans_handle *trans)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
 
+       if (btrfs_need_trans_pressure(trans))
+               return 1;
        if (btrfs_check_space_for_delayed_refs(fs_info))
                return 1;
 
@@ -813,6 +829,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
        btrfs_trans_release_chunk_metadata(trans);
 
+       if (throttle && btrfs_need_trans_pressure(trans))
+               return btrfs_commit_transaction(trans);
        if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
                if (throttle)
                        return btrfs_commit_transaction(trans);
--

2.22.0

#5 lore raw
In reply to Filipe Manana
Quoted 7 lines · Filipe Manana
Quoted 3 lines

Originally planned to use this feature to catch the exact update, but the problem is, with this pressure, we need an extra ioctl to wait the full subvolume drop to finish.

That, the ioctl to wait (or better, poll) for subvolume removal to complete (either all subvolumes or just a specific one), would be useful.

The polling for subvolume drop is implemented using the SEARCH_TREE ioctl and provided as 'btrfs subvolume sync' command. Is there something that this approach does not provide and would need a new ioctl?

#6 lore raw
Quoted 5 lines · David Sterba
Quoted 4 lines · Filipe Manana
Quoted 3 lines

Originally planned to use this feature to catch the exact update, but the problem is, with this pressure, we need an extra ioctl to wait the full subvolume drop to finish.

Quoted 9 lines
Quoted 3 lines

That, the ioctl to wait (or better, poll) for subvolume removal to complete (either all subvolumes or just a specific one), would be useful.

The polling for subvolume drop is implemented using the SEARCH_TREE ioctl and provided as 'btrfs subvolume sync' command. Is there something that this approach does not provide and would need a new ioctl?

That interface is good enough for my use case already.

Thanks,
Qu

#7 lore raw
In reply to Filipe Manana
Quoted 65 lines · Filipe Manana
Quoted 40 lines · Qu Wenruo

Btrfs has btrfs_end_transaction_throttle() which could try to commit transaction when needed.

However under most cases btrfs_end_transaction_throttle() won't really commit transaction, due to the hard timing requirement.

Now introduce a new error injection point, btrfs_need_trans_pressure(), to allow btrfs_should_end_transaction() to return 1 and btrfs_end_transaction_throttle() to fallback to btrfs_commit_transaction().

With such more aggressive transaction commit, we can dig deeper into cases like snapshot drop.
Now each reference drop of btrfs_drop_snapshot() will lead to a transaction commit, allowing dm-logwrites to catch more details, other than one big transaction dropping everything.

---
Changelog:
v2:
- Add comment to explain why this function is needed

---
 fs/btrfs/transaction.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
fs/btrfs/transaction.c +1 -0
index 3f6811cdf803..8c5471b01d03 100644
@@ -10,6 +10,7 @@
 #include <linux/pagemap.h>
 #include <linux/blkdev.h>
 #include <linux/uuid.h>
+#include <linux/error-injection.h>
 #include "ctree.h"
 #include "disk-io.h"
 #include "transaction.h"

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 758

Quoted 9 lines
fs/btrfs/transaction.c +6 -0
@@ -749,10 +750,25 @@ void btrfs_throttle(struct btrfs_fs_info *fs_info)
        wait_current_trans(fs_info);
 }
 
+/*
+ * This function is to allow BPF to override the return value so that we can
+ * make btrfs to commit transaction more aggressively.
+ *
+ * It's a debug only feature, mainly used with dm-log-writes to catch more details
+ * of transient operations like balance and subvolume drop.

Transient? I think you mean long running operations that can span multiple transactions.

fs/btrfs/transaction.c void btrfs_throttle(struct btrfs_fs_info *fs_info) · line 764

Quoted 6 lines
fs/btrfs/transaction.c +6 -0
+ */
+static noinline bool btrfs_need_trans_pressure(struct btrfs_trans_handle *trans)
+{
+       return false;
+}
+ALLOW_ERROR_INJECTION(btrfs_need_trans_pressure, TRUE);

So, I'm not sure if it's really a good idea to have such specific things like this.
Has this proven useful already? I.e., have you already found any bug using this?

Quoted 7 lines

I often add such similar things myself for testing and debugging, but because they are so specific, or ugly or verbose, I keep them to myself.

Allowing the return value of should_end_transaction() to be overridden, using the same approach, would be more generic for example.

Forgot to mention there is another function checking this:
__btrfs_end_transaction.

If btrfs_need_trans_pressure() returns true, __btrfs_end_transaction() will try to commit transaction for btrfs_end_transaction_throttle().

Thanks,
Qu

Quoted 27 lines

Thanks.

Quoted 22 lines
fs/btrfs/transaction.c +5 -1
+
 static int should_end_transaction(struct btrfs_trans_handle *trans)
 {
        struct btrfs_fs_info *fs_info = trans->fs_info;
 
+       if (btrfs_need_trans_pressure(trans))
+               return 1;
        if (btrfs_check_space_for_delayed_refs(fs_info))
                return 1;
 
@@ -813,6 +829,8 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
 
        btrfs_trans_release_chunk_metadata(trans);
 
+       if (throttle && btrfs_need_trans_pressure(trans))
+               return btrfs_commit_transaction(trans);
        if (lock && READ_ONCE(cur_trans->state) == TRANS_STATE_BLOCKED) {
                if (throttle)
                        return btrfs_commit_transaction(trans);
--

2.22.0