[PATCH 2/5] Disable resize operations on filesystems whose current size is unknown.

Anne Mulhern amulhern at redhat.com
Mon Nov 17 23:41:41 UTC 2014





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Monday, November 17, 2014 2:36:05 PM
> Subject: [PATCH 2/5] Disable resize operations on filesystems whose current	size is unknown.
> 
> 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

I _think_ that with these changes as I understand them now, the filesystem can
only be resizable in installer mode, cause _resizable can only be set to True
by entering that if block.

>  
>          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):

What is the purpose of comparing self._size to 0?

> +                self._resizable = self.__class__._resizable
> +            else:
> +                self._resizable = False
>  
>          self._getMinSize(info=info)   # force calculation of minimum size
>  
> --
> 1.9.3
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

- mulhern


More information about the anaconda-patches mailing list