Re: [PATCH 2/3] null_blk: give the file-scope mutex a descriptive name

From: Zizhi Wo

Date: Mon Jul 06 2026 - 09:31:52 EST




在 2026/7/6 21:12, Bart Van Assche 写道:
On 7/6/26 5:35 AM, Zizhi Wo wrote:
The file-scope lock mutex mainly serializes access to the global nullb_list
and related device setup. Rename it to "nullb_list_lock" to make its
purpose clear. No functional change.

From commit a2db328b0839 ("null_blk: fix null-ptr-dereference while
configuring 'power' and 'submit_queues'"):

    Writing 'power' and 'submit_queues' concurrently will trigger kernel
    panic:
    [ ... ]
    Fix this problem by resuing the global mutex to protect
    nullb_device_power_store() and nullb_update_nr_hw_queues() from configfs.

This makes it clear that the "lock" mutex has a broader purpose than
only protecting nullb_list. Hence, the name nullb_list_lock is
confusing. How about using the name "nullb_lock"?

Thanks,

Bart.

Thanks for the reminder! Agreed that "nullb_list_lock" is too narrow
since it also serializes nullb_device_power_store() and
nullb_update_nr_hw_queues().

However, I'm a bit worried that "nullb_lock" is easy to confuse with the
per-device spinlock "nullb->lock"... They are only one "->" apart?

Would "nullb_global_lock" (or "nullb_config_lock") work better? It
reflects the broader purpose and avoids clashing with nullb->lock.

Thanks,
Zizhi Wo