Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp819742pxb; Tue, 3 Nov 2020 13:27:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJw0bWLtsTME2eF0DS8eDP+GfMCbTUJpqWAdBT553Hc0qyPaMxDVZ/O2/afgMtDHGBZLj64U X-Received: by 2002:aa7:c2c4:: with SMTP id m4mr15239755edp.66.1604438863453; Tue, 03 Nov 2020 13:27:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604438863; cv=none; d=google.com; s=arc-20160816; b=Wptmi4pujFBUd6mPA3NN7vs/RKvhUUPOr+uSvrwWMmTm7GRrL6Hjgratufvrgz2uZg Nhp2j/jjbPjiZciKAs/nuPAFBJL1VfKTAib/RmuyUU9VACtvpDc6Y/B1MzkU/FTOQA7E D32hs1vpwlv4kBlih/iRqJZ1sQndmu2Qm9rGSUtCrZq0pGK7JvrvgIPhXGry49Ycc3Uz A+EOtijBNbc/CH7JqWI5L/5QN5454y5bE/LSUOJ+MEqdVl7MvEL0V14KlTxrss6fUi/I a9egEhWF2QbnAMmZnr8w+4kxfVKC3Wx92TmkHFfNzZgGTZ5/GHpUsiUTw2xqQ74DzPb8 jsrg== 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=XMoKDVjrmF4Xcc50a9JgbCmeHItoRfMRuQCiRs8t/w4=; b=qTbhi0U93+PJ74CwW1ZmegI9b9WYD+Cs0iskveapEcOaBvGZ2hDRVTiL/H52kTBFUZ J9VXCqThLZH/dBJN3TfUOTy15Ipy+2fUnVWsjRD2UPCxZgO2qJjYH6OrltlwGQpuqjad s6vRDJ8cKJIm4+PByfrtsb88Dn/h6KAScm+zp29idNS20/OQsKH2jQwGyRUov20jn/dO SBB0SUg0RitT48urSMPPdPUSAZyBeNZ/83plSbmVCUF2T/L9+B+UU4crBsFMSvwMp7TA VaZwKc2jQ0weOzkr+VmF4BUM1k7kSu3k61yblPATYyO9kedHKzItvEpCP/0L+4RJXTYi FKsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VIbtFGAD; 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 a2si7694303edn.504.2020.11.03.13.27.20; Tue, 03 Nov 2020 13:27:43 -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=VIbtFGAD; 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 S2388536AbgKCVWw (ORCPT + 99 others); Tue, 3 Nov 2020 16:22:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:43376 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733309AbgKCVFD (ORCPT ); Tue, 3 Nov 2020 16:05:03 -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 2EBDF20658; Tue, 3 Nov 2020 21:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437502; bh=bKFOTbjVA6NiWP2keuxj4jlXt49FXZ0JSbyAGRstkRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VIbtFGADG/b0cQovBMlBUW8AkCT2nLRuSnRa79XPtD6gKfddWbqDM6oqYmGpTIbFG sHTeAl5taXYQmID8dkiCaAXrq6H2puyzQpuXtAxtR42W719g4D9w/2kEAs0+dbwH9o aa9IekPqPa2eM79CYKS3E2Ro55rtTNrOzjxu/aJI= 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 4.19 087/191] xfs: dont free rt blocks when were doing a REMAP bunmapi call Date: Tue, 3 Nov 2020 21:36:19 +0100 Message-Id: <20201103203242.198873703@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@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 f35e1801f1c90..fc9950a505e62 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -4920,20 +4920,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