ndctl/zero-labels: Display error if regions are active
diff mbox series

Message ID 20191206064731.283172-1-santosh@fossix.org
State New
Headers show
Series
  • ndctl/zero-labels: Display error if regions are active
Related show

Commit Message

Santosh Sivaraj Dec. 6, 2019, 6:47 a.m. UTC
Get zero-labels behave similar to init-labels.

Signed-off-by: Santosh Sivaraj <santosh@fossix.org>
---
 ndctl/dimm.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Dan Williams Dec. 10, 2019, 7:05 p.m. UTC | #1
On Thu, Dec 5, 2019 at 10:48 PM Santosh Sivaraj <santosh@fossix.org> wrote:
>
> Get zero-labels behave similar to init-labels.

This changelog could be more precise. I'll fix this up to be.

"Make zero-labels behave the same as init-labels with respect to
failing the operation while the DIMM is active (i.e. label area is
busy)."

>
> Signed-off-by: Santosh Sivaraj <santosh@fossix.org>

...otherwise, looks good, applied.

Patch
diff mbox series

diff --git a/ndctl/dimm.c b/ndctl/dimm.c
index b1b84c2..8b039fb 100644
--- a/ndctl/dimm.c
+++ b/ndctl/dimm.c
@@ -80,6 +80,12 @@  static int action_enable(struct ndctl_dimm *dimm, struct action_context *actx)
 
 static int action_zero(struct ndctl_dimm *dimm, struct action_context *actx)
 {
+	if (ndctl_dimm_is_active(dimm)) {
+		fprintf(stderr, "%s: regions active, abort label write\n",
+			ndctl_dimm_get_devname(dimm));
+		return -EBUSY;
+	}
+
 	return ndctl_dimm_zero_label_extent(dimm, param.len, param.offset);
 }