3.2.4.4.1.6 IVolumeClient::DeletePartition (Opnum 8)

The DeletePartition method deletes a specified partition. This is a synchronous task.

 HRESULT DeletePartition(
   [in] REGION_SPEC partitionSpec,
   [in] boolean force,
   [out] TASK_INFO* tinfo
 );

partitionSpec: A REGION_SPEC structure that specifies the type and length of the partition to delete.

force: Value that determines whether deletion of the partition will be forced. If the force parameter is not set, the call will fail if the volume cannot be locked.

Value

Meaning

FALSE

0

Deletion will not be forced if the partition is in use.

TRUE

1

Deletion will be forced.

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.<31>

  3. Verify that the region type specified by partitionSpec.regionType matches the regionType field of the object.

  4. Verify that the start of the partition specified by partitionSpec.start matches the start field of the object.

  5. Verify that the length of the partition specified by partitionSpec.length is greater than or equal to the length field of the object.

  6. 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. Attempt to delete the partition specified by partitionSpec.regionId from the disk specified by partitionSpec.diskId, as specified by the force parameter.

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

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

    TASK_INFO member

    Required for this operation

    TASK_INFO::id

    Required.

    TASK_INFO::storageId

    Not required.

    TASK_INFO::createTime

    Not required.<32>

    TASK_INFO::clientID

    Not required.<33>

    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.<34>

  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:<35>

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

  2. Delete the disk region object that corresponds to the partition.

  3. Create a new free region object or modify an adjacent free region object to account for the free space created by the deletion.

  4. Modify the drive letter object associated with the partition to mark it as free.

  5. Delete the file system object associated with the partition.