On Wed, May 25, 2016 at 06:23:21PM +0200, Michael Matz wrote:
> Hi,
> 
> On Wed, 25 May 2016, Stefan Hundhammer wrote:
> 
> > Brainstorming approach #4: Add read-only mode to parted
> > =======================================================
> > 
> > "parted -l", which we are using in this situation, should already be a 
> > read-only operation. Unfortunately, strace shows that this is not the 
> > case: It starts with opening the disk device read-only, reads 
> > information, closes it - and then for whatever reason opens it again 
> > read-write which triggers the code that sends the ioctl() to make the 
> > kernel re-read the partition table.
> 
> That's of course stupid of parted.
> 
> > We consider that a bug 
> > (https://bugzilla.suse.com/show_bug.cgi?id=979275), but it does not seem 
> > to be easy to fix. Any contribution to that would be very welcome.
> 
> See attached, fixes the bug by always opening read-only and lazily 
> switching to read-write only when necessary (i.e. a write or flush 
> operation occurs).  No libparted API changes, purely internal to the linux 
> "backend".  I think I got all places where _ensure_read_write must be 
> called, if you hit problems it should be easy to diagnose, because a 
> forgotten call will lead to obvious errors for using a write on a 
> read-only FD, so should be easy to diagnose and add.
> (also contains a local fix when not using blkid)

Michael, many thanks for the patch. I was really convinced I would
have change the libparted API, but you have proved me wrong.

I did some adjustments to the patch (e.g. it was necessary to call
_flush_cache() from _ensure_read_write()), attached it to
bsc#979275 and submitted to Factory. Whether to submit it to Beta2 or
wait for Beta3 is being discussed now.


Thanks again,

        Petr



-- 
Petr Uzel
TL SUSE L3 Team 2

Attachment: signature.asc
Description: Digital signature

Reply via email to