Linux SCSI subsystem development
 help / color / mirror / Atom feed
* [PATCH v4 0/8] scsi_debug: Enable lock context analysis
@ 2026-10-07  5:07 Bart Van Assche
  2026-10-07  5:07 ` [PATCH v4 1/8] scsi: scsi_debug: Fix a locking bug in resp_write_same() Bart Van Assche
                   ` (7 more replies)
  0 siblings, 8 replies; 18+ messages in thread
From: Bart Van Assche @ 2026-10-07  5:07 UTC (permalink / raw)
  To: Martin K . Petersen
  Cc: linux-scsi, John Garry, Christoph Hellwig, Bart Van Assche

Hi Martin,

This patch series enables compiler-based lock context analysis for the
scsi_debug driver. Conditional locking is eliminated across command response
and error injection functions so that static analysis can verify lock
acquisitions and releases. Internal locking helper functions are annotated
with __acquires(),__releases(), __acquires_shared() and __releases_shared()
attributes. An error-path lock leak in resp_write_same() is fixed. Finally,
lock context analysis is enabled in drivers/scsi/Makefile.

Changes compared to v3:
- Add a new patch to split resp_atomic_write() and eliminate conditional
  locking in atomic write handling.
- Pass the LBP state boolean down into __resp_write_same(),
  __corrupt_lbas(), and __resp_write_dt0() to avoid repeated calls to
  scsi_debug_lbp().
- Drop unused function arguments from __resp_read_dt0_dix() and
  __resp_write_dt0_dix().
- Correct the return value descriptions in the header comments of
  __resp_read_dt0_dix() and __resp_write_dt0_dix().

Changes compared to v2:
 - Moved DIX/DIF verification into a helper function (__resp_read_dt0_dix())
   to reduce indentation.
 - Removed unnecessary 'else' branches after 'return'.
 - Set the SCSI status code only if do_device_access() fails instead of
   unconditionally setting it to DID_ERROR << 16 beforehand.

Changes compared to v1:
 - Fixed an issue where the error code was clobbered in resp_write_same() and
   __resp_write_same() when fetch_to_dev_buffer() fails (John Garry and
   sashiko-bot).
 - Fixed return value handling in resp_read_dt0() and resp_write_dt0():
   previously a positive byte count returned by do_device_access() was
   incorrectly treated as a SCSI status code and returned to the caller. Now,
   the SCSI status is passed via an output pointer and only negative return
   values trigger an error return (sashiko-bot).
 - Improved lock context annotations:
   * Annotated existing rwlock_t members (&sip->macc_data_lck,
     &sip->macc_sector_lck, &sip->macc_meta_lck) directly with __acquires /
     __releases instead of defining and embedding dummy context lock structs
     in struct sdeb_store_info.
   * Dropped the unwarranted __context_unsafe() annotation from
     sdeb_data_read_lock().
   * Updated the commit descriptions to match the code changes.

Bart Van Assche (8):
  scsi: scsi_debug: Fix a locking bug in resp_write_same()
  scsi: scsi_debug: Split resp_write_same()
  scsi: scsi_debug: Split corrupt_lbas()
  scsi: scsi_debug: Split resp_read_dt0()
  scsi: scsi_debug: Split resp_write_dt0()
  scsi: scsi_debug: Split resp_atomic_write()
  scsi: scsi_debug: Improve lock context annotations
  scsi: core: Enable lock context analysis for the scsi_debug driver

 drivers/scsi/Makefile     |   1 +
 drivers/scsi/scsi_debug.c | 418 +++++++++++++++++++++++---------------
 2 files changed, 254 insertions(+), 165 deletions(-)


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-10-08  7:10 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07  5:07 [PATCH v4 0/8] scsi_debug: Enable lock context analysis Bart Van Assche
2026-10-07  5:07 ` [PATCH v4 1/8] scsi: scsi_debug: Fix a locking bug in resp_write_same() Bart Van Assche
2026-10-07  5:07 ` [PATCH v4 2/8] scsi: scsi_debug: Split resp_write_same() Bart Van Assche
2026-10-07  5:07 ` [PATCH v4 3/8] scsi: scsi_debug: Split corrupt_lbas() Bart Van Assche
2026-10-07  5:07 ` [PATCH v4 4/8] scsi: scsi_debug: Split resp_read_dt0() Bart Van Assche
2026-10-07  5:07 ` [PATCH v4 5/8] scsi: scsi_debug: Split resp_write_dt0() Bart Van Assche
2026-10-07 13:12   ` Christoph Hellwig
2026-10-07 20:08     ` Bart Van Assche
2026-10-08  7:09       ` Christoph Hellwig
2026-10-07  5:07 ` [PATCH v4 6/8] scsi: scsi_debug: Split resp_atomic_write() Bart Van Assche
2026-10-07 13:12   ` Christoph Hellwig
2026-10-07  5:07 ` [PATCH v4 7/8] scsi: scsi_debug: Improve lock context annotations Bart Van Assche
2026-10-07  5:17   ` sashiko-bot
2026-10-07 13:14   ` Christoph Hellwig
2026-10-07 14:31     ` Marco Elver
2026-10-07 20:10     ` Bart Van Assche
2026-10-08  7:10       ` Christoph Hellwig
2026-10-07  5:07 ` [PATCH v4 8/8] scsi: core: Enable lock context analysis for the scsi_debug driver Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox