g2p / bcache-tools

bcache-tools, part of the bcache hybrid storage project (features, debian packaging)
http://bcache.evilpiepirate.org/
GNU General Public License v2.0
119 stars 46 forks source link

Possible temporary udev race condition breaks bcache-register #14

Open rolffokkens opened 10 years ago

rolffokkens commented 10 years ago

From: http://thread.gmane.org/gmane.linux.kernel.bcache.devel/2594

If I understand udev correctly, this sort of "conflict" is an inevitable consequence of its asynchronous nature, and helper programs like bcache-register need to be robust enough to deal with them.

(If I'm wrong about this, then I guess this is a udev bug?)

BTW, this is what the bcache-related dmesg entries look like when I hit the conflict with my patches applied:

[ 1.761932] bcache: bch_journal_replay() journal replay done, 1972 keys in 75 entries, seq 312536 [ 1.762043] bcache: register_cache() registered cache device sda2 [ 1.762631] bcache: register_bcache() error opening /dev/md126p5: device busy [ 1.862949] bcache: register_bdev() registered backing device md126p5 [ 1.864268] bcache: bch_cached_dev_attach() Caching md126p5 as bcache0 on set fb8d253b-6144-4b48-8ed6-7b1724ed83a7 [ 3.553053] bcache: register_bcache() error opening /dev/sda2: device already registered [ 4.182180] bcache: register_bcache() error opening /dev/md126p5: device already registered

You can see that the backing device is busy when it first tries to register it, but it succeeds 1/10th of a second later. (I'm assuming the last two "already registered" messages occur when udev replays its events later in the boot process.)