diff --git a/[refs] b/[refs] index 529a63ec9ae2..263c3597139b 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3b2710824e00d238554c13b5add347e6c701ab1a +refs/heads/master: 5988ce239682854d4e632fb58bff000700830394 diff --git a/trunk/drivers/block/nbd.c b/trunk/drivers/block/nbd.c index fdee7567fd15..f533f3375e24 100644 --- a/trunk/drivers/block/nbd.c +++ b/trunk/drivers/block/nbd.c @@ -754,9 +754,20 @@ static int __init nbd_init(void) return -ENOMEM; part_shift = 0; - if (max_part > 0) + if (max_part > 0) { 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) return -EINVAL;