scsi: remove the stream_status member from scsi_stream_status_header
PATCH 1/1 scsi: remove the stream_status member from scsi_stream_status_header
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.
--- drivers/scsi/sd.c | 2 +- include/scsi/scsi_proto.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-)
drivers/scsi/sd.c +1 -1
@@ -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)
include/scsi/scsi_proto.h +0 -1
@@ -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 );
Signature · 1 line
2.47.2
Quoted 6 lines · Christoph Hellwig
Having a variable length array at the end of
scsi_stream_status_headeronly 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 <[email protected]>
Quoted 4 lines · Christoph Hellwig
Having a variable length array at the end of
scsi_stream_status_headeronly 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.
Quoted 18 lines
drivers/scsi/sd.c +1
-1@@ -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)include/scsi/scsi_proto.h +0
-0
include/scsi/scsi_proto.h struct scsi_stream_status_header { · line 354
Quoted 7 lines
include/scsi/scsi_proto.h +0
-1@@ -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.
Quoted 4 lines · Bart Van Assche
There is an implicit assumption behind this patch, namely that the compiler does not insert padding bytes between struct
scsi_stream_status_headerand structscsi_stream_status. Shouldn't this be made explicit with aBUILD_BUG_ON()expression?
We make that assumption for all our naturally alignend structures in every on-disk and on the wire structure.
include/scsi/scsi_proto.h struct scsi_stream_status_header { · line 352
Quoted 10 lines · Christoph Hellwig
include/scsi/scsi_proto.h +0
-1@@ -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.