[parted-devel] [PATCH] parted: fix the resizepart command logic

Wang Dong dongdwdw at linux.vnet.ibm.com
Wed Apr 19 03:28:40 UTC 2017



On 04/18/2017 09:29 PM, Phil Susi wrote:
> On 3/31/2017 6:31 AM, Wang Dong wrote:
>> When to resize a partition in interactive mode, if user provides an end
>> point which is before the old end point, parted will raise a warning
>> of data loss. But parted will modify the disk information even before
>> the response from user. Further more, if user finally declines to resize
>> at last, the disk information in memory will not be committed to device,
>> and will be different from that on device. This might lead to some confusion.
>> Becaus user will only see the disk in memory but not the real on device.
>>
>> Now in the same situation, parted will raise warning first and decide whether
>> to change the disk information according user's response.
> Good catch, but not quite the right implementation.  The reason the in
> memory disk layout was changed first is because doing so might result in
> the end not being exactly where the user requested it, so that must be
> done before checking if the end shrank.  Before I made the PedDisk
> persist across commands, simply not committing the modified disk and
> discarding it was sufficient.  Now this command will need to duplicate
> it, modify the temporary copy, and if the exception says to bail out,
> discard that temporary copy.
>
>
The user offers an end, and if it is smaller than the partition end,
it is a shrinking.  And this exception will only be raised when a shrinking
happens. I think we can check if it is a shrinking earlier. I mean before to
change the disk layout.

Yeah, it should be discarded when user says "No". I cannot understand
why to keep it when users say no.

"Your discard" can not be done without a device re-reading. User has to 
re-read
the device to get the real disk layout. This is not good I think. It 
will confuse
user.

But the discard can be made by destroying the disk in memory when a 
command fails.
I have another patch for this.



-- 
Best regards. Wang Dong




More information about the parted-devel mailing list