Clone Functions
Clone functions provide the ability to create and destroy snap clones of files.
CLib does not provide the ability to determine the clone status of a file.
To determine a file’s clone status utilise the PixStor command mmclone show <filename>
.
Description
- arcapix.fs.gpfs.clib.clone.clone_copy(source, dest)
Creates a file clone of a read-only clone parent file.
- Parameters
source – path of a read-only source file to clone. The source file can be a file in a snapshot or a clone parent file created with clone_snap()
dest – path of the destination file to create. The destination file will become the file clone.
- arcapix.fs.gpfs.clib.clone.clone_snap(source, dest=None)
Creates a read-only clone parent from a source file.
- Parameters
source – path of the source file to clone.
dest – path of the destination file to create.
If dest is None, the source file will be changed in place into a read-only clone parent. When using this method to create a clone parent, the specified file cannot be open for writing or have hard links.
- arcapix.fs.gpfs.clib.clone.clone_split(pathname, ancestor_limit=GPFS_CLONE_ALL)
Splits a file clone from its clone parent.
- Parameters
pathname – path of a file clone to split from its clone parent.
ancestor_limit – Specifies what to remove, one of the following: GPFS_CLONE_ALL - Remove references to all clone parents. (default) GPFS_CLONE_PARENT_ONLY - Remove references from the immediate clone parent only.
- arcapix.fs.gpfs.clib.clone.clone_unsnap(pathname)
Changes a clone parent with no file clones back to a regular file.
- Parameters
pathname – path of a clone parent to convert back to a regular file.
- arcapix.fs.gpfs.clib.clone.declone(pathname, blocks=- 1, offset=0, ancestor_limit=GPFS_CLONE_ALL)
Removes file clone references to clone parent blocks.
- Parameters
pathname – path of a file clone.
blocks – maximum number of GPFS blocks to copy. If blocks=-1, all remaining blocks will be decloned.
offset – starting offset within the file clone.
ancestor_limit – Specifies what to remove, one of the following: GPFS_CLONE_ALL - Remove references to all clone parents. (default) GPFS_CLONE_PARENT_ONLY - Remove references from the immediate clone parent only.
- Returns
the offset of the next block to process, or -1 if there no more blocks.
Examples
Create a clone of a file
>>> from arcapix.fs.gpfs.clib.clone import clone_snap, clone_copy
>>>
>>> # create clone parent 'base.img' of file 'test01.img'
... clone_snap('test01.img', 'base.img')
>>>
>>> # use clone parent to create file clone 'test02.img'
... clone_copy('base.img', 'test02.img')
Split a clone from its parent
>>> from arcapix.fs.gpfs.clib.clone import declone, clone_split
>>>
>>> # if a clone is non-empty, it has to be 'decloned'
... # before it can be split to remove clone references
... declone('test01.img')
>>>
>>> # split the decloned file from its parent
... clone_split('test01.img')