bug-parted
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

new PedDisk interface


From: Andrew Clausen
Subject: new PedDisk interface
Date: Thu, 18 Jan 2001 17:27:24 -0200

Hi all,

I've been thinking a lot about a new PedDisk interface.
Motivation for changes:
* automatic partitioning, allowing things like simulated annealing
* "commit everything at the end" (like fdisk) - more user
friendly / safer
* the existing interface is rather awkward - there is lots
of code duplication between *_{create,open,read,write}

So basically, this is the "operation queue" thing.  Sort of.

I think something like this is best:

PedDisk* ped_disk_probe (PedDevice* dev);
int ped_disk_clobber (PedDevice* dev);

/* creates an empty label in mem */
PedDisk* ped_disk_new_clean (PedDevice* dev);

/* creates a label, reading from the device */
PedDisk* ped_disk_new_from_dev (PedDevice* dev);

/* destroys the in-memory disk */
int ped_disk_destroy (PedDisk* disk);

/* commits all changes to disk */
int ped_disk_commit (PedDisk* disk);


int ped_disk_push_checkpoint (PedDisk* disk);
int ped_disk_pop_checkpoint (PedDisk* disk);
int ped_disk_flush_checkpoints (PedDisk* disk);


ped_disk_{push,pop}_checkpoint() are interesting, and probably
going to be contentious!  I still don't know how I'm going to
implement it... (I'm still not convinced it's the best way to go...)

Anyway, before we discussed (mainly on IRC) creating a "front end"
to the existing API, that would have operation queues.  The big
problem is, it's very difficult to implement "undo" with the existing
API.  You would have to replay "inverse" operations.  It's impossible
if you want to preserve pointers.  (If you don't preserve pointers,
then how do you maintain the identify of partitions, for example?)

So, with checkpoints, undo is trivial.

But, implementing checkpoints looks very hard.  The only way I
can think of is:
* create a *_duplicate(), which duplicates everything in the
disk label
* have a translation list, for pointers, and associated
memory.  i.e.

        struct _TranslationList {
                TranslationList*        next;
                void*                   orig;
                void*                   copy;
                size_t                  length;
        };

So, creating a checkpoint involves:
(1) duplicating everything
(2) remembering the address of everything, by mapping the duplicated
stuff to their original addresses.

Restoring a checkpoint involves memcpy() everything from copy to orig.

Yes, it's UGLY.  I hate it.  Better ideas?

Perhaps a better way to refer to partitions (and everything else), than
pointers?  Perhaps some identifier code is assigned for PedPartitions,
PedFileSystems, etc.  Then, for checkpoints, we just need to duplicate
everything.  Only the PedDisk* needs to have it's address preserved -
but it's contents don't change, anyway.

Comments?

Side note: the checkpoint stuff can be implemented after the rest.
I intend to do "the rest" RSN.  i.e. fork off 1.5.x RSN.

If some people have no idea what I'm talking about, then please
prod for a deeper explaination.  My mind isn't thinking properly
today!

Andrew Clausen



reply via email to

[Prev in Thread] Current Thread [Next in Thread]