diff options
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/nbd.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index fdee7567fd15..f533f3375e24 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -754,9 +754,20 @@ static int __init nbd_init(void) | |||
754 | return -ENOMEM; | 754 | return -ENOMEM; |
755 | 755 | ||
756 | part_shift = 0; | 756 | part_shift = 0; |
757 | if (max_part > 0) | 757 | if (max_part > 0) { |
758 | part_shift = fls(max_part); | 758 | part_shift = fls(max_part); |
759 | 759 | ||
760 | /* | ||
761 | * Adjust max_part according to part_shift as it is exported | ||
762 | * to user space so that user can know the max number of | ||
763 | * partition kernel should be able to manage. | ||
764 | * | ||
765 | * Note that -1 is required because partition 0 is reserved | ||
766 | * for the whole disk. | ||
767 | */ | ||
768 | max_part = (1UL << part_shift) - 1; | ||
769 | } | ||
770 | |||
760 | if ((1UL << part_shift) > DISK_MAX_PARTS) | 771 | if ((1UL << part_shift) > DISK_MAX_PARTS) |
761 | return -EINVAL; | 772 | return -EINVAL; |
762 | 773 | ||