archive mirror
 help / color / mirror / Atom feed
From: David Teigland <>
To: "" <>
Cc: Zdenek Kabelac <>,
	LVM general discussion and development <>
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: <> (raw)
In-Reply-To: <>

On Tue, Nov 17, 2020 at 11:52:28AM +0800, 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:;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.


  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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* 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).