Bug 506343

Summary: gfs2_edit -p block# shows wrong height/offset on gfs1 and segfaults on gfs2
Product: Red Hat Enterprise Linux 5 Reporter: Jaroslav Kortus <jkortus>
Component: gfs2-utilsAssignee: Robert Peterson <rpeterso>
Status: CLOSED ERRATA QA Contact: Cluster QE <mspqa-list>
Severity: medium Docs Contact:
Priority: low    
Version: 5.4CC: edamato
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gfs2-utils-0.1.62-4.el5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-03-30 08:54:01 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
Patch to fix the problem
none
Revised patch none

Description Jaroslav Kortus 2009-06-16 19:11:57 UTC
Description of problem:
gfs2_edit -p block# should print the content of the block. It does so until you hit last block of links (pointing directly to data). This scenario causes gfs2_edit print wrong height and some nonsense as data offset on GFS1 filesystem. Same scenario on GFS2 filesystem ends with segmentation fault.

Version-Release number of selected component (if applicable):
gfs2_edit version 0.1.58 (built May 29 2009 15:43:58)
gfs-utils-0.1.19-3.el5
gfs2-utils-0.1.58-1.el5
kmod-gfs-0.1.33-2.el5

How reproducible:
always

Steps to Reproduce:
1. mkfs.gfs -O -t a3cluster:a3gfs2 -p lock_nolock -j 2 -J 32 ${DEVICE}
or
1. mkfs.gfs2 -O -t a3cluster:a3gfs2 -p lock_nolock -j 2 -J 8 ${DEVICE}
2. mount and create 10M file (yes | head -c 10000000 > file-01)
3. use gfs2_edit to walk through the filesystem and walk through the created file. Every time you change block# in the interactive editor, try "gfs2_edit -p block# ${DEVICE}" with the same block# as you see in the header of the editor.
4. at last page the height will be different and data offset will be a nonsense
  
Actual results:
different values for different usage of gfs2_edit

Expected results:
values are the same, utility does not crash

Additional info:

GFS1 (1G filesystem, 10M file):
gfs2_edit -p '35' /dev/GFSVG/GFS
Block #35    (0x23) of 262144 (0x40000) (indir blklist)

Indirect Block:
  mh_magic              0x01161970(hex)
  mh_type               5                   0x5
  mh_format             500                 0x1f4

This indirect block contains 1 indirect blocks
  (at height=2)
Indirect blocks:
0 => 0x9e2 / 2530     (data offset 0x57ff500000000000 / 6340874761291169792 /   5.50E)   

GFS2:
segfault with:
Core was generated by `gfs2_edit -p 5143 /dev/GFSVG/GFS'.
Program terminated with signal 11, Segmentation fault.
[New process 28810]
#0  0x0000000000401fea in print_gfs2 (fmt=Cannot access memory at address 0x790a790a790a7732
) at gfs2hex.c:95
95      }
(gdb) bt full
#0  0x0000000000401fea in print_gfs2 (fmt=Cannot access memory at address 0x790a790a790a7732
) at gfs2hex.c:95
        args = Cannot access memory at address 0x790a790a790a783a

The address here seems like the data read from the data block (all "y")
Remark: it seems to work on ia64 for GFS1. For GFS2 the segfault occurs.

Comment 1 Robert Peterson 2009-06-23 14:37:28 UTC
I've known about this bug for a very long time.  It's in the gfs2
debugger tool, gfs2_edit, so low priority, but it should get fixed.
Requesting ack flags so we can fix it in RHEL5.5.

Comment 2 Robert Peterson 2009-08-18 21:29:09 UTC
Created attachment 357855 [details]
Patch to fix the problem

Although it's not real straightforward, this patch fixes the
problem for both interactive and print mode.  I haven't tested
heights > 2.

Comment 3 Robert Peterson 2009-09-01 21:34:57 UTC
Created attachment 359452 [details]
Revised patch

This patch fixes a bug I found while testing the previous patch.

Comment 4 Robert Peterson 2009-09-02 16:06:21 UTC
The patch was pushed to the master branch of the gfs2-utils git
repository and the STABLE3, STABLE2 and RHEL55 branches of the
cluster git repository for inclusion into 5.5.  Changing status
to POST while I do builds.

RHEL55:  90097fd
master:  7ad8cc8
STABLE3: 03a04c4
STABLE2: 9193f20

Comment 5 Robert Peterson 2009-09-02 16:34:06 UTC
Build complete and successful.  Changing status to Modified.

Comment 10 errata-xmlrpc 2010-03-30 08:54:01 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-0287.html