[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: support for partitioned linux md devices
From: |
Jim Meyering |
Subject: |
Re: support for partitioned linux md devices |
Date: |
Fri, 24 Aug 2012 09:01:31 +0200 |
Miquel van Smoorenburg wrote:
> I've also filed this as a debian bugreport,
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684713
>
> Linux md raid array devices come in two flavours: partionable
> (/dev/md_d0) and non-partitionable (/dev/md0). Or at least,
> that used to be the case, until kernel 2.6.28 where the two have
> been consolidated. Now all md devices can have partitions.
>
> However, there is one minor oversight/bug in the kernel: the
> sysfs "range" key is still set to "1" for md devices. That means
> libparted thinks that it's not possible to partition that device,
> when in fact it is.
>
> The attached patch reckognizes that situation: if running on
> a kernel >= 2.6.28, and the device is a PED_DEVICE_MD, and the
> sysfs 'range' key is set to '1', _device_get_partition_range()
> returns MAX_NUM_PARTS instead.
>
> Mike.
>
> Index: parted-2.3/libparted/arch/linux.c
> ===================================================================
> --- parted-2.3.orig/libparted/arch/linux.c 2010-05-10 10:57:54.000000000
> +0000
> +++ parted-2.3/libparted/arch/linux.c 2012-08-05 13:24:14.449768577 +0000
> @@ -2415,6 +2415,11 @@
> ok = fscanf(fp, "%d", &range) == 1;
> fclose(fp);
>
> + /* starting at 2.6.28 partitions are OK but "range" doesn't show it */
> + if (dev->type == PED_DEVICE_MD && range == 1 &&
> + _get_linux_version() >= KERNEL_VERSION (2,6,28))
> + ok = 0;
> +
> /* (range <= 0) is none sense.*/
> return ok && range > 0 ? range : MAX_NUM_PARTS;
> }
Thanks for the patch.
FYI, Petr Uzel made the following change in v3.0-61-gca97da9:
http://anonscm.debian.org/gitweb/?p=parted/parted.git;a=commitdiff;h=ca97da905bd21f2a4371f4717f7c46a936af6b2c
commit ca97da905bd21f2a4371f4717f7c46a936af6b2c
Author: Petr Uzel <address@hidden>
Date: Sat Nov 26 15:45:08 2011 +0100
libparted: use ext_range to find out largest possible partition
Parted uses /sys/block/DEV/range file to find out how many partitions
can the blockdevice hold and uses this number in its algorithm
for informing the kernel about modified partitions. This works
fine for most devices, however, it fails on partitionable MD arrays,
because these have 1 in range file. Using ext_range should be safer
and work for all devices.
* libparted/arch/linux.c (_device_get_partition_range): Use
/sys/block/DEV/ext_range instead of range sysfs file
* NEWS: Mention the change.
Addresses: http://bugzilla.novell.com/567652
diff --git a/NEWS b/NEWS
index 566484c..5d8df35 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,10 @@ GNU parted NEWS -*-
outline -*-
with an HFS or HFS+ signature, but with invalid ->total_blocks and/or
->block_size values.
+ parted now uses ext_range device sysfs attribute to determine maximum number
+ of partitions the device can hold. With this change, parted now correctly
+ informs kernel about new partitions on partitionable MD RAID devices.
+
** Changes in behavior
parted: mkpart command has changed semantics with regard to specifying end
diff --git a/libparted/arch/linux.c b/libparted/arch/linux.c
index ab3d904..1da3343 100644
--- a/libparted/arch/linux.c
+++ b/libparted/arch/linux.c
@@ -2484,7 +2484,7 @@ _loop_get_partition_range(PedDevice const* dev)
/*
* The number of partitions that a device can have depends on the kernel.
- * If we don't find this value in /sys/block/DEV/range, we will use our own
+ * If we don't find this value in /sys/block/DEV/ext_range, we will use our own
* value.
*/
static unsigned int
@@ -2495,7 +2495,7 @@ _device_get_partition_range(PedDevice const* dev)
return _loop_get_partition_range(dev);
int range;
- bool ok = _sysfs_int_entry_from_dev(dev, "range", &range);
+ bool ok = _sysfs_int_entry_from_dev(dev, "ext_range", &range);
return ok && range > 0 ? range : MAX_NUM_PARTS;
}