diff options
Diffstat (limited to 'drivers/block/nbd.c')
-rw-r--r-- | drivers/block/nbd.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index e6fc716aca45..f533f3375e24 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c | |||
@@ -192,7 +192,8 @@ static int sock_xmit(struct nbd_device *lo, int send, void *buf, int size, | |||
192 | if (lo->xmit_timeout) | 192 | if (lo->xmit_timeout) |
193 | del_timer_sync(&ti); | 193 | del_timer_sync(&ti); |
194 | } else | 194 | } else |
195 | result = kernel_recvmsg(sock, &msg, &iov, 1, size, 0); | 195 | result = kernel_recvmsg(sock, &msg, &iov, 1, size, |
196 | msg.msg_flags); | ||
196 | 197 | ||
197 | if (signal_pending(current)) { | 198 | if (signal_pending(current)) { |
198 | siginfo_t info; | 199 | siginfo_t info; |
@@ -753,9 +754,26 @@ static int __init nbd_init(void) | |||
753 | return -ENOMEM; | 754 | return -ENOMEM; |
754 | 755 | ||
755 | part_shift = 0; | 756 | part_shift = 0; |
756 | if (max_part > 0) | 757 | if (max_part > 0) { |
757 | part_shift = fls(max_part); | 758 | part_shift = fls(max_part); |
758 | 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 | |||
771 | if ((1UL << part_shift) > DISK_MAX_PARTS) | ||
772 | return -EINVAL; | ||
773 | |||
774 | if (nbds_max > 1UL << (MINORBITS - part_shift)) | ||
775 | return -EINVAL; | ||
776 | |||
759 | for (i = 0; i < nbds_max; i++) { | 777 | for (i = 0; i < nbds_max; i++) { |
760 | struct gendisk *disk = alloc_disk(1 << part_shift); | 778 | struct gendisk *disk = alloc_disk(1 << part_shift); |
761 | if (!disk) | 779 | if (!disk) |