3.2.4.4.1.3 IVolumeClient::CreatePartition (Opnum 5)

The CreatePartition method creates a partition.

 HRESULT CreatePartition(
   [in] REGION_SPEC partitionSpec,
   [out] TASK_INFO* tinfo
 );

partitionSpec: A REGION_SPEC structure that defines the region type and length to create.

tinfo: Pointer to a TASK_INFO structure that the client can use to track the request's progress.

Return Values: The method MUST return 0 or a nonerror HRESULT on success, or an implementation-specific nonzero error code on failure (as specified in [MS-ERREF] section 2.1; see also section 2.2.1 for HRESULT values predefined by the Disk Management Remote Protocol).

Upon receiving this message, the server MUST validate parameters:

  1. Verify that the disk specified by partitionSpec.diskId is in the list of storage objects.

  2. Verify that the disk region specified by partitionSpec.regionId is in the list of storage objects, and check whether partitionSpec.LastKnownState matches the LastKnownState field of the object.

  3. Verify that the partitionSpec.regionId specified matches with the regionId field of one of the regions in the disk specified by partitionSpec.diskId.

  4. Verify that tinfo is not NULL.

If parameter validation fails, the server MUST fail the operation immediately, returning an appropriate error as its response to the client.

Otherwise, the server MUST process the message as follows:

  1. Create a partition on the free disk region specified by partitionSpec.regionId of the disk specified by partitionSpec.diskId. The starting offset of the partition is specified by partitionSpec.start and the length of the partition is specified by partitionSpec.length. The type of the partition to be created is specified by the partitionType.regionType parameter.<19>

  2. Wait for the partition creation to either succeed or fail.

  3. Fill in the tinfo output parameter. This is a synchronous task.

    • Field tinfo.storageId MUST be set to the identifier of the disk region object that corresponds to the new partition. Other tinfo values MUST be set as follows.

      TASK_INFO member

      Required for this operation

      TASK_INFO::id

      Required.

      TASK_INFO::storageId

      Required if the partition is created successfully.

      TASK_INFO::createTime

      Not required.<20>

      TASK_INFO::clientID

      Not required.<21>

      TASK_INFO::percentComplete

      Required for any task that returns REQ_IN_PROGRESS.

      TASK_INFO::status

      Required.

      TASK_INFO::type

      Required if PercentageComplete is being used.

      TASK_INFO::error

      Required.

      TASK_INFO::tflag

      Not required.<22>

  4. Return a response to the client that contains tinfo and the status of the operation.

If the operation is successful, the server MUST make the following changes to the list of storage objects before returning the response:

  1. Modify the disk object where the new partition resides to account for the change in region allocation.

  2. Create a new disk region object that corresponds to the new partition.

  3. Modify or delete the free disk region object where the partition was created to account for the allocation of a new partition in that region.<23>

  4. Create a new file system object that corresponds to the new partition.<24>