Hi,
在 2024/10/28 17:44, Christoph Hellwig 写道:
On Mon, Oct 28, 2024 at 05:07:26PM +0800, Yang Erkun wrote:
Fix this problem by following what loop_init() does. Besides,
reintroduce brd_devices_mutex to help serialize modifications to
brd_list.
This looks generally good. Minor comments below:
+ snprintf(buf, DISK_NAME_LEN, "ram%d", i);
+ mutex_lock(&brd_devices_mutex);
+ list_for_each_entry(brd, &brd_devices, brd_list) {
+ if (brd->brd_number == i) {
+ mutex_unlock(&brd_devices_mutex);
+ err = -EEXIST;
+ goto out;
This now prints an error message for an already existing
device, which should not happen for the module_init case,
but will happen all the time for the probe callback, and
is really annoying. Please drop that part of the change.
I don't quite understand this, if the gendisk already exists,
the probe callback won't be called from the open path, because
ilookup() from blkdev_get_no_open() will found the bdev inode.
Hence there will only be a small race windown for concurrent
create on open callers to return -EEXIST here.
Thanks,
Kuai