All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Volkan Unal" <vunal@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
	linux-s390@vger.kernel.org, "Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH 3/3] s390/dasd: Make FBA discard support conditional per device
Date: Wed, 22 Jul 2026 15:38:01 +0000	[thread overview]
Message-ID: <20260722153801.DA2681F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722151651.292621-4-vunal@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

New issues:
- [Medium] Physical FBA devices can falsely inherit discard support if they bind to a bus_id previously used by a virtual FBA device.

Pre-existing issues:
- [High] Processing a discard or write zeroes request via `dasd_fba_free_cp()` causes a NULL pointer dereference when accessing `bio->bi_io_vec`.
--

--- Patch [3]: [PATCH 3/3] s390/dasd: Make FBA discard support conditional per device ---
commit 87109ad16dbff96168935ae6a9f15a26e6baaf51
Author: Volkan Unal <vunal@linux.ibm.com>

s390/dasd: Make FBA discard support conditional per device
    
This commit replaces the static discipline->has_discard flag with dynamic
per-device feature checks. Discard support is conditionally enabled only for
virtual FBA devices (6310/9336), while physical FBA devices (3880/3370) will
report no discard support.

> diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
> index 3181c06d91ce3..3e009217c130d 100644
> --- a/drivers/s390/block/dasd.c
> +++ b/drivers/s390/block/dasd.c
> @@ -327,7 +327,7 @@ static int dasd_state_basic_to_ready(struct dasd_device *device)
>  	 */
>  	lim.dma_alignment = lim.logical_block_size - 1;
>  
> -	if (device->discipline->has_discard) {
> +	if (dasd_get_feature(device->cdev, DASD_FEATURE_DISCARD) > 0) {
>  		unsigned int max_bytes;
>  
>  		lim.discard_granularity = block->bp_block;
> diff --git a/drivers/s390/block/dasd_fba.c b/drivers/s390/block/dasd_fba.c
> index 029acb83ecab6..b28661b7c0446 100644
> --- a/drivers/s390/block/dasd_fba.c
> +++ b/drivers/s390/block/dasd_fba.c
[ ... ]
> @@ -162,8 +172,9 @@ dasd_fba_check_characteristics(struct dasd_device *device)
>  	if (readonly)
>  		set_bit(DASD_FLAG_DEVICE_RO, &device->flags);
>  
> -	/* FBA supports discard, set the according feature bit */
> -	dasd_set_feature(cdev, DASD_FEATURE_DISCARD, 1);
> +	/* Virtual and EDEV FBA supports discard, set the according feature bit */
> +	if (cdev_is_virtual_or_edev(cdev))
> +		dasd_set_feature(cdev, DASD_FEATURE_DISCARD, 1);

[Severity: Medium]
Will physical FBA devices inherit discard support if they bind to a bus_id
previously used by a virtual FBA device?

If a virtual device is unbound, the devmap persists in memory with the
DASD_FEATURE_DISCARD bit set. If a physical FBA device is subsequently bound
to the same subchannel, this code doesn't explicitly clear the bit, which
might cause the physical device to incorrectly advertise discard support.

Should there be an else branch to clear the feature bit for physical devices?

[ ... ]
> @@ -763,7 +774,6 @@ static struct dasd_discipline dasd_fba_discipline = {
>  	.owner = THIS_MODULE,
>  	.name = "FBA ",
>  	.ebcname = "FBA ",
> -	.has_discard = true,
>  	.check_device = dasd_fba_check_characteristics,

[Severity: High]
This is a pre-existing issue, but does dasd_fba_free_cp() crash when
processing discard or write zeroes requests?

If the kernel is booted with the fixedbuffers parameter (initializing
dasd_page_cache), dasd_fba_free_cp() unconditionally enters the segment loop:

drivers/s390/block/dasd_fba.c:dasd_fba_free_cp() {
    ...
	if (!dasd_page_cache)
		goto out;
    ...
	rq_for_each_segment(bv, req, iter) {
    ...
}

Since discard and write zeroes requests have no data payload, bio->bi_io_vec
is NULL, which will cause a NULL pointer dereference.

Does this iteration need a blk_rq_bytes() or bio_has_data() check before
traversing the segments?

>  	.do_analysis = dasd_fba_do_analysis,

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260722151651.292621-1-vunal@linux.ibm.com?part=3

      reply	other threads:[~2026-07-22 15:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 15:16 [PATCH 0/3] s390/dasd: Restrict discard support to virtual DASD devices Volkan Unal
2026-07-22 15:16 ` [PATCH 1/3] s390/dasd: Add device type defines for FBA devices Volkan Unal
2026-07-22 15:20   ` sashiko-bot
2026-07-22 15:16 ` [PATCH 2/3] s390/dasd: Restrict discard support to virtual DASD devices Volkan Unal
2026-07-22 15:33   ` sashiko-bot
2026-07-22 15:16 ` [PATCH 3/3] s390/dasd: Make FBA discard support conditional per device Volkan Unal
2026-07-22 15:38   ` sashiko-bot [this message]

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=20260722153801.DA2681F000E9@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=vunal@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 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.