From patchwork Fri Oct 25 06:36:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13850105 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E9ABD18DF85 for ; Fri, 25 Oct 2024 06:36:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838215; cv=none; b=G/sLwSlZYsZv71jwG/NcsLHNXawhIoNxrXV5wFUCh8neDt+YsYkPVcuDoOG1Oe5Ngujlcu5ewhK70HqNSgHrO22wWqp/Mq2tTxbiwOS+X7NUw+NNUdhNuYAUp7isoxiiBKbflV66EMmlm37N+EdmUPQPJRtq0MiYclKKjKTiJFo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838215; c=relaxed/simple; bh=NgO7z3TYt2jtT1+faAZdwvuECjOqF94AKAkKPZNbpKc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MaiTjjaYjUVC6ORm+5SBFTPfTxl/VwnC3IgQ4vPY5YAkvcouV+R4+S6x1y8s2yuarD7GsfN62aoNXHeOTV363uKn3Yy1+Imeg+m26iRvgffUiqM6XPR4sDAzjWjzuc/XkoBvwmhcf0lFoD8w5d8wGjbSSDCUxAaVzMZBrQpwhRg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Sy9/Ov4p; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Sy9/Ov4p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9058EC4CEC3; Fri, 25 Oct 2024 06:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729838214; bh=NgO7z3TYt2jtT1+faAZdwvuECjOqF94AKAkKPZNbpKc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Sy9/Ov4pK6juoZjoPjtlLKcG9xUpIB7fNdVTo9eKnWF/11PuUsBfHg8bAy6otExjJ J8qgFMBknxmF509P3PLCo5nUh/RVRHUQoOO/4QSeLFpd77tk0VGI2cnOq25IlB4h1Z Kge87U3EjydgUzkhtSHdZtIltqNWY5eGdH2S0zPoAQviK1YsaghHv2TLQ0enELeE18 G8AT7JezyoPyfGzay/zyI8cz+xevYq3myW7XsaaVN+vX0mOYuGjeTqQcDWUEZPKXZx iczjY1LThOJAmsFJFX10CQCsAnhM61CDNN5hz3KlmX44zna37c2a57ptuMchQWzd3p lLAbpN73wjNsg== Date: Thu, 24 Oct 2024 23:36:54 -0700 Subject: [PATCH 1/6] xfs_repair: checking rt free space metadata must happen during phase 4 From: "Darrick J. Wong" To: cem@kernel.org, aalbersh@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172983774454.3041643.14059149217223950457.stgit@frogsfrogsfrogs> In-Reply-To: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> References: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Darrick J. Wong Back in the really old days, xfs_repair would generate the new free space information for the realtime section during phase 5, and write the contents to the rtbitmap and summary files during phase 6. This was ok because the incore information isn't used until phase 6. Then I changed the behavior to check the generated information against what was on disk and complain about the discrepancies. Unfortunately, there was a subtle flaw here -- for a non -n run, we'll have regenerated the AG metadata before we actually check the rt free space information. If the AG btree regeneration should clobber one of the old rtbitmap or summary blocks, this will be reported as a corruption even though nothing's wrong. Move check_rtmetadata to the end of phase 4 so that this doesn't happen. Cc: # v5.19.0 Fixes: f2e388616d7491 ("xfs_repair: check free rt extent count") Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/phase4.c | 7 +++++++ repair/phase5.c | 6 ------ repair/xfs_repair.c | 3 --- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/repair/phase4.c b/repair/phase4.c index 5e5d8c3c7d9b96..071f20ed736e4b 100644 --- a/repair/phase4.c +++ b/repair/phase4.c @@ -401,4 +401,11 @@ phase4(xfs_mount_t *mp) */ quotino_check(mp); quota_sb_check(mp); + + /* Check the rt metadata before we rebuild */ + if (mp->m_sb.sb_rblocks) { + do_log( + _(" - generate realtime summary info and bitmap...\n")); + check_rtmetadata(mp); + } } diff --git a/repair/phase5.c b/repair/phase5.c index d18ec095b0524b..9207da7172c05b 100644 --- a/repair/phase5.c +++ b/repair/phase5.c @@ -694,12 +694,6 @@ phase5(xfs_mount_t *mp) free(sb_ifree_ag); free(sb_fdblocks_ag); - if (mp->m_sb.sb_rblocks) { - do_log( - _(" - generate realtime summary info and bitmap...\n")); - check_rtmetadata(mp); - } - do_log(_(" - reset superblock...\n")); /* diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index e325d61f10367e..3ade85bbcbb7fd 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -1318,9 +1318,6 @@ main(int argc, char **argv) if (no_modify) { printf(_("No modify flag set, skipping phase 5\n")); - - if (mp->m_sb.sb_rblocks > 0) - check_rtmetadata(mp); } else { phase5(mp); } From patchwork Fri Oct 25 06:37:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13850106 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 55D5118C935 for ; Fri, 25 Oct 2024 06:37:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838230; cv=none; b=ZGMYMIKWWrTymv7DOJugh8bFV0BAcW2ZibIqhn7aSd3LFnn2PYVK6AW+BC0KptW4nPujZruvl7uIHzZJEgh994MbgT93RfKaRF4+xKjSaCR2Qqmx090IvXwosAWhSb7CP5zkP/eZqDjbD7CnR1rpN0p0eXHItghk6jrpN7cAE8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838230; c=relaxed/simple; bh=/rPgtyWDqZuKbDXvkpgoOAHAfCL7gvGUGLEZgWay05I=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hIy9XmcU/0QEZexH+S6EccNNo0PbPoCxfW8VErGpuLWMT/aqf7DrCdkVToxC+AziV4mnL6BiJFEUQcwUixpS5gcq6hWcJuuB/EjJqEvC3DxDi9TO5xYRoWS225SxBBTSriRwwfTBeGyJDVvqa8CeRO+UN/xE2HAGfUeRn9hSC18= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tAIS8X/K; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tAIS8X/K" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33B99C4CEC3; Fri, 25 Oct 2024 06:37:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729838230; bh=/rPgtyWDqZuKbDXvkpgoOAHAfCL7gvGUGLEZgWay05I=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=tAIS8X/KlzeplMAmw9LRtbGlkHTCFC/kcFQ+8UHFx4OhjRp674DbkNNBADHmgT+DC 48lXB5PVfHFffmRxs8HNCV3fbq2DE/QtkEFNSl2GWz4vz+ajRInl6iDK9qQGftmeQC dYtKejXa925+lqZ5JevVaGskuxoreLZZFTHLBdktBHf+54lBpSnjRNhzrUNrQSHhw3 y6cWf4zv4C7aFSU8zqNqVzyte7Ao+ilB20sZ/c2sdXe0uKIKaK3oTqvBo6GVPftzw2 FpnatTEptKj6NqJ+NObZFRiY2X5JJx5nFkOEeiXW5s7kpgntbzwEq+Vf7Li7TlRKhx xMtVB/ygfrvMg== Date: Thu, 24 Oct 2024 23:37:09 -0700 Subject: [PATCH 2/6] xfs_repair: use xfs_validate_rt_geometry From: "Darrick J. Wong" To: cem@kernel.org, aalbersh@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172983774469.3041643.11171513742936148834.stgit@frogsfrogsfrogs> In-Reply-To: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> References: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Use shared libxfs code with the kernel instead of reimplementing it. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/libxfs_api_defs.h | 1 + repair/sb.c | 40 ++-------------------------------------- 2 files changed, 3 insertions(+), 38 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index a4173e5f7a595c..7c08d766623c0c 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -309,6 +309,7 @@ #define xfs_update_secondary_sbs libxfs_update_secondary_sbs +#define xfs_validate_rt_geometry libxfs_validate_rt_geometry #define xfs_validate_stripe_geometry libxfs_validate_stripe_geometry #define xfs_verify_agbno libxfs_verify_agbno #define xfs_verify_agbext libxfs_verify_agbext diff --git a/repair/sb.c b/repair/sb.c index 4b49c1b33c6c83..1320929caee590 100644 --- a/repair/sb.c +++ b/repair/sb.c @@ -447,44 +447,8 @@ verify_sb(char *sb_buf, xfs_sb_t *sb, int is_primary_sb) return(XR_BAD_SECT_SIZE_DATA); } - /* - * real-time extent size is always set - */ - if (sb->sb_rextsize * sb->sb_blocksize > XFS_MAX_RTEXTSIZE) - return(XR_BAD_RT_GEO_DATA); - - if (sb->sb_rextsize * sb->sb_blocksize < XFS_MIN_RTEXTSIZE) - return(XR_BAD_RT_GEO_DATA); - - if (sb->sb_rblocks == 0) { - if (sb->sb_rextents != 0) - return(XR_BAD_RT_GEO_DATA); - - if (sb->sb_rbmblocks != 0) - return(XR_BAD_RT_GEO_DATA); - - if (sb->sb_rextslog != 0) - return(XR_BAD_RT_GEO_DATA); - - if (sb->sb_frextents != 0) - return(XR_BAD_RT_GEO_DATA); - } else { - /* - * if we have a real-time partition, sanity-check geometry - */ - if (sb->sb_rblocks / sb->sb_rextsize != sb->sb_rextents) - return(XR_BAD_RT_GEO_DATA); - - if (sb->sb_rextents == 0) - return XR_BAD_RT_GEO_DATA; - - if (sb->sb_rextslog != libxfs_compute_rextslog(sb->sb_rextents)) - return(XR_BAD_RT_GEO_DATA); - - if (sb->sb_rbmblocks != (xfs_extlen_t) howmany(sb->sb_rextents, - NBBY * sb->sb_blocksize)) - return(XR_BAD_RT_GEO_DATA); - } + if (!libxfs_validate_rt_geometry(sb)) + return XR_BAD_RT_GEO_DATA; /* * verify correctness of inode alignment if it's there From patchwork Fri Oct 25 06:37:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13850107 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0183D18C935 for ; Fri, 25 Oct 2024 06:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838246; cv=none; b=EpSc3UmYsRwX1Hnc66tf41e2Lsr8wB+PGNkjqCJJ3VHneQ558qqIOA4NWCxQk4MmVRAcF5rwCttPl6v/+3C8jcvfXgq4NtMGrU25gA7GGZCTH3LV/V/oixM6PCOUa42xO3Lsn1KKh2D+uCJBokW0KGMLFr/ILM4ax9uoRsk/WnQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838246; c=relaxed/simple; bh=UjNpHV+k9RorUDh45wvtXOvZiBxlhSv06rMjJTZC6RA=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Fl2rIdMiGsJddAcdgz7yLzgG2ybcIRbX/m9yPmoxVjkVoHtke6i3+iqqS6h6TF3wvnVu/yE1DMHW4a0L5r+wzt3bI0W4m+DIwcCFtKfKUkfJbHOhr6fhXKL9JoRZP9CbG19nYlaPP8YChAT6qDuia7g+8HWccnQqD6iEOHal6OY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gzmLX1hL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gzmLX1hL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C5DD1C4CEC3; Fri, 25 Oct 2024 06:37:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729838245; bh=UjNpHV+k9RorUDh45wvtXOvZiBxlhSv06rMjJTZC6RA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=gzmLX1hLCOmg0bLvA4srh5aw7l6lueh/FBIqTtclybgJArDeyEf0OfdjG66qJgbqZ Bw2gaRXNl0s7gpQhvaEEx6KfDujP/XxrLEe79L4zZrdmOn4pzG3j+/IDo6ePVK1+6T LDLrsM6azvRgql8j78tNv5x5HyISTyOoLeyNGYQtZ/x6KlS9viykgcR1FUWMG3Dzce hkRJ7AavBWR1Xeuxs6H0klKyJE4kgAMNuGBjrWaiajvcNdU8MRTth8MTnCixCnUEZg mLoaa9oNIFYvPfEMdOBTyEZ9E78glHMmSJ9qpTcm75nvy2yoH1FvOHb9yF6adGuEsK 6oU5IXoGHI3Iw== Date: Thu, 24 Oct 2024 23:37:25 -0700 Subject: [PATCH 3/6] mkfs: remove a pointless rtfreesp_init forward declaration From: "Darrick J. Wong" To: cem@kernel.org, aalbersh@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172983774485.3041643.1809910276287170254.stgit@frogsfrogsfrogs> In-Reply-To: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> References: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- mkfs/proto.c | 1 - 1 file changed, 1 deletion(-) diff --git a/mkfs/proto.c b/mkfs/proto.c index 06010980c5b313..9d21f027c0b174 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -18,7 +18,6 @@ static struct xfs_trans * getres(struct xfs_mount *mp, uint blocks); static void rsvfile(xfs_mount_t *mp, xfs_inode_t *ip, long long len); static char *newregfile(char **pp, int *len); static void rtinit(xfs_mount_t *mp); -static void rtfreesp_init(struct xfs_mount *mp); static long filesize(int fd); static int slashes_are_spaces; From patchwork Fri Oct 25 06:37:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13850111 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF4701A4F2F for ; Fri, 25 Oct 2024 06:37:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838262; cv=none; b=QGvqEjJagIDOCAbZZWeoprIZBRTiZnLjsz1vmn/EFv65MMFeqY1nAcev5aNjPcxRX+VlgvOB+k4YIaBz16cxFcg0YoxvkxIFA6Oqy12vCSlGa5U0nFca2bxk8ByWRg0Jx+w8oAdbNsARr00KUHchXH+2ol4/LSuwp9+Vzp6t3Vg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838262; c=relaxed/simple; bh=HrJ28cuS1uvF/SMNvwsDMxgAV5KLnCXbMMF7GvmCmKw=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=V+7a8CxkUBmq+fN3ZNgN+xZUlxodNRIYPJ/tA2eFllZIHiIHuTtXkPsu+HIN7mDffMiubNgDVS7/NWV02CqAW1oI4QE/XC4qYbnA4/0JzYvCvK6ghdH5SFDXUkl7U8BJv8DYw8FzixECeY9cMwHnT0fH89Gf+1ig5xVYzq9P8T4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=czTovTc/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="czTovTc/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64608C4CEC3; Fri, 25 Oct 2024 06:37:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729838261; bh=HrJ28cuS1uvF/SMNvwsDMxgAV5KLnCXbMMF7GvmCmKw=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=czTovTc/HCNq2tiu3GtBTXr3epkpLYxtjubkMA4xUtD0AJRI09ur0KsWitbH7rPM+ TODeL0R2RwiG+C0aFJtH4i6Qcnz5hL9tvJqsFzfO/fVNAyXCOFh5078ir5DbQev8PT ThVBQfUX9WO3M7enFsGYTOH8IG1hf54mRYUDdB+SyVR70IJFqlD9Xcu3bYvbqp6fzO KmQSy7luxClEV/Vv8QOBb7cy5XEPEmk5Nv1ewIXCUINfr6mNFMMzecpOLlMF0DPbKa RfZw/vqVF5cD9EVq7Ro3cP3y+Ck5uC/aWb6UiVSZ1adj+0PxL9ehOLJ08iGUoDpVSh BecINNwWNU2WA== Date: Thu, 24 Oct 2024 23:37:40 -0700 Subject: [PATCH 4/6] mkfs: use xfs_rtfile_initialize_blocks From: "Darrick J. Wong" To: cem@kernel.org, aalbersh@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172983774500.3041643.17973290321317681320.stgit@frogsfrogsfrogs> In-Reply-To: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> References: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Use the new libxfs helper for initializing the rtbitmap/summary files for rtgroup-enabled file systems. Also skip the zeroing of the blocks for rtgroup file systems as we'll overwrite every block instantly. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- libxfs/libxfs_api_defs.h | 1 mkfs/proto.c | 106 +++++++--------------------------------------- 2 files changed, 17 insertions(+), 90 deletions(-) diff --git a/libxfs/libxfs_api_defs.h b/libxfs/libxfs_api_defs.h index 7c08d766623c0c..c5682504e41a66 100644 --- a/libxfs/libxfs_api_defs.h +++ b/libxfs/libxfs_api_defs.h @@ -263,6 +263,7 @@ #define xfs_suminfo_add libxfs_suminfo_add #define xfs_suminfo_get libxfs_suminfo_get #define xfs_rtsummary_wordcount libxfs_rtsummary_wordcount +#define xfs_rtfile_initialize_blocks libxfs_rtfile_initialize_blocks #define xfs_rtfree_extent libxfs_rtfree_extent #define xfs_rtfree_blocks libxfs_rtfree_blocks diff --git a/mkfs/proto.c b/mkfs/proto.c index 9d21f027c0b174..d8eb6ca33672bd 100644 --- a/mkfs/proto.c +++ b/mkfs/proto.c @@ -819,94 +819,6 @@ rtsummary_create( ihold(VFS_I(ip)); } -/* Zero the realtime bitmap. */ -static void -rtbitmap_init( - struct xfs_mount *mp) -{ - struct xfs_bmbt_irec map[XFS_BMAP_MAX_NMAP]; - struct xfs_trans *tp; - struct xfs_bmbt_irec *ep; - xfs_fileoff_t bno; - uint blocks; - int i; - int nmap; - int error; - - blocks = mp->m_sb.sb_rbmblocks + - XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1; - error = -libxfs_trans_alloc_rollable(mp, blocks, &tp); - if (error) - res_failed(error); - - libxfs_trans_ijoin(tp, mp->m_rbmip, 0); - bno = 0; - while (bno < mp->m_sb.sb_rbmblocks) { - nmap = XFS_BMAP_MAX_NMAP; - error = -libxfs_bmapi_write(tp, mp->m_rbmip, bno, - (xfs_extlen_t)(mp->m_sb.sb_rbmblocks - bno), - 0, mp->m_sb.sb_rbmblocks, map, &nmap); - if (error) - fail(_("Allocation of the realtime bitmap failed"), - error); - - for (i = 0, ep = map; i < nmap; i++, ep++) { - libxfs_device_zero(mp->m_ddev_targp, - XFS_FSB_TO_DADDR(mp, ep->br_startblock), - XFS_FSB_TO_BB(mp, ep->br_blockcount)); - bno += ep->br_blockcount; - } - } - - error = -libxfs_trans_commit(tp); - if (error) - fail(_("Block allocation of the realtime bitmap inode failed"), - error); -} - -/* Zero the realtime summary file. */ -static void -rtsummary_init( - struct xfs_mount *mp) -{ - struct xfs_bmbt_irec map[XFS_BMAP_MAX_NMAP]; - struct xfs_trans *tp; - struct xfs_bmbt_irec *ep; - xfs_fileoff_t bno; - uint blocks; - int i; - int nmap; - int error; - - blocks = mp->m_rsumblocks + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1; - error = -libxfs_trans_alloc_rollable(mp, blocks, &tp); - if (error) - res_failed(error); - libxfs_trans_ijoin(tp, mp->m_rsumip, 0); - - bno = 0; - while (bno < mp->m_rsumblocks) { - nmap = XFS_BMAP_MAX_NMAP; - error = -libxfs_bmapi_write(tp, mp->m_rsumip, bno, - (xfs_extlen_t)(mp->m_rsumblocks - bno), - 0, mp->m_rsumblocks, map, &nmap); - if (error) - fail(_("Allocation of the realtime summary failed"), - error); - - for (i = 0, ep = map; i < nmap; i++, ep++) { - libxfs_device_zero(mp->m_ddev_targp, - XFS_FSB_TO_DADDR(mp, ep->br_startblock), - XFS_FSB_TO_BB(mp, ep->br_blockcount)); - bno += ep->br_blockcount; - } - } - error = -libxfs_trans_commit(tp); - if (error) - fail(_("Block allocation of the realtime summary inode failed"), - error); -} - /* * Free the whole realtime area using transactions. * Do one transaction per bitmap block. @@ -920,6 +832,22 @@ rtfreesp_init( xfs_rtxnum_t ertx; int error; + /* + * First zero the realtime bitmap and summary files. + */ + error = -libxfs_rtfile_initialize_blocks(mp->m_rbmip, 0, + mp->m_sb.sb_rbmblocks, NULL); + if (error) + fail(_("Initialization of rtbitmap inode failed"), error); + + error = -libxfs_rtfile_initialize_blocks(mp->m_rsumip, 0, + mp->m_rsumblocks, NULL); + if (error) + fail(_("Initialization of rtsummary inode failed"), error); + + /* + * Then free the blocks into the allocator, one bitmap block at a time. + */ for (rtx = 0; rtx < mp->m_sb.sb_rextents; rtx = ertx) { error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_itruncate, 0, 0, 0, &tp); @@ -953,8 +881,6 @@ rtinit( create_sb_metadata_file(mp, rtbitmap_create); create_sb_metadata_file(mp, rtsummary_create); - rtbitmap_init(mp); - rtsummary_init(mp); rtfreesp_init(mp); } From patchwork Fri Oct 25 06:37:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13850112 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71D531A3AB9 for ; Fri, 25 Oct 2024 06:37:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838277; cv=none; b=s45Pd+G9zyVOhU6Iql3zRUsq8gDW7wzRnL3fEsqQ/9is2VCM+QZByOtg6toJtNIEIMxjn8Cr3JBb8cww52NB0LV8otzjb4G7aZg7HNkphqw4GAP1z+CfiQqbsqD0MMlAwa6i1nNG7g0nogJcQw9n6b5W+9oxy56l1DNB30SBRyQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838277; c=relaxed/simple; bh=xEOiA3GlXGGIbYMUXDQ9vw3RahS7fPrF7pQfmD+JO3U=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jA/oFuHTk08Pd1vQJWTjE00KEyeXJWUksmCGhNVH5mydy9EW3IrjN4y0FN3c6T7Gz7ZLZL2K7LFamXGqHMvkrii3p1tpBYGw3d05K71mrEJVt1G1K19qCkd+x+yva0jhRGXvnMZWtKUq+DoVArUqcSgZ/9lHEpVSrE+lb6nllpY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=aoygsbbB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="aoygsbbB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0ED53C4CEC3; Fri, 25 Oct 2024 06:37:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729838277; bh=xEOiA3GlXGGIbYMUXDQ9vw3RahS7fPrF7pQfmD+JO3U=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=aoygsbbBo+duZE0mdecCeePx2Dp4iKog0eWawBiMToPnZ1E9sSABP3z9B7PG945ut A6OssoEnaRnhm+wJCMsHPqQhsZzDWCChI5PRXckWS5EMzLlvCsuZWbSvovR7m9Iply LnwM0TL4HZ3mjFELNAlGr8qfN75J41eGyFQylNiPh+06c/LBBvKZ+ZoM2Da3ijiNtE +InkOks9pz8BEE8IEsUz5DgWsOXDCqrzYKTpSK0E2X3bG/ebRUZZlGdZdLb485yCoz sHG9WU/0eklXLs+8mii7QjJA1rdr91v5Zm8yGSiAeYOoAB/HqbuO0Qsqd8HZMzAO5X ZsbyLyeTlg2Ag== Date: Thu, 24 Oct 2024 23:37:56 -0700 Subject: [PATCH 5/6] xfs_repair: use libxfs_rtfile_initialize_blocks From: "Darrick J. Wong" To: cem@kernel.org, aalbersh@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172983774514.3041643.10169739076819272552.stgit@frogsfrogsfrogs> In-Reply-To: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> References: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Use libxfs_rtfile_initialize_blocks to write the re-computed rtbitmap and rtsummary contents. This removes duplicate code and prepares for even more sharing once the rtgroup features adds a metadata header to the rtbitmap and rtsummary blocks. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- repair/phase6.c | 168 ++++++++++--------------------------------------------- 1 file changed, 32 insertions(+), 136 deletions(-) diff --git a/repair/phase6.c b/repair/phase6.c index c96b50cf6a69dd..310a2b9c07bff0 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -547,157 +547,60 @@ mk_rbmino(xfs_mount_t *mp) libxfs_irele(ip); } -static int -fill_rbmino(xfs_mount_t *mp) +static void +fill_rbmino( + struct xfs_mount *mp) { - struct xfs_buf *bp; - xfs_trans_t *tp; - xfs_inode_t *ip; - union xfs_rtword_raw *bmp; - int nmap; - int error; - xfs_fileoff_t bno; - xfs_bmbt_irec_t map; - - bmp = btmcompute; - bno = 0; + struct xfs_trans *tp; + struct xfs_inode *ip; + int error; error = -libxfs_trans_alloc_rollable(mp, 10, &tp); if (error) res_failed(error); error = -libxfs_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip); - if (error) { + libxfs_trans_cancel(tp); + if (error) do_error( - _("couldn't iget realtime bitmap inode -- error - %d\n"), - error); - } - - while (bno < mp->m_sb.sb_rbmblocks) { - struct xfs_rtalloc_args args = { - .mp = mp, - .tp = tp, - }; - union xfs_rtword_raw *ondisk; - - /* - * fill the file one block at a time - */ - nmap = 1; - error = -libxfs_bmapi_write(tp, ip, bno, 1, 0, 1, &map, &nmap); - if (error || nmap != 1) { - do_error( - _("couldn't map realtime bitmap block %" PRIu64 ", error = %d\n"), - bno, error); - } - - ASSERT(map.br_startblock != HOLESTARTBLOCK); - - error = -libxfs_trans_read_buf( - mp, tp, mp->m_dev, - XFS_FSB_TO_DADDR(mp, map.br_startblock), - XFS_FSB_TO_BB(mp, 1), 1, &bp, NULL); - - if (error) { - do_warn( -_("can't access block %" PRIu64 " (fsbno %" PRIu64 ") of realtime bitmap inode %" PRIu64 "\n"), - bno, map.br_startblock, mp->m_sb.sb_rbmino); - return(1); - } +_("couldn't iget realtime bitmap inode, error %d\n"), error); - args.rbmbp = bp; - ondisk = xfs_rbmblock_wordptr(&args, 0); - memcpy(ondisk, bmp, mp->m_blockwsize << XFS_WORDLOG); - - libxfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); - - bmp += mp->m_blockwsize; - bno++; - } - - libxfs_trans_ijoin(tp, ip, 0); - error = -libxfs_trans_commit(tp); + error = -libxfs_rtfile_initialize_blocks(ip, 0, mp->m_sb.sb_rbmblocks, + btmcompute); if (error) - do_error(_("%s: commit failed, error %d\n"), __func__, error); + do_error( +_("couldn't re-initialize realtime bitmap inode, error %d\n"), error); + libxfs_irele(ip); - return(0); } -static int -fill_rsumino(xfs_mount_t *mp) +static void +fill_rsumino( + struct xfs_mount *mp) { - struct xfs_buf *bp; - xfs_trans_t *tp; - xfs_inode_t *ip; - union xfs_suminfo_raw *smp; - int nmap; - int error; - xfs_fileoff_t bno; - xfs_bmbt_irec_t map; - - smp = sumcompute; - bno = 0; + struct xfs_trans *tp; + struct xfs_inode *ip; + int error; error = -libxfs_trans_alloc_rollable(mp, 10, &tp); if (error) res_failed(error); error = -libxfs_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip); - if (error) { + libxfs_trans_cancel(tp); + if (error) do_error( - _("couldn't iget realtime summary inode -- error - %d\n"), - error); - } - - while (bno < mp->m_rsumblocks) { - struct xfs_rtalloc_args args = { - .mp = mp, - .tp = tp, - }; - union xfs_suminfo_raw *ondisk; - - /* - * fill the file one block at a time - */ - nmap = 1; - error = -libxfs_bmapi_write(tp, ip, bno, 1, 0, 1, &map, &nmap); - if (error || nmap != 1) { - do_error( - _("couldn't map realtime summary inode block %" PRIu64 ", error = %d\n"), - bno, error); - } - - ASSERT(map.br_startblock != HOLESTARTBLOCK); - - error = -libxfs_trans_read_buf( - mp, tp, mp->m_dev, - XFS_FSB_TO_DADDR(mp, map.br_startblock), - XFS_FSB_TO_BB(mp, 1), 1, &bp, NULL); - - if (error) { - do_warn( -_("can't access block %" PRIu64 " (fsbno %" PRIu64 ") of realtime summary inode %" PRIu64 "\n"), - bno, map.br_startblock, mp->m_sb.sb_rsumino); - libxfs_irele(ip); - return(1); - } +_("couldn't iget realtime summary inode, error %d\n"), error); - args.sumbp = bp; - ondisk = xfs_rsumblock_infoptr(&args, 0); - memcpy(ondisk, smp, mp->m_blockwsize << XFS_WORDLOG); - - libxfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1); - - smp += mp->m_blockwsize; - bno++; - } - - libxfs_trans_ijoin(tp, ip, 0); - error = -libxfs_trans_commit(tp); + mp->m_rsumip = ip; + error = -libxfs_rtfile_initialize_blocks(ip, 0, mp->m_rsumblocks, + sumcompute); + mp->m_rsumip = NULL; if (error) - do_error(_("%s: commit failed, error %d\n"), __func__, error); + do_error( +_("couldn't re-initialize realtime summary inode, error %d\n"), error); + libxfs_irele(ip); - return(0); } static void @@ -3302,15 +3205,8 @@ phase6(xfs_mount_t *mp) if (!no_modify) { do_log( _(" - resetting contents of realtime bitmap and summary inodes\n")); - if (fill_rbmino(mp)) { - do_warn( - _("Warning: realtime bitmap may be inconsistent\n")); - } - - if (fill_rsumino(mp)) { - do_warn( - _("Warning: realtime bitmap may be inconsistent\n")); - } + fill_rbmino(mp); + fill_rsumino(mp); } mark_standalone_inodes(mp); From patchwork Fri Oct 25 06:38:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13850113 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 25E2718C935 for ; Fri, 25 Oct 2024 06:38:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838293; cv=none; b=GtAOHuO1LZ7qMmqnZhQhfsrCF1rnRtcpszGN938Jn6LiH7BMl+s26TPkViC6tKxPZlIgZXhmlCrSDwybv1xopNdlPXtb4nvxW0ZLXoqJWVYiZBeEhn1OKgM2BBOmKwDz+uzqECK69LOyPwTp5lsnxt1mnJ/Q3wbBKMz0lfAlUBw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729838293; c=relaxed/simple; bh=rMS04JzWbTA10NoNgT1uDwTz6/mlMY+uwx8e75a0h5c=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TX9VDDmPSzW5Dl0bmD69rNleoEgqGiS/gQLRKhzM9SEbuJqi2h0nGx22RGC4Bngd/XmYP1DmSc02ezYK+z9XLmZUUIiaFAPLcuGZ1Lm73I5rAeobFkKFhPem+LCZxz1eCmdl0Op1+LWjO8rFUvWgFZNok+7Vu/0Pg52EaaYKLYk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y9F7BrdT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y9F7BrdT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3B57C4CEC3; Fri, 25 Oct 2024 06:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729838292; bh=rMS04JzWbTA10NoNgT1uDwTz6/mlMY+uwx8e75a0h5c=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=Y9F7BrdTNGbk5s24VgPJQk6MT5G/mrjDbIblknYWmMM6aLWT/zz4ylotEOvqjBnxm EOzpptBtHw38VqLt+DjzEHi9pRTGBmdIoiG5GsZXJNASUwJT1+p0iJsc4/n5TaXVpg VHpB9IT6IDJ0+B2UXXvxe4ffaSilpB7mQ0MhbUqLXBkcq6+lxe3sw/OfvMdHUJyML9 nymFJLVAJWGWVqjwRbUJOvcEAMRF7Q/Wxt8arbvWxuLcmJCg0trcht4yYnVoiqRrv2 6kqzK+HOCywvGofkSK1/3lwwzZe5zJe/5ZYrb1WwdOOvf7qF5hYVHrQY90mZ82RzYl bDQmMPuDdzRAA== Date: Thu, 24 Oct 2024 23:38:12 -0700 Subject: [PATCH 6/6] xfs_repair: stop preallocating blocks in mk_rbmino and mk_rsumino From: "Darrick J. Wong" To: cem@kernel.org, aalbersh@kernel.org, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, hch@lst.de Message-ID: <172983774529.3041643.15165877380135579779.stgit@frogsfrogsfrogs> In-Reply-To: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> References: <172983774433.3041643.7410184047224484972.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Christoph Hellwig Now that repair is using libxfs_rtfile_initialize_blocks to write to the rtbitmap and rtsummary inodes, space allocation is already taken care of that helper and there is no need to preallocate it. Remove the code to do so. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong --- repair/phase6.c | 116 +++++++------------------------------------------------ 1 file changed, 14 insertions(+), 102 deletions(-) diff --git a/repair/phase6.c b/repair/phase6.c index 310a2b9c07bff0..630617ef8ab8fe 100644 --- a/repair/phase6.c +++ b/repair/phase6.c @@ -475,24 +475,16 @@ reset_sbroot_ino( } static void -mk_rbmino(xfs_mount_t *mp) +mk_rbmino( + struct xfs_mount *mp) { - xfs_trans_t *tp; - xfs_inode_t *ip; - xfs_bmbt_irec_t *ep; - int i; - int nmap; - int error; - xfs_fileoff_t bno; - xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP]; - uint blocks; + struct xfs_trans *tp; + struct xfs_inode *ip; + int error; - /* - * first set up inode - */ - i = -libxfs_trans_alloc_rollable(mp, 10, &tp); - if (i) - res_failed(i); + error = -libxfs_trans_alloc_rollable(mp, 10, &tp); + if (error) + res_failed(error); error = -libxfs_iget(mp, tp, mp->m_sb.sb_rbmino, 0, &ip); if (error) { @@ -508,42 +500,6 @@ mk_rbmino(xfs_mount_t *mp) error = -libxfs_trans_commit(tp); if (error) do_error(_("%s: commit failed, error %d\n"), __func__, error); - - /* - * then allocate blocks for file and fill with zeroes (stolen - * from mkfs) - */ - blocks = mp->m_sb.sb_rbmblocks + - XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1; - error = -libxfs_trans_alloc_rollable(mp, blocks, &tp); - if (error) - res_failed(error); - - libxfs_trans_ijoin(tp, ip, 0); - bno = 0; - while (bno < mp->m_sb.sb_rbmblocks) { - nmap = XFS_BMAP_MAX_NMAP; - error = -libxfs_bmapi_write(tp, ip, bno, - (xfs_extlen_t)(mp->m_sb.sb_rbmblocks - bno), - 0, mp->m_sb.sb_rbmblocks, map, &nmap); - if (error) { - do_error( - _("couldn't allocate realtime bitmap, error = %d\n"), - error); - } - for (i = 0, ep = map; i < nmap; i++, ep++) { - libxfs_device_zero(mp->m_ddev_targp, - XFS_FSB_TO_DADDR(mp, ep->br_startblock), - XFS_FSB_TO_BB(mp, ep->br_blockcount)); - bno += ep->br_blockcount; - } - } - error = -libxfs_trans_commit(tp); - if (error) { - do_error( - _("allocation of the realtime bitmap failed, error = %d\n"), - error); - } libxfs_irele(ip); } @@ -606,22 +562,13 @@ _("couldn't re-initialize realtime summary inode, error %d\n"), error); static void mk_rsumino(xfs_mount_t *mp) { - xfs_trans_t *tp; - xfs_inode_t *ip; - xfs_bmbt_irec_t *ep; - int i; - int nmap; - int error; - xfs_fileoff_t bno; - xfs_bmbt_irec_t map[XFS_BMAP_MAX_NMAP]; - uint blocks; + struct xfs_trans *tp; + struct xfs_inode *ip; + int error; - /* - * first set up inode - */ - i = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 10, 0, 0, &tp); - if (i) - res_failed(i); + error = -libxfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 10, 0, 0, &tp); + if (error) + res_failed(error); error = -libxfs_iget(mp, tp, mp->m_sb.sb_rsumino, 0, &ip); if (error) { @@ -637,41 +584,6 @@ mk_rsumino(xfs_mount_t *mp) error = -libxfs_trans_commit(tp); if (error) do_error(_("%s: commit failed, error %d\n"), __func__, error); - - /* - * then allocate blocks for file and fill with zeroes (stolen - * from mkfs) - */ - blocks = mp->m_rsumblocks + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) - 1; - error = -libxfs_trans_alloc_rollable(mp, blocks, &tp); - if (error) - res_failed(error); - - libxfs_trans_ijoin(tp, ip, 0); - bno = 0; - while (bno < mp->m_rsumblocks) { - nmap = XFS_BMAP_MAX_NMAP; - error = -libxfs_bmapi_write(tp, ip, bno, - (xfs_extlen_t)(mp->m_rsumblocks - bno), - 0, mp->m_rsumblocks, map, &nmap); - if (error) { - do_error( - _("couldn't allocate realtime summary inode, error = %d\n"), - error); - } - for (i = 0, ep = map; i < nmap; i++, ep++) { - libxfs_device_zero(mp->m_ddev_targp, - XFS_FSB_TO_DADDR(mp, ep->br_startblock), - XFS_FSB_TO_BB(mp, ep->br_blockcount)); - bno += ep->br_blockcount; - } - } - error = -libxfs_trans_commit(tp); - if (error) { - do_error( - _("allocation of the realtime summary ino failed, error = %d\n"), - error); - } libxfs_irele(ip); }