[parted-devel] Warning message if create partition when a partition is mounted

Curtis Gedak gedakc at gmail.com
Mon Oct 19 19:42:30 UTC 2009



Curtis Gedak wrote:
> Jim Meyering wrote:
>> Curtis Gedak wrote:
>>  
>>> Jim Meyering wrote:
>>>    
>>>> Curtis Gedak wrote:
>>>>
>>>>      
>>>>> There appears to be a regression in (alpha) parted-2.0 since 
>>>>> parted-1.9.0.
>>>>>
>>>>> Specifically something has changed that causes a warning message 
>>>>> to be
>>>>> displayed when a new partition is created and at least one partition
>>>>> on the device is mounted.  The warning messaged displayed is:
>>>>>
>>>>>    Warning: The kernel was unable to re-read the partition table
>>>>>    on /dev/sdd (Device or resource busy).  This means Linux
>>>>>    won't know anything about the modifications you made until
>>>>>    you reboot.  You should reboot your computer before doing
>>>>>    anything with /dev/sdd.
>>>>>
>>>>> This change occurs with (alpha) parted-2.0 that was downloaded from:
>>>>> ftp://alpha.gnu.org/gnu/parted/parted-2.0.tar.gz
>>>>>
>>>>>         
>
> There is still something in the back of my mind that says to me that 
> the error message is merely a symptom of a change introduced in a 
> different location in the code.
>
> Of course this hunch is kind of wishy-washy to know exactly what to 
> investigate.  :-\
>
> I have quite a few things on my plate to do with GParted now, but 
> hopefully soon I will have some time to try to follow up on this hunch.
>

Hi Jim,

Recently I have made some time to dig further into this change in 
behaviour.  Following is a description of where the change in behaviour 
was introduced.


Using GParted as a starting point, I have been able to trace the change 
in behaviour to a call to the function ped_disk_commit_to_os() in the 
file libparted/disk.c.

This function in turn calls ped_architecture->disk_ops->disk_commit() 
which in the case of linux is stored in libparted/arch/linux.c.

I believe the change in behaviour is due to the removal of the following 
code (and many supporting functions) from the function linux_disk_commit():

                /* The ioctl() command BLKPG_ADD_PARTITION does not notify
                 * the devfs system; consequently, /proc/partitions will not
                 * be up to date, and the proper links in /dev are not
                 * created.  Therefore, if using DevFS, we must get the 
kernel
                 * to re-read and grok the partition table.
                 */
                /* Work around kernel dasd problem so we really do 
BLKRRPART */
                if (disk->dev->type != PED_DEVICE_DASD &&
                    _have_blkpg () && !_have_devfs ()) {
                        if (_disk_sync_part_table (disk))
                                return 1;
                }


Without this code, the function _linux_disk_commit() returns a value of 0.

This change was introduced with the following commit:
http://git.debian.org/?p=parted/parted.git;a=commitdiff;h=1d8f9bece138e4d8e58f7b059b4195aff6f39deb;hp=d16300a88d9200e0f1e08d56e39392e028412611

To confirm that this indeed the source of the change in behaviour, I 
started with a the BETA parted-2.0 tarball and then re-introduced the 
code that was removed by this commit.  Lo and behold, the change in 
behaviour disappears.  Specifically the warning message no longer 
appears when a new partition is created on a device that has at least 
one partition mounted.

Unfortunately this commit involves the removal of much code, and is 
quite complex in nature.  As a consequence I am unsure of how this 
problem should be addressed.

Your thoughts on this would be appreciated.

Regards,
Curtis Gedak



More information about the parted-devel mailing list