From: David Teigland <teigland@redhat.com>
To: "heming.zhao@suse.com" <heming.zhao@suse.com>
Cc: Zdenek Kabelac <zkabelac@redhat.com>,
LVM general discussion and development <linux-lvm@redhat.com>
Subject: Re: [linux-lvm] issue about return value in _lvchange_activate_single
Date: Tue, 17 Nov 2020 09:45:16 -0600 [thread overview]
Message-ID: <20201117154516.GA18257@redhat.com> (raw)
In-Reply-To: <a966550b-aacc-85bc-da74-d34a3e4ccd99@suse.com>
On Tue, Nov 17, 2020 at 11:52:28AM +0800, heming.zhao@suse.com wrote:
> In lvm functions, it treats "return 0" as error case.
>
> if _lvchange_activate() return ECMD_FAILED, the caller _lvchange_activate_single() think as normal:
> ```
> if (!_lvchange_activate(cmd, lv)) <== ECMD_FAILED is 5, won't enter if case.
> return_ECMD_FAILED;
Thanks for finding that. In some places 0 is the error value and in other
places ECMD_FAILED is the error value; they frequently get mixed up.
I believe this is the bug you are seeing:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=aba9652e584b6f6a422233dea951eb59326a3de2
> 2. node2 change the systemid to itself
>
> ```
> [tb-clustermd2 ~]# vgchange -y --config "local/extra_system_ids='tb-clustermd1'" --systemid tb-clustermd2 vg1
> Volume group "vg1" successfully changed
> [tb-clustermd2 ~]# lvchange -ay vg1/lv1
> [tb-clustermd2 ~]# dmsetup ls
> vg1-lv1 (254:0)
This is what the LVM-activate resource agent does, except it wouldn't be
done while the LV is active on another running host. Just wanted to
clarify that, I don't think it's the point of your illustration here.
> 3. this time both sides have dm device.
> ```
> [tb-clustermd1 ~]# dmsetup ls
> vg1-lv1 (254:0)
> [tb-clustermd2 ~]# dmsetup ls
> vg1-lv1 (254:0)
> ```
For the sake of anyone looking at this later, this shouldn't happen in a
properly running cluster. (If you wanted the LV active on two hosts at
once, you'd use lvmlockd and no system ID on the VG.)
> 4. node1 executes lvchange cmds. please note the return value is 0
> ```
> [tb-clustermd1 ~]# lvchange -ay vg1/lv1 ; echo $?
> WARNING: Found LVs active in VG vg1 with foreign system ID tb-clustermd2. Possible data corruption.
> Cannot activate LVs in a foreign VG.
> 0
That's the one fixed by the commit above.
Dave
next prev parent reply other threads:[~2020-11-17 15:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-17 3:52 [linux-lvm] issue about return value in _lvchange_activate_single heming.zhao
2020-11-17 15:45 ` David Teigland [this message]
2020-11-18 14:45 ` heming.zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201117154516.GA18257@redhat.com \
--to=teigland@redhat.com \
--cc=heming.zhao@suse.com \
--cc=linux-lvm@redhat.com \
--cc=zkabelac@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).