Re: [Nbd] How to find a free NBD device?
- To: Paul Clements <paul.clements@...856...>
- Cc: "nbd-general@lists.sourceforge.net" <nbd-general@lists.sourceforge.net>, Wouter Verhelst <w@...112...>
- Subject: Re: [Nbd] How to find a free NBD device?
- From: Andreas Klauer <Andreas.Klauer@...1264...>
- Date: Thu, 6 Mar 2014 01:57:22 +0100
- Message-id: <20140306005722.GA9504@...1265...>
- In-reply-to: <CAECXXi4cUQvZArjQV37nJV30dH3tLcDcdtay_9zWj9s-p8FGYg@...18...>
- References: <20140303174147.GA16734@...1265...> <20140303181619.GA17222@...1265...> <CAECXXi4x5j9ZmGyFuyTZ0ua2hbmkU_zMeXRCJa-yJPoKfSmXeA@...18...> <4914518.b6MtihjsKu@...3...> <CAECXXi4cUQvZArjQV37nJV30dH3tLcDcdtay_9zWj9s-p8FGYg@...18...>
On Wed, Mar 05, 2014 at 03:20:55PM -0500, Paul Clements wrote:
> Although I wonder how bad the current situation really is.
The losetup --find --show being racy kind of stumped me, I'm not sure if
this issue is known at all, Google doesn't give me anything except this:
http://www.spinics.net/lists/util-linux-ng/msg00221.html
It seems the --show was added in the first place to avoid race, yet it
suffers from one; (for i in {1..100}; do losetup -f -s $i & done) does
not give you a hundred loop devices... instead it keeps reusing already
used ones.
If nobody notices such an issue in years it's probably not relevant
in practice...
> Are people having difficulties with races and such in trying to
> allocate nbds?
I guess the race is a problem of a very theoretical nature only...
two processes trying to find a nbd device at the same millisecond
is just extremely unlikely.
Finding a free nbd device still seems a bit of a challenge to me.
Although that may be because my buggy program is leaving behind nbd
devices in a bad state, so they're still listed in /proc/partitions even
though there is no process using them anymore, and even nbd-client -d
does not get rid of them.
The /sys/block/nbd*/pid seems to be the safest way to check, and never
mind the race conditions...
Regards
Andreas Klauer
Reply to: