@@ -47,6 +47,7 @@ static u16 nvmet_get_smart_log_nsid(struct nvmet_req *req,
47
47
if (!ns ) {
48
48
pr_err ("Could not find namespace id : %d\n" ,
49
49
le32_to_cpu (req -> cmd -> get_log_page .nsid ));
50
+ req -> error_loc = offsetof(struct nvme_rw_command , nsid );
50
51
return NVME_SC_INVALID_NS ;
51
52
}
52
53
@@ -380,6 +381,7 @@ static void nvmet_execute_identify_ns(struct nvmet_req *req)
380
381
u16 status = 0 ;
381
382
382
383
if (le32_to_cpu (req -> cmd -> identify .nsid ) == NVME_NSID_ALL ) {
384
+ req -> error_loc = offsetof(struct nvme_identify , nsid );
383
385
status = NVME_SC_INVALID_NS | NVME_SC_DNR ;
384
386
goto out ;
385
387
}
@@ -500,6 +502,7 @@ static void nvmet_execute_identify_desclist(struct nvmet_req *req)
500
502
501
503
ns = nvmet_find_namespace (req -> sq -> ctrl , req -> cmd -> identify .nsid );
502
504
if (!ns ) {
505
+ req -> error_loc = offsetof(struct nvme_identify , nsid );
503
506
status = NVME_SC_INVALID_NS | NVME_SC_DNR ;
504
507
goto out ;
505
508
}
@@ -562,8 +565,10 @@ static u16 nvmet_set_feat_write_protect(struct nvmet_req *req)
562
565
u16 status = NVME_SC_FEATURE_NOT_CHANGEABLE ;
563
566
564
567
req -> ns = nvmet_find_namespace (req -> sq -> ctrl , req -> cmd -> rw .nsid );
565
- if (unlikely (!req -> ns ))
568
+ if (unlikely (!req -> ns )) {
569
+ req -> error_loc = offsetof(struct nvme_common_command , nsid );
566
570
return status ;
571
+ }
567
572
568
573
mutex_lock (& subsys -> lock );
569
574
switch (write_protect ) {
@@ -602,8 +607,10 @@ u16 nvmet_set_feat_async_event(struct nvmet_req *req, u32 mask)
602
607
{
603
608
u32 val32 = le32_to_cpu (req -> cmd -> common .cdw11 );
604
609
605
- if (val32 & ~mask )
610
+ if (val32 & ~mask ) {
611
+ req -> error_loc = offsetof(struct nvme_common_command , cdw11 );
606
612
return NVME_SC_INVALID_FIELD | NVME_SC_DNR ;
613
+ }
607
614
608
615
WRITE_ONCE (req -> sq -> ctrl -> aen_enabled , val32 );
609
616
nvmet_set_result (req , val32 );
@@ -635,6 +642,7 @@ static void nvmet_execute_set_features(struct nvmet_req *req)
635
642
status = nvmet_set_feat_write_protect (req );
636
643
break ;
637
644
default :
645
+ req -> error_loc = offsetof(struct nvme_common_command , cdw10 );
638
646
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR ;
639
647
break ;
640
648
}
@@ -648,9 +656,10 @@ static u16 nvmet_get_feat_write_protect(struct nvmet_req *req)
648
656
u32 result ;
649
657
650
658
req -> ns = nvmet_find_namespace (req -> sq -> ctrl , req -> cmd -> common .nsid );
651
- if (!req -> ns )
659
+ if (!req -> ns ) {
660
+ req -> error_loc = offsetof(struct nvme_common_command , nsid );
652
661
return NVME_SC_INVALID_NS | NVME_SC_DNR ;
653
-
662
+ }
654
663
mutex_lock (& subsys -> lock );
655
664
if (req -> ns -> readonly == true)
656
665
result = NVME_NS_WRITE_PROTECT ;
@@ -716,6 +725,8 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
716
725
case NVME_FEAT_HOST_ID :
717
726
/* need 128-bit host identifier flag */
718
727
if (!(req -> cmd -> common .cdw11 & cpu_to_le32 (1 << 0 ))) {
728
+ req -> error_loc =
729
+ offsetof(struct nvme_common_command , cdw11 );
719
730
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR ;
720
731
break ;
721
732
}
@@ -727,6 +738,8 @@ static void nvmet_execute_get_features(struct nvmet_req *req)
727
738
status = nvmet_get_feat_write_protect (req );
728
739
break ;
729
740
default :
741
+ req -> error_loc =
742
+ offsetof(struct nvme_common_command , cdw10 );
730
743
status = NVME_SC_INVALID_FIELD | NVME_SC_DNR ;
731
744
break ;
732
745
}
@@ -848,5 +861,6 @@ u16 nvmet_parse_admin_cmd(struct nvmet_req *req)
848
861
849
862
pr_err ("unhandled cmd %d on qid %d\n" , cmd -> common .opcode ,
850
863
req -> sq -> qid );
864
+ req -> error_loc = offsetof(struct nvme_common_command , opcode );
851
865
return NVME_SC_INVALID_OPCODE | NVME_SC_DNR ;
852
866
}
0 commit comments