anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame fb13dfb-zero_info_block-skip-seed-devices.patch

Bryan Gurney bc084d
zero_info_block: skip seed devices
Bryan Gurney bc084d
Bryan Gurney bc084d
BZ: 
Bryan Gurney bc084d
Brew: 
Bryan Gurney bc084d
Bryan Gurney bc084d
commit fb13dfb8d84c4f0a749665c8f07179450b199f3e
Bryan Gurney bc084d
Author: Jeff Moyer <jmoyer@redhat.com>
Bryan Gurney bc084d
Date:   Tue Feb 9 16:51:53 2021 -0500
Bryan Gurney bc084d
Bryan Gurney bc084d
    zero_info_block: skip seed devices
Bryan Gurney bc084d
    
Bryan Gurney bc084d
    Currently, ndctl destroy-namespace -f all will output errors of the
Bryan Gurney bc084d
    form:
Bryan Gurney bc084d
    
Bryan Gurney bc084d
      Error: destroy namespace: namespace0.0 failed to enable for zeroing, continuing
Bryan Gurney bc084d
    
Bryan Gurney bc084d
    for any zero-sized namespace.  That particular namespace looks like this:
Bryan Gurney bc084d
    
Bryan Gurney bc084d
      {
Bryan Gurney bc084d
        "dev":"namespace0.0",
Bryan Gurney bc084d
        "mode":"raw",
Bryan Gurney bc084d
        "size":0,
Bryan Gurney bc084d
        "uuid":"00000000-0000-0000-0000-000000000000",
Bryan Gurney bc084d
        "sector_size":512,
Bryan Gurney bc084d
        "state":"disabled"
Bryan Gurney bc084d
      }
Bryan Gurney bc084d
    
Bryan Gurney bc084d
    This patch skips over namespaces with size=0 when zeroing out info
Bryan Gurney bc084d
    blocks.
Bryan Gurney bc084d
    
Bryan Gurney bc084d
    Fixes: 46654c2d60b70 ("ndctl/namespace: Always zero info-blocks")
Bryan Gurney bc084d
    Reported-by: Zhang Yi <yizhan@redhat.com>
Bryan Gurney bc084d
    Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Bryan Gurney bc084d
    Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Bryan Gurney bc084d
    Link: https://lore.kernel.org/r/x49r1lohpty.fsf@segfault.boston.devel.redhat.com
Bryan Gurney bc084d
Bryan Gurney bc084d
diff --git a/ndctl/namespace.c b/ndctl/namespace.c
Bryan Gurney bc084d
index 1feb74d..1e8a2cd 100644
Bryan Gurney bc084d
--- a/ndctl/namespace.c
Bryan Gurney bc084d
+++ b/ndctl/namespace.c
Bryan Gurney bc084d
@@ -1052,6 +1052,9 @@ static int zero_info_block(struct ndctl_namespace *ndns)
Bryan Gurney bc084d
 	void *buf = NULL, *read_buf = NULL;
Bryan Gurney bc084d
 	char path[50];
Bryan Gurney bc084d
 
Bryan Gurney bc084d
+	if (ndctl_namespace_get_size(ndns) == 0)
Bryan Gurney bc084d
+		return 1;
Bryan Gurney bc084d
+
Bryan Gurney bc084d
 	ndctl_namespace_set_raw_mode(ndns, 1);
Bryan Gurney bc084d
 	rc = ndctl_namespace_enable(ndns);
Bryan Gurney bc084d
 	if (rc < 0) {