Bug 2188718

Summary: 'pvck --dump -f <file>' should give a better error when the file already exists
Product: Red Hat Enterprise Linux 9 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM Team <lvm-team>
lvm2 sub component: Command-line tools QA Contact: cluster-qe <cluster-qe>
Status: VERIFIED --- Docs Contact:
Severity: low    
Priority: low CC: agk, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, teigland, thornber, zkabelac
Version: 9.3Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.21-2.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 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 Corey Marthaler 2023-04-21 20:40:45 UTC
Description of problem:
[root@virt-506 ~]# ls -l /tmp/meta.txt
-rw-------. 1 root root 15189 Apr 21 22:36 /tmp/meta.txt

[root@virt-506 ~]# pvck --dump metadata_search --settings metadata_offset=3870720 -f /tmp/meta.txt /dev/sdb
  Searching for metadata at offset 4096 size 4190208
  Failed to create file /tmp/meta.txt

[root@virt-506 ~]# pvck --dump metadata_search --settings metadata_offset=3870720 -f /tmp/meta2.txt /dev/sdb
  Searching for metadata at offset 4096 size 4190208
  metadata at 3870720 length 15190 crc 6afa48cc vg resize_matrix seqno 281 id VwYvXu-zDWf-M6FO-szLS-Z47u-zQlV-2FrQ2W



Version-Release number of selected component (if applicable):
lvm2-2.03.20-2.el9    BUILT: Thu Apr  6 01:40:29 PM CEST 2023
lvm2-libs-2.03.20-2.el9    BUILT: Thu Apr  6 01:40:29 PM CEST 2023

Comment 1 David Teigland 2023-04-28 18:35:16 UTC
fix in main
https://sourceware.org/git/?p=lvm2.git;a=commit;h=c4440b5b495a2d11ff541dd7e7791e2a83c83609

$ touch foo
$ pvck --dump metadata -f foo /dev/sdb 
  File already exists.
$ echo $?
5

Comment 3 Corey Marthaler 2023-05-30 18:22:12 UTC
Marking Verified:Tested in the latest rpms.

# before fix (lvm2-2.03.17-7.el9)
[root@virt-030 ~]# pvck --dump metadata /dev/sda -f /tmp/pvck_meta.459.1767298
  metadata text at 4608 crc 0xc6449eab # vgname df seqno 1
[root@virt-030 ~]# pvck --dump metadata /dev/sda -f /tmp/pvck_meta.459.1767298
  metadata text at 4608 crc 0xc6449eab # vgname df seqno 1
  Failed to create file /tmp/pvck_meta.459.1767298
[root@virt-030 ~]# echo $?
0


# after fix (lvm2-2.03.21-2.el9)
[root@virt-521 ~]# pvck --dump metadata /dev/sda -f /tmp/pvck_meta.459.1767298
  metadata text at 4608 crc 0x71775faf # vgname df seqno 1
[root@virt-521 ~]# pvck --dump metadata /dev/sda -f /tmp/pvck_meta.459.1767298
  File already exists.
[root@virt-521 ~]# echo $?
5