summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2009-10-29 16:46:22 -1000
committerDavid Cantrell <dcantrell@redhat.com>2009-10-29 17:55:44 -1000
commit3eac92e97d13e4dbbbf3c21ecca2d293eba4d97e (patch)
tree965aa08e77d3cad2a2e6293575a19f8ef78f713c
parent78486c9dd278632b55c004dda6534656793cfd58 (diff)
downloadanaconda-3eac92e97d13e4dbbbf3c21ecca2d293eba4d97e.tar.gz
anaconda-3eac92e97d13e4dbbbf3c21ecca2d293eba4d97e.tar.xz
anaconda-3eac92e97d13e4dbbbf3c21ecca2d293eba4d97e.zip
Fix "resize failed: 1" errors for ext2/ext3/ext4 (#517491).
The following install test case has been failing: https://fedoraproject.org/wiki/QA:Testcase_Anaconda_autopart_%28shrink%29_install The problem was with the minSize property in Ext2FS. We use resize2fs to get the minSize for ext2/3/4 filesystems, which is good because resize2fs accounts for additional things an extX volume may need. The problem is the value it reports is in blocks. We have to convert those blocks to bytes, then to megabytes, then round up to account for any fractional megabytes. Use dumpe2fs to get the block size and use resize2fs as we have been, but modify the calculation of size. Also the _setTargetSize() method in FS needed a change. minSize can be less than or equal to newsize, not just less than.
-rw-r--r--storage/formats/fs.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/storage/formats/fs.py b/storage/formats/fs.py
index 2f9b6e2e2..b1f6761d2 100644
--- a/storage/formats/fs.py
+++ b/storage/formats/fs.py
@@ -168,7 +168,7 @@ class FS(DeviceFormat):
self._targetSize = None
return
- if not self.minSize < newsize < self.maxSize:
+ if not self.minSize <= newsize < self.maxSize:
raise ValueError("invalid target size request")
self._targetSize = newsize
@@ -860,7 +860,23 @@ class Ext2FS(FS):
# try once in the beginning to get the minimum size for an
# existing filesystem.
size = self._minSize
+ blockSize = None
+
if self.exists and os.path.exists(self.device):
+ # get block size
+ buf = iutil.execWithCapture(self.infofsProg,
+ ["-h", self.device],
+ stderr="/dev/tty5")
+ for line in buf.splitlines():
+ if line.startswith("Block size:"):
+ blockSize = int(line.split(" ")[-1])
+ break
+
+ if blockSize is None:
+ raise FSError("failed to get block size for %s filesystem "
+ "on %s" % (self.mountType, self.device))
+
+ # get minimum size according to resize2fs
buf = iutil.execWithCapture(self.resizefsProg,
["-P", self.device],
stderr="/dev/tty5")
@@ -868,9 +884,15 @@ class Ext2FS(FS):
if "minimum size of the filesystem:" not in line:
continue
+ # line will look like:
+ # Estimated minimum size of the filesystem: 1148649
+ #
+ # NOTE: The minimum size reported is in blocks. Convert
+ # to bytes, then megabytes, and finally round up.
(text, sep, minSize) = line.partition(": ")
-
- size = int(minSize) / 1024.0
+ size = long(minSize) * blockSize
+ size = math.ceil(size / 1024.0 / 1024.0)
+ break
if size is None:
log.warning("failed to get minimum size for %s filesystem "