Bug 1482542

Summary: gfs2_edit is not saving symlinks
Product: Red Hat Enterprise Linux 7 Reporter: Robert Peterson <rpeterso>
Component: gfs2-utilsAssignee: Andrew Price <anprice>
Status: CLOSED ERRATA QA Contact: cluster-qe <cluster-qe>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.5CC: cluster-maint, gfs2-maint, jpayne, rpeterso
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: gfs2-utils-3.1.10-4.el7 Doc Type: No Doc Update
Doc Text:
undefined
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-04-10 08:43:19 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Robert Peterson 2017-08-17 13:51:31 UTC
Description of problem:
I got a set of GFS2 metadata from a customer, only to discover
the symlinks were all blank. That's because in gfs2_edit's
savemeta.c function get_gfs_struct_info it has:

(After a special case for saving directories)
		else if (!inode->i_di.di_height && !block_is_systemfile(owner) &&
			 !S_ISDIR(inode->i_di.di_mode))
			*gstruct_len = sizeof(struct gfs2_dinode);

So savemeta should also save the full contents for symlinks.
In this case, we can simply add something like:

              && !S_ISLNK(inode->i_di.di_mode))

Or some such.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.ln -s /etc/fstab /mnt/gfs2/my_symlink
2.umount /mnt/gfs2
3.gfs2_edit savemeta <dev>
4.gfs2_edit restoremeta <dev>

Actual results:
Restored symlink has empty/zeroed contents.

Expected results:
Symlinks should be preserved for file system analysis.

Additional info:

Comment 2 Andrew Price 2017-08-18 10:01:24 UTC
Upstream patch: https://pagure.io/gfs2-utils/c/1742ab40bfbdc1b411710cb2263460cc43753c51

Comment 5 Justin Payne 2018-01-17 22:34:01 UTC
Verified in gfs2-utils-3.1.10-6.el7:

[root@host-002 ~]# rpm -q gfs2-utils
gfs2-utils-3.1.10-6.el7.x86_64
[root@host-002 ~]# mkfs.gfs2 -p lock_nolock -O -j1 /dev/mapper/testvg1-testlv1
It appears to contain an existing filesystem (gfs2)
/dev/mapper/testvg1-testlv1 is a symbolic link to /dev/dm-2
This will destroy any data on /dev/dm-2
Discarding device contents (may take a while on large devices): Done
Adding journals: Done 
Building resource groups: Done 
Creating quota file: Done
Writing superblock and syncing: Done
Device:                    /dev/mapper/testvg1-testlv1
Block size:                4096
Device size:               1.99 GB (522240 blocks)
Filesystem size:           1.99 GB (522239 blocks)
Journals:                  1
Resource groups:           9
Locking protocol:          "lock_nolock"
Lock table:                ""
UUID:                      c906db4c-0877-4c64-8b0f-a3b4f60d600a
[root@host-002 ~]# mount -tgfs2 /dev/mapper/testvg1-testlv1 /mnt/gfs2/
[root@host-002 ~]# ln -s /etc/fstab /mnt/gfs2/my_symlink
[root@host-002 ~]# umount /mnt/gfs2
[root@host-002 ~]# gfs2_edit savemeta /dev/mapper/testvg1-testlv1
There are 522239 blocks of 4096 bytes in the filesystem.
Filesystem size: 1.1015GB
522239 blocks processed, 33139 saved (100%)

Metadata saved to file /tmp/gfsmeta.tsx8Rx (gzipped, level 9).
[root@host-002 ~]# gfs2_edit restoremeta /tmp/gfsmeta.tsx8Rx /dev/mapper/testvg1-testlv1
Metadata saved at Wed Jan 17 16:30:33 2018
File system size 1.1015GB
Block size is 4096B
This is gfs2 metadata.
There are 522240 free blocks on the destination device.
Highest saved block is 461070 (0x7090e)
461071 blocks processed, 33139 saved (100%)
File /tmp/gfsmeta.tsx8Rx restore successful.
[root@host-002 ~]# mount -tgfs2 /dev/mapper/testvg1-testlv1 /mnt/gfs2/
[root@host-002 ~]# ls -alt /mnt/gfs2/my_symlink 
lrwxrwxrwx. 1 root root 10 Jan 17 16:30 /mnt/gfs2/my_symlink -> /etc/fstab

Comment 9 errata-xmlrpc 2018-04-10 08:43:19 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:0668