> + spin_lock_init(&dev->zone_res_lock); > + if (dev->memory_backed) > dev->zone_locks = bitmap_zalloc(dev->nr_zones, GFP_KERNEL); > + else > + dev->zone_locks = kmalloc_array(dev->nr_zones, > + sizeof(spinlock_t), GFP_KERNEL); > + if (!dev->zone_locks) { Using the same pointer for different types is pretty horrible. At very least we should use a union. But I think we'd end up with less contention if we add a new struct nullb_zone that contains the fields of blk_zone that we actuall care about plus: union { spinlock_t spinlock; mutex_t mutex; } and then use the proper lock primitive also for the memory backed case.