rpms/parted/devel parted-1.7.1-gpt.patch, NONE, 1.1 parted-1.7.1-O_DIRECT.patch, 1.2, 1.3 parted.spec, 1.81, 1.82

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Thu Aug 17 17:52:09 UTC 2006


Author: dcantrel

Update of /cvs/dist/rpms/parted/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv1003

Modified Files:
	parted-1.7.1-O_DIRECT.patch parted.spec 
Added Files:
	parted-1.7.1-gpt.patch 
Log Message:
- Updated O_DIRECT patch to work around s390 problems
- Update LastUsableLBA on GPT-labeled disks after LUN resize (#194238)
- Fix exception when backup GPT table is not in the correction location
  and parted tries to move it (#194238)


parted-1.7.1-gpt.patch:
 libparted/labels/gpt.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++--
 parted/ui.c            |    2 +-
 2 files changed, 47 insertions(+), 3 deletions(-)

--- NEW FILE parted-1.7.1-gpt.patch ---
--- parted-1.7.1/libparted/labels/gpt.c.gpt	2006-05-25 13:28:55.000000000 -0400
+++ parted-1.7.1/libparted/labels/gpt.c	2006-08-17 13:44:17.000000000 -0400
@@ -607,11 +607,13 @@
 }
 
 static int
-_parse_header (PedDisk* disk, GuidPartitionTableHeader_t* gpt)
+_parse_header (PedDisk* disk, GuidPartitionTableHeader_t* gpt, int *update_needed)
 { 
 	GPTDiskData* gpt_disk_data = disk->disk_specific;
 	PedSector first_usable;
 	PedSector last_usable;
+	PedSector last_usable_if_grown, last_usable_min_default;
+	static int asked_already;
 
 	PED_ASSERT (_header_is_valid (disk->dev, gpt), return 0);
 
@@ -633,8 +635,50 @@
 
 	first_usable = PED_CPU_TO_LE64 (gpt->FirstUsableLBA);
 	last_usable = PED_CPU_TO_LE64 (gpt->LastUsableLBA);
+
+	/*
+	 * Need to check whether the volume has grown, the LastUsableLBA is
+	 * normally set to disk->dev->length - 2 - ptes_size (at least for parted
+	 * created volumes), where ptes_size is the number of entries * 
+	 * size of each entry / sector size or 16k / sector size, whatever the
+	 * greater.  If the volume has grown, offer the user the chance to use
+	 * the new space or continue with the current usable area.  Only ask once
+	 * per parted invocation.
+	 */
+
+	last_usable_if_grown =
+		PED_CPU_TO_LE64 (disk->dev->length - 2 - 
+		((PedSector)(PED_CPU_TO_LE32(gpt->NumberOfPartitionEntries)) * 
+		(PedSector)(PED_CPU_TO_LE32(gpt->SizeOfPartitionEntry)) / 
+		disk->dev->sector_size));
+
+	last_usable_min_default = disk->dev->length - 2 - 
+		GPT_DEFAULT_PARTITION_ENTRY_ARRAY_SIZE / disk->dev->sector_size;
+
+	if (last_usable_if_grown > last_usable_min_default)
+		last_usable_if_grown = last_usable_min_default;
+
 	PED_ASSERT (last_usable > first_usable, return 0);
 	PED_ASSERT (last_usable <= disk->dev->length, return 0);
+
+	PED_ASSERT (last_usable_if_grown > first_usable, return 0);
+	PED_ASSERT (last_usable_if_grown <= disk->dev->length, return 0);
+
+	if (!asked_already && last_usable < last_usable_if_grown) {
+		int q = ped_exception_throw(PED_EXCEPTION_WARNING,
+		                            PED_EXCEPTION_FIX | PED_EXCEPTION_IGNORE,
+		                            _("Not all of the space available to this "
+		                              "disk appears to be used, you can fix "
+		                              "the GPT to use all of the space or "
+		                              "continue with the current setting? "));
+		if (q == PED_EXCEPTION_FIX) {
+			last_usable = last_usable_if_grown;
+			*update_needed = 1;
+		}
+
+		asked_already = 1;
+	}
+
 	ped_geometry_init (&gpt_disk_data->data_area, disk->dev,
 			   first_usable, last_usable - first_usable + 1);
 
@@ -795,7 +839,7 @@
 		}
 	}
 
