Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 512722

Summary: gfs_fsck cannot repair rindex problems when directly on blockdevice
Product: Red Hat Enterprise Linux 5 Reporter: Jaroslav Kortus <jkortus>
Component: gfs-utilsAssignee: Robert Peterson <rpeterso>
Status: CLOSED ERRATA QA Contact: Cluster QE <mspqa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 5.4CC: adas, bmarzins, edamato, jcastillo, swhiteho
Target Milestone: rc   
Target Release: 5.5   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gfs-utils-0.1.20-4.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-03-30 08:55:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
gfs_fsck output
none
metadata with one blaster rg entry
none
Proposed patch
none
Revised Patch
none
Try 3 patch none

Description Jaroslav Kortus 2009-07-20 14:51:52 UTC
Created attachment 354356 [details]
gfs_fsck output

Description of problem:
gfs_fsck cannot repair rindex kind of problems when the filesystem is directly on block device (like /dev/sdc1). It works well with LVM device.

Version-Release number of selected component (if applicable):
gfs-utils-0.1.20-1.el5

How reproducible:
100%

Steps to Reproduce:
1. mkfs.gfs -O -t corruption:rgblast -p lock_nolock -j 2 -J 32 -b 4096 /dev/sda10
2. blast (set to zero) first rindex entry
3. run gfs_fsck -y /dev/sda10

Actual results:
rindex cannot be repaired

Expected results:
rindex repaired as when the filesystem is on LVM device

Additional info:
see attachments

Comment 1 Jaroslav Kortus 2009-07-20 14:53:18 UTC
Created attachment 354357 [details]
metadata with one blaster rg entry

Comment 2 Robert Peterson 2009-07-20 15:08:38 UTC
The problem is that mkfs sets a 16-block gap after the journals
in some cases, which confuses fsck's rindex repair code.

Here is the output of a small file system with this issue:

[root@hp-xw8400-01 ~]# gfs2_fsck -vv /dev/sda10
Initializing fsck
Initializing lists...
Old gfs1 file system detected.
(initialize.c:357)	<backtrace> - initialize()
[root@hp-xw8400-01 ~]# gfs_fsck -vv /dev/sda10
Initializing fsck
Initializing lists...
(bio.c:140)	Writing to 65536 - 16 4096
Initializing special inodes...
(file.c:45)	readi:  Offset (160) is >= the file size (160).
(super.c:226)	2 journals found.
Validating Resource Group index.
Level 1 check.
Invalid length 0 found in rindex.
(failed--trying again at level 2)
Level 2 check.
(super.c:997)	fs_total_size = 0xFFEA9 blocks.
(super.c:1001)	subdevice_size = 0x7DF60.
The middle RG is not on an even boundary (fs has grown?)
(failed--trying again at level 3)
Level 3 check.
(super.c:392)	fs_total_size = 0xFFEA9 blocks.
(super.c:470)	Likely damage to rgindex entry 1.
(super.c:496)	Not enough data to figure it out--skipped.
(super.c:501)	Index entries/section=8, third section addr = 0xffea7
(super.c:536)	1:RG found at block 0x11
(super.c:545)	Start of section 1.
(super.c:599)	Section 1 RG 1(1): shortest=0xfbeb
(super.c:631)	R(0xfbf5)
(super.c:536)	1:RG found at block 0xfbfc
(super.c:553)	1:dist 0xfbeb = 0xfbfc - 0x11(super.c:569)	
(super.c:599)	Section 1 RG 2(2): shortest=0xfbe8
(super.c:631)	R(0x1f7e0)
(super.c:536)	1:RG found at block 0x1f7e4
(super.c:553)	1:dist 0xfbe8 = 0x1f7e4 - 0xfbfc(super.c:569)	
(super.c:631)	R(0x2f3c8)
(super.c:536)	1:RG found at block 0x2f3cc
(super.c:553)	1:dist 0xfbe8 = 0x2f3cc - 0x1f7e4(super.c:569)	
(super.c:666)	First RG distance: 0xfbeb
(super.c:668)	Section 1: distance between RGs: 0xfbe8
(super.c:669)	Section size: 0x7df60
(super.c:536)	2:RG found at block 0x81f40
(super.c:545)	Start of section 2.
(super.c:599)	Section 2 RG 1(9): shortest=0xfc03
(super.c:628)	2(0x91b28)
(super.c:536)	2:RG found at block 0x91b43
(super.c:553)	2:dist 0xfc03 = 0x91b43 - 0x81f40(super.c:569)	
(super.c:599)	Section 2 RG 2(10): shortest=0xfbea
(super.c:628)	2(0xa172b)
(super.c:536)	2:RG found at block 0xa172d
(super.c:553)	2:dist 0xfbea = 0xa172d - 0x91b43(super.c:569)	
(super.c:628)	2(0xb1315)
(super.c:536)	2:RG found at block 0xb1317
(super.c:553)	2:dist 0xfbea = 0xb1317 - 0xa172d(super.c:569)	
(super.c:666)	First RG distance: 0xfc03
(super.c:668)	Section 2: distance between RGs: 0xfbea
(super.c:669)	Section size: 0x7df60
Section 1: 0x11 - 0x7df5f
(super.c:757)	Block 0x11
  RG 1 at block 0x11 intact [length 0xfbeb]
