Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

RDMA/srp: Apply the __packed attribute to members instead of structures

Applying the __packed attribute to an entire data structure results in
suboptimal code on architectures that do not support unaligned accesses.
Hence apply the __packed attribute only to those data members that are
not naturally aligned.

Link: https://lore.kernel.org/r/20210524041211.9480-4-bvanassche@acm.org
Cc: Nicolas Morey-Chaisemartin <nmoreychaisemartin@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>

authored by

Bart Van Assche and committed by
Jason Gunthorpe
6dc26498 c838de1a

+9 -17
+9 -17
include/scsi/srp.h
··· 107 107 * having the 20-byte structure padded to 24 bytes on 64-bit architectures. 108 108 */ 109 109 struct srp_indirect_buf { 110 - struct srp_direct_buf table_desc; 110 + struct srp_direct_buf table_desc __packed __aligned(4); 111 111 __be32 len; 112 - struct srp_direct_buf desc_list[]; 113 - } __attribute__((packed)); 112 + struct srp_direct_buf desc_list[] __packed __aligned(4); 113 + }; 114 114 115 115 /* Immediate data buffer descriptor as defined in SRP2. */ 116 116 struct srp_imm_buf { ··· 175 175 u8 opcode; 176 176 u8 reserved1[3]; 177 177 __be32 req_lim_delta; 178 - u64 tag; 178 + u64 tag __packed __aligned(4); 179 179 __be32 max_it_iu_len; 180 180 __be32 max_ti_iu_len; 181 181 __be16 buf_fmt; 182 182 u8 rsp_flags; 183 183 u8 reserved2[25]; 184 - } __attribute__((packed)); 184 + }; 185 185 186 186 struct srp_login_rej { 187 187 u8 opcode; ··· 207 207 u64 tag; 208 208 }; 209 209 210 - /* 211 - * We need the packed attribute because the SRP spec only aligns the 212 - * 8-byte LUN field to 4 bytes. 213 - */ 214 210 struct srp_tsk_mgmt { 215 211 u8 opcode; 216 212 u8 sol_not; ··· 221 225 u8 reserved5[8]; 222 226 }; 223 227 224 - /* 225 - * We need the packed attribute because the SRP spec only aligns the 226 - * 8-byte LUN field to 4 bytes. 227 - */ 228 228 struct srp_cmd { 229 229 u8 opcode; 230 230 u8 sol_not; ··· 258 266 u8 sol_not; 259 267 u8 reserved1[2]; 260 268 __be32 req_lim_delta; 261 - u64 tag; 269 + u64 tag __packed __aligned(4); 262 270 u8 reserved2[2]; 263 271 u8 flags; 264 272 u8 status; ··· 267 275 __be32 sense_data_len; 268 276 __be32 resp_data_len; 269 277 u8 data[]; 270 - } __attribute__((packed)); 278 + }; 271 279 272 280 struct srp_cred_req { 273 281 u8 opcode; ··· 293 301 u8 sol_not; 294 302 u8 reserved[2]; 295 303 __be32 req_lim_delta; 296 - u64 tag; 304 + u64 tag __packed __aligned(4); 297 305 u32 reserved2; 298 306 struct scsi_lun lun; 299 307 __be32 sense_data_len; 300 308 u32 reserved3; 301 309 u8 sense_data[]; 302 - } __attribute__((packed)); 310 + }; 303 311 304 312 struct srp_aer_rsp { 305 313 u8 opcode;