zfcp: small changes for 5.10
Subsystems (3)
cover zfcp: small changes for 5.10
Hello Martin, James,
here are some small changes for zfcp I'd like to include in 5.10 if possible. They apply cleanly on Martin's scsi-queue, and James' misc branches.
Both patches make the driver a bit cleaner, and hopefully easier to maintain.
Both have been in our CI for quite a while now, running every night. I also gave them a separate regression run just now with I/O and error-injects such as cable pulls and other external error sources. So I am rather confident that they don't break anything for us - apart from that they're straight forward code changes.
As always, feedback and further reviews are appreciated :-)
Julian Wiedmann (2):
zfcp: use list_first_entry_or_null() in zfcp_erp_thread()
zfcp: clarify access to erp_action in zfcp_fsf_req_complete()
drivers/s390/scsi/zfcp_erp.c | 8 +++----- drivers/s390/scsi/zfcp_fsf.c | 10 ++++++++-- 2 files changed, 11 insertions(+), 7 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 zfcp: use list_first_entry_or_null() in zfcp_erp_thread()
From: Julian Wiedmann <[email protected]>
Use the right helper to avoid poking around in the list's internals.
--- drivers/s390/scsi/zfcp_erp.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/s390/scsi/zfcp_erp.c +3 -5
@@ -1607,7 +1607,6 @@ static enum zfcp_erp_act_result zfcp_erp_strategy(static int zfcp_erp_thread (void *data) {struct zfcp_adapter *adapter = (struct zfcp_adapter *) data; -struct list_head *next;struct zfcp_erp_action *act;unsigned long flags;
@@ -1620,12 +1619,11 @@ static int zfcp_erp_thread(void *data)break ;write_lock_irqsave (&adapter->erp_lock, flags); - next = adapter->erp_ready_head.next; + act =list_first_entry_or_null (&adapter->erp_ready_head, + struct zfcp_erp_action, list);write_unlock_irqrestore (&adapter->erp_lock, flags); -if (next != &adapter->erp_ready_head) { - act = list_entry(next, struct zfcp_erp_action, list); - +if (act) {/* there is more to come after dismission, no notify */ if (zfcp_erp_strategy (act) !=ZFCP_ERP_DISMISSED )zfcp_erp_wakeup (adapter);
Signature · 1 line
2.26.2
PATCH 2/2 zfcp: clarify access to erp_action in zfcp_fsf_req_complete()
In reply to Benjamin BlockFrom: Julian Wiedmann <[email protected]>
While reviewing
commit 936e6b85da04 ("scsi: zfcp: Fix panic on ERP timeout for previously dismissed ERP action"),
I stumbled over zfcp_fsf_req_complete() and wondered whether it has similar issues wrt concurrent modification of req->erp_action by zfcp_erp_strategy_check_fsfreq().
But a closer look shows that both its two callers [zfcp_fsf_reqid_check(), zfcp_fsf_req_dismiss_all()] remove the request from the adapter's req_list under the req_list's lock.
Hence we can trust that if zfcp_erp_strategy_check_fsfreq() concurrently looks up the corresponding req_id, it won't find this request and is thus unable to modify it while it's being processed by zfcp_fsf_req_complete().
Add a code comment that hopefully makes this easier for future readers, and condense the two accesses to ->erp_action that made me trip over this code path in the first place.
--- drivers/s390/scsi/zfcp_fsf.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/s390/scsi/zfcp_fsf.c +8 -2
@@ -426,9 +426,14 @@ static void zfcp_fsf_protstatus_eval(struct zfcp_fsf_req *req)* or it has been dismissed due to a queue shutdown, this function * is called to process the completion status and trigger further * events related to the FSF request. +* Caller must ensure that the request has been removed from +* adapter->req_list, to protect against concurrent modification +* by zfcp_erp_strategy_check_fsfreq(). */ static void zfcp_fsf_req_complete (struct zfcp_fsf_req *req) { +struct zfcp_erp_action *erp_action; +if (unlikely (zfcp_fsf_req_is_status_read_buffer (req))) {zfcp_fsf_status_read_handler (req);return ;
@@ -439,8 +444,9 @@ static void zfcp_fsf_req_complete(struct zfcp_fsf_req *req)zfcp_fsf_fsfstatus_eval (req); req->handler (req); -if (req->erp_action) -zfcp_erp_notify (req->erp_action,0 ); + erp_action = req->erp_action; +if (erp_action) +zfcp_erp_notify (erp_action,0 );if (likely (req->status &ZFCP_STATUS_FSFREQ_CLEANUP ))zfcp_fsf_req_free (req);
Signature · 1 line
2.26.2
Martin K. Petersen
AppliedBenjamin,
Quoted 2 lines
here are some small changes for zfcp I'd like to include in 5.10 if possible.
Applied to 5.10/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 8 lines · Benjamin Block
here are some small changes for zfcp I'd like to include in 5.10 if possible. They apply cleanly on Martin's
scsi-queue, and James'miscbranches.Both patches make the driver a bit cleaner, and hopefully easier to maintain.
[...]
Applied to 5.10/scsi-queue, thanks!
[1/2] scsi: zfcp: Use list_first_entry_or_null() in zfcp_erp_thread()
https://git.kernel.org/mkp/scsi/c/addf13729615 [2/2] scsi: zfcp: Clarify access to erp_action in zfcp_fsf_req_complete() https://git.kernel.org/mkp/scsi/c/d251193d1732
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 9 lines · Martin K. Petersen
Quoted 7 lines · Benjamin Block
here are some small changes for zfcp I'd like to include in 5.10 if possible. They apply cleanly on Martin's
scsi-queue, and James'miscbranches.Both patches make the driver a bit cleaner, and hopefully easier to maintain.
Quoted 9 lines
Quoted 1 line
[...]
Applied to 5.10/scsi-queue, thanks!
[1/2] scsi: zfcp: Use
list_first_entry_or_null()inzfcp_erp_thread()https://git.kernel.org/mkp/scsi/c/addf13729615 [2/2] scsi: zfcp: Clarify access to erp_action in zfcp_fsf_req_complete() https://git.kernel.org/mkp/scsi/c/d251193d1732
Thanks Martin!
Signature · 4 lines
Best Regards, Benjamin Block / Linux on IBM Z Kernel Development / IBM Systems IBM Deutschland Research & Development GmbH / https://www.ibm.com/privacy Vorsitz. AufsR.: Gregor Pillen / Gesch�ftsf�hrung: Dirk Wittkopp Sitz der Gesellschaft: B�blingen / Registergericht: AmtsG Stuttgart, HRB 243294