[PATCH 5/5] btrfs: use GFP_NOWAIT when inhibiting eb writeback

Boris Burkov <[email protected]>
Newsgroups org.kernel.vger.linux-btrfs
Message-ID <1f4545756c36e7b3e7aab1f6ace60d72de1ed7cd.1782249000.git.boris@bur.io>
Inhibition allocation is already best effort and done while holding
locks so switch it to NOWAIT.

Signed-off-by: Boris Burkov <[email protected]>
---
 fs/btrfs/extent_io.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index b40d3c47eb0d..43c361ef61a2 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3002,10 +3002,11 @@ static inline void btrfs_release_extent_buffer(struct extent_buffer *eb)
  * @trans:  transaction handle that will own the inhibitor
  * @eb:      extent buffer to inhibit writeback on
  *
- * Attempt to track this extent buffer in the transaction's inhibited set.  If
- * memory allocation fails, the buffer is simply not tracked. It may be written
- * back and need re-COW, which is the original behavior.  This is acceptable
- * since inhibiting writeback is an optimization.
+ * Attempt to track this extent buffer in the transaction's inhibited set.  We
+ * are called under eb->lock, so try with GFP_NOWAIT rather than entering
+ * reclaim under the lock.  If the allocation fails, the buffer is simply not
+ * tracked. It may be written back and need re-COW, which is the original
+ * behavior. This is acceptable since inhibiting writeback is an optimization.
  */
 void btrfs_inhibit_eb_writeback(struct btrfs_trans_handle *trans, struct extent_buffer *eb)
 {
@@ -3021,7 +3022,7 @@ void btrfs_inhibit_eb_writeback(struct btrfs_trans_handle *trans, struct extent_
 	/* Take reference for the xarray entry. */
 	refcount_inc(&eb->refs);
 
-	old = xa_store(&trans->writeback_inhibited_ebs, index, eb, GFP_NOFS);
+	old = xa_store(&trans->writeback_inhibited_ebs, index, eb, GFP_NOWAIT);
 	if (xa_is_err(old)) {
 		/* Allocation failed, just skip inhibiting this buffer. */
 		free_extent_buffer(eb);
-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.