* [PATCH] scsi-dh-emc: fix activate vs set_params race
@ 2013-04-03 0:09 Mikulas Patocka
2013-04-04 23:11 ` [dm-devel] " Mike Christie
0 siblings, 1 reply; 4+ messages in thread
From: Mikulas Patocka @ 2013-04-03 0:09 UTC (permalink / raw)
To: Alasdair G. Kergon, Mike Snitzer, Mike Christie, Chandra Seetharaman
Cc: dm-devel, linux-scsi
Hi
This fixes a possible race in scsi_dh_emc. It is untested because I don't
have the hardware. It could happen when we reload a multipath device and
path failure happens at the same time.
This is a theoretical race condition (there are no reports of it
hapenning), but a different bug was already triggered under the same
conditions in QA testing.
Mikulas
---
scsi-dh-emc: fix activate vs set_params race
The activate routine may be called concurrently with the set_params
routine. This can happen when dm-multipath device is reloaded. When we
reload a device mapper device, the new target instance is being created
(that could call the set_params method) while the old target instance is
still active (that could call the activate method).
The activate and set_params routine share the same data and sense buffer,
so it could result in incorrect behaviour if they are called concurrently.
This patch adds a mutex to fix the race.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
drivers/scsi/device_handler/scsi_dh_emc.c | 11 +++++++++++
1 file changed, 11 insertions(+)
Index: linux-3.9-rc5-fast/drivers/scsi/device_handler/scsi_dh_emc.c
===================================================================
--- linux-3.9-rc5-fast.orig/drivers/scsi/device_handler/scsi_dh_emc.c 2013-04-03 01:32:16.000000000 +0200
+++ linux-3.9-rc5-fast/drivers/scsi/device_handler/scsi_dh_emc.c 2013-04-03 01:45:13.000000000 +0200
@@ -111,6 +111,8 @@ struct clariion_dh_data {
* path's mapped LUN
*/
int current_sp;
+
+ struct mutex mtx;
};
static inline struct clariion_dh_data
@@ -536,6 +538,8 @@ static int clariion_activate(struct scsi
struct clariion_dh_data *csdev = get_clariion_data(sdev);
int result;
+ mutex_lock(&csdev->mtx);
+
result = clariion_send_inquiry(sdev, csdev);
if (result != SCSI_DH_OK)
goto done;
@@ -562,6 +566,8 @@ done:
csdev->port, lun_state[csdev->lun_state],
csdev->default_sp + 'A');
+ mutex_unlock(&csdev->mtx);
+
if (fn)
fn(data, result);
return 0;
@@ -602,6 +608,8 @@ static int clariion_set_params(struct sc
else
csdev->flags &= ~CLARIION_HONOR_RESERVATIONS;
+ mutex_lock(&csdev->mtx);
+
/*
* If this path is owned, we have to send a trespass command
* with the new parameters. If not, simply return. Next trespass
@@ -618,6 +626,8 @@ static int clariion_set_params(struct sc
/* Update status */
result = clariion_send_inquiry(sdev, csdev);
+ mutex_unlock(&csdev->mtx);
+
done:
return result;
}
@@ -683,6 +693,7 @@ static int clariion_bus_attach(struct sc
h->lun_state = CLARIION_LUN_UNINITIALIZED;
h->default_sp = CLARIION_UNBOUND_LU;
h->current_sp = CLARIION_UNBOUND_LU;
+ mutex_init(&h->mtx);
err = clariion_std_inquiry(sdev, h);
if (err != SCSI_DH_OK)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dm-devel] [PATCH] scsi-dh-emc: fix activate vs set_params race
2013-04-03 0:09 [PATCH] scsi-dh-emc: fix activate vs set_params race Mikulas Patocka
@ 2013-04-04 23:11 ` Mike Christie
2013-04-04 23:17 ` Laurence Oberman
0 siblings, 1 reply; 4+ messages in thread
From: Mike Christie @ 2013-04-04 23:11 UTC (permalink / raw)
To: device-mapper development
Cc: Mikulas Patocka, Alasdair G. Kergon, Mike Snitzer,
Chandra Seetharaman, linux-scsi, Rob Evers
On 04/02/2013 07:09 PM, Mikulas Patocka wrote:
> Hi
>
> This fixes a possible race in scsi_dh_emc. It is untested because I don't
> have the hardware. It could happen when we reload a multipath device and
> path failure happens at the same time.
I think this patch is ok. I do not have the hw to test it anymore.
If you wanted to test just to make sure it is safe you should bug Rob
Evers. He can help you find a machine in the westford lab that has it
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dm-devel] [PATCH] scsi-dh-emc: fix activate vs set_params race
2013-04-04 23:11 ` [dm-devel] " Mike Christie
@ 2013-04-04 23:17 ` Laurence Oberman
2013-04-05 21:27 ` Mikulas Patocka
0 siblings, 1 reply; 4+ messages in thread
From: Laurence Oberman @ 2013-04-04 23:17 UTC (permalink / raw)
To: Mike Christie
Cc: device-mapper development, Mikulas Patocka, Alasdair G. Kergon,
Mike Snitzer, Chandra Seetharaman, linux-scsi, Rob Evers
I can test it. I have a clarion Cx3
Will get to it next week, traveling tomorrow
Laurence
Sent from my iPhone
On Apr 4, 2013, at 7:11 PM, Mike Christie <michaelc@cs.wisc.edu> wrote:
> On 04/02/2013 07:09 PM, Mikulas Patocka wrote:
>> Hi
>>
>> This fixes a possible race in scsi_dh_emc. It is untested because I don't
>> have the hardware. It could happen when we reload a multipath device and
>> path failure happens at the same time.
>
>
> I think this patch is ok. I do not have the hw to test it anymore.
>
> If you wanted to test just to make sure it is safe you should bug Rob
> Evers. He can help you find a machine in the westford lab that has it
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dm-devel] [PATCH] scsi-dh-emc: fix activate vs set_params race
2013-04-04 23:17 ` Laurence Oberman
@ 2013-04-05 21:27 ` Mikulas Patocka
0 siblings, 0 replies; 4+ messages in thread
From: Mikulas Patocka @ 2013-04-05 21:27 UTC (permalink / raw)
To: Laurence Oberman
Cc: Mike Christie, device-mapper development, Alasdair G. Kergon,
Mike Snitzer, Chandra Seetharaman, linux-scsi, Rob Evers
On Thu, 4 Apr 2013, Laurence Oberman wrote:
> I can test it. I have a clarion Cx3
> Will get to it next week, traveling tomorrow
> Laurence
>
> Sent from my iPhone
OK.
So, enable most debug options in kernel configuration and try the patch.
Mikulas
> On Apr 4, 2013, at 7:11 PM, Mike Christie <michaelc@cs.wisc.edu> wrote:
>
> > On 04/02/2013 07:09 PM, Mikulas Patocka wrote:
> >> Hi
> >>
> >> This fixes a possible race in scsi_dh_emc. It is untested because I don't
> >> have the hardware. It could happen when we reload a multipath device and
> >> path failure happens at the same time.
> >
> >
> > I think this patch is ok. I do not have the hw to test it anymore.
> >
> > If you wanted to test just to make sure it is safe you should bug Rob
> > Evers. He can help you find a machine in the westford lab that has it
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-04-05 21:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-03 0:09 [PATCH] scsi-dh-emc: fix activate vs set_params race Mikulas Patocka
2013-04-04 23:11 ` [dm-devel] " Mike Christie
2013-04-04 23:17 ` Laurence Oberman
2013-04-05 21:27 ` Mikulas Patocka
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.