From patchwork Mon Apr 29 06:15:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13646300 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A92DAD534 for ; Mon, 29 Apr 2024 06:15:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371337; cv=none; b=Z+D9QcXM7IhSsNNTCIBFb3JInXl+5dYyhcpDb2Att6ZtYDLW18mKLtUDiTkXvOTYrkbuIB2tSDwhcZTQm5g8+KZvKM3+OhaomLFIHBtNZPKkSk+XC1SpwffpqWtKgnYdsYNeF4SOS31nskPwLTJ1t6EHLSFjW/LfePQgmzE7Waw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371337; c=relaxed/simple; bh=BH5hho7Mc5X9rX8Jkz8F0q2k2kraGFTdCqv4MzzX/KE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=iemVY/9aijyxG7X9HcDYYveDp7PInPkG/Ov/arCX9M9xe+JtTgETcQV8eYj0L6aE89XJhiU2FYieQo0F4OPDSnpbOFEP98uvZLGP7prl0a1e9BeDaTIKvXs/lIgsVtZHx3F/Dk5IN+x9cmombwWXKvyWGzbzdmizGzemTZEdo74= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=W3erqSqc; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="W3erqSqc" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=kbDe1Kzj45h8un2uHOfClS0RCdJ7tZKNbYwLzIGmMxQ=; b=W3erqSqcLrJoqG1Nq1KkaQhlSb kFJeBoFYLF4C7eJa2/xZPBulKo/0tZS1tZh/yIcZUug4hFLGh18MdzBtZ5g/M2ZcVFduIBi+ow5GV xBSCnubAFfTnN6GeRRD6dhUGJ1mFREt597c0Wkiq9bTaJymIJJ29qjaSI731ESGINo6zqhON8wDMg ONP3pprpJzOrZPR5lGsLyglOnz8yFfYZLqTAxhMkbolmDwwUhssIXQJb6XwJeAS17dCgjO6UUsKKe Ew0mKzTy8FzTTaX/dAMjo93k4Zj1DSrJ3OHcAV35CtXZmdWILOM5lXpbAcIksB2kFeSWv7RKghQol kDaMiV9A==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1KIY-00000001chc-3ZPL; Mon, 29 Apr 2024 06:15:35 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , linux-xfs@vger.kernel.org, =?utf-8?b?5YiY6YCa?= Subject: [PATCH 1/9] xfs: fix error returns from xfs_bmapi_write Date: Mon, 29 Apr 2024 08:15:21 +0200 Message-Id: <20240429061529.1550204-2-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429061529.1550204-1-hch@lst.de> References: <20240429061529.1550204-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html xfs_bmapi_write can return 0 without actually returning a mapping in mval in two different cases: 1) when there is absolutely no space available to do an allocation 2) when converting delalloc space, and the allocation is so small that it only covers parts of the delalloc extent before the range requested by the caller Callers at best can handle one of these cases, but in many cases can't cope with either one. Switch xfs_bmapi_write to always return a mapping or return an error code instead. For case 1) above ENOSPC is the obvious choice which is very much what the callers expect anyway. For case 2) there is no really good error code, so pick a funky one from the SysV streams portfolio. This fixes the reproducer here: https://lore.kernel.org/linux-xfs/CAEJPjCvT3Uag-pMTYuigEjWZHn1sGMZ0GCjVVCv29tNHK76Cgg@mail.gmail.com0/ which uses reserved blocks to create file systems that are gravely out of space and thus cause at least xfs_file_alloc_space to hang and trigger the lack of ENOSPC handling in xfs_dquot_disk_alloc. Note that this patch does not actually make any caller but xfs_alloc_file_space deal intelligently with case 2) above. Signed-off-by: Christoph Hellwig Reported-by: 刘通 Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_attr_remote.c | 1 - fs/xfs/libxfs/xfs_bmap.c | 46 ++++++++++++++++++++++++++------- fs/xfs/libxfs/xfs_da_btree.c | 20 ++++---------- fs/xfs/scrub/quota_repair.c | 6 ----- fs/xfs/scrub/rtbitmap_repair.c | 2 -- fs/xfs/xfs_bmap_util.c | 31 +++++++++++----------- fs/xfs/xfs_dquot.c | 1 - fs/xfs/xfs_iomap.c | 8 ------ fs/xfs/xfs_reflink.c | 14 ---------- fs/xfs/xfs_rtalloc.c | 2 -- 10 files changed, 57 insertions(+), 74 deletions(-) diff --git a/fs/xfs/libxfs/xfs_attr_remote.c b/fs/xfs/libxfs/xfs_attr_remote.c index a8de9dc1e998a3..beb0efdd8f6b83 100644 --- a/fs/xfs/libxfs/xfs_attr_remote.c +++ b/fs/xfs/libxfs/xfs_attr_remote.c @@ -625,7 +625,6 @@ xfs_attr_rmtval_set_blk( if (error) return error; - ASSERT(nmap == 1); ASSERT((map->br_startblock != DELAYSTARTBLOCK) && (map->br_startblock != HOLESTARTBLOCK)); diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 6053f5e5c71eec..f19191d6eade7e 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4217,8 +4217,10 @@ xfs_bmapi_allocate( } else { error = xfs_bmap_alloc_userdata(bma); } - if (error || bma->blkno == NULLFSBLOCK) + if (error) return error; + if (bma->blkno == NULLFSBLOCK) + return -ENOSPC; if (bma->flags & XFS_BMAPI_ZERO) { error = xfs_zero_extent(bma->ip, bma->blkno, bma->length); @@ -4397,6 +4399,15 @@ xfs_bmapi_finish( * extent state if necessary. Details behaviour is controlled by the flags * parameter. Only allocates blocks from a single allocation group, to avoid * locking problems. + * + * Returns 0 on success and places the extent mappings in mval. nmaps is used + * as an input/output parameter where the caller specifies the maximum number + * of mappings that may be returned and xfs_bmapi_write passes back the number + * of mappings (including existing mappings) it found. + * + * Returns a negative error code on failure, including -ENOSPC when it could not + * allocate any blocks and -ENOSR when it did allocate blocks to convert a + * delalloc range, but those blocks were before the passed in range. */ int xfs_bmapi_write( @@ -4525,10 +4536,16 @@ xfs_bmapi_write( ASSERT(len > 0); ASSERT(bma.length > 0); error = xfs_bmapi_allocate(&bma); - if (error) + if (error) { + /* + * If we already allocated space in a previous + * iteration return what we go so far when + * running out of space. + */ + if (error == -ENOSPC && bma.nallocs) + break; goto error0; - if (bma.blkno == NULLFSBLOCK) - break; + } /* * If this is a CoW allocation, record the data in @@ -4566,7 +4583,6 @@ xfs_bmapi_write( if (!xfs_iext_next_extent(ifp, &bma.icur, &bma.got)) eof = true; } - *nmap = n; error = xfs_bmap_btree_to_extents(tp, ip, bma.cur, &bma.logflags, whichfork); @@ -4577,7 +4593,22 @@ xfs_bmapi_write( ifp->if_nextents > XFS_IFORK_MAXEXT(ip, whichfork)); xfs_bmapi_finish(&bma, whichfork, 0); xfs_bmap_validate_ret(orig_bno, orig_len, orig_flags, orig_mval, - orig_nmap, *nmap); + orig_nmap, n); + + /* + * When converting delayed allocations, xfs_bmapi_allocate ignores + * the passed in bno and always converts from the start of the found + * delalloc extent. + * + * To avoid a successful return with *nmap set to 0, return the magic + * -ENOSR error code for this particular case so that the caller can + * handle it. + */ + if (!n) { + ASSERT(bma.nallocs >= *nmap); + return -ENOSR; + } + *nmap = n; return 0; error0: xfs_bmapi_finish(&bma, whichfork, error); @@ -4684,9 +4715,6 @@ xfs_bmapi_convert_delalloc( if (error) goto out_finish; - error = -ENOSPC; - if (WARN_ON_ONCE(bma.blkno == NULLFSBLOCK)) - goto out_finish; if (WARN_ON_ONCE(!xfs_valid_startblock(ip, bma.got.br_startblock))) { xfs_bmap_mark_sick(ip, whichfork); error = -EFSCORRUPTED; diff --git a/fs/xfs/libxfs/xfs_da_btree.c b/fs/xfs/libxfs/xfs_da_btree.c index b13796629e2213..16a529a8878083 100644 --- a/fs/xfs/libxfs/xfs_da_btree.c +++ b/fs/xfs/libxfs/xfs_da_btree.c @@ -2297,8 +2297,8 @@ xfs_da_grow_inode_int( struct xfs_inode *dp = args->dp; int w = args->whichfork; xfs_rfsblock_t nblks = dp->i_nblocks; - struct xfs_bmbt_irec map, *mapp; - int nmap, error, got, i, mapi; + struct xfs_bmbt_irec map, *mapp = ↦ + int nmap, error, got, i, mapi = 1; /* * Find a spot in the file space to put the new block. @@ -2314,14 +2314,7 @@ xfs_da_grow_inode_int( error = xfs_bmapi_write(tp, dp, *bno, count, xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA|XFS_BMAPI_CONTIG, args->total, &map, &nmap); - if (error) - return error; - - ASSERT(nmap <= 1); - if (nmap == 1) { - mapp = ↦ - mapi = 1; - } else if (nmap == 0 && count > 1) { + if (error == -ENOSPC && count > 1) { xfs_fileoff_t b; int c; @@ -2339,16 +2332,13 @@ xfs_da_grow_inode_int( args->total, &mapp[mapi], &nmap); if (error) goto out_free_map; - if (nmap < 1) - break; mapi += nmap; b = mapp[mapi - 1].br_startoff + mapp[mapi - 1].br_blockcount; } - } else { - mapi = 0; - mapp = NULL; } + if (error) + goto out_free_map; /* * Count the blocks we got, make sure it matches the total. diff --git a/fs/xfs/scrub/quota_repair.c b/fs/xfs/scrub/quota_repair.c index 0bab4c30cb85ab..90cd1512bba961 100644 --- a/fs/xfs/scrub/quota_repair.c +++ b/fs/xfs/scrub/quota_repair.c @@ -77,8 +77,6 @@ xrep_quota_item_fill_bmap_hole( irec, &nmaps); if (error) return error; - if (nmaps != 1) - return -ENOSPC; dq->q_blkno = XFS_FSB_TO_DADDR(mp, irec->br_startblock); @@ -444,10 +442,6 @@ xrep_quota_data_fork( XFS_BMAPI_CONVERT, 0, &nrec, &nmap); if (error) goto out; - if (nmap != 1) { - error = -ENOSPC; - goto out; - } ASSERT(nrec.br_startoff == irec.br_startoff); ASSERT(nrec.br_blockcount == irec.br_blockcount); diff --git a/fs/xfs/scrub/rtbitmap_repair.c b/fs/xfs/scrub/rtbitmap_repair.c index 46f5d5f605c915..0fef98e9f83409 100644 --- a/fs/xfs/scrub/rtbitmap_repair.c +++ b/fs/xfs/scrub/rtbitmap_repair.c @@ -108,8 +108,6 @@ xrep_rtbitmap_data_mappings( 0, &map, &nmaps); if (error) return error; - if (nmaps != 1) - return -EFSCORRUPTED; /* Commit new extent and all deferred work. */ error = xrep_defer_finish(sc); diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 53aa90a0ee3a85..2e6f08198c0719 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -721,33 +721,32 @@ xfs_alloc_file_space( if (error) goto error; - error = xfs_bmapi_write(tp, ip, startoffset_fsb, - allocatesize_fsb, XFS_BMAPI_PREALLOC, 0, imapp, - &nimaps); - if (error) - goto error; - - ip->i_diflags |= XFS_DIFLAG_PREALLOC; - xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); - - error = xfs_trans_commit(tp); - xfs_iunlock(ip, XFS_ILOCK_EXCL); - 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. + * xfs_bmapi_write will return -ENOSR. * * 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) { + error = xfs_bmapi_write(tp, ip, startoffset_fsb, + allocatesize_fsb, XFS_BMAPI_PREALLOC, 0, imapp, + &nimaps); + if (error) { + if (error != -ENOSR) + goto error; + error = 0; + } else { startoffset_fsb += imapp->br_blockcount; allocatesize_fsb -= imapp->br_blockcount; } + + ip->i_diflags |= XFS_DIFLAG_PREALLOC; + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); + + error = xfs_trans_commit(tp); + xfs_iunlock(ip, XFS_ILOCK_EXCL); } return error; diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c index 13aba84bd64afb..43acb4f0d17433 100644 --- a/fs/xfs/xfs_dquot.c +++ b/fs/xfs/xfs_dquot.c @@ -357,7 +357,6 @@ xfs_dquot_disk_alloc( goto err_cancel; ASSERT(map.br_blockcount == XFS_DQUOT_CLUSTER_SIZE_FSB); - ASSERT(nmaps == 1); ASSERT((map.br_startblock != DELAYSTARTBLOCK) && (map.br_startblock != HOLESTARTBLOCK)); diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 9ce0f6b9df93e6..60463160820b62 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -322,14 +322,6 @@ xfs_iomap_write_direct( if (error) goto out_unlock; - /* - * Copy any maps to caller's array and return any error. - */ - if (nimaps == 0) { - error = -ENOSPC; - goto out_unlock; - } - if (unlikely(!xfs_valid_startblock(ip, imap->br_startblock))) { xfs_bmap_mark_sick(ip, XFS_DATA_FORK); error = xfs_alert_fsblock_zero(ip, imap); diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 7da0e8f961d351..5ecb52a234becc 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -430,13 +430,6 @@ xfs_reflink_fill_cow_hole( if (error) return error; - /* - * Allocation succeeded but the requested range was not even partially - * satisfied? Bail out! - */ - if (nimaps == 0) - return -ENOSPC; - convert: return xfs_reflink_convert_unwritten(ip, imap, cmap, convert_now); @@ -499,13 +492,6 @@ xfs_reflink_fill_delalloc( error = xfs_trans_commit(tp); if (error) return error; - - /* - * Allocation succeeded but the requested range was not even - * partially satisfied? Bail out! - */ - if (nimaps == 0) - return -ENOSPC; } while (cmap->br_startoff + cmap->br_blockcount <= imap->br_startoff); return xfs_reflink_convert_unwritten(ip, imap, cmap, convert_now); diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index b476a876478d93..150f544445ca82 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -709,8 +709,6 @@ xfs_growfs_rt_alloc( nmap = 1; error = xfs_bmapi_write(tp, ip, oblocks, nblocks - oblocks, XFS_BMAPI_METADATA, 0, &map, &nmap); - if (!error && nmap < 1) - error = -ENOSPC; if (error) goto out_trans_cancel; /* From patchwork Mon Apr 29 06:15:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13646301 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CDCE3D534 for ; Mon, 29 Apr 2024 06:15:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371339; cv=none; b=f0NqUQtmJnJIs70BRrORffHS7KrMiaOXuWviZrabMN0wjvgQj5ODNvkahjZMgPiAZ0/cJQ4XdsbV3B7lTRDxQOoQZlNYOodrRcC9qzUAm5hd8QWduqXTl9e1oVCInaUS1kRzR5kK5RAUOyAeyujhIzVxvPHcdsmCPAaJbhACC+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371339; c=relaxed/simple; bh=I0agVvLdO3ZnCpMFi0oOJZTzdZZ6hn1jLejOXAy46Ow=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WZeUgmphI8sgfcdddZkS91lxx3hsRsfnqzmMbydUyCjyenOaABadooDaGrzQvGPT2qqBxmrvXLuBRz9iDldaA2baaN72GJckbZun5vlmAbfoi2Why+uf9u1ViTppax/O0gtveyJjRLYY6mm7P1+5JqFv7MCijsv36hAlk9NL+SM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=tTtCv9mT; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="tTtCv9mT" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=mmqbceSLjqfsFeCo/uFED4Gr7gistXzQcq1Gr2B0qSg=; b=tTtCv9mTJ1CUP/b5qIpAOe8Q7N NK+nzrykzdaILwOe8tX4gjN0v5CP2QzrN7kQG33tuQxLdRs8P/ROdq3vExhFrQjC2whZ0FqyJgt0g wMb+okxPf3bDhUKM1YcC9YzBPOqyOw/N89+A5Z/0HJthDs+Q6AuSiv1cdK90+bn5sjVyzDV8PNw6W RXE4jwxpZh9JW2aCN8z2+tpcKmd7uvEvxdOXY+1GCumnCvFhCKfBPQJyZ0enUJ/BI01e5g/ls4HGy AgKf03+orcJrLhfZA69nOgaP3wcI8NfdjCJzpUDMt+DuvSyzy8hlGx4bQQh3wjN7eutmDkllEMdnv RD5LjzcQ==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1KIb-00000001ciK-0WQ6; Mon, 29 Apr 2024 06:15:37 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 2/9] xfs: remove the unusued tmp_logflags variable in xfs_bmapi_allocate Date: Mon, 29 Apr 2024 08:15:22 +0200 Message-Id: <20240429061529.1550204-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429061529.1550204-1-hch@lst.de> References: <20240429061529.1550204-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html tmp_logflags is initialized to 0 and then ORed into bma->logflags, which isn't actually doing anything. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index f19191d6eade7e..1ea1b78ad5a560 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4182,7 +4182,6 @@ xfs_bmapi_allocate( struct xfs_mount *mp = bma->ip->i_mount; int whichfork = xfs_bmapi_whichfork(bma->flags); struct xfs_ifork *ifp = xfs_ifork_ptr(bma->ip, whichfork); - int tmp_logflags = 0; int error; ASSERT(bma->length > 0); @@ -4253,8 +4252,6 @@ xfs_bmapi_allocate( error = xfs_bmap_add_extent_hole_real(bma->tp, bma->ip, whichfork, &bma->icur, &bma->cur, &bma->got, &bma->logflags, bma->flags); - - bma->logflags |= tmp_logflags; if (error) return error; From patchwork Mon Apr 29 06:15:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13646302 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F810D534 for ; Mon, 29 Apr 2024 06:15:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371341; cv=none; b=FsQJYJ6NZEcRV10zpiiF3pSpmRNjwPIwNGr9IeFtpziQ6ZuVPTyxiAug2gxMubjpS2TH0+b2TyMgBCgh8TafK283awI+G+OrKyMC+ihV++mnP7lpInvIXEzCLyrOSOINrqnTLo7inoepA/fJgr8e40J13ERQ9qjg2UsX13QXilE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371341; c=relaxed/simple; bh=x+bwI0h3Sw363+KCqhUmoRGZnbhHS6zmLPC0eK+2Hvw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cz8+uSYjKt++HVB8Md68fNQG8hE0ULO32jGkIb4u+iLI2GNsN3NlpoLp4tcOivcNa6qch8k7FfhEPAYMyOeKH7jUUVVPPfciADZkA6iZbMucKXCww7HYwvK3R+K2WpbMK8oiiteCT0Oic9iZiOi3QjqBaVFVuHMuZSDpZ9zyNA4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=PhdMo+xj; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="PhdMo+xj" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=iHkmBhkA81Vza9SmVcK/Iih05U/1+xHRggmweECE7I0=; b=PhdMo+xjkH63sA/theUge3Ficb 0UyfiWSMMLvHbSNG9aLnI345yNBUHP/OkVay7NkffoNu5OlOKyy1FWjkgIYc3CRIDMQHhWNjOLih2 HX0rcI7ym9yrmIb7PgsmPOYPbc1S58ruSVqxTDNH3gLGBxj6jLqTP2ON2D1/0NIDYLKadCivcb6zO tqREs2VlIRq4K1jbXPNzl82Ypajit4vcmUQq4NaXga3sMPElDCdwkJ66MQYEHePbPf0cGIGAo2GQt 1eAd90HSyN8hS1gd4vvyoXbRr50G+juijt9HLsg7cM+NZLwLD0rIchJx7TFAPjwsHZzv5ZKiCPo6S yIvSAUpg==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1KId-00000001ciq-1i1a; Mon, 29 Apr 2024 06:15:39 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 3/9] xfs: lift a xfs_valid_startblock into xfs_bmapi_allocate Date: Mon, 29 Apr 2024 08:15:23 +0200 Message-Id: <20240429061529.1550204-4-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429061529.1550204-1-hch@lst.de> References: <20240429061529.1550204-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html xfs_bmapi_convert_delalloc has a xfs_valid_startblock check on the block allocated by xfs_bmapi_allocate. Lift it into xfs_bmapi_allocate as we should assert the same for xfs_bmapi_write. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 1ea1b78ad5a560..ee8f86c03185fc 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4221,6 +4221,11 @@ xfs_bmapi_allocate( if (bma->blkno == NULLFSBLOCK) return -ENOSPC; + if (WARN_ON_ONCE(!xfs_valid_startblock(bma->ip, bma->blkno))) { + xfs_bmap_mark_sick(bma->ip, whichfork); + return -EFSCORRUPTED; + } + if (bma->flags & XFS_BMAPI_ZERO) { error = xfs_zero_extent(bma->ip, bma->blkno, bma->length); if (error) @@ -4712,12 +4717,6 @@ xfs_bmapi_convert_delalloc( if (error) goto out_finish; - if (WARN_ON_ONCE(!xfs_valid_startblock(ip, bma.got.br_startblock))) { - xfs_bmap_mark_sick(ip, whichfork); - error = -EFSCORRUPTED; - goto out_finish; - } - XFS_STATS_ADD(mp, xs_xstrat_bytes, XFS_FSB_TO_B(mp, bma.length)); XFS_STATS_INC(mp, xs_xstrat_quick); From patchwork Mon Apr 29 06:15:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13646303 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E34D1101DA for ; Mon, 29 Apr 2024 06:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371344; cv=none; b=CdKDy5TOzVZSBYVvUVpXlN9rYlf+0y10KvA3N8pS8OIT60BdghJO6fqCbVqrwxu+IZLNBsuDJrr0Ml927FMkfl0wjgv0bEWVLmnlO3z39XEXsxJB0WIfnE/2G+8S5YM8fhawCUbqUYVPhWwd2rB38PhwGB/MwQeplpBQE/Pkpcs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371344; c=relaxed/simple; bh=Lx3jFaLXRHLtD1SDoeQlGtRXJB62W6iX53QUoM0fFZM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Sv8eabzFXWD8Qh4ugrmsZ9XRtfHtgkntjzj5Xoy9jHAdiuRb1fUkLlHZ/x4ZhSP1Ag3nAinAIZQAA1M1Qvl8XSDKCdLTw0Kapk8XaL0lD2NXuaRDE05JCMf6IK23dPT2+3+mYDdYokEf2To7b0sambPatTxWucovzz8/WWuRPL8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=bhHzJX8M; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="bhHzJX8M" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Uv2ouj9BLPeR3dwFzYKkTY4S4vz2j7mzWQDFj7Rn3yo=; b=bhHzJX8MJQp6GME0lEGbtnLQVX sCtQ4tFMsnYMrrKtLw9yI0widP1tvPHg8T6nzRdNl26qREs8U6dNLdL3JwgoywQPX1JlQ2RNFApVu Cqo3OUe1H7qA44WpzDKT9DvBhZbniuklV8zlpd8GHtXcdjKcqX+RP2V7sbVD0vZsR85UomNR6SeB+ 9e0/r2rjaDLttIDpTE6M+u3Tb+YIqkGbiQ2i9nQJbSFE59kUo2QYQdhlVZlrB1zhmlBHO6v+HcjtU gyPJuKmA6Fi6UNb3w15K7TkM8adLSmtfOeV/nqiZ13YaaXSPN27963WxqETFwFLLFZVsy27lA+aIc Pxk5+nGw==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1KIg-00000001cjU-0mI8; Mon, 29 Apr 2024 06:15:42 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 4/9] xfs: don't open code XFS_FILBLKS_MIN in xfs_bmapi_write Date: Mon, 29 Apr 2024 08:15:24 +0200 Message-Id: <20240429061529.1550204-5-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429061529.1550204-1-hch@lst.de> References: <20240429061529.1550204-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html XFS_FILBLKS_MIN uses min_t and thus does the comparison using the correct xfs_filblks_t type. Use it in xfs_bmapi_write and slightly adjust the comment document th potential pitfall to take account of this Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index ee8f86c03185fc..f7b263d0b0cf1c 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4528,14 +4528,11 @@ xfs_bmapi_write( * allocation length request (which can be 64 bits in * length) and the bma length request, which is * xfs_extlen_t and therefore 32 bits. Hence we have to - * check for 32-bit overflows and handle them here. + * be careful and do the min() using the larger type to + * avoid overflows. */ - if (len > (xfs_filblks_t)XFS_MAX_BMBT_EXTLEN) - bma.length = XFS_MAX_BMBT_EXTLEN; - else - bma.length = len; + bma.length = XFS_FILBLKS_MIN(len, XFS_MAX_BMBT_EXTLEN); - ASSERT(len > 0); ASSERT(bma.length > 0); error = xfs_bmapi_allocate(&bma); if (error) { From patchwork Mon Apr 29 06:15:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13646304 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E72C101CF for ; Mon, 29 Apr 2024 06:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371346; cv=none; b=B/sakvejMRsZoSgr/l5aZS9yl37oe8ezMhsaQliNfaOs1zIuvfFxwDW8P3zpnbjTwi0UZnaaPsUD6xYKOWahxh/aULJn7rtZnDVoVR/yHFaOqKfVHCGSLaj6XITsbTgryemxGv78A+28fpECCfG+znOtpGzGu7iuiboewlx1Vas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371346; c=relaxed/simple; bh=qnXzoggrA5CPM3U2HU6IFmk4RGO1BrrTHjezom89XLg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sDyHPL5+uQzD1ZychMkim2X1M2GG2o8krXvxLiHSsqEGmnGlQvP0rgCPlOgy5EGgRyRVzgHapKW2elo0rgsToA15O7VzUh/J9bnVepyPNq8x4iYKDYu15JUlwpb51qmsYhIwwrmb5/dyQmYRkBemfZe5hTP9U0uLgpjakt60r3c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=d1H/100b; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="d1H/100b" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=Pve09adpjPd1rnc3XwsIcY6dISM+qwYvGnvqBoNKaM4=; b=d1H/100bwpu0fkOuMvZqkg7ZUz 9RQKbDCiW3mjXqam/DA0Ee01maFXcres0rz5FduORjx0InZFacqUuC9ifJ210jRUJu0fkxBQTP8jp K3UGUH4oipMMeQ882KcHpNSutSGQqr7xzcy8iZAy1kmX9Pmp2mNnjG9UvANvKWGouwQXixOfdK2C9 YuKrpQ81BASSeZ4TQr8EKsimFLiafYkDISQRFKzBOk8er6RWmPE522Ql0blsepep3qftr3GzF+FgE +aR+5ZGO/+xODZ1NghVp5sazNEKJhJfY1UF4mLkqBLbxJ5b4cK05cvbEDpuUE3y65OCEbZmY5Zcwd 1+01Q74Q==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1KIi-00000001ckv-257U; Mon, 29 Apr 2024 06:15:45 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 5/9] xfs: pass the actual offset and len to allocate to xfs_bmapi_allocate Date: Mon, 29 Apr 2024 08:15:25 +0200 Message-Id: <20240429061529.1550204-6-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429061529.1550204-1-hch@lst.de> References: <20240429061529.1550204-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html xfs_bmapi_allocate currently overwrites offset and len when converting delayed allocations, and duplicates the length cap done for non-delalloc allocations. Move all that logic into the callers to avoid duplication and to make the calling conventions more obvious. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index f7b263d0b0cf1c..fe1ccc083eb3c4 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4185,21 +4185,11 @@ xfs_bmapi_allocate( int error; ASSERT(bma->length > 0); + ASSERT(bma->length <= XFS_MAX_BMBT_EXTLEN); - /* - * For the wasdelay case, we could also just allocate the stuff asked - * for in this bmap call but that wouldn't be as good. - */ if (bma->wasdel) { - bma->length = (xfs_extlen_t)bma->got.br_blockcount; - bma->offset = bma->got.br_startoff; if (!xfs_iext_peek_prev_extent(ifp, &bma->icur, &bma->prev)) bma->prev.br_startoff = NULLFILEOFF; - } else { - bma->length = XFS_FILBLKS_MIN(bma->length, XFS_MAX_BMBT_EXTLEN); - if (!bma->eof) - bma->length = XFS_FILBLKS_MIN(bma->length, - bma->got.br_startoff - bma->offset); } if (bma->flags & XFS_BMAPI_CONTIG) @@ -4533,6 +4523,15 @@ xfs_bmapi_write( */ bma.length = XFS_FILBLKS_MIN(len, XFS_MAX_BMBT_EXTLEN); + if (wasdelay) { + bma.offset = bma.got.br_startoff; + bma.length = bma.got.br_blockcount; + } else { + if (!eof) + bma.length = XFS_FILBLKS_MIN(bma.length, + bma.got.br_startoff - bno); + } + ASSERT(bma.length > 0); error = xfs_bmapi_allocate(&bma); if (error) { @@ -4685,11 +4684,16 @@ xfs_bmapi_convert_delalloc( bma.tp = tp; bma.ip = ip; bma.wasdel = true; - bma.offset = bma.got.br_startoff; - bma.length = max_t(xfs_filblks_t, bma.got.br_blockcount, - XFS_MAX_BMBT_EXTLEN); bma.minleft = xfs_bmapi_minleft(tp, ip, whichfork); + /* + * Always allocate convert from the start of the delalloc extent even if + * that is outside the passed in range to create large contiguous + * extents on disk. + */ + bma.offset = bma.got.br_startoff; + bma.length = bma.got.br_blockcount; + /* * When we're converting the delalloc reservations backing dirty pages * in the page cache, we must be careful about how we create the new From patchwork Mon Apr 29 06:15:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13646305 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E67C41118D for ; Mon, 29 Apr 2024 06:15:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371349; cv=none; b=VmdbRnK6poroG1E8SuOc+2gQ/eNXW1U6EVp/uonFMq+rahlX3Dt+ejndoBW1/JsAg42Cw7gybF1LBeQTl6gMZ5HryVcSWBMFYe+M8S57Wv8ED6DRTH6PPtWHr7UFvQEjifGI2Tq9zXD6laq2YKDUmi6y62TmW4L9y25n1EnEmyc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371349; c=relaxed/simple; bh=wWYTLysWbZVwx7UkQnw3UiKd7VQJ5KYAU9/cdo+r31M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gfsCqQO5sWdmCwG0wwq9Z8oI/QK8lwEGVNQJMSe9IKkLLxWlTVIfjAa1L8J+SEi/8rcpgksOUK2iimb4d+BbiONpCrc1d/hxbxnW90FRfoEFpk70J5QEFnIDhKnCNShHMkHcKql1Q/k6PRFjUlC/TcUs7JXf6qLXepAkKAfQkPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=yKLBrQk2; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="yKLBrQk2" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=qK56DxKJVjW1wJhi47rvMJIDsf6HftF/f95Q7f1GKwI=; b=yKLBrQk2aopyV1wpq57rzwka1K QSGxknPInfv0jJ6rfD7aRrVvPNTk5CN+OsfIimQMQfxjn948zUu31TamgxZZQ2z2gXgpTwRnJsr/G 2poGdBn2PLgI4I+QAuj8eBP3L14YglJNNnZiJzsWaeWARgdGGgXRLQVpKjlaDW4qYrXseJuoU+fXV x8mDqM8AL3W+p7PoE0CG+bwhWwLwoROsvgXqQ9Wo/j4UrFse2zW1jI58Z9n6wSlLaAm17P6GZ61x8 W3owp1TztIYjh/EdI6CHGbRIYBRrhDVkpssTRc8jtTFPGjc6PJ4IESzxBqPxhZdBW/1j+WR4FFyoq uJKGDFkg==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1KIl-00000001cm2-0wtV; Mon, 29 Apr 2024 06:15:47 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 6/9] xfs: remove the xfs_iext_peek_prev_extent call in xfs_bmapi_allocate Date: Mon, 29 Apr 2024 08:15:26 +0200 Message-Id: <20240429061529.1550204-7-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429061529.1550204-1-hch@lst.de> References: <20240429061529.1550204-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Both callers of xfs_bmapi_allocate already initialize bma->prev, don't redo that in xfs_bmapi_allocate. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index fe1ccc083eb3c4..472c795beb8add 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4187,11 +4187,6 @@ xfs_bmapi_allocate( ASSERT(bma->length > 0); ASSERT(bma->length <= XFS_MAX_BMBT_EXTLEN); - if (bma->wasdel) { - if (!xfs_iext_peek_prev_extent(ifp, &bma->icur, &bma->prev)) - bma->prev.br_startoff = NULLFILEOFF; - } - if (bma->flags & XFS_BMAPI_CONTIG) bma->minlen = bma->length; else From patchwork Mon Apr 29 06:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13646306 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6BBB134DE for ; Mon, 29 Apr 2024 06:15:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371352; cv=none; b=HnN10n1YbLlbWhCUH2sQD2Cn6ULy3UA2jmKZSSRrJd/mpexT4Mg0MBX6VXaUI9CX9x+FliBTAoaGvdAHWcKCrbLY3dSJZiyTYcNVkYPFf1pqbln1yi5jHMqBymbYZX95GmzxjispB+iYKxgoVFWsqvzusjSCsnYzWKQ9EkIATh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371352; c=relaxed/simple; bh=VamDX7Hz8gDgr43cFn+nvfl78SUVTVTO2mO3BmqurZM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D1PkmAp3h5ZrY1wQDXeR30xv/YxXDcg6CvSOnACqrSVq0TgA4gYvKA3/UW5Oz9dLWI0jWog6x7j5AudFvjNH8dgPDcLq/YRXCTUD+D1VUjewOI4CZJ9N/4u0j5tt8SVX1FHbQagmGb4Xf6Cxsz8bk0LV9Y8DaUOu7A+hC1moIKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=TMz16zDm; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="TMz16zDm" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=omZPRAxrXfcXg3AvCfX2DjCl1BQe5B1jL+WmzZWd5i8=; b=TMz16zDm1GA1D67UlpkNGKAlbU khvlT2mny3fAv6l2B1zpg1kwS7I2ObnuUx6TOuNeD0/p7tWI/tTzBXYwcuCNbDwY78Idc7PPzEYSN ZCAt4xkVe8BwlSpF2U2llcuaqBKR878aRzmhHVXy2GCTY/eT1OeFXu3vdPU1nZznKhNBcKqHa5Vq8 kmhPRdWB09FGWGmPZ0nXRzeg+dF9HixQ8BX0FN/h3qwpwGFBIWq5t3a7RT9RACIb/R5OPVCHZdcTP kpW1fn1hSQ0Y/C4pBYq7dPB3uEAMULPe4wPtcC/YmnKYaA97A3fY4L/lL1JwX6U9cNbaK1Gf/ZCpl bhXFlcjg==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1KIn-00000001cmc-2vlV; Mon, 29 Apr 2024 06:15:50 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 7/9] xfs: fix xfs_bmap_add_extent_delay_real for partial conversions Date: Mon, 29 Apr 2024 08:15:27 +0200 Message-Id: <20240429061529.1550204-8-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429061529.1550204-1-hch@lst.de> References: <20240429061529.1550204-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html xfs_bmap_add_extent_delay_real takes parts or all of a delalloc extent and converts them to a real extent. It is written to deal with any potential overlap of the to be converted range with the delalloc extent, but it turns out that currently only converting the entire extents, or a part starting at the beginning is actually exercised, as the only caller always tries to convert the entire delalloc extent, and either succeeds or at least progresses partially from the start. If it only converts a tiny part of a delalloc extent, the indirect block calculation for the new delalloc extent (da_new) might be equivalent to that of the existing delalloc extent (da_old). If this extent conversion now requires allocating an indirect block that gets accounted into da_new, leading to the assert that da_new must be smaller or equal to da_new unless we split the extent to trigger. Except for the assert that case is actually handled by just trying to allocate more space, as that already handled for the split case (which currently can't be reached at all), so just reusing it should be fine. Except that without dipping into the reserved block pool that would make it a bit too easy to trigger a fs shutdown due to ENOSPC. So in addition to adjusting the assert, also dip into the reserved block pool. Note that I could only reproduce the assert with a change to only convert the actually asked range instead of the full delalloc extent from xfs_bmapi_write. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 472c795beb8add..42c5a2efa656a5 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -1570,6 +1570,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_LEFT_CONTIG: @@ -1600,6 +1601,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING | BMAP_RIGHT_CONTIG: @@ -1634,6 +1636,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_RIGHT_FILLING: @@ -1668,6 +1671,7 @@ xfs_bmap_add_extent_delay_real( goto done; } } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING | BMAP_LEFT_CONTIG: @@ -1706,6 +1710,7 @@ xfs_bmap_add_extent_delay_real( if (error) goto done; } + ASSERT(da_new <= da_old); break; case BMAP_LEFT_FILLING: @@ -1796,6 +1801,7 @@ xfs_bmap_add_extent_delay_real( xfs_iext_update_extent(bma->ip, state, &bma->icur, &PREV); xfs_iext_next(ifp, &bma->icur); xfs_iext_update_extent(bma->ip, state, &bma->icur, &RIGHT); + ASSERT(da_new <= da_old); break; case BMAP_RIGHT_FILLING: @@ -1845,6 +1851,7 @@ xfs_bmap_add_extent_delay_real( PREV.br_blockcount = temp; xfs_iext_insert(bma->ip, &bma->icur, &PREV, state); xfs_iext_next(ifp, &bma->icur); + ASSERT(da_new <= da_old); break; case 0: @@ -1967,12 +1974,10 @@ xfs_bmap_add_extent_delay_real( } /* adjust for changes in reserved delayed indirect blocks */ - if (da_new < da_old) { + if (da_new < da_old) xfs_add_fdblocks(mp, da_old - da_new); - } else if (da_new > da_old) { - ASSERT(state == 0); - error = xfs_dec_fdblocks(mp, da_new - da_old, false); - } + else if (da_new > da_old) + error = xfs_dec_fdblocks(mp, da_new - da_old, true); xfs_bmap_check_leaf_extents(bma->cur, bma->ip, whichfork); done: From patchwork Mon Apr 29 06:15:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13646307 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFA901079D for ; Mon, 29 Apr 2024 06:15:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371354; cv=none; b=rInRxWDpCiTkZtJl4VODSY1YakmonKechaTSx0h3WxDDUHpOopr1uuDyWR0x9mwUM/m/v0iSc7VbM2Fo0Gn+7hyPMz0KnndL7q2hnNDz/S/mUpFZAyDoasnVdq+PEI+1WwnQ0hpr74pYFLGQcDenCNgaGVILUQVtw85l8TI7190= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371354; c=relaxed/simple; bh=B6lo7376fRlMrFW8S5XxqHhRb6VuV0njd/UWRmqgisI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=dPjIcmo/nWNUZS0+H7sHVtRH+YpZ/8B9Hngyah8zBGGZknfPVluaU7V3JDZNYh/8lBsmc+la12YRW8s9GIJxDGwIecvVabmUxFYeX5PftuEXaS9cANNY+O4hUmqCm2BuXIfvoNnIMHPrBHfvwnOB6wAg7jz7UQpjUtgqZ9s/B5o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=xRd2iapw; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="xRd2iapw" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc: To:From:Sender:Reply-To:Content-ID:Content-Description; bh=L6rTEMcYceK2RrJKk6zfTIDhU+azZqufOGOX5balu8s=; b=xRd2iapwsIdx9wp5+RF2wUn160 uG5XExr8CWuzxjFm3gN01P8r9sgIOLXx/1kXGjcxVRl25AFdVXeOk+LwRSpNCRXg/qyMzJOnXYhRe 2ya+LvUcjPrw/Odr33Zp2HmZeOunzve24U937hxqqnGkCpY7ONMn3vWU2CUURSTG3wCqzeI0LJdJ/ +y6jmXTht8U713lCUR/gSYmwbLXGeyGtzGAErd6x+f5fasBZTquAs0XI5QCoOFvUVbmD9G962az6Z fWGJYaBrn+/NRhtOjRFZuGlsc/ksde2yFjpoiX5Wyt8T2l54UlXn1ab2VmG/yEmzmWRYp9asOIbM5 MTo55rNQ==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1KIq-00000001cnM-1K9a; Mon, 29 Apr 2024 06:15:52 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 8/9] xfs: do not allocate the entire delalloc extent in xfs_bmapi_write Date: Mon, 29 Apr 2024 08:15:28 +0200 Message-Id: <20240429061529.1550204-9-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429061529.1550204-1-hch@lst.de> References: <20240429061529.1550204-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html While trying to convert the entire delalloc extent is a good decision for regular writeback as it leads to larger contigous on-disk extents, but for other callers of xfs_bmapi_write is is rather questionable as it forced them to loop creating new transactions just in case there is no large enough contiguous extent to cover the whole delalloc reservation. Change xfs_bmapi_write to only allocate the passed in range instead, whіle the writeback path through xfs_bmapi_convert_delalloc and xfs_bmapi_allocate still always converts the full extents. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 42c5a2efa656a5..f5488cc975342b 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4524,8 +4524,9 @@ xfs_bmapi_write( bma.length = XFS_FILBLKS_MIN(len, XFS_MAX_BMBT_EXTLEN); if (wasdelay) { - bma.offset = bma.got.br_startoff; - bma.length = bma.got.br_blockcount; + bma.length = XFS_FILBLKS_MIN(bma.length, + bma.got.br_blockcount - + (bno - bma.got.br_startoff)); } else { if (!eof) bma.length = XFS_FILBLKS_MIN(bma.length, From patchwork Mon Apr 29 06:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13646308 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B91DD1079D for ; Mon, 29 Apr 2024 06:15:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371357; cv=none; b=N1qt4MTX3Y+QdnbQxpmdw6ouKZULtN4ph9MJz/MCclJFSthDnbPs4aiExycUTIdgukNRsSMgQUWeR2KJUfJSt3IJB/BmtE0mQxFo7v81OnBFZK+oIupoK2kObNU272+XWnS3hb1WPR6IkojzzQRn9xtl0WUwha+2mEYakECw+0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714371357; c=relaxed/simple; bh=pqxBVrqJ+ScVtgxtK0xuEKxmTDGnhUH+oQBYu6lOlVY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=l62qSPwELBwz7Yz0PUWaSNloVKMzpZZpis8shWOdq/DnxZrLneNwbyPA/fMOHthL2TH9yHf4CJufs2BA4YKFpsL95wy/5ofnSAHw8+c4GZza01pJFi8bvvLfzOILUdHtRnirzL6MbZTd+5Tz0lQPJZXEFiZnaZwGBroX6+gB6G0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=rkyvispZ; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="rkyvispZ" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=1NPsFOdaXYv2sK/E/aNE5+0Ct82FPTWrDFkYQp4JuSI=; b=rkyvispZxbWye0XvIC+UPzuQx7 DzJisxiPNg2HiKezPeWz+iAe4fZR72E/CA5WANKCN+/sCZ/hFENS4KMIcpaXPDMnxx5AxXwC/YC2E EA+BR/sJXarppUjz123WDM4kXI5KHfbVr/ey1fl/8UDX21IgyMVcAACg69x5mAlbCweY4ZI3/flP9 GfjeUrLcPkTRgE6EHsrRhhXN4I78/Rae6MEq1MAlMEDGVOsnno7aCLACvSqRQL59GrPPEIy2QYpic eOM0ooENH0L0yJR/rHlzh9WZbXU7lApXxTFSS80+/lD0D93cjez1a6QCsaek8nrN5EtMYYLX8JKop yneuEQOg==; Received: from 2a02-8389-2341-5b80-39d3-4735-9a3c-88d8.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:39d3:4735:9a3c:88d8] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1s1KIs-00000001coV-36Lw; Mon, 29 Apr 2024 06:15:55 +0000 From: Christoph Hellwig To: Chandan Babu R , "Darrick J. Wong" Cc: Dave Chinner , linux-xfs@vger.kernel.org Subject: [PATCH 9/9] mm,page_owner: don't remove GFP flags in add_stack_record_to_list Date: Mon, 29 Apr 2024 08:15:29 +0200 Message-Id: <20240429061529.1550204-10-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240429061529.1550204-1-hch@lst.de> References: <20240429061529.1550204-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html This loses flags like GFP_NOFS and GFP_NOIO that are important to avoid deadlocks as well as GFP_NOLOCKDEP that otherwise generates lockdep false positives. Fixes: 217b2119b9e2 ("mm,page_owner: implement the tracking of the stacks count") Signed-off-by: Christoph Hellwig --- mm/page_owner.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/page_owner.c b/mm/page_owner.c index d17d1351ec84af..d214488846fa92 100644 --- a/mm/page_owner.c +++ b/mm/page_owner.c @@ -168,9 +168,7 @@ static void add_stack_record_to_list(struct stack_record *stack_record, unsigned long flags; struct stack *stack; - /* Filter gfp_mask the same way stackdepot does, for consistency */ gfp_mask &= ~GFP_ZONEMASK; - gfp_mask &= (GFP_ATOMIC | GFP_KERNEL); gfp_mask |= __GFP_NOWARN; set_current_in_page_owner();