From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Christoph Hellwig <hch@lst.de>,
"Darrick J. Wong" <djwong@kernel.org>,
Chandan Babu R <chandanbabu@kernel.org>,
Leah Rumancik <leah.rumancik@gmail.com>
Subject: [PATCH 6.1 19/49] xfs: handle nimaps=0 from xfs_bmapi_write in xfs_alloc_file_space
Date: Thu, 30 Jan 2025 15:01:55 +0100 [thread overview]
Message-ID: <20250130140134.611180323@linuxfoundation.org> (raw)
In-Reply-To: <20250130140133.825446496@linuxfoundation.org>
6.1-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit 35dc55b9e80cb9ec4bcb969302000b002b2ed850 ]
If xfs_bmapi_write finds a delalloc extent at the requested range, it
tries to convert the entire delalloc extent to a real allocation.
But 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.
Note that this could affect any caller of xfs_bmapi_write that covers
an existing delayed allocation. As far as I can tell we do not have
any other such caller, though - the regular writeback path uses
xfs_bmapi_convert_delalloc to convert delayed allocations to real ones,
and direct I/O invalidates the page cache first.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
Signed-off-by: Leah Rumancik <leah.rumancik@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
fs/xfs/xfs_bmap_util.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -780,12 +780,10 @@ xfs_alloc_file_space(
{
xfs_mount_t *mp = ip->i_mount;
xfs_off_t count;
- xfs_filblks_t allocated_fsb;
xfs_filblks_t allocatesize_fsb;
xfs_extlen_t extsz, temp;
xfs_fileoff_t startoffset_fsb;
xfs_fileoff_t endoffset_fsb;
- int nimaps;
int rt;
xfs_trans_t *tp;
xfs_bmbt_irec_t imaps[1], *imapp;
@@ -808,7 +806,6 @@ xfs_alloc_file_space(
count = len;
imapp = &imaps[0];
- nimaps = 1;
startoffset_fsb = XFS_B_TO_FSBT(mp, offset);
endoffset_fsb = XFS_B_TO_FSB(mp, offset + count);
allocatesize_fsb = endoffset_fsb - startoffset_fsb;
@@ -819,6 +816,7 @@ xfs_alloc_file_space(
while (allocatesize_fsb && !error) {
xfs_fileoff_t s, e;
unsigned int dblocks, rblocks, resblks;
+ int nimaps = 1;
/*
* Determine space reservations for data/realtime.
@@ -884,15 +882,19 @@ xfs_alloc_file_space(
if (error)
break;
- allocated_fsb = imapp->br_blockcount;
-
- if (nimaps == 0) {
- error = -ENOSPC;
- 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;
}
-
- startoffset_fsb += allocated_fsb;
- allocatesize_fsb -= allocated_fsb;
}
return error;
next prev parent reply other threads:[~2025-01-30 14:29 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 14:01 [PATCH 6.1 00/49] 6.1.128-rc1 review Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 01/49] ASoC: wm8994: Add depends on MFD core Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 02/49] ASoC: samsung: Add missing selects for MFD_WM8994 Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 03/49] seccomp: Stub for !CONFIG_SECCOMP Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 04/49] scsi: iscsi: Fix redundant response for ISCSI_UEVENT_GET_HOST_STATS request Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 05/49] drm/amd/display: Use HW lock mgr for PSR1 Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 06/49] irqchip/sunxi-nmi: Add missing SKIP_WAKE flag Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 07/49] ASoC: samsung: midas_wm1811: Map missing jack kcontrols Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 08/49] ASoC: samsung: Add missing depends on I2C Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 09/49] regmap: detach regmap from dev on regmap_exit Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 10/49] ipv6: Fix soft lockups in fib6_select_path under high next hop churn Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 11/49] softirq: Allow raising SCHED_SOFTIRQ from SMP-call-function on RT kernel Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 12/49] xfs: bump max fsgeom struct version Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 13/49] xfs: hoist freeing of rt data fork extent mappings Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 14/49] xfs: prevent rt growfs when quota is enabled Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 15/49] xfs: rt stubs should return negative errnos when rt disabled Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 16/49] xfs: fix units conversion error in xfs_bmap_del_extent_delay Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 17/49] xfs: make sure maxlen is still congruent with prod when rounding down Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 18/49] xfs: introduce protection for drop nlink Greg Kroah-Hartman
2025-01-30 14:01 ` Greg Kroah-Hartman [this message]
2025-01-30 14:01 ` [PATCH 6.1 20/49] xfs: allow read IO and FICLONE to run concurrently Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 21/49] xfs: factor out xfs_defer_pending_abort Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 22/49] xfs: abort intent items when recovery intents fail Greg Kroah-Hartman
2025-01-30 14:01 ` [PATCH 6.1 23/49] xfs: only remap the written blocks in xfs_reflink_end_cow_extent Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 24/49] xfs: up(ic_sema) if flushing data device fails Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 25/49] xfs: fix internal error from AGFL exhaustion Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 26/49] xfs: inode recovery does not validate the recovered inode Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 27/49] xfs: clean up dqblk extraction Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 28/49] xfs: dquot recovery does not validate the recovered dquot Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 29/49] xfs: clean up FS_XFLAG_REALTIME handling in xfs_ioctl_setattr_xflags Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 30/49] xfs: respect the stable writes flag on the RT device Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 31/49] gfs2: Truncate address space when flipping GFS2_DIF_JDATA flag Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 32/49] io_uring: fix waiters missing wake ups Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 33/49] net: sched: fix ets qdisc OOB Indexing Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 34/49] block: fix integer overflow in BLKSECDISCARD Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 35/49] Revert "HID: multitouch: Add support for lenovo Y9000P Touchpad" Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 36/49] vfio/platform: check the bounds of read/write syscalls Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 37/49] ext4: fix access to uninitialised lock in fc replay path Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 38/49] ipv4: ip_tunnel: Fix suspicious RCU usage warning in ip_tunnel_find() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 39/49] scsi: storvsc: Ratelimit warning logs to prevent VM denial of service Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 40/49] wifi: iwlwifi: add a few rate index validity checks Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 41/49] smb: client: fix UAF in async decryption Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 42/49] USB: serial: quatech2: fix null-ptr-deref in qt2_process_read_urb() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 43/49] Revert "usb: gadget: u_serial: Disable ep before setting port to null to fix the crash caused by port being null" Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 44/49] ALSA: usb-audio: Add delay quirk for USB Audio Device Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 45/49] Input: atkbd - map F23 key to support default copilot shortcut Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 46/49] Input: xpad - add unofficial Xbox 360 wireless receiver clone Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 47/49] Input: xpad - add support for wooting two he (arm) Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 48/49] smb: client: fix NULL ptr deref in crypto_aead_setkey() Greg Kroah-Hartman
2025-01-30 14:02 ` [PATCH 6.1 49/49] ASoC: samsung: midas_wm1811: Fix Headphone Switch control creation Greg Kroah-Hartman
2025-01-30 17:58 ` [PATCH 6.1 00/49] 6.1.128-rc1 review Mark Brown
2025-01-30 21:31 ` Florian Fainelli
2025-01-31 5:38 ` Jon Hunter
2025-01-31 12:57 ` Pavel Machek
2025-01-31 13:57 ` Ron Economos
2025-01-31 15:26 ` Naresh Kamboju
2025-01-31 16:58 ` Muhammad Usama Anjum
2025-02-01 8:15 ` [PATCH 6.1] " Hardik Garg
2025-02-01 12:19 ` [PATCH 6.1 00/49] " Peter Schneider
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=20250130140134.611180323@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=chandanbabu@kernel.org \
--cc=djwong@kernel.org \
--cc=hch@lst.de \
--cc=leah.rumancik@gmail.com \
--cc=patches@lists.linux.dev \
--cc=stable@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;
as well as URLs for NNTP newsgroup(s).