* [PATCH] scsi: remove the stream_status member from scsi_stream_status_header
@ 2025-05-01 18:16 Christoph Hellwig
2025-05-02 11:30 ` John Garry
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Christoph Hellwig @ 2025-05-01 18:16 UTC (permalink / raw)
To: martin.petersen; +Cc: linux-scsi
Having a variable length array at the end of scsi_stream_status_header
only cause problems. Remove it and switch the one place that actually
used it to use the struct member directly following in the actual on-disk
structure instead.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/scsi/sd.c | 2 +-
include/scsi/scsi_proto.h | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 950d8c9fb884..3f6e87705b62 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3215,7 +3215,7 @@ static bool sd_is_perm_stream(struct scsi_disk *sdkp, unsigned int stream_id)
return false;
if (get_unaligned_be32(&buf.h.len) < sizeof(struct scsi_stream_status))
return false;
- return buf.h.stream_status[0].perm;
+ return buf.s.perm;
}
static void sd_read_io_hints(struct scsi_disk *sdkp, unsigned char *buffer)
diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
index aeca37816506..bc8f2b2226be 100644
--- a/include/scsi/scsi_proto.h
+++ b/include/scsi/scsi_proto.h
@@ -349,7 +349,6 @@ struct scsi_stream_status_header {
__be32 len; /* length in bytes of stream_status[] array. */
u16 reserved;
__be16 number_of_open_streams;
- DECLARE_FLEX_ARRAY(struct scsi_stream_status, stream_status);
};
static_assert(sizeof(struct scsi_stream_status_header) == 8);
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] scsi: remove the stream_status member from scsi_stream_status_header
2025-05-01 18:16 [PATCH] scsi: remove the stream_status member from scsi_stream_status_header Christoph Hellwig
@ 2025-05-02 11:30 ` John Garry
2025-05-03 19:05 ` Bart Van Assche
2025-05-04 3:08 ` Bart Van Assche
2 siblings, 0 replies; 9+ messages in thread
From: John Garry @ 2025-05-02 11:30 UTC (permalink / raw)
To: Christoph Hellwig, martin.petersen; +Cc: linux-scsi
On 01/05/2025 19:16, Christoph Hellwig wrote:
> Having a variable length array at the end of scsi_stream_status_header
> only cause problems. Remove it and switch the one place that actually
> used it to use the struct member directly following in the actual on-disk
> structure instead.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] scsi: remove the stream_status member from scsi_stream_status_header
2025-05-01 18:16 [PATCH] scsi: remove the stream_status member from scsi_stream_status_header Christoph Hellwig
2025-05-02 11:30 ` John Garry
@ 2025-05-03 19:05 ` Bart Van Assche
2025-05-05 6:06 ` Christoph Hellwig
2025-05-04 3:08 ` Bart Van Assche
2 siblings, 1 reply; 9+ messages in thread
From: Bart Van Assche @ 2025-05-03 19:05 UTC (permalink / raw)
To: Christoph Hellwig, martin.petersen; +Cc: linux-scsi
On 5/1/25 11:16 AM, Christoph Hellwig wrote:
> Having a variable length array at the end of scsi_stream_status_header
> only cause problems. Remove it and switch the one place that actually
> used it to use the struct member directly following in the actual on-disk
> structure instead.
"on-disk" is misleading since these data structures should not be stored
on the storage medium.
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 950d8c9fb884..3f6e87705b62 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -3215,7 +3215,7 @@ static bool sd_is_perm_stream(struct scsi_disk *sdkp, unsigned int stream_id)
> return false;
> if (get_unaligned_be32(&buf.h.len) < sizeof(struct scsi_stream_status))
> return false;
> - return buf.h.stream_status[0].perm;
> + return buf.s.perm;
> }
>
> static void sd_read_io_hints(struct scsi_disk *sdkp, unsigned char *buffer)
> diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
> index aeca37816506..bc8f2b2226be 100644
> --- a/include/scsi/scsi_proto.h
> +++ b/include/scsi/scsi_proto.h
> @@ -349,7 +349,6 @@ struct scsi_stream_status_header {
> __be32 len; /* length in bytes of stream_status[] array. */
> u16 reserved;
> __be16 number_of_open_streams;
> - DECLARE_FLEX_ARRAY(struct scsi_stream_status, stream_status);
> };
>
> static_assert(sizeof(struct scsi_stream_status_header) == 8);
There is an implicit assumption behind this patch, namely that the
compiler does not insert padding bytes between struct
scsi_stream_status_header and struct scsi_stream_status. Shouldn't this
be made explicit with a BUILD_BUG_ON() expression?
Thanks,
Bart.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] scsi: remove the stream_status member from scsi_stream_status_header
2025-05-01 18:16 [PATCH] scsi: remove the stream_status member from scsi_stream_status_header Christoph Hellwig
2025-05-02 11:30 ` John Garry
2025-05-03 19:05 ` Bart Van Assche
@ 2025-05-04 3:08 ` Bart Van Assche
2 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2025-05-04 3:08 UTC (permalink / raw)
To: Christoph Hellwig, martin.petersen; +Cc: linux-scsi
On 5/1/25 11:16 AM, Christoph Hellwig wrote:
> diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
> index aeca37816506..bc8f2b2226be 100644
> --- a/include/scsi/scsi_proto.h
> +++ b/include/scsi/scsi_proto.h
> @@ -349,7 +349,6 @@ struct scsi_stream_status_header {
> __be32 len; /* length in bytes of stream_status[] array. */
> u16 reserved;
> __be16 number_of_open_streams;
> - DECLARE_FLEX_ARRAY(struct scsi_stream_status, stream_status);
> };
An additional note: the following comment needs to be updated since
the member it refers to is removed:
/* length in bytes of stream_status[] array. */
Bart.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] scsi: remove the stream_status member from scsi_stream_status_header
2025-05-03 19:05 ` Bart Van Assche
@ 2025-05-05 6:06 ` Christoph Hellwig
0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2025-05-05 6:06 UTC (permalink / raw)
To: Bart Van Assche; +Cc: Christoph Hellwig, martin.petersen, linux-scsi
On Sat, May 03, 2025 at 12:05:46PM -0700, Bart Van Assche wrote:
> There is an implicit assumption behind this patch, namely that the compiler
> does not insert padding bytes between struct
> scsi_stream_status_header and struct scsi_stream_status. Shouldn't this be
> made explicit with a BUILD_BUG_ON() expression?
We make that assumption for all our naturally alignend structures
in every on-disk and on the wire structure.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] scsi: remove the stream_status member from scsi_stream_status_header
@ 2025-05-05 6:06 Christoph Hellwig
2025-05-05 16:50 ` Bart Van Assche
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Christoph Hellwig @ 2025-05-05 6:06 UTC (permalink / raw)
To: martin.petersen; +Cc: linux-scsi, bvanassche, Gustavo A. R. Silva, John Garry
Having a variable length array at the end of scsi_stream_status_header
only cause problems. Remove it and switch sd_is_perm_stream which is
the only place that currently uses it to use the scsi_stream_status
directly following it in the local buf structure.
Besides being a much better data structure design, this also avoids
a -Wflex-array-member-not-at-end warning.
Reported-by: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
---
drivers/scsi/sd.c | 2 +-
include/scsi/scsi_proto.h | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 950d8c9fb884..3f6e87705b62 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3215,7 +3215,7 @@ static bool sd_is_perm_stream(struct scsi_disk *sdkp, unsigned int stream_id)
return false;
if (get_unaligned_be32(&buf.h.len) < sizeof(struct scsi_stream_status))
return false;
- return buf.h.stream_status[0].perm;
+ return buf.s.perm;
}
static void sd_read_io_hints(struct scsi_disk *sdkp, unsigned char *buffer)
diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
index aeca37816506..f64385cde5b9 100644
--- a/include/scsi/scsi_proto.h
+++ b/include/scsi/scsi_proto.h
@@ -346,10 +346,9 @@ static_assert(sizeof(struct scsi_stream_status) == 8);
/* GET STREAM STATUS parameter data */
struct scsi_stream_status_header {
- __be32 len; /* length in bytes of stream_status[] array. */
+ __be32 len; /* length in bytes of following payload */
u16 reserved;
__be16 number_of_open_streams;
- DECLARE_FLEX_ARRAY(struct scsi_stream_status, stream_status);
};
static_assert(sizeof(struct scsi_stream_status_header) == 8);
--
2.47.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] scsi: remove the stream_status member from scsi_stream_status_header
2025-05-05 6:06 Christoph Hellwig
@ 2025-05-05 16:50 ` Bart Van Assche
2025-05-13 2:17 ` Martin K. Petersen
2025-05-21 2:19 ` Martin K. Petersen
2 siblings, 0 replies; 9+ messages in thread
From: Bart Van Assche @ 2025-05-05 16:50 UTC (permalink / raw)
To: Christoph Hellwig, martin.petersen
Cc: linux-scsi, Gustavo A. R. Silva, John Garry
On 5/4/25 11:06 PM, Christoph Hellwig wrote:
> Having a variable length array at the end of scsi_stream_status_header
> only cause problems. Remove it and switch sd_is_perm_stream which is
> the only place that currently uses it to use the scsi_stream_status
> directly following it in the local buf structure.
>
> Besides being a much better data structure design, this also avoids
> a -Wflex-array-member-not-at-end warning.
>
> Reported-by: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: John Garry <john.g.garry@oracle.com>
> ---
> drivers/scsi/sd.c | 2 +-
> include/scsi/scsi_proto.h | 3 +--
> 2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> index 950d8c9fb884..3f6e87705b62 100644
> --- a/drivers/scsi/sd.c
> +++ b/drivers/scsi/sd.c
> @@ -3215,7 +3215,7 @@ static bool sd_is_perm_stream(struct scsi_disk *sdkp, unsigned int stream_id)
> return false;
> if (get_unaligned_be32(&buf.h.len) < sizeof(struct scsi_stream_status))
> return false;
> - return buf.h.stream_status[0].perm;
> + return buf.s.perm;
> }
>
> static void sd_read_io_hints(struct scsi_disk *sdkp, unsigned char *buffer)
> diff --git a/include/scsi/scsi_proto.h b/include/scsi/scsi_proto.h
> index aeca37816506..f64385cde5b9 100644
> --- a/include/scsi/scsi_proto.h
> +++ b/include/scsi/scsi_proto.h
> @@ -346,10 +346,9 @@ static_assert(sizeof(struct scsi_stream_status) == 8);
>
> /* GET STREAM STATUS parameter data */
> struct scsi_stream_status_header {
> - __be32 len; /* length in bytes of stream_status[] array. */
> + __be32 len; /* length in bytes of following payload */
> u16 reserved;
> __be16 number_of_open_streams;
> - DECLARE_FLEX_ARRAY(struct scsi_stream_status, stream_status);
> };
>
> static_assert(sizeof(struct scsi_stream_status_header) == 8);
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] scsi: remove the stream_status member from scsi_stream_status_header
2025-05-05 6:06 Christoph Hellwig
2025-05-05 16:50 ` Bart Van Assche
@ 2025-05-13 2:17 ` Martin K. Petersen
2025-05-21 2:19 ` Martin K. Petersen
2 siblings, 0 replies; 9+ messages in thread
From: Martin K. Petersen @ 2025-05-13 2:17 UTC (permalink / raw)
To: Christoph Hellwig
Cc: martin.petersen, linux-scsi, bvanassche, Gustavo A. R. Silva,
John Garry
Christoph,
> Having a variable length array at the end of scsi_stream_status_header
> only cause problems. Remove it and switch sd_is_perm_stream which is
> the only place that currently uses it to use the scsi_stream_status
> directly following it in the local buf structure.
Applied to 6.16/scsi-staging, thanks!
--
Martin K. Petersen
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] scsi: remove the stream_status member from scsi_stream_status_header
2025-05-05 6:06 Christoph Hellwig
2025-05-05 16:50 ` Bart Van Assche
2025-05-13 2:17 ` Martin K. Petersen
@ 2025-05-21 2:19 ` Martin K. Petersen
2 siblings, 0 replies; 9+ messages in thread
From: Martin K. Petersen @ 2025-05-21 2:19 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Martin K . Petersen, linux-scsi, bvanassche, Gustavo A. R. Silva,
John Garry
On Mon, 05 May 2025 08:06:37 +0200, Christoph Hellwig wrote:
> Having a variable length array at the end of scsi_stream_status_header
> only cause problems. Remove it and switch sd_is_perm_stream which is
> the only place that currently uses it to use the scsi_stream_status
> directly following it in the local buf structure.
>
> Besides being a much better data structure design, this also avoids
> a -Wflex-array-member-not-at-end warning.
>
> [...]
Applied to 6.16/scsi-queue, thanks!
[1/1] scsi: remove the stream_status member from scsi_stream_status_header
https://git.kernel.org/mkp/scsi/c/cd6856d38881
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-05-21 2:20 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-01 18:16 [PATCH] scsi: remove the stream_status member from scsi_stream_status_header Christoph Hellwig
2025-05-02 11:30 ` John Garry
2025-05-03 19:05 ` Bart Van Assche
2025-05-05 6:06 ` Christoph Hellwig
2025-05-04 3:08 ` Bart Van Assche
-- strict thread matches above, loose matches on Subject: below --
2025-05-05 6:06 Christoph Hellwig
2025-05-05 16:50 ` Bart Van Assche
2025-05-13 2:17 ` Martin K. Petersen
2025-05-21 2:19 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).