Date: Sun, 13 Mar 2016 09:08:31 +0100 From: =?UTF-8?Q?Gustau_P=c3=a9rez?= <gustau.perez@gmail.com> To: FreeBSD XEN <freebsd-xen@freebsd.org> Subject: Re: Porting the block-iscsi hotplug script Message-ID: <56E51FFF.1010400@gmail.com> In-Reply-To: <CAOJdW3Rd1GOuEHh6B8jJXP968bBbemPuTCPAeS3bMyDWfz8WcA@mail.gmail.com> References: <553DEB97.5000300@entel.upc.edu> <56C6FA2F.8040900@gmail.com> <56CAC8CB.8030107@gmail.com> <56CADEDA.4050007@citrix.com> <56CB0057.1060509@gmail.com> <56CB041E.1020009@citrix.com> <56CB2D90.5080809@gmail.com> <56CB34BA.6060809@citrix.com> <56CC24BD.6050609@gmail.com> <56CC32E5.5010101@citrix.com> <56CC7637.3080408@gmail.com> <56CF5668.6090605@citrix.com> <56D0091F.80408@gmail.com> <56D02863.7040100@citrix.com> <56D03D95.9090509@gmail.com> <56D04E5F.8070901@citrix.com> <56D42A28.8050701@gmail.com> <56D434FC.8030905@citrix.com> <56D57110.2060406@gmail.com> <56D587D8.6030702@citrix.com> <56D590EA.609@gmail.com> <56D591BA.4020303@gmail.com> <56D5929F.7040001@citrix.com> <56D5C722.3080205@gmail.com> <56D6B68D.8080809@citrix.com> <56D7FEFE.9050000@gmail.com> <alpine.OSX.2.20.1603041055250.20397@mac> <56D97762.7000908@gmail.com> <alpine.OSX.2.20.1603041647160.22025@mac> <56E16604.2040007@gmail.com> <CAOJdW3Rd1GOuEHh6B8jJXP968bBbemPuTCPAeS3bMyDWfz8WcA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
El 11/03/16 a les 15:30, Gustau PĂ©rez ha escrit: > > Answering myself again: > I guess the locks need to be released before the hotplug finishes or > there would be stale locks in the system. This is not entirely true. The holds would be dropped when then hotplug script finishes (the fd will be closed by the system when the script finishes). > - I'll ask you something about the advisory locks. Perhaps this > evening if I find some time to spend. > The previous question (in this mail) leaded me to think that perhaps the locking facility is a bit complex. Please correct me if I'm wrong: 1. But we only need to keep track of the lock files created by a hotplug script during its execution, right? : 2. If the script does its job, the hotplug script should release the locks it is holding once its job is done, right? 3. If the domain has two disks defined, the hotplug script would be called two times, right? If that's so, I don't see how during the second execution of the hotplug script the _lockdict array in locking.sh would have the values of the first execution. 4. The hotplug scripts needs to keep track of the lock it holds, that would help the script to release only the lock it holds and not other locks. This is way the _lockdict array is needed. In fact, because the hotplug script should release the locks it has acquired before finishing, I think it would be enough to keep track of the locking files a hotplug script has created (no the fd's) and use the timeout argument of the lockf. If a second domain tries to lock a file, it should loop waiting a fixed amount of time until the lock becomes available. If it becomes available is because: 1. The holder released the lock by calling release_lock 2. Or the holder finished its work a called exit * *Either way the lock would be available. I don't understand why the Linux locking script seems that complex. Perhaps I'm missing something, if anyone sees the point, please let me know. Gustau
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?56E51FFF.1010400>