(super.c:757)	Block 0xfbfc
(super.c:828)	Prev ri_data set to: fbe4.
  RG 2 at block 0xFBFC intact [length 0xfbe8]
(super.c:757)	Block 0x1f7e4
(super.c:828)	Prev ri_data set to: fbe4.
  RG 3 at block 0x1F7E4 intact [length 0xfbe8]
(super.c:757)	Block 0x2f3cc
(super.c:828)	Prev ri_data set to: fbe4.
  RG 4 at block 0x2F3CC intact [length 0xfbe8]
(super.c:757)	Block 0x3efb4
(super.c:828)	Prev ri_data set to: fbe4.
  RG 5 at block 0x3EFB4 intact [length 0xfbe8]
(super.c:757)	Block 0x4eb9c
(super.c:828)	Prev ri_data set to: fbe4.
  RG 6 at block 0x4EB9C intact [length 0xfbe8]
(super.c:757)	Block 0x5e784
(super.c:828)	Prev ri_data set to: fbe4.
  RG 7 at block 0x5E784 intact [length 0xfbe8]
(super.c:757)	Block 0x6e36c
(super.c:828)	Prev ri_data set to: fbe4.
  RG 8 at block 0x6E36C intact [length 0xfbe8]
(super.c:757)	Block 0x7df54
(super.c:828)	Prev ri_data set to: fbe4.
  RG 9 at block 0x7DF54 intact [length 0xfbe8]
Section 2: 0x81f40 - 0xffe9f
(super.c:757)	Block 0x81f40
(super.c:793)	Missing or damaged RG at block 0x81f40
* RG 10 at block 0x81F40 *** DAMAGED *** [length 0xfc03]
(super.c:757)	Block 0x91b43
(super.c:828)	Prev ri_data set to: fbfc.
  RG 11 at block 0x91B43 intact [length 0xfbea]
(super.c:757)	Block 0xa172d
(super.c:828)	Prev ri_data set to: fbe4.
  RG 12 at block 0xA172D intact [length 0xfbea]
(super.c:757)	Block 0xb1317
(super.c:828)	Prev ri_data set to: fbe4.
  RG 13 at block 0xB1317 intact [length 0xfbea]
(super.c:757)	Block 0xc0f01
(super.c:828)	Prev ri_data set to: fbe4.
  RG 14 at block 0xC0F01 intact [length 0xfbea]
(super.c:757)	Block 0xd0aeb
(super.c:828)	Prev ri_data set to: fbe4.
  RG 15 at block 0xD0AEB intact [length 0xfbea]
(super.c:757)	Block 0xe06d5
(super.c:828)	Prev ri_data set to: fbe4.
  RG 16 at block 0xE06D5 intact [length 0xfbea]
(super.c:757)	Block 0xf02bf
(super.c:828)	Prev ri_data set to: fbe4.
  RG 17 at block 0xF02BF intact [length 0xfbea]
Section 3: 0xffea0 - 0xffea8
(super.c:757)	Block 0xffea0
(super.c:793)	Missing or damaged RG at block 0xffea0
(file.c:45)	readi:  Offset (1536) is >= the file size (1536).

