From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs <linux-btrfs@vger.kernel.org>
Subject: systemtap script to controlled induce of media error
Date: Wed, 24 Dec 2014 23:34:47 +0800 [thread overview]
Message-ID: <549ADD17.60705@oracle.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 467 bytes --]
A simple script which would fake media error back the upper
level.
First read write files and list block numbers being read/written,
and then specify block number on which media error has to be created.
IO will fake fail, btrfs can be tested for these error conditions.
You won't be able to test for data consistency.
Works on any SCSI device no need of LVM or any IO special kernel
module.
attached script is still a rough cut.
Thanks, Anand
[-- Attachment #2: induce-media-err.stap --]
[-- Type: text/plain, Size: 2329 bytes --]
#! /usr/bin/env stap
global inject
global dev_block
global dev_device
global fail_read = 0
#global dev_device1 = "sde"
#global dev_device2= "sdd"
#global dev_device1 = "sdg"
#global dev_device2= "sdf"
#global dev_device1 = "sdb"
#global dev_device2= "sdc"
probe begin
{
inject = $1
dev_block = $2
dev_device = @3
#printf("BEGIN: %d %lx %s %s %s\n", inject, dev_block, dev_device, dev_device1, dev_device2);
printf("BEGIN: %d %lx %s\n", inject, dev_block, dev_device);
}
probe kernel.function("sd_prep_fn") !,
module("*").function("sd_prep_fn")
{
if ($rq->rq_disk->disk_name != NULL)
device = kernel_string($rq->rq_disk->disk_name)
else
device = "none"
#if (device == dev_device1 || device == dev_device2) {
if (device == dev_device) {
if($rq->cmd_flags & 1)
read_or_write = "w"
else
read_or_write = "r"
printf("%s %s %lx\n", device, read_or_write, $rq->__sector)
#if (inject && (dev_device1 == device || dev_device2 == device) && dev_block == $rq->__sector) {
if (inject && dev_device == device && dev_block == $rq->__sector) {
if (read_or_write == "r") {
fail_read = 1
printf("Trigger enabled.. ");
} else if (read_or_write == "w" && fail_read) {
fail_read = 0
printf("Fix write appeared. Trigger disabled\n");
}
}
}
}
probe module("*").function("scsi_decide_disposition@drivers/scsi/scsi_error.c") !,
kernel.function("scsi_decide_disposition@drivers/scsi/scsi_error.c")
{
if ($scmd->request->rq_disk->disk_name != NULL)
device = kernel_string($scmd->request->rq_disk->disk_name)
else
device = "none"
if($scmd->request->cmd_flags & 1)
read_or_write = "w"
else
read_or_write = "r"
block = $scmd->request->__sector
#if ((device == dev_device1 || device == dev_device2) && fail_read && block == dev_block && read_or_write == "r")
if (device == dev_device && fail_read && block == dev_block && read_or_write == "r")
{
printf("Failing the CDB .. ")
printf("%s %s %lx\n", device, read_or_write, block)
/* create fake status and sense data */
$scmd->result = 0x02
$scmd->sense_buffer[0] = 0x70
$scmd->sense_buffer[2] = 0x03
$scmd->sense_buffer[7] = 0x13
$scmd->sense_buffer[12] = 0x11
$scmd->sense_buffer[13] = 0x04
}
}
probe end
{
delete inject
delete dev_block
delete dev_device
}
reply other threads:[~2014-12-24 15:32 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=549ADD17.60705@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).