aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorIlya Dryomov <ilya.dryomov@inktank.com>2013-12-16 12:26:32 -0500
committerIlya Dryomov <ilya.dryomov@inktank.com>2013-12-31 13:32:04 -0500
commit7e513d43669a0505ee3b122344176147a674bcbf (patch)
treeb1c8b984589b20699d7432082bdc1d742d2c76ba /drivers/block
parent183028052b48db2b34c09fd54f0bc465eaa305eb (diff)
rbd: enable extended devt in single-major mode
If single-major device number allocation scheme is turned on, instead of reserving 256 minors per device, which imposes a limit of 4096 images mapped at once, reserve 16 minors per device and enable extended devt feature. This results in a theoretical limit of 65536 images mapped at once, and still allows to have more than 15 partititions: partitions starting with 16th are mapped under major 259 (Block Extended Major): $ rbd showmapped id pool image snap device 0 rbd b5 - /dev/rbd0 # no partitions 1 rbd b2 - /dev/rbd1 # 40 partitions 2 rbd b3 - /dev/rbd2 # 2 partitions $ cat /proc/partitions 251 0 1024 rbd0 251 16 1024 rbd1 251 17 0 rbd1p1 251 18 0 rbd1p2 ... 251 30 0 rbd1p14 251 31 0 rbd1p15 259 0 0 rbd1p16 259 1 0 rbd1p17 ... 259 23 0 rbd1p39 259 24 0 rbd1p40 251 32 1024 rbd2 251 33 0 rbd2p1 251 34 0 rbd2p2 (major 251 was assigned dynamically at module load time) Signed-off-by: Ilya Dryomov <ilya.dryomov@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/rbd.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index e5ddcb58e9a2..11ae4c1238a6 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -91,7 +91,8 @@ static int atomic_dec_return_safe(atomic_t *v)
91 91
92#define RBD_DRV_NAME "rbd" 92#define RBD_DRV_NAME "rbd"
93 93
94#define RBD_PART_SHIFT 8 94#define RBD_MINORS_PER_MAJOR 256
95#define RBD_SINGLE_MAJOR_PART_SHIFT 4
95 96
96#define RBD_SNAP_DEV_NAME_PREFIX "snap_" 97#define RBD_SNAP_DEV_NAME_PREFIX "snap_"
97#define RBD_MAX_SNAP_NAME_LEN \ 98#define RBD_MAX_SNAP_NAME_LEN \
@@ -415,12 +416,12 @@ static void rbd_spec_put(struct rbd_spec *spec);
415 416
416static int rbd_dev_id_to_minor(int dev_id) 417static int rbd_dev_id_to_minor(int dev_id)
417{ 418{
418 return dev_id << RBD_PART_SHIFT; 419 return dev_id << RBD_SINGLE_MAJOR_PART_SHIFT;
419} 420}
420 421
421static int minor_to_rbd_dev_id(int minor) 422static int minor_to_rbd_dev_id(int minor)
422{ 423{
423 return minor >> RBD_PART_SHIFT; 424 return minor >> RBD_SINGLE_MAJOR_PART_SHIFT;
424} 425}
425 426
426static BUS_ATTR(add, S_IWUSR, NULL, rbd_add); 427static BUS_ATTR(add, S_IWUSR, NULL, rbd_add);
@@ -3434,7 +3435,9 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
3434 u64 segment_size; 3435 u64 segment_size;
3435 3436
3436 /* create gendisk info */ 3437 /* create gendisk info */
3437 disk = alloc_disk(1 << RBD_PART_SHIFT); 3438 disk = alloc_disk(single_major ?
3439 (1 << RBD_SINGLE_MAJOR_PART_SHIFT) :
3440 RBD_MINORS_PER_MAJOR);
3438 if (!disk) 3441 if (!disk)
3439 return -ENOMEM; 3442 return -ENOMEM;
3440 3443
@@ -3442,6 +3445,8 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)
3442 rbd_dev->dev_id); 3445 rbd_dev->dev_id);
3443 disk->major = rbd_dev->major; 3446 disk->major = rbd_dev->major;
3444 disk->first_minor = rbd_dev->minor; 3447 disk->first_minor = rbd_dev->minor;
3448 if (single_major)
3449 disk->flags |= GENHD_FL_EXT_DEVT;
3445 disk->fops = &rbd_bd_ops; 3450 disk->fops = &rbd_bd_ops;
3446 disk->private_data = rbd_dev; 3451 disk->private_data = rbd_dev;
3447 3452