[PATCH 2/2] barrier-test: Allow filesystem to specify special test request

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Create new request flag by which a filesystem can say that this block is
special and it's reordering is interesting for causing breakage. So we submit
the block immediately and possibly crash just after the IO is finished.

Signed-off-by: Jan Kara <jack@xxxxxxx>
---
 block/barrier-test-iosched.c |   41 +++++++++++++++++++++++++++++++----------
 include/linux/blk_types.h    |    6 +++++-
 2 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/block/barrier-test-iosched.c b/block/barrier-test-iosched.c
index 8c30461..1d66097 100644
--- a/block/barrier-test-iosched.c
+++ b/block/barrier-test-iosched.c
@@ -74,7 +74,9 @@ struct barrier_test_data {
 	/* this is for waiting until prending_rqs is zero */
 	wait_queue_head_t pending_rq_wait;
 
-	int random_reboot;
+	int random_flush_reboot;
+	int random_rq_reboot;
+
 	int total_barriers;
 };
 
@@ -144,7 +146,13 @@ static void barrier_test_end_io_fn(struct request *rq, int err)
 
 	q = rq->q;
 	nd = q->elevator->elevator_data;
-
+	if (rq->cmd_flags & REQ_BARRIER_TEST &&
+	    atomic_read(&nd->pending_rqs) > 256 &&
+	    nd->random_rq_reboot) {
+		printk(KERN_CRIT "doing random crash after request "
+			"completion\n");
+		emergency_restart();
+	}
 	list_add(&rq->queuelist, &nd->spare_requests);
 
 	/* if there are no more pending requests, we can
@@ -200,7 +208,8 @@ static int can_delay_request(struct request *rq)
 {
 	if (!(rq->cmd_flags & REQ_WRITE))
 		return 0;
-	if (rq->cmd_flags & (REQ_DISCARD | REQ_FLUSH | REQ_FUA))
+	if (rq->cmd_flags &
+	    (REQ_DISCARD | REQ_FLUSH | REQ_FUA))
 		return 0;
 	if (rq->bio != rq->biotail)
 		return 0;
@@ -360,7 +369,7 @@ static void queue_all_delayed(struct barrier_test_data *nd, int for_barrier)
 		 * some
 		 */
 		if (for_barrier && orig_delayed_nr > 256 &&
-		    nr == 256 && nd->random_reboot) {
+		    nr == 256 && nd->random_flush_reboot) {
 			printk(KERN_CRIT "doing random crash before barrier submit\n");
 			emergency_restart();
 		}
@@ -486,8 +495,16 @@ static void barrier_test_add_request(struct request_queue *q, struct request *rq
 	 */
 	list_add_tail(&rq->queuelist, &nd->writeback_requests);
 
-	/* add our copy to the delayed_requests list */
-	list_add_tail(&copy->queuelist, &nd->delayed_requests);
+	if (!(copy->cmd_flags & REQ_BARRIER_TEST)) {
+		/* add our copy to the delayed_requests list */
+		list_add_tail(&copy->queuelist, &nd->delayed_requests);
+	} else {
+		/*
+		 * add our copy directly to dispatch list. We couldn't do it
+		 * with original request since we need special end_io function
+		 */
+		list_add_tail(&copy->queuelist, &nd->queue);
+	}
 
 	/* if we're depleting our list of spares, start the writeback IO */
 	if (atomic_read(&nd->pending_rqs) > (NR_SPARE_REQUESTS / 2))
@@ -560,7 +577,8 @@ static void *barrier_test_init_queue(struct request_queue *q)
 	init_waitqueue_head(&nd->pending_rq_wait);
 	atomic_set(&nd->pending_rqs, 0);
 	bio_list_init(&nd->spare_bios);
-	nd->random_reboot = 0;
+	nd->random_flush_reboot = 0;
+	nd->random_rq_reboot = 0;
 	nd->total_barriers = 0;
 
 	for (i = 0; i < NR_SPARE_REQUESTS; i++) {
@@ -632,7 +650,8 @@ static ssize_t __FUNC(struct elevator_queue *e, char *page)		\
 		__data = jiffies_to_msecs(__data);			\
 	return barrier_test_var_show(__data, (page));			\
 }
-SHOW_FUNCTION(barrier_test_random_reboot_show, dd->random_reboot, 0);
+SHOW_FUNCTION(barrier_test_random_flush_reboot_show, dd->random_flush_reboot, 0);
+SHOW_FUNCTION(barrier_test_random_rq_reboot_show, dd->random_rq_reboot, 0);
 #undef SHOW_FUNCTION
 
 #define STORE_FUNCTION(__FUNC, __PTR, MIN, MAX, __CONV)			\
@@ -651,7 +670,8 @@ static ssize_t __FUNC(struct elevator_queue *e, const char *page, size_t count)
 		*(__PTR) = __data;					\
 	return ret;							\
 }
-STORE_FUNCTION(barrier_test_random_reboot_store, &dd->random_reboot, 0, 1, 0);
+STORE_FUNCTION(barrier_test_random_flush_reboot_store, &dd->random_flush_reboot, 0, 1, 0);
+STORE_FUNCTION(barrier_test_random_rq_reboot_store, &dd->random_rq_reboot, 0, 1, 0);
 #undef STORE_FUNCTION
 
 #define BT_ATTR(name) \
@@ -659,7 +679,8 @@ STORE_FUNCTION(barrier_test_random_reboot_store, &dd->random_reboot, 0, 1, 0);
 				      barrier_test_##name##_store)
 
 static struct elv_fs_entry barrier_test_attrs[] = {
-	BT_ATTR(random_reboot),
+	BT_ATTR(random_flush_reboot),
+	BT_ATTR(random_rq_reboot),
 	__ATTR_NULL
 };
 
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 4053cbd..1e94ebc 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -128,6 +128,8 @@ enum rq_flag_bits {
 	__REQ_NOIDLE,		/* don't anticipate more IO after this one */
 	__REQ_FUA,		/* forced unit access */
 	__REQ_FLUSH,		/* request for cache flush */
+	__REQ_BARRIER_TEST,	/* request whose reordering is interesting
+				 * for barrier test */
 
 	/* bio only flags */
 	__REQ_RAHEAD,		/* read ahead, can fail anytime */
@@ -162,12 +164,14 @@ enum rq_flag_bits {
 #define REQ_PRIO		(1 << __REQ_PRIO)
 #define REQ_DISCARD		(1 << __REQ_DISCARD)
 #define REQ_NOIDLE		(1 << __REQ_NOIDLE)
+#define REQ_BARRIER_TEST	(1 << __REQ_BARRIER_TEST)
 
 #define REQ_FAILFAST_MASK \
 	(REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | REQ_FAILFAST_DRIVER)
 #define REQ_COMMON_MASK \
 	(REQ_WRITE | REQ_FAILFAST_MASK | REQ_SYNC | REQ_META | REQ_PRIO | \
-	 REQ_DISCARD | REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE)
+	 REQ_DISCARD | REQ_NOIDLE | REQ_FLUSH | REQ_FUA | REQ_SECURE | \
+	 REQ_BARRIER_TEST)
 #define REQ_CLONE_MASK		REQ_COMMON_MASK
 
 #define REQ_RAHEAD		(1 << __REQ_RAHEAD)
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux