Message ID | 20240412-vv-daxctl-fixes-v1-1-6e808174e24f@intel.com (mailing list archive) |
---|---|
State | Accepted |
Commit | d78f57ebdc0764cfcc161873449aab3f20520456 |
Delegated to: | Patchwork Bot |
Headers | show |
Series | daxctl: Fix error handling and propagation in daxctl/device.c | expand |
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.williams@intel.com> > Cc: Alison Schofield <alison.schofield@intel.com> > Reported-by: Ira Weiny <ira.weiny@intel.com> > Reported-by: Dave Jiang <dave.jiang@intel.com> > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Looks good, Reviewed-by: Dan Williams <dan.j.williams@intel.com>
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.williams@intel.com> > Cc: Alison Schofield <alison.schofield@intel.com> > Reported-by: Ira Weiny <ira.weiny@intel.com> > Reported-by: Dave Jiang <dave.jiang@intel.com> > Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> Reviewed-by: Dave Jiang <dave.jiang@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; > >
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;
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.williams@intel.com> Cc: Alison Schofield <alison.schofield@intel.com> Reported-by: Ira Weiny <ira.weiny@intel.com> Reported-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> --- daxctl/device.c | 7 +++++++ 1 file changed, 7 insertions(+)