From: Lars Marowsky-Bree <lmb@suse.de>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] loop device failing on demand (2.4)
Date: Mon, 26 Aug 2002 14:06:42 +0200 [thread overview]
Message-ID: <20020826120642.GP7119@marowsky-bree.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 518 bytes --]
The attached small patch allows to "fail" a loop device on demand. Any further
request to the loop device will simply fail.
Even though it of course doesn't simulate the failures one might see in the
field, it is kind of handy for automated tests, for example for multipath I/O.
Done by Jens Axboe. The reason why I am sending it: I need it most and he is
on vacation.
Sincerely,
Lars Marowsky-Brée <lmb@suse.de>
--
Immortality is an adequate definition of high availability for me.
--- Gregory F. Pfister
[-- Attachment #2: loopdevice.patch --]
[-- Type: text/plain, Size: 1532 bytes --]
diff -ur /opt/kernel/linux-2.4.20-pre1/drivers/block/loop.c linux/drivers/block/loop.c
--- /opt/kernel/linux-2.4.20-pre1/drivers/block/loop.c 2002-08-03 02:39:43.000000000 +0200
+++ linux/drivers/block/loop.c 2002-08-09 09:59:42.000000000 +0200
@@ -473,6 +473,11 @@
atomic_inc(&lo->lo_pending);
spin_unlock_irq(&lo->lo_lock);
+ if (lo->lo_flags & LO_FLAGS_FAIL) {
+ printk("%s: failing %s\n", kdevname(rbh->b_rdev), rw == WRITE ? "write" : "read");
+ goto err;
+ }
+
if (rw == WRITE) {
if (lo->lo_flags & LO_FLAGS_READ_ONLY)
goto err;
@@ -877,6 +880,14 @@
case LOOP_GET_STATUS:
err = loop_get_status(lo, (struct loop_info *) arg);
break;
+ case LOOP_SET_FAIL:
+ lo->lo_flags |= LO_FLAGS_FAIL;
+ err = 0;
+ break;
+ case LOOP_CLEAR_FAIL:
+ lo->lo_flags &= ~LO_FLAGS_FAIL;
+ err = 0;
+ break;
case BLKGETSIZE:
if (lo->lo_state != Lo_bound) {
err = -ENXIO;
diff -ur /opt/kernel/linux-2.4.20-pre1/include/linux/loop.h linux/include/linux/loop.h
--- /opt/kernel/linux-2.4.20-pre1/include/linux/loop.h 2001-09-17 22:16:30.000000000 +0200
+++ linux/include/linux/loop.h 2002-08-08 12:01:56.000000000 +0200
@@ -78,6 +78,7 @@
#define LO_FLAGS_DO_BMAP 1
#define LO_FLAGS_READ_ONLY 2
#define LO_FLAGS_BH_REMAP 4
+#define LO_FLAGS_FAIL 8
/*
* Note that this structure gets the wrong offsets when directly used
@@ -151,5 +152,7 @@
#define LOOP_CLR_FD 0x4C01
#define LOOP_SET_STATUS 0x4C02
#define LOOP_GET_STATUS 0x4C03
+#define LOOP_SET_FAIL 0x4c04
+#define LOOP_CLEAR_FAIL 0x4c05
#endif
reply other threads:[~2002-08-26 12:02 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=20020826120642.GP7119@marowsky-bree.de \
--to=lmb@suse.de \
--cc=linux-kernel@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