* scsi: Adding lock to protect variables of bit-field in struct scsi_device
@ 2016-12-05 6:37 jiangyiwen
0 siblings, 0 replies; only message in thread
From: jiangyiwen @ 2016-12-05 6:37 UTC (permalink / raw)
To: linux-scsi, Martin K. Petersen, James E.J. Bottomley,
Hannes Reinecke
Cc: wangyibin, Subo (A), xuejiufei@huawei.com
Hi guys,
I'm sorry if someone else has already asked the same question before,
but here's what we are facing with scsi mid-level.
Variables of bit-field in struct scsi_device are not protected by
lock, such as no_report_opcodes, is_visible and so on. I guess
everyone think these variable can't be accessed by multi-processes,
but unfortunately, I came across one problem as follows:
Assuming there is a process A which is executing the operation of
adding device, so it will call scsi_sysfs_add_sdev, and eventually
it will start an async kworker B to execute sd_probe_async.
In this way, process A will set "sdev->is_visible = 1" in the function
of scsi_sysfs_add_sdev, in the meantime, aysnc kworker B may set
"sdev->no_report_opcodes = 1" in the function of sd_read_write_same.
Neither of the variables are protected by any lock, setting the value
of no_report_opcodes may change value of is_visible from 1 to 0, which
alters the bit field unexpectedly. Did I miss anything?
So I'd like to know whether these variable of bit-field should
be protected by lock or not.
Please advise. Thanks in advance!
Best regards,
Yiwen
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-12-05 6:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-05 6:37 scsi: Adding lock to protect variables of bit-field in struct scsi_device jiangyiwen
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.