Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp829223pxb; Tue, 3 Nov 2020 13:44:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfni/As9vg3lfAF9mP+6q5EdQgOQaQNXRHH6jNoL3pCUmd7ibJV92W7gWO//GdwD0JdmIi X-Received: by 2002:a17:906:1352:: with SMTP id x18mr18872965ejb.476.1604439896165; Tue, 03 Nov 2020 13:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439896; cv=none; d=google.com; s=arc-20160816; b=aMtxAQd/tG32XWyemL9dtU7PJoqquCxdE8cChPQySe0Cs0R7pqfMG9y2y3GTStSs3t DLw/T6/cCzsHayHKV2RH18zfWdt2UrB1zK6x71m90UoDGHY0EsA6nrSFnuHrGBGKIUD+ Oa8VC1JqkiW4TYtol/f3pkzCMgqWT8ZA4GUQggcgaXRu3Wq2/h10A1TLswJLyvDosAJp LbGgmv6IAHlU5lf26aFWU9/4oqg0Ll8IfxODFJ3Nt+ieaBt4BIOea87BfRVRfEa1MwZB Nzmnh9B6NOXZTasgP0BwzuZZvOZP+mRVJYjwfMJnHf32SZu3xuHCYjNiCIw5ZveMegzm 3hpA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=apCx+lttgyv50/hXCpzFFmvuY4tPKsjQYxIYcpryT90=; b=pmQBxETNMiGtYYso2wjtVdTwRXdFqJVMK7SPJO/nZUGn3tsC1PMU3/90puc+RGeHR7 UrauFfXma2q4ne8VVTvGOGB3lGgLmyYllioasE7DtP7PyneKY6TIeZCoEfFzxhfRHV6J jkTX1Ses+RMxkbI74FIE4m01EA+s5S9GndTOdRYNdD9NB0m5aQdCSu8Eg3FPkOP33103 EpPn4PuLjmvxCqautoMVr02PzBnQ+PvWsualR6DQ+17bDhVfBiVQTbY4iQDCKnqWYr5p 097VMSAHCwo5Rf84YF774AauYGPQM2HFiVRMaBlgSExwgKwboGnQlSGe4jJ8zHKxkZEb wMbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="CX/+naJ0"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si107776ejp.348.2020.11.03.13.44.33; Tue, 03 Nov 2020 13:44:56 -0800 (PST) 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="CX/+naJ0"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732307AbgKCUz1 (ORCPT + 99 others); Tue, 3 Nov 2020 15:55:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:55420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732242AbgKCUzN (ORCPT ); Tue, 3 Nov 2020 15:55:13 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8F8582053B; Tue, 3 Nov 2020 20:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436913; bh=wq5DBJCkBhOeDeG63sfmtQYCwTQmAJnj0LNi+e1pePk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CX/+naJ02vbiLTYwGN0eLd+7RwzrjU7LhEJ+bLq0sSoOgHWRWWdXXa/WyODAKtHTG 4p6i/rZABz+CHpo9Uomin+aYjM3PzacR/GFDPAjJuF0vOv+XcD0LM/mFgktHnfO/3v AZln3Q5YAlbZeuxkZJwVovDqNIxC0/ELll/KxFWA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Christoph Hellwig , Dave Chinner , Sasha Levin Subject: [PATCH 5.4 064/214] xfs: dont free rt blocks when were doing a REMAP bunmapi call Date: Tue, 3 Nov 2020 21:35:12 +0100 Message-Id: <20201103203256.377202168@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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.27.0