Use a big-lock for kernel sychronization instead of fine-grained locking
This commit is contained in:
@@ -14,8 +14,6 @@
|
||||
|
||||
static int device_probe_partitions_dos(struct proc* proc, struct reschedule_ctx* rctx,
|
||||
struct device* device) {
|
||||
uint64_t fd, fsd;
|
||||
|
||||
struct dos_mbr mbr;
|
||||
memset(&mbr, 0, sizeof(mbr));
|
||||
size_t sector = 0;
|
||||
@@ -31,19 +29,15 @@ static int device_probe_partitions_dos(struct proc* proc, struct reschedule_ctx*
|
||||
[XDRV_PARTITION_RESCAN] = &partdrv_partition_rescan,
|
||||
};
|
||||
|
||||
spin_lock(&device->lock, &fd);
|
||||
device_op(device, XDRV_GET_SECTOR_SIZE, proc, rctx, §or_size);
|
||||
|
||||
device_op(device, XDRV_GET_SECTOR_SIZE, proc, rctx, &fd, §or_size);
|
||||
|
||||
int ret = device_op(device, XDRV_READ, proc, rctx, &fd, §or, §or_count, &mbr);
|
||||
int ret = device_op(device, XDRV_READ, proc, rctx, §or, §or_count, &mbr);
|
||||
|
||||
if (ret < 0) {
|
||||
spin_unlock(&device->lock, fd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (!(mbr.valid_sign[0] == 0x55 && mbr.valid_sign[1] == 0xAA)) {
|
||||
spin_unlock(&device->lock, fd);
|
||||
return -ST_PARTITION_ERROR;
|
||||
}
|
||||
|
||||
@@ -63,13 +57,9 @@ static int device_probe_partitions_dos(struct proc* proc, struct reschedule_ctx*
|
||||
struct device* part_dev = device_create(DEVICE_TYPE_DRIVE, key, ops, lengthof(ops),
|
||||
&partdrv_init, &partdrv_fini, &init, proc, rctx);
|
||||
|
||||
spin_lock(&part_dev->lock, &fsd);
|
||||
list_append(device->subdevices, &part_dev->subdevices_link);
|
||||
spin_unlock(&part_dev->lock, fsd);
|
||||
}
|
||||
|
||||
spin_unlock(&device->lock, fd);
|
||||
|
||||
return ST_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user