-	if (!_parse_header (disk, gpt))
+	if (!_parse_header (disk, gpt, &write_back))
 		goto error_free_gpt;
 
 
--- parted-1.7.1/parted/ui.c.gpt	2006-05-25 13:28:42.000000000 -0400
+++ parted-1.7.1/parted/ui.c	2006-08-17 12:11:30.000000000 -0400
@@ -1027,13 +1027,13 @@
 
 	opt = PED_EXCEPTION_OPTION_FIRST;
 	while (1) {
-		opt = option_get_next (options, opt);
 		if (strcmp (opt_name,
 			    ped_exception_get_option_string (opt)) == 0)
 			break;
 		if (strcmp (opt_name,
 			    _(ped_exception_get_option_string (opt))) == 0)
 			break;
+		opt = option_get_next (options, opt);
 	}
 	free (opt_name);
 	return opt;

parted-1.7.1-O_DIRECT.patch:
 linux.c |   45 +++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 41 insertions(+), 4 deletions(-)

Index: parted-1.7.1-O_DIRECT.patch
===================================================================
RCS file: /cvs/dist/rpms/parted/devel/parted-1.7.1-O_DIRECT.patch,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- parted-1.7.1-O_DIRECT.patch	22 Jun 2006 18:35:07 -0000	1.2
+++ parted-1.7.1-O_DIRECT.patch	17 Aug 2006 17:52:06 -0000	1.3
@@ -1,5 +1,5 @@
---- parted-1.7.1/libparted/arch/linux.c.o_direct	2006-06-22 14:31:38.000000000 -0400
-+++ parted-1.7.1/libparted/arch/linux.c	2006-06-22 14:32:59.000000000 -0400
+--- parted-1.7.1/libparted/arch/linux.c.o_direct	2006-08-17 11:20:31.000000000 -0400
++++ parted-1.7.1/libparted/arch/linux.c	2006-08-17 11:24:13.000000000 -0400
 @@ -30,6 +30,7 @@
  #include <libgen.h>
  #include <stdint.h>
@@ -8,30 +8,39 @@
  #include <string.h>
  #include <syscall.h>
  #include <unistd.h>
