Skip to contentSkip to conversation

MD Acceleration: raid5 changes to support asynchronous operation

RFC PATCH New Dan Williams 1 participant 1 message Feb 3, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 MD Acceleration: raid5 changes to support asynchronous operation

This patch replaces one call to compute_parity with the new raid5_issue_compute_parity. To support md_adma a number of routines and definitions needed to be made available in raid5.h. In anticipation of raid6 support the handle_stripe and release_stripe routines were prefixed with raid5_.

drivers/md/Kconfig +2 -2
index ac43f98..b45720c 100644
@@ -106,7 +106,7 @@ config MD_RAID10
 
 config MD_RAID5
 	tristate "RAID-4/RAID-5 mode"
-	depends on BLK_DEV_MD
+	depends on BLK_DEV_MD && ADMA
 	---help---
 	  A RAID-5 set of N drives with a capacity of C MB per drive provides
 	  the capacity of C * (N - 1) MB, and protects against a failure
@@ -129,7 +129,7 @@ config MD_RAID5
 
 config MD_RAID6
 	tristate "RAID-6 mode"
-	depends on BLK_DEV_MD
+	depends on BLK_DEV_MD && ADMA
 	---help---
 	  A RAID-6 set of N drives with a capacity of C MB per drive
 	  provides the capacity of C * (N - 2) MB, and protects
drivers/md/Makefile +2 -2
index d3efedf..9b3e65f 100644
@@ -25,8 +25,8 @@ obj-$(CONFIG_MD_LINEAR)		+= linear.o
 obj-$(CONFIG_MD_RAID0)		+= raid0.o
 obj-$(CONFIG_MD_RAID1)		+= raid1.o
 obj-$(CONFIG_MD_RAID10)		+= raid10.o
-obj-$(CONFIG_MD_RAID5)		+= raid5.o xor.o
-obj-$(CONFIG_MD_RAID6)		+= raid6.o xor.o
+obj-$(CONFIG_MD_RAID5)		+= raid5.o md_adma.o xor.o
+obj-$(CONFIG_MD_RAID6)		+= raid6.o md_adma.o xor.o
 obj-$(CONFIG_MD_MULTIPATH)	+= multipath.o
 obj-$(CONFIG_MD_FAULTY)		+= faulty.o
 obj-$(CONFIG_BLK_DEV_MD)	+= md-mod.o
drivers/md/raid5.c +40 -48

210 lines not on this page · raw message

include/linux/raid/raid5.h +26 -1
index 394da82..968f40c 100644
@@ -3,6 +3,7 @@
 
 #include <linux/raid/md.h>
 #include <linux/raid/xor.h>
+#include <linux/adma/md_adma.h>
 
 /*
  *
@@ -133,13 +134,14 @@ struct stripe_head {
 	int			pd_idx;			/* parity disk index */
 	unsigned long		state;			/* state flags */
 	atomic_t		count;			/* nr of active thread/requests */
+	atomic_t		xor_count;		/* nr of async adma ops in flight */
 	spinlock_t		lock;
 	int			bm_seq;	/* sequence number for bitmap flushes */
 	struct r5dev {
 		struct bio	req;
 		struct bio_vec	vec;
 		struct page	*page;
-		struct bio	*toread, *towrite, *written;
+		struct bio	*toread, *towrite, *written, *inwrite;
 		sector_t	sector;			/* sector of this page */
 		unsigned long	flags;
 	} dev[1]; /* allocated with extra space depending of RAID geometry */
@@ -155,6 +157,7 @@ struct stripe_head {
 #define	R5_Overlap	7	/* There is a pending overlapping request on this block */
 #define	R5_ReadError	8	/* seen a read error here recently */
 #define	R5_ReWrite	9	/* have tried to over-write the readerror */
+#define 	R5_InAsyncXor	10	/* softens R5_LOCKED to allow queueing additional ops */
 
 /*
  * Write method
@@ -163,6 +166,8 @@ struct stripe_head {
 #define READ_MODIFY_WRITE	2
 /* not a write method, but a compute_parity mode */
 #define	CHECK_PARITY		3
+/* not a write method, but a xor operation recognized by raid5_adma_callback */
+#define COMPUTE_BLOCK		4
 
 /*
  * Stripe state
@@ -215,6 +220,7 @@ struct raid5_private_data {
 	struct list_head	delayed_list; /* stripes that have plugged requests */
 	struct list_head	bitmap_list; /* stripes delaying awaiting bitmap update */
 	atomic_t		preread_active_stripes; /* stripes with scheduled io */
+	adma_engine_t		*adma_engine; /* async data operations engine handle */
 
 	char			cache_name[20];
 	kmem_cache_t		*slab_cache; /* for allocating stripes */
@@ -246,6 +252,8 @@ struct raid5_private_data {
 typedef struct raid5_private_data raid5_conf_t;
 
 #define mddev_to_conf(mddev) ((raid5_conf_t *) mddev->private)
+void raid5_handle_stripe(struct stripe_head *sh);
+void raid5_release_stripe(struct stripe_head *sh);
 
 /*
  * Our supported algorithms
@@ -255,4 +263,21 @@ typedef struct raid5_private_data raid5_
 #define ALGORITHM_LEFT_SYMMETRIC	2
 #define ALGORITHM_RIGHT_SYMMETRIC	3
 
+/* Definitions needed by md_adma */
+
+/* bio's attached to a stripe+device for I/O are linked together in bi_sector
+ * order without overlap.  There may be several bio's per stripe+device, and
+ * a bio could span several devices.
+ * When walking this list for a particular stripe+device, we must never proceed
+ * beyond a bio that extends past this device, as the next bio might no longer
+ * be valid.
+ * This macro is used to determine the 'next' bio in the list, given the sector
+ * of the current stripe+device
+ */
+#define r5_next_bio(bio, sect) ( ( (bio)->bi_sector + ((bio)->bi_size>>9) < sect + STRIPE_SECTORS) ? (bio)->bi_next : NULL)
+
+#define IO_THRESHOLD			1
+#define STRIPE_SIZE		PAGE_SIZE
+#define STRIPE_SECTORS		(STRIPE_SIZE>>9)
+
 #endif
drivers/Kconfig +2 -0
index bddf431..c887854 100644
@@ -68,6 +68,8 @@ source "drivers/infiniband/Kconfig"
 
 source "drivers/sn/Kconfig"
 
+source "drivers/adma/Kconfig"
+
 source "drivers/edac/Kconfig"
 
 endmenu
drivers/Makefile +1 -0
index 619dd96..df547d5 100644
@@ -73,3 +73,4 @@ obj-$(CONFIG_SGI_IOC4)		+= sn/
 obj-y				+= firmware/
 obj-$(CONFIG_CRYPTO)		+= crypto/
 obj-$(CONFIG_SUPERH)		+= sh/
+obj-$(CONFIG_ADMA)              += adma/