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

関連情報