linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Darren Lavender <dl1@hppine99.gbr.hp.com>
To: linux-lvm@redhat.com
Subject: [linux-lvm] LVM2 tools lvmcmdline.c major and minor number limits
Date: Wed, 13 Feb 2008 11:02:00 +0000	[thread overview]
Message-ID: <1202900520.4345.115.camel@localhost.localdomain> (raw)


I was wondering whether there was any particular reason why the
limitations below are still present given that these were changed
between 2.4 and 2.6 linux kernels?

Eg:


LVM2/tools/lvmcmdline.c

int minor_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
{
        char *ptr;

        if (!_get_int_arg(a, &ptr) || (*ptr) || (a->sign == SIGN_MINUS))
                return 0;

        if (a->i_value > 255) {
                log_error("Minor number outside range 0-255");
                return 0;
        }

        return 1;
}

int major_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
{
        char *ptr;

        if (!_get_int_arg(a, &ptr) || (*ptr) || (a->sign == SIGN_MINUS))
                return 0;

        if (a->i_value > 255) {
                log_error("Major number outside range 0-255");
                return 0;
        }

        /* FIXME Also Check against /proc/devices */

        return 1;
}


Linux 2.4 kernel appears to have a major number of 8 bits, likewise for
the minor number.

By comparison, 2.6 appears to have 12 bits for the major and 20 bits for
the minor, significantly larger, eg:


  4 #define MINORBITS       20
  5 #define MINORMASK       ((1U << MINORBITS) - 1)
  6 
  7 #define MAJOR(dev)      ((unsigned int) ((dev) >> MINORBITS))
  8 #define MINOR(dev)      ((unsigned int) ((dev) & MINORMASK))
  9 #define MKDEV(ma,mi)    (((ma) << MINORBITS) | (mi))



Whilst these LVM2 hardcoded limits do not prevent device nodes being
created during normal operation they do prevent the user from specifying
specific major/minor numbers via the cmdline, eg:

 # lvcreate -n bigminor -l 5 -M y --major 253 --minor 270 vgtest
  Minor number outside range 0-255
  Invalid argument 270
  Error during parsing of command line.




Rebuilding without these limits (a quick hack/test) produces a device
node that seems to work just fine:

# ./lvm lvcreate -n highminor -l 5 -M y --major 253 --minor 260 vgtest
  Logical volume "highminor" created

# ll /dev/mapper/
total 128
drwxr-xr-x   2 root root     4096 Feb 12 16:29 .
drwxr-xr-x  35 root root   122880 Feb 12 16:29 ..
lrwxrwxrwx   1 root root       16 Feb 12 15:52 control -> ../device-mapper
brw-------   1 root root 253, 260 Feb 12 16:29 vgtest-highminor
brw-------   1 root root 253, 250 Feb 12 16:04 vgtest-lowminor
brw-------   1 root root 253,   0 Feb 12 16:04 vgtest-nominor



Can this limitation be either removed or updated to bring it in line
with more recent kernel functionality?  Or is there some reason that I
am missing for their continued existence/assigned values.....


Thanks & regards

-- 
Darren Lavender <dl1@hppine99.gbr.hp.com>

             reply	other threads:[~2008-02-13 11:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-02-13 11:02 Darren Lavender [this message]
2008-02-13 12:15 ` [linux-lvm] LVM2 tools lvmcmdline.c major and minor number limits Alasdair G Kergon
2008-02-13 13:36   ` Darren Lavender
2008-02-13 14:53     ` Alasdair G Kergon

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=1202900520.4345.115.camel@localhost.localdomain \
    --to=dl1@hppine99.gbr.hp.com \
    --cc=linux-lvm@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).