-@@ -1212,7 +1213,7 @@
+@@ -1212,7 +1213,11 @@
                  if (!name)
                          break;
                  if (!_partition_is_mounted_by_path (name)) {
--                        fd = open (name, O_WRONLY, 0);
++#if defined(__s390__) || defined(__s390x__)
+                         fd = open (name, O_WRONLY, 0);
++#else
 +                        fd = open (name, O_WRONLY | O_DIRECT, 0);
++#endif
                          if (fd > 0) {
                                  ioctl (fd, BLKFLSBUF);
                                  close (fd);
-@@ -1228,11 +1229,11 @@
+@@ -1228,11 +1233,19 @@
          LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
  
  retry:
--        arch_specific->fd = open (dev->path, O_RDWR);
++#if defined(__s390__) || defined(__s390x__)
+         arch_specific->fd = open (dev->path, O_RDWR);
++#else
 +        arch_specific->fd = open (dev->path, O_RDWR | O_DIRECT);
++#endif
          if (arch_specific->fd == -1) {
                  char*   rw_error_msg = strerror (errno);
  
--                arch_specific->fd = open (dev->path, O_RDONLY);
++#if defined(__s390__) || defined(__s390x__)
+                 arch_specific->fd = open (dev->path, O_RDONLY);
++#else
 +                arch_specific->fd = open (dev->path, O_RDONLY | O_DIRECT);
++#endif
                  if (arch_specific->fd == -1) {
                          if (ped_exception_throw (
                                  PED_EXCEPTION_ERROR,
-@@ -1375,6 +1376,7 @@
+@@ -1375,6 +1388,7 @@
          int                     status;
          PedExceptionOption      ex_status;
          size_t                  read_length = count * dev->sector_size;
@@ -39,7 +48,7 @@
  
          PED_ASSERT (dev->sector_size % 512 == 0, return 0);
  
-@@ -1412,8 +1414,12 @@
+@@ -1412,8 +1426,12 @@
                  }
          }
  
@@ -53,7 +62,7 @@
                  if (status == count * dev->sector_size) break;
                  if (status > 0) {
                          read_length -= status;
-@@ -1430,6 +1436,7 @@
+@@ -1430,6 +1448,7 @@
  
                  switch (ex_status) {
                          case PED_EXCEPTION_IGNORE:
@@ -61,7 +70,7 @@
                                  return 1;
  
                          case PED_EXCEPTION_RETRY:
-@@ -1438,9 +1445,11 @@
+@@ -1438,9 +1457,11 @@
                          case PED_EXCEPTION_UNHANDLED:
                                  ped_exception_catch ();
                          case PED_EXCEPTION_CANCEL:
@@ -73,7 +82,7 @@
  
          return 1;
  }
-@@ -1486,6 +1495,8 @@
+@@ -1486,6 +1507,8 @@
          int                     status;
          PedExceptionOption      ex_status;
          size_t                  write_length = count * dev->sector_size;
@@ -82,7 +91,7 @@
  
          PED_ASSERT(dev->sector_size % 512 == 0, return 0);
  
-@@ -1539,12 +1550,16 @@
+@@ -1539,12 +1562,16 @@
                  dev->path, buffer, (int) start, (int) count);
  #else
          dev->dirty = 1;
@@ -101,7 +110,7 @@
                          continue;
                  }
  
-@@ -1556,6 +1571,7 @@
+@@ -1556,6 +1583,7 @@
  
                  switch (ex_status) {
                          case PED_EXCEPTION_IGNORE:
@@ -109,7 +118,7 @@
                                  return 1;
  
                          case PED_EXCEPTION_RETRY:
-@@ -1564,9 +1580,11 @@
+@@ -1564,9 +1592,11 @@
                          case PED_EXCEPTION_UNHANDLED:
                                  ped_exception_catch ();
                          case PED_EXCEPTION_CANCEL:
@@ -121,7 +130,7 @@
  #endif /* !READ_ONLY */
          return 1;
  }
-@@ -1579,18 +1597,25 @@
+@@ -1579,18 +1609,25 @@
          LinuxSpecific*  arch_specific = LINUX_SPECIFIC (dev);
          PedSector       done = 0;
          int             status;


Index: parted.spec
===================================================================
RCS file: /cvs/dist/rpms/parted/devel/parted.spec,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -r1.81 -r1.82
--- parted.spec	15 Aug 2006 20:04:16 -0000	1.81
+++ parted.spec	17 Aug 2006 17:52:06 -0000	1.82
@@ -4,7 +4,7 @@
 Summary: The GNU disk partition manipulation program.
 Name: parted
 Version: 1.7.1
-Release: 11%{?dist}
+Release: 12%{?dist}
 Source: ftp://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.bz2
 Patch0: parted-1.7.0-fat.c.patch
 Patch1: parted-1.7.0-sx8.patch
@@ -15,6 +15,7 @@
 Patch7: parted-1.7.1-vtoc-errbuf.patch
 Patch8: parted-1.7.1-O_DIRECT.patch
 Patch9: parted-1.7.1-get_exception.patch
+Patch10: parted-1.7.1-gpt.patch
 
 Buildroot: %{_tmppath}/%{name}-root
 License: GPL
@@ -51,10 +52,9 @@
 %patch5 -p1 -b .dm
 %patch6 -p1 -b .aix
 %patch7 -p1 -b .vtoc_errbuf
-%ifnarch s390 s390x
 %patch8 -p1 -b .o_direct
-%endif
 %patch9 -p1 -b .get_exception
+%patch10 -p1 -b .gpt
 
 iconv -f iso-8859-1 -t utf-8 < doc/pt_BR-parted.8 > doc/pt_BR-parted.8_
 mv doc/pt_BR-parted.8_ doc/pt_BR-parted.8
@@ -108,6 +108,12 @@
 %{_libdir}/*.so
 
 %changelog
+* Thu Aug 17 2006 David Cantrell <dcantrell at redhat.com> - 1.7.1-12
+- Updated O_DIRECT patch to work around s390 problems
+- Update LastUsableLBA on GPT-labeled disks after LUN resize (#194238)
+- Fix exception when backup GPT table is not in the correction location
+  and parted tries to move it (#194238)
+
 * Tue Aug 15 2006 David Cantrell <dcantrell at redhat.com> - 1.7.1-11
 - Expand error buffer to 8192 bytes in vtoc_error()
 - Do not apply O_DIRECT patch on S/390 or S/390x platforms




More information about the fedora-cvs-commits mailing list