diff mbox series

scsi: remove the stream_status member from scsi_stream_status_header

Message ID 20250501181623.2942698-1-hch@lst.de
State Superseded
Headers show
Series scsi: remove the stream_status member from scsi_stream_status_header | expand

Commit Message

Christoph Hellwig May 1, 2025, 6:16 p.m. UTC
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(-)

Comments

Christoph Hellwig May 5, 2025, 6:06 a.m. UTC | #1
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.
diff mbox series

Patch

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);