From patchwork Mon Mar 17 05:44:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 14018674 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 BC4B714A0A8 for ; Mon, 17 Mar 2025 05:45:18 +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=1742190320; cv=none; b=YiJ9ms8xaQT1J1DdagussBeEXa7yfphlmsQcIZ4Mi3pwdPbJsny+GLnYT86rs0Z896qEy4WamD9YLz2OBbqJkKjC9Xdex5RuAtQb+5/1fO/nFguzulL64GZBktYPWZVIDocaHcYdMFt+KzIaHP1OICSdVm7/QbqDM7UlNTl7opc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190320; c=relaxed/simple; bh=n0cV9ItDVVoMoh8QfjmznGd/8w2VVimHxww4zWuDgsE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oAXlFbM5Rck4VfeeJT0aLD2cE4T3+n3VvXWz38m8Ig6nK0lCUyKlCbQGXMIvlouAEMYkZoNeQKdDhD3DwykgF3/2OpoZTjWEeORSzlB+e0vgP6HdSxQBA4Kc89s7i/JyGgEzfv7939xYUVwVX9K1TwUthZ063TYe0CtQVItDSlQ= 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=sOpAssbX; 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="sOpAssbX" 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=Vn0u7Ea63cebEyUv0H2kRY7Sn+nVHt9uzFUjWqwjlXI=; b=sOpAssbX7l2GoHnIGkaXNYpRMD bVaq+lgH7wwDG3ea3S2/HDghItXAe8RTcuAXJUoOr1cfcWGybUx4q6GcKFBGquTFVk7ih41DJGdx+ PpDQHbE8Onxtkv7bOkesVU2OqCtCUj7vetAsO4hriuV4oKOaWHGcjcEdF6fgs9RY0392EaLiPBs5u IrzTeD27x081jL0REZRZWhYjwJmh+58WAe/CY0SceAaLLMfmUF8kWxXPTDqSqe6xCX2K7HMjEEeEh G3IRJ0wxJo3krvhhKpzMddS0diIeqUXmc4P17zYUjcsirhgkWPpvFcA+dCaGyPPX4k7KU5wAy/2tA /xsrqkug==; Received: from [2001:4bb8:2dd:4138:8d2f:1fda:8eb2:7cb7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tu3Hp-00000001IVp-3L1w; Mon, 17 Mar 2025 05:45:18 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , Dan Carpenter , Hans Holmberg , linux-xfs@vger.kernel.org Subject: [PATCH 1/3] xfs: fix a missing unlock in xfs_growfs_data Date: Mon, 17 Mar 2025 06:44:52 +0100 Message-ID: <20250317054512.1131950-2-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250317054512.1131950-1-hch@lst.de> References: <20250317054512.1131950-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 The newly added check for the internal RT device needs to unlock m_growlock just like all ther other error cases. Fixes: bdc03eb5f98f ("xfs: allow internal RT devices for zoned mode") Reported-by: Dan Carpenter Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino --- fs/xfs/xfs_fsops.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index ee2cefbd5df8..d7658b7dcdbd 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -301,7 +301,7 @@ xfs_growfs_data( struct xfs_mount *mp, struct xfs_growfs_data *in) { - int error = 0; + int error; if (!capable(CAP_SYS_ADMIN)) return -EPERM; @@ -309,8 +309,10 @@ xfs_growfs_data( return -EWOULDBLOCK; /* we can't grow the data section when an internal RT section exists */ - if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart) - return -EINVAL; + if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart) { + error = -EINVAL; + goto out_error; + } /* update imaxpct separately to the physical grow of the filesystem */ if (in->imaxpct != mp->m_sb.sb_imax_pct) { From patchwork Mon Mar 17 05:44:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 14018675 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 9166314A0A8 for ; Mon, 17 Mar 2025 05:45:22 +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=1742190324; cv=none; b=rrDIvxOPAn4pzABmNzIk00U+tsBpBxAP9Jaj0rwJtH/Q2+64yh+1628ISD1NInBQp76y0bZTC1ev2+MwaEgXS/IHyi35+hRUz9lXeSTgOwl8TPCW/NzBPRLclZllXW+7ndqP4U1Zw0D0aBgRVLlao7Teu8navqor+c1UJX/RSas= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190324; c=relaxed/simple; bh=A8DgtxxmqnXEEsr9PV2V4eoL2O3PIA8+G3AhLpAJcR4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tstnP18K+Ba/H187Kz3Rl2imfMejTHZ4h8CxwDDYzTByGDwBmlPMmlUDND8XzEIog+15OmlnmnohduX+IKnYF5C51MoagixTTNjd6LKGuF6MGcGZPF9GabJWSvcYObo5COgFSGRvhRbpC39yAwWiUD6xAiNr2xMxrQXFt+XcvZs= 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=Vt+rlsep; 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="Vt+rlsep" 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=swsQsqynUt7owVwtkE3+UTvvqHKPqFOmeljnUkiOzW8=; b=Vt+rlsep2gLVS9HUWoQKEqLUz2 yQfcDyzY1BDHB2RMiFvWe+768SytCO2omtlwU4PvELx1sxqiC0RqQOJlAlnJsIlV0n+o/m0epj+Ey T/ga/r5m2b15qfT4UVsghXc3vxG1wjjo+mbd4QOqr3iZqZLwXTnfk1iB0PlOi3OXM35cuO84qc+yC mDqDY/dNHh89nMEciD8JipGnExsbVAIaLtmGAUwkfqGltu8XkfJ00A9W8dAnRhE8EE2u0MLD49DHK vcG4o9tnfu3neqD9SfP881oJjgjW7sIegp8lRAC3Ts40DbTABP2+2b/wiDqT2HxDS0Ye0c/HTJT7A wFb2L7Og==; Received: from [2001:4bb8:2dd:4138:8d2f:1fda:8eb2:7cb7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tu3Ht-00000001IWI-1eet; Mon, 17 Mar 2025 05:45:22 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , Dan Carpenter , Hans Holmberg , linux-xfs@vger.kernel.org Subject: [PATCH 2/3] xfs: don't increment m_generation for all errors in xfs_growfs_data Date: Mon, 17 Mar 2025 06:44:53 +0100 Message-ID: <20250317054512.1131950-3-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250317054512.1131950-1-hch@lst.de> References: <20250317054512.1131950-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_growfs_data needs to increment m_generation as soon as the primary superblock has been updated. As the update of the secondary superblocks was part of xfs_growfs_data_private that mean the incremented had to be done unconditionally once that was called. Later, commit 83a7f86e39ff ("xfs: separate secondary sb update in growfs") split the secondary superblock update into a separate helper, so now the increment on error can be limited to failed calls to xfs_update_secondary_sbs. Signed-off-by: Christoph Hellwig Reviewed-by: Carlos Maiolino --- fs/xfs/xfs_fsops.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c index d7658b7dcdbd..b6f3d7abdae5 100644 --- a/fs/xfs/xfs_fsops.c +++ b/fs/xfs/xfs_fsops.c @@ -311,20 +311,20 @@ xfs_growfs_data( /* we can't grow the data section when an internal RT section exists */ if (in->newblocks != mp->m_sb.sb_dblocks && mp->m_sb.sb_rtstart) { error = -EINVAL; - goto out_error; + goto out_unlock; } /* update imaxpct separately to the physical grow of the filesystem */ if (in->imaxpct != mp->m_sb.sb_imax_pct) { error = xfs_growfs_imaxpct(mp, in->imaxpct); if (error) - goto out_error; + goto out_unlock; } if (in->newblocks != mp->m_sb.sb_dblocks) { error = xfs_growfs_data_private(mp, in); if (error) - goto out_error; + goto out_unlock; } /* Post growfs calculations needed to reflect new state in operations */ @@ -338,13 +338,12 @@ xfs_growfs_data( /* Update secondary superblocks now the physical grow has completed */ error = xfs_update_secondary_sbs(mp); -out_error: /* - * Increment the generation unconditionally, the error could be from - * updating the secondary superblocks, in which case the new size - * is live already. + * Increment the generation unconditionally, after trying to update the + * secondary superblocks, as the new size is live already at this point. */ mp->m_generation++; +out_unlock: mutex_unlock(&mp->m_growlock); return error; } From patchwork Mon Mar 17 05:44:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hch X-Patchwork-Id: 14018676 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 CC7F938DEC for ; Mon, 17 Mar 2025 05:45:25 +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=1742190327; cv=none; b=t29e0Rvr9BzSLw7sj510ZMEb4MRM77t2Dt0T8rJGM12bFadIwTgMd3n1DxL1w/BmHXc2AqIu+3HCX/oO7TPRUNzBr60/Fv3GzxxxgRpVshwEA47+l5MBIXq/Z9UgV3nXIhlgYt5HfewsLhip1cMXtMtXuLi6AG5FMdQ+EHrwte4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742190327; c=relaxed/simple; bh=MQuBqFEfDtCBa5NhmQS3Znm1xWk6/QoviB3NNgHkUTU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cqM9sSVeRN2x72PaiAwZSAbrO0z53aYHc3ptTKXhgu1AhfjnuE3iTeb62CCg0/gySWqRfWy+GmLIipO/VTIMFg/fHrvNfVkGCgSl/a9CAKK7l2cumV2/Jir+r2je8lduzxRthu5o78t7PpREb/6FAclv+DiUp2HiiWLnGya4lmw= 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=hqB3GRqB; 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="hqB3GRqB" 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=zOh6h2Gp4AVjW1PAgvFdTmqcnrutzSzreGR3aXuhFOg=; b=hqB3GRqBqQa9xFTdSy3/NBZ2Af qiFyMTEVegfNg7XPXUMFavO5ZbvM+z8j292k8Bma0zSd6cHTA2977bJeAYAXC4himtXuuvbqEVn1o 1YmTj6ErpAE0SVD+SAJ8brjSPKR/Al+1gmN640brfDqRYrKmoIO32YYMtaqc7qgBUdHiQM0ikNoy+ hGE4gO8cC9raNfkMx6Kkz5bD6wGUGKJ2iIKctrMV70/XSC9FaFlQ73WizP4Dv2x5qxteKwhQJLLPG qtWGz0QFE6DhWkEEEtHFwlcqYWogN2s1WQ2hkiZ6nCRRKpGR/4vEuSglFASjXQgJb8gP12a19WURA wrPB0CZw==; Received: from [2001:4bb8:2dd:4138:8d2f:1fda:8eb2:7cb7] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.98 #2 (Red Hat Linux)) id 1tu3Hw-00000001IWc-3eGg; Mon, 17 Mar 2025 05:45:25 +0000 From: Christoph Hellwig To: Carlos Maiolino Cc: "Darrick J. Wong" , Dan Carpenter , Hans Holmberg , linux-xfs@vger.kernel.org Subject: [PATCH 3/3] xfs: don't wake zone space waiters without m_zone_info Date: Mon, 17 Mar 2025 06:44:54 +0100 Message-ID: <20250317054512.1131950-4-hch@lst.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20250317054512.1131950-1-hch@lst.de> References: <20250317054512.1131950-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 From: "Darrick J. Wong" xfs_zoned_wake_all checks SB_ACTIVE to make sure it does the right thing when a shutdown happens during unmount, but it fails to account for the log recovery special case that sets SB_ACTIVE temporarily. Add a NULL check to cover both cases. Signed-off-by: Darrick J. Wong [hch: added a commit log and comment] Signed-off-by: Christoph Hellwig Reviewed-by: Hans Holmberg Reviewed-by: Carlos Maiolino --- fs/xfs/xfs_zone_alloc.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/fs/xfs/xfs_zone_alloc.c b/fs/xfs/xfs_zone_alloc.c index fd4c60a050e6..52af234936a2 100644 --- a/fs/xfs/xfs_zone_alloc.c +++ b/fs/xfs/xfs_zone_alloc.c @@ -853,13 +853,22 @@ xfs_zone_alloc_and_submit( bio_io_error(&ioend->io_bio); } +/* + * Wake up all threads waiting for a zoned space allocation when the file system + * is shut down. + */ void xfs_zoned_wake_all( struct xfs_mount *mp) { - if (!(mp->m_super->s_flags & SB_ACTIVE)) - return; /* can happen during log recovery */ - wake_up_all(&mp->m_zone_info->zi_zone_wait); + /* + * Don't wake up if there is no m_zone_info. This is complicated by the + * fact that unmount can't atomically clear m_zone_info and thus we need + * to check SB_ACTIVE for that, but mount temporarily enables SB_ACTIVE + * during log recovery so we can't entirely rely on that either. + */ + if ((mp->m_super->s_flags & SB_ACTIVE) && mp->m_zone_info) + wake_up_all(&mp->m_zone_info->zi_zone_wait); } /*