Microsoft Virtualization Discussions

How do I provide BlockRanges to Start-NaClone

ktim
3,567 Views

I'm trying to do a sub-file clone using the toolkit. Start-NaClone has a [-BlockRanges <BlockRange[]>] parameter.

Each block range is an instance of type DataONTAP.Types.Clone.BlockRange, but I can't work out how to populate a BlockRange object, and can't find any examples or documentation around this.

Any ideas?

-Tim

1 ACCEPTED SOLUTION

beam
3,567 Views

Hi Tim,

The BlockRange object is a block range descriptor containing three key fields:  SourceBlockNumber, DestinationBlockNumber, and BlockCount.  For LUNs, these block ranges are 512-byte LBA ranges, and for WAFL files they are 4k blocks.

You can create a BlockRange object using the New-Object cmdlet, for example:

$blockRange = New-Object DataONTAP.Types.Clone.BlockRange

$blockRange.SourceBlockNumber = 0

$blockRange.DestinationBlockNumber = 1024

$blockRange.BlockCount = 4096

Calculating the block ranges is the tricky part.  For WAFL files it is fairly straightforward as long as you remember there are 4096 bytes in a WAFL block.  If you are trying to sub-file clone a file on a LUN, it is significantly more complicated (and risky).  You must find the block ranges the file occupies on the LUN, then calculate which block ranges fall in the part of the file you want to clone.  Copy-NaHostFile handles this for you, but does not do sub-file cloning.  Getting the source and destination block numbers wrong could very easily corrupt the LUN.

-Steven

View solution in original post

4 REPLIES 4

vinith
3,567 Views

Check out the help for this cmdlet.

Get-Help Start-NaClone -Examples

PS C:\Windows\system32> Get-Help Start-NaClone -Examples

NAME

    Start-NaClone

SYNOPSIS

    Starts a file/LUN or sub-file/sub-LUN clone operation.

    --------------  Example 1 --------------

    C:\PS>Start-NaClone /vol/vol2/lun1 /vol/vol2/lun1clone

    Create a clone 'lun1clone' of LUN 'lun1'.

    SourceFile      : /vol/vol2/lun1

    DestinationFile : /vol/vol2/lun1clone

    CloneState      : running

    TotalBytes      : 21476192256

    PercentDone     : 0

    BytesCopied     : 0

    CloneType       : lun

    CloneId         : 12

    Error           :

    Reason          :

--------------  Example 2 --------------

C:\PS>Get-NaLun /vol/vol2/lun1 | Start-NaClone

Clone LUN 'lun1' and accept the default destination name 'lun1Clone'.

ktim
3,567 Views

Hi Vinith,

Been there... no information on how to construct BlockRanges...

Regards,

Tim

beam
3,568 Views

Hi Tim,

The BlockRange object is a block range descriptor containing three key fields:  SourceBlockNumber, DestinationBlockNumber, and BlockCount.  For LUNs, these block ranges are 512-byte LBA ranges, and for WAFL files they are 4k blocks.

You can create a BlockRange object using the New-Object cmdlet, for example:

$blockRange = New-Object DataONTAP.Types.Clone.BlockRange

$blockRange.SourceBlockNumber = 0

$blockRange.DestinationBlockNumber = 1024

$blockRange.BlockCount = 4096

Calculating the block ranges is the tricky part.  For WAFL files it is fairly straightforward as long as you remember there are 4096 bytes in a WAFL block.  If you are trying to sub-file clone a file on a LUN, it is significantly more complicated (and risky).  You must find the block ranges the file occupies on the LUN, then calculate which block ranges fall in the part of the file you want to clone.  Copy-NaHostFile handles this for you, but does not do sub-file cloning.  Getting the source and destination block numbers wrong could very easily corrupt the LUN.

-Steven

ktim
3,567 Views

Fantastic. Thanks Steven!

Calculating the block ranges is no problem... just want to have as few calls to Invoke-N?SystemApi as possible...

Public