Unable to use rindex; doing block-by-block search.
This will be slow, so be patient.
* RG 18 at block 0xFFEA0 *** DAMAGED *** [length 0x1]
(super.c:757)	Block 0xffea1
(super.c:757)	Block 0xffea2
(super.c:757)	Block 0xffea3
(super.c:757)	Block 0xffea4
(super.c:757)	Block 0xffea5
(super.c:757)	Block 0xffea6
(super.c:757)	Block 0xffea7
(super.c:757)	Block 0xffea8
(super.c:920)	Prev ri_data set to: 1.
(super.c:931)	RG index rebuilt as follows:
(super.c:937)	1: 4 / 0x15 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	2: 4 / 0xfc00 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	3: 4 / 0x1f7e8 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	4: 4 / 0x2f3d0 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	5: 4 / 0x3efb8 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	6: 4 / 0x4eba0 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	7: 4 / 0x5e788 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	8: 4 / 0x6e370 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	9: 1 / 0x7df55 / 0x00000000 / 0x00000000
(super.c:937)	10: 1 / 0x81f41 / 0x0000FBFC / 0x00003EFF
(super.c:937)	11: 4 / 0x91b47 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	12: 4 / 0xa1731 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	13: 4 / 0xb131b / 0x0000FBE4 / 0x00003EF9
(super.c:937)	14: 4 / 0xc0f05 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	15: 4 / 0xd0aef / 0x0000FBE4 / 0x00003EF9
(super.c:937)	16: 4 / 0xe06d9 / 0x0000FBE4 / 0x00003EF9
(super.c:937)	17: 4 / 0xf02c3 / 0x00000000 / 0x00000000
(super.c:937)	18: 1 / 0xffea1 / 0x00000000 / 0x00000000
(super.c:946)	Number of RGs = 18.
rgindex #1 ri_addr discrepancy: index 0x0 != expected: 0x11
rgindex #1 ri_length discrepancy: index 0x0 != expected: 0x4
rgindex #1 ri_data1 discrepancy: index 0x0 != expected: 0x15
rgindex #1 ri_data discrepancy: index 0x0 != expected: 0xfbe4
rgindex #1 ri_bitbytes discrepancy: index 0x0 != expected: 0x3ef9
Fix the index? (y/n)

In this case, the journals are: 0x1ff segments of 0x10 blocks.
Journal0 starts at 0x7df60.  So 0x7df60+0x1ff0 = 0x7ff50.  And so
the fsck rindex repair code thinks the next journal should be at
0x7ff50, which is on a nice, neat block boundary.  Makes sense.
But mkfs previously decided to put it at 0x7ff60, thus wasting 64K
of file system space.  Likewise, mkfs decided to put the first RG
of the second sub-section (immediately following the last journal)
at 0x81f55 rather than the block calculated by rindex repair:
0x81f40.

These odd calculations and wasted disk space might be viewed as
a bug in mkfs.gfs but since we can't change customer's file systems
in the field, we'll have to somehow adjust fsck.gfs to accommodate
the miscalculations.

Comment 3 Robert Peterson 2009-07-20 15:10:05 UTC
I don't have a fix yet but it should just be a matter of trudging
through the calculations to get it right.  Requesting ACK flags
for 5.5.

Comment 4 Robert Peterson 2009-08-17 15:07:27 UTC
Created attachment 357663 [details]
Proposed patch

This patch fixes the failing scenario but has not undergone a
full battery of fsck "hell" tests.  Basically, the "best" way to
fix the problem is to use the same calculations that gfs_mkfs
uses to create the original file systems.  Therefore, I copied and
morphed a couple of functions from gfs_mkfs and adjusted the
algorithm accordingly.

Comment 5 Robert Peterson 2009-09-02 19:11:21 UTC
Created attachment 359576 [details]
Revised Patch

This patch is basically the same as the previous, except that it
fixes some white-space issues and compiler warnings caused by
uninitialized variables.  The patch was retested against the
failing scenario.

Comment 6 Robert Peterson 2009-09-03 14:05:39 UTC
Created attachment 359683 [details]
Try 3 patch

This patch fixes two things: first, the previous patch did not
apply to the latest RHEL55 branch due to the repository I generated
it from being out of date.  Second, I fixed a nasty bug that I
found while running the gfs_fsck_hell tests.

Comment 7 Robert Peterson 2009-09-03 14:48:10 UTC
The fix was tested on roth-01 and kool, including all the
gfs_fsck_hell tests.  It was pushed to the master branch of the
gfs1-utils git repository and the STABLE3, STABLE2 and RHEL55
branches of the cluster git tree for inclusion into 5.5.
Here are the patch IDs:

master:  5a5e1d0
STABLE3: 5453587
STABLE2: 1ffca8c
RHEL55:  eb810c1

Changing status to POST while the new version is being build.

Comment 8 Robert Peterson 2009-09-03 15:18:12 UTC
Build successful; changing status to Modified.

Comment 13 errata-xmlrpc 2010-03-30 08:55:48 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2010-0290.html