Hi,

Thanks for the comments, Brian and Gabriel. Agreeing with Brian, I think that if
we try to do this with DM_DEV_REMOVE ioct we might end up with a lot more code
than necessary. Since we already have this simple solution, I followed Gabriel's
suggestion regarding the $PATH variable in the v2 of this patch. I also added a
function prototype that was missing from my previous commit and was printing
some compiler warnings, but did not affect the build process.

Thanks!

-- >8 --
Since commit 0b693bd29cbe (iprutils: Unbind device before JBOD -> AF
formatting), multipath and /dev/sd device removal is done by the
binding and unbinding operations prior to formatting. We can now remove
the manual 'rm' calls in ipr_format_unit() and just flush unused multipath maps.
This patch also fixes a missing function prototype for the aforementioned 
commit.

Signed-off-by: Heitor Ricardo Alves de Siqueira <hal...@linux.vnet.ibm.com>
---
 iprlib.c | 23 +++++++++--------------
 iprlib.h |  2 ++
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/iprlib.c b/iprlib.c
index c5dfd8bb50c0..242baefa3137 100644
--- a/iprlib.c
+++ b/iprlib.c
@@ -3738,23 +3738,18 @@ int ipr_format_unit(struct ipr_dev *dev)
        u8 *defect_list_hdr;
        int length = IPR_DEFECT_LIST_HDR_LEN;
        char *name = dev->gen_name;
-       char cmnd[1000];
-       struct ipr_dev *multipath_dev;
 
        if (strlen(dev->dev_name) && dev->scsi_dev_data->device_id) {
-               sprintf(cmnd, "/sbin/multipathd -k\"del path %s\" > /dev/null 
2>&1", strrchr(dev->dev_name, '/') + 1);
-               system(cmnd);
-               sprintf(cmnd, "/bin/rm -rf %s %s%s", dev->dev_name, 
dev->dev_name, "[0-9]*");
-               system(cmnd);
-
-               multipath_dev = find_multipath_jbod(dev);
-               if (multipath_dev) {
-                       sprintf(cmnd, "/sbin/multipathd -k\"del path %s\" > 
/dev/null 2>&1", strrchr(multipath_dev->dev_name, '/') + 1);
-                       system(cmnd);
-                       sprintf(cmnd, "/bin/rm -rf %s %s%s", 
multipath_dev->dev_name, multipath_dev->dev_name , "[0-9]*");
-                       system(cmnd);
+               int pid, status;
+
+               /* flush unused multipath device maps */
+               pid = fork();
+               if (pid == 0) {
+                       execlp("multipath", "-F", NULL);
+                       _exit(errno);
+               } else {
+                       waitpid(pid, &status, 0);
                }
-               system("/sbin/multipath -F > /dev/null 2>&1");
        }
 
        if (strlen(name) == 0)
diff --git a/iprlib.h b/iprlib.h
index 16fe1e162650..3340b6830f57 100644
--- a/iprlib.h
+++ b/iprlib.h
@@ -38,6 +38,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#include <sys/wait.h>
 #include <ctype.h>
 #include <syslog.h>
 #include <term.h>
@@ -2906,6 +2907,7 @@ u32 get_ioa_ucode_version(char *);
 int ipr_improper_device_type(struct ipr_dev *);
 int ipr_get_fw_version(struct ipr_dev *, u8 release_level[4]);
 int ipr_get_live_dump(struct ipr_ioa *);
+int ipr_jbod_sysfs_bind(struct ipr_dev *, u8);
 
 static inline u32 ipr_get_dev_res_handle(struct ipr_ioa *ioa, struct 
ipr_dev_record *dev_rcd)
 {
-- 
2.4.3


------------------------------------------------------------------------------
_______________________________________________
Iprdd-devel mailing list
Iprdd-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iprdd-devel

Reply via email to