[PATCH 4/6] ignore passive devices before checking serial numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jim Rees <rees@xxxxxxxxx>
---
 utils/blkmapd/device-discovery.c |   33 +++++++++++++++++----------------
 utils/blkmapd/device-inq.c       |   19 +++++++++++--------
 2 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/utils/blkmapd/device-discovery.c b/utils/blkmapd/device-discovery.c
index 71b4d48..c8bd39c 100644
--- a/utils/blkmapd/device-discovery.c
+++ b/utils/blkmapd/device-discovery.c
@@ -26,24 +26,25 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <dirent.h>
-#include <ctype.h>
-#include <linux/kdev_t.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include <sys/select.h>
+#include <linux/kdev_t.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_ioctl.h>
+#include <scsi/sg.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <dirent.h>
+#include <ctype.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <libgen.h>
 #include <errno.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_ioctl.h>
-#include <scsi/sg.h>
 
 #include "device-discovery.h"
 
@@ -127,7 +128,7 @@ void bl_add_disk(char *filepath)
 	struct stat sb;
 	off_t size = 0;
 	struct bl_serial *serial = NULL;
-	enum bl_path_state_e ap_state = BL_PATH_STATE_PASSIVE;
+	enum bl_path_state_e ap_state;
 	struct bl_disk_path *diskpath = NULL, *path = NULL;
 	dev_t dev;
 
@@ -152,6 +153,11 @@ void bl_add_disk(char *filepath)
 
 	dev = sb.st_rdev;
 	serial = bldev_read_serial(fd, filepath);
+	bldev_read_ap_state(fd, &ap_state);
+	close(fd);
+
+	if (ap_state == BL_PATH_STATE_PASSIVE)
+		return;
 
 	for (disk = visible_disk_list; disk != NULL; disk = disk->next) {
 		/* Already scanned or a partition?
@@ -164,13 +170,8 @@ void bl_add_disk(char *filepath)
 		}
 	}
 
-	if (disk && diskpath) {
-		close(fd);
+	if (disk && diskpath)
 		return;
-	}
-
-	bldev_read_ap_state(fd, &ap_state);
-	close(fd);
 
 	BL_LOG_ERR("%s: %s\n", __func__, filepath);
 
diff --git a/utils/blkmapd/device-inq.c b/utils/blkmapd/device-inq.c
index ff38fd6..7817c5a 100644
--- a/utils/blkmapd/device-inq.c
+++ b/utils/blkmapd/device-inq.c
@@ -28,23 +28,25 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <dirent.h>
-#include <ctype.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include <sys/select.h>
+#include <scsi/scsi.h>
+#include <scsi/scsi_ioctl.h>
+#include <scsi/sg.h>
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <dirent.h>
+#include <ctype.h>
 #include <fcntl.h>
 #include <unistd.h>
 #include <libgen.h>
 #include <errno.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_ioctl.h>
-#include <scsi/sg.h>
+
 #include "device-discovery.h"
 
 #define DEF_ALLOC_LEN	255
@@ -161,6 +163,7 @@ void bldev_read_ap_state(int fd, enum bl_path_state_e *ap_state_out)
 	if (status)
 		goto out;
 
+	printf("buffer[4]=%d\n", (int) buffer[4]);
 	if (buffer[4] < 0x02)
 		*ap_state_out = BL_PATH_STATE_PASSIVE;
  out:
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux