From: sashiko-bot@kernel.org
To: "Stefan Haberland" <sth@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Heiko Carstens" <hca@linux.ibm.com>,
linux-s390@vger.kernel.org
Subject: Re: [PATCH v3 03/13] s390/dasd: Add range-based format-track collision detection
Date: Thu, 23 Jul 2026 14:13:11 +0000 [thread overview]
Message-ID: <20260723141312.37F111F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260723134743.672413-4-sth@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [Critical] Uninitialized track range fields in data requests break collision detection.
- [High] Unreachable collision detection logic due to incorrect callback.
- [High] Collision detection loop ignores queued requests, skipping the ones it is meant to wake up.
- [High] Error paths perform unprotected list deletions and permanently leak format array slots.
--
--- Patch [3]: [PATCH v3 03/13] s390/dasd: Add range-based format-track collision detection ---
commit 1d2db2dae28f75e003a69468da44050bd92fdedd
Author: Stefan Haberland <sth@linux.ibm.com>
s390/dasd: Add range-based format-track collision detection
Replace the single per-device format_entry slot with an array of 16
slots so multiple format requests can be in flight at once, and extend
struct dasd_format_entry with a start_trk/end_trk/cqr range (replacing
the single track field).
> diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
> --- a/drivers/s390/block/dasd.c
> +++ b/drivers/s390/block/dasd.c
[ ... ]
> @@ -2855,6 +2848,27 @@ static void __dasd_process_block_ccw_queue(struct dasd_block *block,
>
> static void dasd_return_cqr_cb(struct dasd_ccw_req *cqr, void *data)
> {
> + struct dasd_ccw_req *temp_cqr;
> + struct dasd_block *block;
> +
> + /* only format CQRs are candidates */
> + if (!cqr->block || unlikely(!cqr->format))
> + goto out;
[Severity: High]
Does this guard prevent the collision logic from ever being executed?
Regular data requests use dasd_return_cqr_cb() as their callback but they
do not have cqr->format set. ESE format requests have cqr->format set, but
they use dasd_eckd_ese_format_cb() as their callback instead of this one.
Will this path always take the goto out, making the collision logic
unreachable?
> +
> + block = cqr->block;
> + /*
> + * Mark queued CQRs that overlap this just-completed format
> + * range so they re-check in test_and_set_format.
> + */
> + list_for_each_entry(temp_cqr, &block->ccw_queue, blocklist) {
> + if (temp_cqr != cqr &&
> + temp_cqr->status != DASD_CQR_FILLED &&
> + temp_cqr->status != DASD_CQR_QUEUED &&
[Severity: High]
Does this explicitly skip requests in the queued state, which are exactly
the ones waiting to be flagged?
Requests delayed due to a conflict (returning -EEXIST from
test_and_set_format_track) are put in the DASD_CQR_QUEUED state. If this
loop filters out DASD_CQR_QUEUED, does it ignore the exact requests it was
designed to evaluate and flag with collision = true?
> + dasd_req_conflict(cqr, temp_cqr)) {
> + temp_cqr->collision = true;
> + }
> + }
> +out:
> dasd_schedule_block_bh(cqr->block);
> }
>
> diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
> --- a/drivers/s390/block/dasd_eckd.c
> +++ b/drivers/s390/block/dasd_eckd.c
[ ... ]
> @@ -3232,17 +3245,27 @@ dasd_eckd_ese_format(struct dasd_device *startdev, struct dasd_ccw_req *cqr,
> fdata.intensity = private->uses_cdl ? DASD_FMT_INT_COMPAT : 0;
>
> rc = dasd_eckd_format_sanity_checks(base, &fdata);
> - if (rc)
> + if (rc) {
> + if (format)
> + list_del(&format->list);
> return ERR_PTR(-EINVAL);
> + }
>
> /*
> * We're building the request with PAV disabled as we're reusing
> * the former startdev.
> */
> fcqr = dasd_eckd_build_format(base, startdev, &fdata, 0);
> - if (IS_ERR(fcqr))
> + if (IS_ERR(fcqr)) {
> + if (format)
> + list_del(&format->list);
> return fcqr;
> + }
[Severity: High]
Are we modifying the list without holding block->format_lock here?
These error paths call list_del(&format->list) without acquiring the lock.
Additionally, they do not set format->cqr = NULL. Since
test_and_set_format_track() identifies free slots by checking
!device->format_entry[i].cqr, does this permanently leak format array slots?
Could this use clear_format_track(format, block) instead to properly lock
and clear the state?
> diff --git a/drivers/s390/block/dasd_int.h b/drivers/s390/block/dasd_int.h
> --- a/drivers/s390/block/dasd_int.h
> +++ b/drivers/s390/block/dasd_int.h
[ ... ]
> @@ -834,6 +842,13 @@ static inline void *dasd_get_callback_data(struct dasd_ccw_req *cqr)
> return cqr->callback_data;
> }
>
> +static inline bool dasd_req_conflict(struct dasd_ccw_req *cqr1,
> + struct dasd_ccw_req *cqr2)
> +{
> + return !(cqr1->format->end_trk < cqr2->start_trk ||
> + cqr2->end_trk < cqr1->format->start_trk);
> +}
> +
[Severity: Critical]
Are start_trk and end_trk guaranteed to be initialized for normal data
requests?
Since dasd_fmalloc_request() zero-allocates memory, cqr2->start_trk and
cqr2->end_trk default to 0 for normal data requests. When evaluated here,
the comparison cqr2->end_trk < cqr1->format->start_trk evaluates as
0 < format->start_trk, which is always true for any track > 0.
Does this silently fail to detect collisions for any tracks other than
track 0?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260723134743.672413-1-sth@linux.ibm.com?part=3
next prev parent reply other threads:[~2026-07-23 14:13 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-23 13:47 [PATCH v3 00/13] s390/dasd: ESE thin-provisioning performance improvements Stefan Haberland
2026-07-23 13:47 ` [PATCH v3 01/13] s390/dasd: Optimize max blocks per request for track alignment Stefan Haberland
2026-07-23 13:58 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 02/13] s390/dasd: Add infrastructure for ESE full-track write Stefan Haberland
2026-07-23 14:11 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 03/13] s390/dasd: Add range-based format-track collision detection Stefan Haberland
2026-07-23 14:13 ` sashiko-bot [this message]
2026-07-23 13:47 ` [PATCH v3 04/13] s390/dasd: Extend prepare_itcw() to support WRITE_FULL_TRACK Stefan Haberland
2026-07-23 14:25 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 05/13] s390/dasd: Add dasd_eckd_build_cp_tpm_writefulltrack() Stefan Haberland
2026-07-23 14:14 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 06/13] s390/dasd: Use WRITE_FULL_TRACK in ESE format handler Stefan Haberland
2026-07-23 14:13 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 07/13] s390/dasd: Add full_track_bias sysfs attribute to control fulltrack write mode Stefan Haberland
2026-07-23 14:16 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 08/13] s390/dasd: Derive adaptive ESE fulltrack heuristic from ft_bias Stefan Haberland
2026-07-23 14:09 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 09/13] s390/dasd: Stamp a format label into newly formatted volumes Stefan Haberland
2026-07-23 14:09 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 10/13] s390/dasd: Detect ESE volumes from the on-disk format label Stefan Haberland
2026-07-23 14:19 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 11/13] s390/dasd: Report ESE capability and format mode at device online Stefan Haberland
2026-07-23 14:14 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 12/13] s390/dasd: Re-enable discard support for ESE volumes Stefan Haberland
2026-07-23 14:30 ` sashiko-bot
2026-07-23 13:47 ` [PATCH v3 13/13] s390/dasd: Read cached unit address and LSS in the CCW build path Stefan Haberland
2026-07-23 14:35 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260723141312.37F111F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=linux-s390@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sth@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox