On Wed, Oct 25, 2023 at 05:54:39PM +0200, Jan Kara wrote: > This test implicitely assumes that 0 is BD_CLAIM_DEFAULT. I guess that's > fine although I somewhat prefer explicit value test like: > > if (whole->bd_claim != BD_CLAIM_DEFAULT) I find the BD_CLAIM_DEFAULT confusing to be honest. I'd expect null to just be check as: if (whole->bd_claim) That being said, instead of doing all the manual atomic magic, why not add an unsigned long bd_state; to struct block_device instead of bd_claim, then define a single bit for a device being clamed and simply everything while also giving us space for more bits if we ever need them?