Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3269134pxb; Mon, 9 Nov 2020 07:02:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyVZNqgukJAIPHNetLq3tEZEDSfsB2k7jp1CI4TS09O82FWYOkuosP/OQH5Pm3ZBAHC42xx X-Received: by 2002:adf:9507:: with SMTP id 7mr18305272wrs.365.1604934135386; Mon, 09 Nov 2020 07:02:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604934135; cv=none; d=google.com; s=arc-20160816; b=fCSY2lUSYNBpZCriomgQggide10DyC5s1yCLUa5G5z6zLTr6fkf4g45HXGW+AMeJRb yyy5a5icmXKEsHQDcjOvjODG0ZMNIrpGq/uAUnSBioA0fOgFMMKWK4BE9JDxMCOVVXuc golazklMfoBSYtANYHgfjoV1fI3YSOBIdxzcKV7KSPiuETxT6T8VKszg5HdWBEkVqA7n Jz0cWJ20NyAnN+u0HlvyUdRGrzOtFLHScUqjOIHuCKzkycAd8I2vPLNCrtTsxQtLCDCP JyZIWLq6BYeLKqUP21vxL72vACF+Qo5yzqfopWgFi7mdYS0ZOg3ZikTjxUeRjweOvJcb y1oQ== 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=1bMr9wktTyN2iUf85CpKC6nPrYH9nEeWVjwI1octyFI=; b=U43v4ooa0imLFw+eZm/gyuoEDFbqeG6AS1pywJCcdTq7ih5aSRJEWtrKv+XLQRQ4BS v130d1u+PddrQKP24RuvpXm0KP2TT8bN0MIGNZ56rldSmSpTdWtdPlZJn9d9aOG6jzow /xX8Okb/sc7/U2zepXlJid1prVQEozaRJF/4k25n1pMR67KU0hqPKQdQfL1PMXKg056v LatT+Bqg+BYYhnm3+LC3rleJ2lvMkUIII7QW7xet9v3my5vj6S12ltvNleQGAHP+XfPx koXfAUdn8T0YlzbsootJn1TrrU5ZoLuhxSLPH3kBy3n0HC6TKc72HCoJ6lnHpoXkU4nk TkMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pteFpIPQ; 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 pg11si7024468ejb.92.2020.11.09.07.01.40; Mon, 09 Nov 2020 07:02:15 -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=pteFpIPQ; 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 S1730066AbgKINqc (ORCPT + 99 others); Mon, 9 Nov 2020 08:46:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:52020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730025AbgKIM5i (ORCPT ); Mon, 9 Nov 2020 07:57:38 -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 4616620789; Mon, 9 Nov 2020 12:57:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604926657; bh=WzO1IQbu7tkGplJErtDkdXcPt6/7XvSVolon+mwwvN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pteFpIPQtBvYXCCxQqEwfqErE/pyB9AZwqwsqjZpCffRKwwz5G+JS3OxT/Hnws680 cMqmMDrMVZ8fMb4O/dOcsf3gMzhgAKFXgUazAuNHGVxbyeuuaiYFgFmbPkpXOaVsGT +KEgPcf+jN3Rw2IaTWzwJf80irrrppsFw7M0dT/I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Darrick J. Wong" , Chandan Babu R , Sasha Levin Subject: [PATCH 4.4 15/86] xfs: fix realtime bitmap/summary file truncation when growing rt volume Date: Mon, 9 Nov 2020 13:54:22 +0100 Message-Id: <20201109125021.597250892@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125020.852643676@linuxfoundation.org> References: <20201109125020.852643676@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 f4c32e87de7d66074d5612567c5eac7325024428 ] The realtime bitmap and summary files are regular files that are hidden away from the directory tree. Since they're regular files, inode inactivation will try to purge what it thinks are speculative preallocations beyond the incore size of the file. Unfortunately, xfs_growfs_rt forgets to update the incore size when it resizes the inodes, with the result that inactivating the rt inodes at unmount time will cause their contents to be truncated. Fix this by updating the incore size when we change the ondisk size as part of updating the superblock. Note that we don't do this when we're allocating blocks to the rt inodes because we actually want those blocks to get purged if the growfs fails. This fixes corruption complaints from the online rtsummary checker when running xfs/233. Since that test requires rmap, one can also trigger this by growing an rt volume, cycling the mount, and creating rt files. Signed-off-by: Darrick J. Wong Reviewed-by: Chandan Babu R Signed-off-by: Sasha Levin --- fs/xfs/xfs_rtalloc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c index bda5248fc6498..acadeaf72674e 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1017,10 +1017,13 @@ xfs_growfs_rt( xfs_ilock(mp->m_rbmip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, mp->m_rbmip, XFS_ILOCK_EXCL); /* - * Update the bitmap inode's size. + * Update the bitmap inode's size ondisk and incore. We need + * to update the incore size so that inode inactivation won't + * punch what it thinks are "posteof" blocks. */ mp->m_rbmip->i_d.di_size = nsbp->sb_rbmblocks * nsbp->sb_blocksize; + i_size_write(VFS_I(mp->m_rbmip), mp->m_rbmip->i_d.di_size); xfs_trans_log_inode(tp, mp->m_rbmip, XFS_ILOG_CORE); /* * Get the summary inode into the transaction. @@ -1028,9 +1031,12 @@ xfs_growfs_rt( xfs_ilock(mp->m_rsumip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, mp->m_rsumip, XFS_ILOCK_EXCL); /* - * Update the summary inode's size. + * Update the summary inode's size. We need to update the + * incore size so that inode inactivation won't punch what it + * thinks are "posteof" blocks. */ mp->m_rsumip->i_d.di_size = nmp->m_rsumsize; + i_size_write(VFS_I(mp->m_rsumip), mp->m_rsumip->i_d.di_size); xfs_trans_log_inode(tp, mp->m_rsumip, XFS_ILOG_CORE); /* * Copy summary data from old to new sizes. -- 2.27.0