[PATCH 2/5] Disable resize operations on filesystems whose current size is unknown.
David Lehman
dlehman at redhat.com
Mon Nov 17 19:36:05 UTC 2014
It is not safe to attempt to resize without knowing the current size
or to attempt to shrink without knowing the true minimum size.
Related: rhbz#1162215
---
blivet/formats/fs.py | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/blivet/formats/fs.py b/blivet/formats/fs.py
index 9c75d2a..3cffb42 100644
--- a/blivet/formats/fs.py
+++ b/blivet/formats/fs.py
@@ -115,6 +115,9 @@ class FS(DeviceFormat):
self._minInstanceSize = Size(0) # min size of this FS instance
self._mountpoint = None # the current mountpoint when mounted
+ # Resize operations are limited to error-free filesystems whose current
+ # size is known.
+ self._resizable = False
if flags.installer_mode:
# if you want current/min size you have to call updateSizeInfo
try:
@@ -122,7 +125,6 @@ class FS(DeviceFormat):
except FSError:
log.warning("%s filesystem on %s needs repair", self.type,
self.device)
- self._resizable = False
self._targetSize = self._size
@@ -225,15 +227,27 @@ class FS(DeviceFormat):
if not self.exists:
return
+ # We can't allow resize if the filesystem has errors.
try:
self.doCheck()
except FSError:
+ errors = True
raise
+ else:
+ errors = False
finally:
# try to gather current size info anyway
info = self._getFSInfo()
self._size = self._getExistingSize(info=info)
self._minSize = self._size # default to current size
+ # We absolutely need a current size to enable resize. To shrink the
+ # filesystem we need a real minimum size provided by the resize
+ # tool. Failing that, we can default to the current size,
+ # effectively disabling shrink.
+ if not errors and self._size > Size(0):
+ self._resizable = self.__class__._resizable
+ else:
+ self._resizable = False
self._getMinSize(info=info) # force calculation of minimum size
--
1.9.3
More information about the anaconda-patches
mailing list