From: Namhyung Kim <namhyung@gmail.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-kernel@vger.kernel.org,
Laurent Vivier <Laurent.Vivier@bull.net>,
Paul Clements <Paul.Clements@steeleye.com>
Subject: [PATCH 3/3] nbd: adjust 'max_part' according to part_shift
Date: Fri, 27 May 2011 15:00:03 +0900 [thread overview]
Message-ID: <1306476003-4624-3-git-send-email-namhyung@gmail.com> (raw)
In-Reply-To: <1306476003-4624-1-git-send-email-namhyung@gmail.com>
The 'max_part' parameter determines how many partitions are supported
on each nbd device. However the actual number can be changed to the
power of 2 minus 1 form during the module initialization as
alloc_disk() is called with (1 << part_shift) for some reason.
So adjust 'max_part' also at least for consistency with loop and brd.
It is exported via sysfs already, and a user should check this value
after module loading if [s]he wants to use that number correctly
(i.e. fdisk or something).
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Cc: Laurent Vivier <Laurent.Vivier@bull.net>
Cc: Paul Clements <Paul.Clements@steeleye.com>
---
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)
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;
--
1.7.5.2
next prev parent reply other threads:[~2011-05-27 6:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-27 6:00 [PATCH 1/3] nbd: pass MSG_* flags to kernel_recvmsg() Namhyung Kim
2011-05-27 6:00 ` [PATCH 2/3] nbd: limit module parameters to a sane value Namhyung Kim
2011-05-27 12:41 ` Paul Clements
2011-06-06 10:29 ` Pavel Machek
2011-05-27 6:00 ` Namhyung Kim [this message]
2011-05-27 12:59 ` [PATCH 3/3] nbd: adjust 'max_part' according to part_shift Paul Clements
2011-05-27 12:33 ` [PATCH 1/3] nbd: pass MSG_* flags to kernel_recvmsg() Paul Clements
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1306476003-4624-3-git-send-email-namhyung@gmail.com \
--to=namhyung@gmail.com \
--cc=Laurent.Vivier@bull.net \
--cc=Paul.Clements@steeleye.com \
--cc=axboe@kernel.dk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox