|
@@ -754,9 +754,20 @@ static int __init nbd_init(void)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
part_shift = 0;
|
|
part_shift = 0;
|
|
- if (max_part > 0)
|
|
|
|
|
|
+ if (max_part > 0) {
|
|
part_shift = fls(max_part);
|
|
part_shift = fls(max_part);
|
|
|
|
|
|
|
|
+ /*
|
|
|
|
+ * Adjust max_part according to part_shift as it is exported
|
|
|
|
+ * to user space so that user can know the max number of
|
|
|
|
+ * partition kernel should be able to manage.
|
|
|
|
+ *
|
|
|
|
+ * Note that -1 is required because partition 0 is reserved
|
|
|
|
+ * for the whole disk.
|
|
|
|
+ */
|
|
|
|
+ max_part = (1UL << part_shift) - 1;
|
|
|
|
+ }
|
|
|
|
+
|
|
if ((1UL << part_shift) > DISK_MAX_PARTS)
|
|
if ((1UL << part_shift) > DISK_MAX_PARTS)
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
|
|
|