diff options
author | David S. Miller <davem@davemloft.net> | 2011-06-04 13:38:31 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-06-04 13:38:31 -0700 |
commit | e990b37b906b6137d353ef2a918e15e5763d70ec (patch) | |
tree | e802458ee43d4b0a2b6d39eb25929858ceb7fd61 /drivers/block/nbd.c | |
parent | 34624d6631b6b3a1df16407a847286bb6233a96b (diff) | |
parent | 23c79d31a3dd2602ee1a5ff31303b2d7a2d3c159 (diff) | |
download | blackbird-op-linux-e990b37b906b6137d353ef2a918e15e5763d70ec.tar.gz blackbird-op-linux-e990b37b906b6137d353ef2a918e15e5763d70ec.zip |
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6
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, if (lo->xmit_timeout) del_timer_sync(&ti); } else - result = kernel_recvmsg(sock, &msg, &iov, 1, size, 0); + result = kernel_recvmsg(sock, &msg, &iov, 1, size, + msg.msg_flags); if (signal_pending(current)) { siginfo_t info; @@ -753,9 +754,26 @@ 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; + + if (nbds_max > 1UL << (MINORBITS - part_shift)) + return -EINVAL; + for (i = 0; i < nbds_max; i++) { struct gendisk *disk = alloc_disk(1 << part_shift); if (!disk) |