17
17
18
18
static void nvmet_execute_prop_set (struct nvmet_req * req )
19
19
{
20
+ u64 val = le64_to_cpu (req -> cmd -> prop_set .value );
20
21
u16 status = 0 ;
21
22
22
- if (!(req -> cmd -> prop_set .attrib & 1 )) {
23
- u64 val = le64_to_cpu (req -> cmd -> prop_set .value );
24
-
25
- switch (le32_to_cpu (req -> cmd -> prop_set .offset )) {
26
- case NVME_REG_CC :
27
- nvmet_update_cc (req -> sq -> ctrl , val );
28
- break ;
29
- default :
30
- status = NVME_SC_INVALID_FIELD | NVME_SC_DNR ;
31
- break ;
32
- }
33
- } else {
23
+ if (req -> cmd -> prop_set .attrib & 1 ) {
24
+ req -> error_loc =
25
+ offsetof(struct nvmf_property_set_command , attrib );
34
26
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR ;
27
+ goto out ;
35
28
}
36
29
30
+ switch (le32_to_cpu (req -> cmd -> prop_set .offset )) {
31
+ case NVME_REG_CC :
32
+ nvmet_update_cc (req -> sq -> ctrl , val );
33
+ break ;
34
+ default :
35
+ req -> error_loc =
36
+ offsetof(struct nvmf_property_set_command , offset );
37
+ status = NVME_SC_INVALID_FIELD | NVME_SC_DNR ;
38
+ }
39
+ out :
37
40
nvmet_req_complete (req , status );
38
41
}
39
42
@@ -69,6 +72,14 @@ static void nvmet_execute_prop_get(struct nvmet_req *req)
69
72
}
70
73
}
71
74
75
+ if (status && req -> cmd -> prop_get .attrib & 1 ) {
76
+ req -> error_loc =
77
+ offsetof(struct nvmf_property_get_command , offset );
78
+ } else {
79
+ req -> error_loc =
80
+ offsetof(struct nvmf_property_get_command , attrib );
81
+ }
82
+
72
83
req -> rsp -> result .u64 = cpu_to_le64 (val );
73
84
nvmet_req_complete (req , status );
74
85
}
@@ -89,6 +100,7 @@ u16 nvmet_parse_fabrics_cmd(struct nvmet_req *req)
89
100
default :
90
101
pr_err ("received unknown capsule type 0x%x\n" ,
91
102
cmd -> fabrics .fctype );
103
+ req -> error_loc = offsetof(struct nvmf_common_command , fctype );
92
104
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR ;
93
105
}
94
106
@@ -105,10 +117,12 @@ static u16 nvmet_install_queue(struct nvmet_ctrl *ctrl, struct nvmet_req *req)
105
117
old = cmpxchg (& req -> sq -> ctrl , NULL , ctrl );
106
118
if (old ) {
107
119
pr_warn ("queue already connected!\n" );
120
+ req -> error_loc = offsetof(struct nvmf_connect_command , opcode );
108
121
return NVME_SC_CONNECT_CTRL_BUSY | NVME_SC_DNR ;
109
122
}
110
123
if (!sqsize ) {
111
124
pr_warn ("queue size zero!\n" );
125
+ req -> error_loc = offsetof(struct nvmf_connect_command , sqsize );
112
126
return NVME_SC_CONNECT_INVALID_PARAM | NVME_SC_DNR ;
113
127
}
114
128
@@ -157,6 +171,7 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
157
171
if (c -> recfmt != 0 ) {
158
172
pr_warn ("invalid connect version (%d).\n" ,
159
173
le16_to_cpu (c -> recfmt ));
174
+ req -> error_loc = offsetof(struct nvmf_connect_command , recfmt );
160
175
status = NVME_SC_CONNECT_FORMAT | NVME_SC_DNR ;
161
176
goto out ;
162
177
}
@@ -171,8 +186,13 @@ static void nvmet_execute_admin_connect(struct nvmet_req *req)
171
186
172
187
status = nvmet_alloc_ctrl (d -> subsysnqn , d -> hostnqn , req ,
173
188
le32_to_cpu (c -> kato ), & ctrl );
174
- if (status )
189
+ if (status ) {
190
+ if (status == (NVME_SC_INVALID_FIELD | NVME_SC_DNR ))
191
+ req -> error_loc =
192
+ offsetof(struct nvme_common_command , opcode );
175
193
goto out ;
194
+ }
195
+
176
196
uuid_copy (& ctrl -> hostid , & d -> hostid );
177
197
178
198
status = nvmet_install_queue (ctrl , req );
@@ -259,11 +279,13 @@ u16 nvmet_parse_connect_cmd(struct nvmet_req *req)
259
279
if (cmd -> common .opcode != nvme_fabrics_command ) {
260
280
pr_err ("invalid command 0x%x on unconnected queue.\n" ,
261
281
cmd -> fabrics .opcode );
282
+ req -> error_loc = offsetof(struct nvme_common_command , opcode );
262
283
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR ;
263
284
}
264
285
if (cmd -> fabrics .fctype != nvme_fabrics_type_connect ) {
265
286
pr_err ("invalid capsule type 0x%x on unconnected queue.\n" ,
266
287
cmd -> fabrics .fctype );
288
+ req -> error_loc = offsetof(struct nvmf_common_command , fctype );
267
289
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR ;
268
290
}
269
291
0 commit comments