Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp844723pxb; Tue, 3 Nov 2020 14:12:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJxdbiMRWNVg9jzJ/0bpdNTmwNxYVq5zFaVud4xJVo0ei6ZWoCDZEwMSKrm4Urugws3pBvH3 X-Received: by 2002:a50:e087:: with SMTP id f7mr23369468edl.96.1604441552959; Tue, 03 Nov 2020 14:12:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604441552; cv=none; d=google.com; s=arc-20160816; b=CdPIdE3zKs2+nKDV4snpWp33msD7/OYbKWWXInbgl2HImagp/Bk7Elc905Wy7bGFIF BUOlv8ISORHbyMbAgnk5OVj2ZZ5AgJVKdRSFTAow8Two4GC/NMlQgRkdhU1AE6kStRCX MstTieTGsK5GyYhDJk+p2AEhdc4q7Q/GuhKI5HhWi2X9ofQEsQFeYolyjeH1fV6DA4Il ZdAYF2fPAeGEwZJIdMqdwgrmRglTdDqoXCaJ1Bg2lXuXm22E8k4bG5M+xIZ5Bg16X8+K iop435A299o65GSd2gX/rc5cMR7/2ewf20PEawjR74Nd/Opjv45HCOXE2ImNEbl5yHF5 MUpw== 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=JW0ip6GakbHx5veiOl1OBMmaXWQd8M2/zwt81VxM/Cs=; b=GlMxXDCL8wqUPQdRDc3i8UVds5wjWnokU4Xm/+Fng356t+ITP9H0/nipHehMr2Lu8C r9YuyT54CwbqtzOF2JexUlpwTHcjOOP+tvPkBW8/tCPV7CrKsqhbb9ERl6iElirs6B32 DiX/8JKtY72tzkfPZnWx3ieGs4gp5Kc7xK8lDfbimKW5u7vX+NDfS/COjZmtutjIxNir IFjjklbFEYs1g33ARsb0xn6zrDnZ089DA1IqTr7pHMcxfoJ1kFCVO7lzyetjS/mXrPLa 1lcjd3e1kK/JwsGksswkhLCqlw7JwPEWoO+A/kziLZSz/6kTZ4z+hQMPT3qE/RuMnikI Aadw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=K1WALDO+; 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 e13si18576352edj.548.2020.11.03.14.12.10; Tue, 03 Nov 2020 14:12:32 -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=K1WALDO+; 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 S1730197AbgKCUkX (ORCPT + 99 others); Tue, 3 Nov 2020 15:40:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:51612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730181AbgKCUkV (ORCPT ); Tue, 3 Nov 2020 15:40:21 -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 A207C2224E; Tue, 3 Nov 2020 20:40:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436020; bh=RzlbIKFvss9A/9YV6toBMJeyhp4yGEZ++3xFgZMrv84=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K1WALDO+LNm/oU/C3Tyb1L8ylQwOTpK5dKw3iaG58UXNc6Y4r7JZscQEWuHcJRq6h MNWFSTT5tnqaTy1VY4UL1819vqTqoHoMsKwEKSZ/iwg9CAe53Lfvo0HfKdFZbUYhei Z6xA4HiptrtV+dEo3Js4eiCXaOH90ZWDyWKJ24tQ= 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 5.9 069/391] xfs: fix realtime bitmap/summary file truncation when growing rt volume Date: Tue, 3 Nov 2020 21:32:00 +0100 Message-Id: <20201103203351.919324901@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203348.153465465@linuxfoundation.org> References: <20201103203348.153465465@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 0753b1dfd0750..be01bfbc3ad93 100644 --- a/fs/xfs/xfs_rtalloc.c +++ b/fs/xfs/xfs_rtalloc.c @@ -1027,10 +1027,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. @@ -1038,9 +1041,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