Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1258406pxx; Tue, 27 Oct 2020 12:02:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZ8Hxzk+G1brBBj8FLTTzCMnBa4emGrVl/+JnkeTy8HkCYdAqjpLRjchk5EJJlWTFtoTV5 X-Received: by 2002:aa7:cad6:: with SMTP id l22mr3827736edt.229.1603825363028; Tue, 27 Oct 2020 12:02:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603825363; cv=none; d=google.com; s=arc-20160816; b=1GOsl5gJ3DD9T8Gqe+gBCb/txO2cNj4Z6x0oNY/u60g1jIFxntnsTaEC7R4v6nmw06 5IK5bXEogVX/wCCvq+8dJiDMJvIphuw4e/w76BzLQEPe/D7bQenPiaYVTYbQpGiHdYMZ klPQj2hr4fZgRjfsZKd/8OyAdI3gswVF6HOWQ1/F4R9TP/cKzR2azS+AgI9+LiSNxWU+ lfJoex543xxp8Qv1gIJOSjBG5jMUjHbiT4qwvX1S/Q/IPPkEgVLLKwmjkZsFxuw2vZ1w 2dpd+0MrBLTmF6qzy1c0m381+Pfi2cUdNKWKktvuazT5+cxIUaVOSZ8PsA4GX3gcl1AD ZbdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9viEdkrVM7lEPZxzKlAD/GfFIlMYfaQya9yOWw5LUSY=; b=cfJo2GkcUTO1REmp83UdnwIQoH0J5fO5dFRv7woYsvH0osnn9YPPoSE0CMe7xvYvg/ MQ4aJw/suVs88h66ljEDgdhT4uHlh6XH6F80tuxb0FkLhjI5LrGbReiWi51k+7ae/gnh sWF5jGi8ybX7naAwzF8yiRi/UsSxpf5PI63XyqKzsG1ROyMI0P0KwxlWWB+fr/uT3ZFo eRBV2d3BippmwCooS/CQeeEYajzOQRPh/LArCgYLjQ9xvBZaizbx1iO+1SoWgJGCrDJ0 j4LvptZALtal7eTTyy8fRsoKjw6HcMsmvHbK6SDdh7cnnwpBgEFXyRHHhEdv4WreA1iz 3sCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qHGpvs82; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si1683336eja.272.2020.10.27.12.02.21; Tue, 27 Oct 2020 12:02:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qHGpvs82; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2501961AbgJ0AjG (ORCPT + 99 others); Mon, 26 Oct 2020 20:39:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:50770 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409209AbgJZXut (ORCPT ); Mon, 26 Oct 2020 19:50:49 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 66A0E2075B; Mon, 26 Oct 2020 23:50:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756249; bh=SN9hvYg6Tex/aY6jOySTVpRN/tL+jIbw8znebRkPRf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qHGpvs82XknpisJDoLgeUIICs4Hnz+YXy5498AnXNP83ex8p3Ng6l+i6N17iynVKg oOClDcO8By1lEbNErZNNHtIsegajNejefp2tMGl+5k7XFeIvwlhpNrISDWr9JCHT8p rzU8wSuZnM9HybW5FkGD9qqgw46eT3LiLu0Fd7ro= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: "Darrick J. Wong" , Christoph Hellwig , Dave Chinner , Sasha Levin , linux-xfs@vger.kernel.org Subject: [PATCH AUTOSEL 5.9 084/147] xfs: don't free rt blocks when we're doing a REMAP bunmapi call Date: Mon, 26 Oct 2020 19:48:02 -0400 Message-Id: <20201026234905.1022767-84-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026234905.1022767-1-sashal@kernel.org> References: <20201026234905.1022767-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Darrick J. Wong" [ Upstream commit 8df0fa39bdd86ca81a8d706a6ed9d33cc65ca625 ] When callers pass XFS_BMAPI_REMAP into xfs_bunmapi, they want the extent to be unmapped from the given file fork without the extent being freed. We do this for non-rt files, but we forgot to do this for realtime files. So far this isn't a big deal since nobody makes a bunmapi call to a rt file with the REMAP flag set, but don't leave a logic bomb. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig Reviewed-by: Dave Chinner Signed-off-by: Sasha Levin --- fs/xfs/libxfs/xfs_bmap.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index 1b0a01b06a05d..d9a692484eaed 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -5046,20 +5046,25 @@ xfs_bmap_del_extent_real( flags = XFS_ILOG_CORE; if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) { - xfs_fsblock_t bno; xfs_filblks_t len; xfs_extlen_t mod; - bno = div_u64_rem(del->br_startblock, mp->m_sb.sb_rextsize, - &mod); - ASSERT(mod == 0); len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize, &mod); ASSERT(mod == 0); - error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len); - if (error) - goto done; + if (!(bflags & XFS_BMAPI_REMAP)) { + xfs_fsblock_t bno; + + bno = div_u64_rem(del->br_startblock, + mp->m_sb.sb_rextsize, &mod); + ASSERT(mod == 0); + + error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len); + if (error) + goto done; + } + do_fx = 0; nblks = len * mp->m_sb.sb_rextsize; qfield = XFS_TRANS_DQ_RTBCOUNT; -- 2.25.1