163 lines
5.0 KiB
Diff
163 lines
5.0 KiB
Diff
|
|
diff --git a/libmpathpersist/mpath_persist.c b/libmpathpersist/mpath_persist.c
|
||
|
|
index 27c848c..1e6a172 100644
|
||
|
|
--- a/libmpathpersist/mpath_persist.c
|
||
|
|
+++ b/libmpathpersist/mpath_persist.c
|
||
|
|
@@ -199,6 +199,11 @@ int mpath_persistent_reserve_in (int fd, int rq_servact,
|
||
|
|
if (map_present && !dm_is_mpath(alias)){
|
||
|
|
condlog( 0, "%s: not a multipath device.", alias);
|
||
|
|
ret = MPATH_PR_DMMP_ERROR;
|
||
|
|
+ if (curmp)
|
||
|
|
+ vector_free(curmp);
|
||
|
|
+ if (pathvec)
|
||
|
|
+ vector_free(pathvec);
|
||
|
|
+
|
||
|
|
goto out;
|
||
|
|
}
|
||
|
|
|
||
|
|
@@ -297,6 +302,10 @@ int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
|
||
|
|
if (map_present && !dm_is_mpath(alias)){
|
||
|
|
condlog(3, "%s: not a multipath device.", alias);
|
||
|
|
ret = MPATH_PR_DMMP_ERROR;
|
||
|
|
+ if (curmp)
|
||
|
|
+ vector_free(curmp);
|
||
|
|
+ if (pathvec)
|
||
|
|
+ vector_free(pathvec);
|
||
|
|
goto out;
|
||
|
|
}
|
||
|
|
|
||
|
|
@@ -321,7 +330,7 @@ int mpath_persistent_reserve_out ( int fd, int rq_servact, int rq_scope,
|
||
|
|
goto out1;
|
||
|
|
}
|
||
|
|
|
||
|
|
- /* get info of all paths from the dm device */
|
||
|
|
+ /* get info of all paths from the dm device */
|
||
|
|
if (get_mpvec(curmp, pathvec, alias)){
|
||
|
|
condlog(0, "%s: failed to get device info.", alias);
|
||
|
|
ret = MPATH_PR_DMMP_ERROR;
|
||
|
|
@@ -882,7 +891,7 @@ out:
|
||
|
|
return (status);
|
||
|
|
}
|
||
|
|
|
||
|
|
-void * mpath_alloc_prin_response(int prin_sa)
|
||
|
|
+void *mpath_alloc_prin_response(int prin_sa)
|
||
|
|
{
|
||
|
|
void * ptr = NULL;
|
||
|
|
int size=0;
|
||
|
|
@@ -905,6 +914,10 @@ void * mpath_alloc_prin_response(int prin_sa)
|
||
|
|
if (size > 0)
|
||
|
|
{
|
||
|
|
ptr = calloc(size, 1);
|
||
|
|
+ if (!ptr) {
|
||
|
|
+ condlog (0, "failed to allocate MPATH_PRIN_RFSTAT_SA buffer");
|
||
|
|
+ return NULL;
|
||
|
|
+ }
|
||
|
|
}
|
||
|
|
return ptr;
|
||
|
|
}
|
||
|
|
diff --git a/libmpathpersist/mpath_pr_ioctl.c b/libmpathpersist/mpath_pr_ioctl.c
|
||
|
|
index 6dd7403..b317b4e 100644
|
||
|
|
--- a/libmpathpersist/mpath_pr_ioctl.c
|
||
|
|
+++ b/libmpathpersist/mpath_pr_ioctl.c
|
||
|
|
@@ -25,8 +25,8 @@
|
||
|
|
int prin_do_scsi_ioctl(char * dev, int rq_servact, struct prin_resp *resp, int noisy);
|
||
|
|
void mpath_format_readkeys(struct prin_resp *pr_buff, int len , int noisy);
|
||
|
|
void mpath_format_readfullstatus(struct prin_resp *pr_buff, int len, int noisy);
|
||
|
|
-int mpath_translate_response (char * dev, struct sg_io_hdr io_hdr,
|
||
|
|
- SenseData_t *Sensedata, int noisy);
|
||
|
|
+int mpath_translate_response (const char *dev, struct sg_io_hdr *io_hdr,
|
||
|
|
+ const SenseData_t *Sensedata, int noisy);
|
||
|
|
void dumpHex(const char* str, int len, int no_ascii);
|
||
|
|
int prout_do_scsi_ioctl( char * dev, int rq_servact, int rq_scope,
|
||
|
|
unsigned int rq_type, struct prout_param_descriptor *paramp, int noisy);
|
||
|
|
@@ -115,7 +115,7 @@ retry :
|
||
|
|
|
||
|
|
condlog(4, "%s: Duration=%u (ms)", dev, io_hdr.duration);
|
||
|
|
|
||
|
|
- status = mpath_translate_response(dev, io_hdr, &Sensedata, noisy);
|
||
|
|
+ status = mpath_translate_response(dev, &io_hdr, &Sensedata, noisy);
|
||
|
|
condlog(3, "%s: status = %d", dev, status);
|
||
|
|
|
||
|
|
if (status == MPATH_PR_SENSE_UNIT_ATTENTION && (retry > 0))
|
||
|
|
@@ -354,7 +354,7 @@ retry :
|
||
|
|
condlog(3, "%s: duration = %u (ms)", dev, io_hdr.duration);
|
||
|
|
condlog(4, "%s: persistent reservation in: requested %d bytes but got %d bytes)", dev, mx_resp_len, got);
|
||
|
|
|
||
|
|
- status = mpath_translate_response(dev, io_hdr, &Sensedata, noisy);
|
||
|
|
+ status = mpath_translate_response(dev, &io_hdr, &Sensedata, noisy);
|
||
|
|
|
||
|
|
if (status == MPATH_PR_SENSE_UNIT_ATTENTION && (retry > 0))
|
||
|
|
{
|
||
|
|
@@ -399,18 +399,18 @@ out:
|
||
|
|
return status;
|
||
|
|
}
|
||
|
|
|
||
|
|
-int mpath_translate_response (char * dev, struct sg_io_hdr io_hdr,
|
||
|
|
- SenseData_t *Sensedata, int noisy)
|
||
|
|
+int mpath_translate_response (const char *dev, struct sg_io_hdr *io_hdr,
|
||
|
|
+ const SenseData_t *Sensedata, int noisy)
|
||
|
|
{
|
||
|
|
condlog(3, "%s: status driver:%02x host:%02x scsi:%02x", dev,
|
||
|
|
- io_hdr.driver_status, io_hdr.host_status ,io_hdr.status);
|
||
|
|
- io_hdr.status &= 0x7e;
|
||
|
|
- if ((0 == io_hdr.status) &&
|
||
|
|
- (0 == io_hdr.host_status) &&
|
||
|
|
- (0 == io_hdr.driver_status))
|
||
|
|
+ io_hdr->driver_status, io_hdr->host_status ,io_hdr->status);
|
||
|
|
+ io_hdr->status &= 0x7e;
|
||
|
|
+ if ((0 == io_hdr->status) &&
|
||
|
|
+ (0 == io_hdr->host_status) &&
|
||
|
|
+ (0 == io_hdr->driver_status))
|
||
|
|
return MPATH_PR_SUCCESS;
|
||
|
|
|
||
|
|
- switch(io_hdr.status) {
|
||
|
|
+ switch(io_hdr->status) {
|
||
|
|
case SAM_STAT_GOOD:
|
||
|
|
break;
|
||
|
|
case SAM_STAT_CHECK_CONDITION:
|
||
|
|
@@ -450,13 +450,13 @@ int mpath_translate_response (char * dev, struct sg_io_hdr io_hdr,
|
||
|
|
return MPATH_PR_OTHER;
|
||
|
|
}
|
||
|
|
|
||
|
|
- switch(io_hdr.host_status) {
|
||
|
|
+ switch(io_hdr->host_status) {
|
||
|
|
case DID_OK :
|
||
|
|
break;
|
||
|
|
default :
|
||
|
|
return MPATH_PR_OTHER;
|
||
|
|
}
|
||
|
|
- switch(io_hdr.driver_status)
|
||
|
|
+ switch(io_hdr->driver_status)
|
||
|
|
{
|
||
|
|
case DRIVER_OK:
|
||
|
|
break;
|
||
|
|
diff --git a/mpathpersist/main.c b/mpathpersist/main.c
|
||
|
|
index 0e4d3f2..4db07b2 100644
|
||
|
|
--- a/mpathpersist/main.c
|
||
|
|
+++ b/mpathpersist/main.c
|
||
|
|
@@ -61,7 +61,7 @@ struct udev *udev;
|
||
|
|
|
||
|
|
int main (int argc, char * argv[])
|
||
|
|
{
|
||
|
|
- int fd, c, res;
|
||
|
|
+ int c, res, fd = -1;
|
||
|
|
const char *device_name = NULL;
|
||
|
|
int num_prin_sa = 0;
|
||
|
|
int num_prout_sa = 0;
|
||
|
|
@@ -488,6 +488,7 @@ int main (int argc, char * argv[])
|
||
|
|
}
|
||
|
|
|
||
|
|
res = close (fd);
|
||
|
|
+ fd = -1;
|
||
|
|
if (res < 0)
|
||
|
|
{
|
||
|
|
mpath_lib_exit(conf);
|
||
|
|
@@ -496,6 +497,8 @@ int main (int argc, char * argv[])
|
||
|
|
}
|
||
|
|
|
||
|
|
out :
|
||
|
|
+ if (fd >= 0)
|
||
|
|
+ close(fd);
|
||
|
|
mpath_lib_exit(conf);
|
||
|
|
udev_unref(udev);
|
||
|
|
return (ret >= 0) ? ret : MPATH_PR_OTHER;
|