systemtap 스크립트가 IO 오류를 시뮬레이션하지 못했습니다.

systemtap 스크립트가 IO 오류를 시뮬레이션하지 못했습니다.

다음 systemtap 스크립트를 사용하여 볼륨의 특정 섹터에 대한 읽기/쓰기 오류를 시뮬레이션하려고 합니다.

global error_sector_start  
global error_sector_end  
global error_major  
global error_minor  
global error_type 

probe begin {
    error_sector_start = strtol(@1, 10)
    error_sector_end = strtol(@2, 10)
    error_major = strtol(@3, 10)
    error_minor = strtol(@4, 10)
    error_type = @5
}

probe kernel.function("scsi_dispatch_cmd") {
    cmd = $arg1
    major = cmd->request->rq_disk->major
    minor = cmd->request->rq_disk->first_minor
    sector = cmd->request->__sector
    is_read = (cmd->request->cmd_flags & REQ_OP_READ) != 0
    is_write = (cmd->request->cmd_flags & REQ_OP_WRITE) != 0
    if (major == error_major && minor == error_minor &&
        sector >= error_sector_start && sector <= error_sector_end &&
        ((error_type == "read" && is_read) ||
         (error_type == "write" && is_write) ||
         (error_type == "both" && (is_read || is_write)))) {
        cmd->result = DID_ERROR << 16
        cmd->scsi_done(cmd)
        $return = 0
    }
}

결국 다음과 같은 오류 메시지가 나타납니다.

[root@vm-xr-taas-cdc-test02 ~]# cat /etc/redhat-release 
CentOS Linux release 7.1.1503 (Core) 
[root@vm-xr-taas-cdc-test02 ~]# uname -r 
4.18.0-147.mt20200626.413.el8_1.x86_64
[root@vm-xr-taas-cdc-test02 ~]# stap -g errorio_enhance.stp -v 12345 23456 8 0 read
Pass 1: parsed user script and 475 library scripts using 259056virt/74340res/6564shr/68040data kb, in 700usr/100sys/811real ms.
WARNING: never-assigned local variable 'REQ_OP_READ' (similar: REQ_OP_WRITE, is_read, cmd, major, minor): identifier 'REQ_OP_READ' at errorio_enhance.stp:20:46
source:         is_read = (cmd->request->cmd_flags & REQ_OP_READ) != 0
                                                     ^
WARNING: never-assigned local variable 'REQ_OP_WRITE' (similar: REQ_OP_READ, is_write, cmd, DID_ERROR, is_read): identifier 'REQ_OP_WRITE' at :21:47
source:         is_write = (cmd->request->cmd_flags & REQ_OP_WRITE) != 0
                                                      ^
WARNING: never-assigned local variable 'DID_ERROR' (similar: cmd, major, minor, sector, is_read): identifier 'DID_ERROR' at :27:27
source:             cmd->result = DID_ERROR << 16
                                  ^
WARNING: Eliding side-effect-free expression : identifier 'cmd' at :28:13
source:             cmd->scsi_done(cmd)
                    ^
WARNING: Eliding side-effect-free expression : operator '(' at :28:27
source:             cmd->scsi_done(cmd)
                                  ^
semantic error: while processing probe kernel.function("scsi_dispatch_cmd@drivers/scsi/scsi_lib.c:1547") from: kernel.function("scsi_dispatch_cmd")

semantic error: unable to find local 'arg1', [man error::dwarf] dieoffset 0x7cb0c7e in kernel, near pc 0xffffffff815a618e in scsi_dispatch_cmd drivers/scsi/scsi_lib.c (alternatives: $cmd)): identifier '$arg1' at :16:15
       source:         cmd = $arg1
                             ^

Pass 2: analyzed script: 2 probes, 1 function, 0 embeds, 5 globals using 312484virt/129540res/8372shr/121468data kb, in 1210usr/170sys/1387real ms.
Pass 2: analysis failed.  [man error::pass2]
You have new mail in /var/spool/mail/root

누구든지 스크립트의 문제점을 확인하는 데 도움을 줄 수 있습니까?

아래의 가장 간단한 코드를 사용하여 스크립트를 확인했습니다.

probe kernel.function("scsi_dispatch_cmd") {
   cmd = $cmd
   struct_bio= cmd->request->bio
   block = cmd->request->sector
   req_len = cmd->request_bufflen
   printf("Block: %d, Request Length: %d\n", block, req_len)
}

보고서는 다음과 같습니다.


[root@vm-xr-taas-cdc-test02 ~]# stap -g errorio_enhance.stpWARNING: Eliding assignment to 'struct_bio': operator '=' at errorio_enhance.stp:3:15
 source:     struct_bio= cmd->request->bio
                       ^
WARNING: Eliding side-effect-free expression : identifier 'struct_bio' at :3:5
 source:     struct_bio= cmd->request->bio
             ^
semantic error: while processing probe kernel.function("scsi_dispatch_cmd@drivers/scsi/scsi_lib.c:1547") from: kernel.function("scsi_dispatch_cmd")

semantic error: failed to retrieve location attribute for 'cmd' [man error::dwarf]: identifier '$cmd' at :2:11
        dieoffset: 0x7cb0c97 from /usr/lib/debug/lib/modules/4.18.0-147.mt20200626.413.el8_1.x86_64/vmlinux
        function: scsi_dispatch_cmd at drivers/scsi/scsi_lib.c:1549:30 inlined by scsi_queue_rq at drivers/scsi/scsi_lib.c:1760:11
        source:     cmd = $cmd
                          ^

Pass 2: analysis failed.  [man error::pass2]

enter code here

관련 정보