From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [10.34.131.225] (dhcp131-225.brq.redhat.com [10.34.131.225]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t587HvZw014510 for ; Mon, 8 Jun 2015 03:17:58 -0400 Message-ID: <557541A5.8050808@redhat.com> Date: Mon, 08 Jun 2015 09:17:57 +0200 From: Zdenek Kabelac MIME-Version: 1.0 References: <55704119.4000606@redhat.com> <55715811.8020706@redhat.com> In-Reply-To: Content-Transfer-Encoding: 7bit Subject: Re: [linux-lvm] libdm cannot swap names between two child volumes Reply-To: LVM general discussion and development List-Id: LVM general discussion and development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , List-Id: Content-Type: text/plain; charset="us-ascii"; format="flowed" To: linux-lvm@redhat.com Dne 8.6.2015 v 04:09 M.H. Tsai napsal(a): > 2015-06-05 16:04 GMT+08:00 Zdenek Kabelac : >> The problem with rename is - >> >> you have device 'lv1' you rename it to 'lv2' - yet >> those who opened device with the name 'lv1' still thinks >> the 'lv1' device exits. >> >> So for safety reason before you 'reuse' any existing name in-use, >> there should be 'deactivating' such device first - so there is no 'race' in >> name usage. >> >> It's even possible we miss to track full history of active renamed device. >> >> Since you get into strange scenarios when you start to count >> with udev event handling and link generating here - it's getting nearly >> impossible to synchronize this properly... > > Does that mean, if I can confirm that there's no program using the device name, Hi It doesn't really matter here what you could confirm here - there is a race you can't avoid - i.e. udev is completely 'independent' and may execute trigger udev rules at any random point in time or some other command may try to open device in parallel (i.e. 'dd') So the only way how to ensure there is no such race - is to deactivate such device (which should be possible - since as you said - noone has it open) Also remember - activation routine is 'separate' from command code - as it could run on a completely different node - so you cannot 'validate' from command code there is no user of a device on 'activation' node unless device is locally active. > then it's safe to rename an active device? The devices I want to rename are > internal volumes. I think that there's no user space program using these names, > except LVM. IMHO there is no point to 'optimize' this process - I do not expect anyone is doing million swaps of internal LVs in a second. Thus going through the proper sequence of steps and allowing udev to properly synchronize (i.e. you should not 'mix' activation & deactivation under same cookie) is clearly the best way how to achieve your desired goal. Regards Zdenek