On 4/12/24 2:05 PM, Vishal Verma wrote:
> The kernel has special handling for destroying the 0th dax device under
> any given DAX region (daxX.0). It ensures the size is set to 0, but
> doesn't actually remove the device, instead it returns an EBUSY,
> indicating that this device cannot be removed.
> 
> Add an expectation in daxctl's dev_destroy() helper to handle this case
> instead of returning the error - as far as the user is concerned, the
> size has been set to zero, and the destroy operation has been completed,
> even if the kernel indicated an EBUSY.
> 
> Cc: Dan Williams <dan.j.willi...@intel.com>
> Cc: Alison Schofield <alison.schofi...@intel.com>
> Reported-by: Ira Weiny <ira.we...@intel.com>
> Reported-by: Dave Jiang <dave.ji...@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.ve...@intel.com>

Reviewed-by: Dave Jiang <dave.ji...@intel.com>
> ---
>  daxctl/device.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/daxctl/device.c b/daxctl/device.c
> index 83913430..83c61389 100644
> --- a/daxctl/device.c
> +++ b/daxctl/device.c
> @@ -675,6 +675,13 @@ static int dev_destroy(struct daxctl_dev *dev)
>               return rc;
>  
>       rc = daxctl_region_destroy_dev(daxctl_dev_get_region(dev), dev);
> +     /*
> +      * The kernel treats daxX.0 specially. It can't be deleted to ensure
> +      * there is always a /sys/bus/dax/ present. If this happens, an
> +      * EBUSY is returned. Expect it and don't treat it as an error.
> +      */
> +     if (daxctl_dev_get_id(dev) == 0 && rc == -EBUSY)
> +             return 0;
>       if (rc < 0)
>               return rc;
>  
> 

Reply via email to