Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp916376pxx; Tue, 27 Oct 2020 03:56:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIhs583dbnfoY00YeB7bhxk3/cCaZDUPKSfFCsMNdtdg4whbRanHNDb1ockbIlv4aPTHhz X-Received: by 2002:a17:906:118f:: with SMTP id n15mr1896411eja.394.1603796187596; Tue, 27 Oct 2020 03:56:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603796187; cv=none; d=google.com; s=arc-20160816; b=ehDIx0/dkhVrt3+SPfDj2WnYgGYZUL/VEV0LUeG6uaIZ8tdbdy42TGcoywSw2CW5rK RW6iNT9ZKkVHWOLGStiyZMN5oYq3uNyTUOO0Kz67DpSs9VJThb8HJeppg/Qd1LoTDOkl J3dQQvnND3RCXm6UXdFVlcsH9c6jp+ExBk93hDmHTIcjlp7b7QzapwN/ScvIzW0bPkl0 njjQxE6bzI6hKWVlxilnMjJk0ElMw3joSwkLtU1qTwtUUeMTu5PNzAJvgK0aT4rk1Ne/ R1pt7vbItKsU+rsUmJ6z/dDj1kusUrENcfnIszXsH73HVx3103OAYIN2SxvJpst1KAw7 BClQ== 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=cyybEgMpSadv+IEa6MS0ZoMvktsHCiYhewyjPcXX594=; b=vpAiuaW7Y3R99LaXtNthSrNH7azYXX2uUN/ojLCc3P326OGYTU1XDBj+meTrnwTyIX ODigWROffOuczmXGU+kqhJw17hj/sUkODoO3Y/F8ojG82g/HBWI07N8pae3FAp3ukBBp l5YbuAs40sYHpIrSbRPeHChBQl8ya0WFzjA6tSSAz4xhCaeVKPa7nn2MUBECsFTYEcZq h49KEhoR3p1uYJdWxYzTohyfW8pjKEGsWHXWgCezmqD06WKtzi/UU7kd0TjX2LhnTB2t q2K9LP0QDnSvwq4wdaacNx0PeYXFijYifTpBVwbjyLNRLR94qEaQmfUwBdphng6kJkZ/ mfow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B7rbDC83; 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 mm7si691405ejb.704.2020.10.27.03.56.05; Tue, 27 Oct 2020 03:56:27 -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=B7rbDC83; 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 S1726115AbgJ0AC7 (ORCPT + 99 others); Mon, 26 Oct 2020 20:02:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:35488 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2411054AbgJZX4N (ORCPT ); Mon, 26 Oct 2020 19:56:13 -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 9F0CD2151B; Mon, 26 Oct 2020 23:56:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603756571; bh=VolI0NG8ZRfMBdojfYaKtxeTYyglur0QxGNK8tJCbK8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B7rbDC83tUb3Q6bfS8odjx6fLWKeIdPUABgowbFFl698aFyTZ0JfIcgyB4Na3WAVT QBT7xdLE/tdY1yLdDNY+hn2o3Igrbx5yz/+8p7AHU39Ydw1/nHL3RhYoyPezCIW+xy m22PoQxW4LbvLN8kf3O8CFcgEYB48RSHVWvLF8sk= 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.4 45/80] xfs: don't free rt blocks when we're doing a REMAP bunmapi call Date: Mon, 26 Oct 2020 19:54:41 -0400 Message-Id: <20201026235516.1025100-45-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20201026235516.1025100-1-sashal@kernel.org> References: <20201026235516.1025100-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 f8db3fe616df9..c114d24be6193 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4985,20 +4985,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