[parted-devel] [PATCH 0/5] Add --readonly flag to parted

Arvin Schnell aschnell at suse.com
Wed Feb 15 14:26:24 GMT 2023


On Tue, Feb 14, 2023 at 04:40:08PM -0800, Brian C. Lane wrote:
> On Mon, Feb 13, 2023 at 08:41:35AM +0000, Arvin Schnell wrote:

> > This does not work on Linux if there are partitions that are not
> > mounted. In that case _flush_cache still opens the partitions in
> > WRONLY mode thus triggering udev. The problem seems to be that
> > while _device_open gets the flags correctly (from
> > _device_open_ro), _flush_cache looks at dev->read_only.
> 
> Good catch. I was testing it on a disk.img file and a disk with mounted
> partitions and didn't see that.

I was just lucky to test it on a disk used for LVM (so the
partition is also not mounted).

> It looks like the path there is through the initial probe, using
> _device_open_ro(), and the reason the _flush_cache is there is because
> of commit fb99ba5e which says it was sometimes mis-identifying a
> new filesystem because the cache hadn't been flushed yet.

And the flushing is needed apparently since the file system probe
code looks at the disk device instead of the partition device
(which is nice when using parted on disk images - another new
thing learned).

> So I don't think there is any way to prevent that, it needs to flush it
> to make sure it has the latest data.
> 
> I think this patchset is an improvement over the other options, but I'm
> not totally convinced it matters if it can't keep all the events from
> happening.

I also think it is an improvement, esp. since most partitions
normally are mounted. For me it would also be fine if --readonly
skips the flushing with a note in the documentation about
possibly wrong file system information. For me it works without
the flush.

Kind Regards,
  Arvin

-- 
Arvin Schnell, <aschnell at suse.com>
Senior Software Engineer, Research & Development

SUSE Software Solutions Germany GmbH
Frankenstraße 146
90461 Nürnberg
Germany

(HRB 36809, AG Nürnberg)

Geschäftsführer: Ivo Totev, Andrew Myers, Andrew McDonald,
                 Boudien Moerman



More information about the parted-devel mailing list