[Parted-commits] GNU Parted Official Repository: Changes to 'master'

Jim Meyering meyering at alioth.debian.org
Sun Nov 27 08:56:11 UTC 2011


 .gitignore                       |    1 
 NEWS                             |    4 ++
 libparted/arch/linux.c           |    4 +-
 tests/Makefile.am                |    1 
 tests/t6100-mdraid-partitions.sh |   66 +++++++++++++++++++++++++++++++++++++++
 5 files changed, 74 insertions(+), 2 deletions(-)

New commits:
commit 0e949391543b49e9d7b3a9a2c3682e7faaaa2285
Author: Petr Uzel <petr.uzel at suse.cz>
Date:   Sat Nov 26 15:45:09 2011 +0100

    tests: test for partitions on mdraid
    
    * tests/t6100-mdraid-partitions.sh: New file.
    * tests/Makefile.am: Run this test.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5bc513d..616684e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -49,6 +49,7 @@ TESTS = \
   t4300-nilfs2-tiny.sh \
   t5000-tags.sh \
   t6000-dm.sh \
+  t6100-mdraid-partitions.sh \
   t7000-scripting.sh \
   t8000-loop.sh \
   t8001-loop-blkpg.sh \
diff --git a/tests/t6100-mdraid-partitions.sh b/tests/t6100-mdraid-partitions.sh
new file mode 100755
index 0000000..1fedb69
--- /dev/null
+++ b/tests/t6100-mdraid-partitions.sh
@@ -0,0 +1,66 @@
+#!/bin/sh
+# verify that new kernel is informed about partitions on mdraid devices
+
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
+
+require_root_
+require_scsi_debug_module_
+require_mdadm_
+
+# create memory-backed device
+scsi_debug_setup_ dev_size_mb=10 > dev-name ||
+  skip_ 'failed to create scsi_debug device'
+scsi_dev=$(cat dev-name)
+
+# Arbitrary number, not likely to be used already
+md_name=md99
+md_dev=/dev/$md_name
+
+test -b $md_dev && skip_ "$md_dev already exists"
+
+# Use gpt and create two partitions on the device.
+parted -s "$scsi_dev" mklabel gpt \
+    mkpart p1 ext2 1M 4M \
+    mkpart p2 ext2 5M 8M > out 2>&1 || fail=1
+compare /dev/null out || fail=1
+
+cleanup_fn_() {
+  # stop mdraid array
+  mdadm -S $md_dev || warn_ "Failed to stop MD array, $md_dev"
+}
+
+# create mdraid on top of both partitions
+mdadm -C $md_dev --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2"
+
+# create gpt and two partitions on the raid device
+parted -s $md_dev mklabel gpt \
+    mkpart r1 ext2 1M 2M \
+    mkpart r2 ext2 2M 3M > out 2>&1 || fail=1
+compare /dev/null out || fail=1
+
+# Verify that kernel has been informed about the second device.
+grep "${md_name}p2" /proc/partitions || { fail=1; cat /proc/partitions; }
+
+# Remove partitions from the raid device.
+parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1
+compare /dev/null out || fail=1
+
+# Verify that kernel has been informed about those removals.
+grep "${md_name}p[12]" /proc/partitions && { fail=1; cat /proc/partitions; }
+
+Exit $fail

commit ca97da905bd21f2a4371f4717f7c46a936af6b2c
Author: Petr Uzel <petr.uzel at suse.cz>
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;
 }

commit e76b1af9dfb33292ba915d30a5042dbfe75d75bd
Author: Petr Uzel <petr.uzel at suse.cz>
Date:   Sat Nov 26 15:47:28 2011 +0100

    build: gitignore tests/duplicate
    
    .gitignore: Add tests/duplicate.

diff --git a/.gitignore b/.gitignore
index 98005db..da8d7af 100644
--- a/.gitignore
+++ b/.gitignore
@@ -55,6 +55,7 @@ po/.reference
 stamp-h1
 tags
 tests/dup-clobber
+tests/duplicate
 tests/help-version.log
 tests/old-init.sh
 tests/print-align



More information about the Parted-commits mailing list