public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: linux-xfs@vger.kernel.org
Cc: chandanbabu@kernel.org
Subject: [PATCH 2/4] xfs: xfs_alloc_file_space() fails to detect ENOSPC
Date: Wed,  3 Apr 2024 08:38:17 +1100	[thread overview]
Message-ID: <20240402221127.1200501-3-david@fromorbit.com> (raw)
In-Reply-To: <20240402221127.1200501-1-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

xfs_alloc_file_space ends up in an endless loop when
xfs_bmapi_write() returns nimaps == 0 at ENOSPC. The process is
unkillable, and so just runs around in a tight circle burning CPU
until the system is rebooted.

This is a regression introduced by commit 35dc55b9e80c ("xfs: handle
nimaps=0 from xfs_bmapi_write in xfs_alloc_file_space") which
specifically removed ENOSPC detection from xfs_alloc_file_space()
and replaces it with an endless loop. This attempts to fix an issue
converting a delalloc extent when not enough contiguous free space
is available to convert the entire delalloc extent.

Right now just revert the change as it only manifested on code under
development and isn't currently a real-world problem.

Fixes: 35dc55b9e80c ("xfs: handle nimaps=0 from xfs_bmapi_write in xfs_alloc_file_space")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_bmap_util.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index 19e11d1da660..262557735d4d 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -735,19 +735,13 @@ xfs_alloc_file_space(
 		if (error)
 			break;
 
-		/*
-		 * If the allocator cannot find a single free extent large
-		 * enough to cover the start block of the requested range,
-		 * xfs_bmapi_write will return 0 but leave *nimaps set to 0.
-		 *
-		 * In that case we simply need to keep looping with the same
-		 * startoffset_fsb so that one of the following allocations
-		 * will eventually reach the requested range.
-		 */
-		if (nimaps) {
-			startoffset_fsb += imapp->br_blockcount;
-			allocatesize_fsb -= imapp->br_blockcount;
+		if (nimaps == 0) {
+			error = ENOSPC;
+			break;
 		}
+
+		startoffset_fsb += imapp->br_blockcount;
+		allocatesize_fsb -= imapp->br_blockcount;
 	}
 
 	return error;
-- 
2.43.0


  parent reply	other threads:[~2024-04-02 22:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02 21:38 [PATCH 0/4] xfs: fixes for 6.9-rcX Dave Chinner
2024-04-02 21:38 ` [PATCH 1/4] xfs: use kvmalloc for xattr buffers Dave Chinner
2024-04-03  3:43   ` Darrick J. Wong
2024-04-03  4:39   ` Christoph Hellwig
2024-04-03  6:16     ` Dave Chinner
2024-04-03  6:19       ` Christoph Hellwig
2024-04-17 14:35   ` Pankaj Raghav (Samsung)
2024-04-02 21:38 ` Dave Chinner [this message]
2024-04-03  3:46   ` [PATCH 2/4] xfs: xfs_alloc_file_space() fails to detect ENOSPC Darrick J. Wong
2024-04-03  4:40   ` Christoph Hellwig
2024-04-03  6:34     ` Dave Chinner
2024-04-03 18:23       ` Christoph Hellwig
2024-04-02 21:38 ` [PATCH 3/4] xfs: handle allocation failure in xfs_dquot_disk_alloc() Dave Chinner
2024-04-03  3:48   ` Darrick J. Wong
2024-04-03  4:41   ` Christoph Hellwig
2024-04-03  4:54     ` Darrick J. Wong
2024-04-03  4:56       ` Christoph Hellwig
2024-04-03  5:04         ` Darrick J. Wong
2024-04-03  6:41           ` Dave Chinner
2024-04-03 14:06   ` Christoph Hellwig
2024-04-03 21:49     ` Dave Chinner
2024-04-02 21:38 ` [PATCH 4/4] xfs: validate block count for XFS_IOC_SET_RESBLKS Dave Chinner
2024-04-03  3:53   ` Darrick J. Wong
2024-04-03  6:55     ` Dave Chinner
2024-04-03  4:43   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240402221127.1200501-3-david@fromorbit.com \
    --to=david@fromorbit.com \
    --cc=chandanbabu@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox