[Oberon] RFC: RAIF (Redundant Array of Independant Filesystems)

Patrick.Hunziker at unibas.ch Patrick.Hunziker at unibas.ch
Sat Jan 20 20:17:17 MET 2007


Hi all:
To solve some problems with data backup, I propose a RAIF (analogue to RAID)
which stands for 'redundant array of independant filesystems' allowing
transparent handling of identical files on two different filesystems. A nice
feature would be that 'compressing file systems', 'remote file systems' etc can
be neatly reused.
Please comment this first draft critically, or improve directly the proposed
implementation (which compiles, but is untested):
Some features are not yet done (finalize, copy etc).

MODULE RAIF ;	(**  AUTHOR "Patrick Hunziker"; PURPOSE "RAIF=Redundant Array of
Independent Filesystems";  **)

IMPORT AosFS;

TYPE
RAID5FS=OBJECT (AosFS.FileSystem); (*similar to RAID5 concept offering redundant
data storage*)
	VAR FSA-,FSB-: AosFS.FileSystem; 	(*may also be archive-based, remote, etc;
this will need decoupling of the slow remote FS in separate process*)
			incremental*:BOOLEAN;	(*adds new file version without deleting old one, which
is renamed ('somename.N.Bak'*)

	PROCEDURE &Init*(FSA,FSB: AosFS.FileSystem; incremental:BOOLEAN);
	BEGIN
		SELF.FSA:=FSA;
		SELF.FSB:=FSB;
		SELF.incremental:=incremental;
	END Init;

	PROCEDURE Old*(name:ARRAY OF CHAR):AosFS.File;	(*todo: if file in both file
systems, rather choose the newer one ?*)
	VAR f:AosFS.File;
			name0,fullname: ARRAY AosFS.PrefixLength+AosFS.NameLength OF CHAR;
			prefix: ARRAY AosFS.PrefixLength OF CHAR;
	BEGIN
		AosFS.SplitName(name,prefix, name0);
		AosFS.JoinName(FSA.prefix,name0,fullname);
		f:=AosFS.Old(fullname);
		IF f=NIL THEN
			AosFS.JoinName(FSA.prefix,name0,fullname);
			f:=AosFS.Old(fullname);
		END;
		RETURN f
	END Old;

	PROCEDURE New*(name:ARRAY OF CHAR):AosFS.File;
	VAR f:AosFS.File;
			name0,fullname: ARRAY AosFS.PrefixLength+AosFS.NameLength OF CHAR;
			prefix: ARRAY AosFS.PrefixLength OF CHAR;
	BEGIN
		AosFS.SplitName(name,prefix,name0);
		AosFS.JoinName(FSA.prefix,name0,fullname);	(*default*)
		f:=AosFS.New(fullname);
		RETURN f
	END New;

	PROCEDURE Delete*(name: ARRAY OF CHAR; res: LONGINT);
	VAR f:AosFS.File;
			name0,fullname: ARRAY AosFS.PrefixLength+AosFS.NameLength OF CHAR;
			prefix: ARRAY AosFS.PrefixLength OF CHAR;
			resA,resB:LONGINT;
	BEGIN
		AosFS.SplitName(name,prefix,name0);
		AosFS.JoinName(FSA.prefix,name0,fullname); AosFS.Delete(fullname,resA);
		AosFS.JoinName(FSA.prefix,name0,fullname); AosFS.Delete(fullname,resB);
(*ToDo: what is the correct return value (or are 2 return values needed?)*)
	END Delete;

	PROCEDURE Register*(f:AosFS.File);
	VAR name, name1,name2: ARRAY AosFS.PrefixLength+AosFS.NameLength OF CHAR;
			prefix: ARRAY AosFS.PrefixLength OF CHAR;
			res:LONGINT;
			overwrite:BOOLEAN;
	BEGIN
		AosFS.Register(f);
		f.GetName(name);
		AosFS.SplitName(name, prefix, name1);
		IF prefix=FSA.prefix THEN AosFS.JoinName(FSB.prefix, name1, name2);
		ELSIF prefix=FSB.prefix THEN AosFS.JoinName(FSA.prefix, name1, name2);
		ELSE HALT(100);
		END;
		IF incremental THEN
			overwrite:=FALSE;
			HALT(101); (*incomplete implementation: ToDo: check for identity, dates;
avoid name clashes*)
		ELSE overwrite:=FALSE
		END;
		AosFS.CopyFile(name,name2,overwrite, res);
	END Register;

END RAID5FS;


END RAIF.


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the Oberon mailing list