Blame view

drivers/md/raid10.h 3.99 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
2
  #ifndef _RAID10_H
  #define _RAID10_H
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
  struct mirror_info {
69335ef3b   NeilBrown   md/raid10: prepar...
4
  	struct md_rdev	*rdev, *replacement;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
5
  	sector_t	head_position;
2bb77736a   NeilBrown   md/raid10: Make u...
6
7
8
9
10
  	int		recovery_disabled;	/* matches
  						 * mddev->recovery_disabled
  						 * when we shouldn't try
  						 * recovering this device.
  						 */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11
  };
e879a8793   NeilBrown   md/raid10: typede...
12
  struct r10conf {
fd01b88c7   NeilBrown   md: remove typede...
13
  	struct mddev		*mddev;
0f6d02d58   NeilBrown   md: remove typede...
14
  	struct mirror_info	*mirrors;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
15
  	int			raid_disks;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
16
17
18
  	spinlock_t		device_lock;
  
  	/* geometry */
69335ef3b   NeilBrown   md/raid10: prepar...
19
20
  	int			near_copies;  /* number of copies laid out
  					       * raid0 style */
25985edce   Lucas De Marchi   Fix common misspe...
21
  	int 			far_copies;   /* number of copies laid out
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
22
23
  					       * at large strides across drives
  					       */
69335ef3b   NeilBrown   md/raid10: prepar...
24
25
  	int			far_offset;   /* far_copies are offset by 1
  					       * stripe instead of many
c93983bf5   NeilBrown   [PATCH] md: suppo...
26
  					       */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
28
29
30
  	int			copies;	      /* near_copies * far_copies.
  					       * must be <= raid_disks
  					       */
  	sector_t		stride;	      /* distance between far copies.
c93983bf5   NeilBrown   [PATCH] md: suppo...
31
32
33
  					       * This is size / far_copies unless
  					       * far_offset, in which case it is
  					       * 1 stripe.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
34
  					       */
69335ef3b   NeilBrown   md/raid10: prepar...
35
36
  	sector_t		dev_sectors;  /* temp copy of
  					       * mddev->dev_sectors */
dab8b2924   Trela, Maciej   md: Add support f...
37

69335ef3b   NeilBrown   md/raid10: prepar...
38
39
  	int			chunk_shift; /* shift from chunks to sectors */
  	sector_t		chunk_mask;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
40
41
  
  	struct list_head	retry_list;
6cce3b23f   NeilBrown   [PATCH] md: write...
42
43
  	/* queue pending writes and submit them on unplug */
  	struct bio_list		pending_bio_list;
34db0cd60   NeilBrown   md: add proper wr...
44
  	int			pending_count;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
45
46
  
  	spinlock_t		resync_lock;
69335ef3b   NeilBrown   md/raid10: prepar...
47
48
49
50
  	int			nr_pending;
  	int			nr_waiting;
  	int			nr_queued;
  	int			barrier;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
51
  	sector_t		next_resync;
6cce3b23f   NeilBrown   [PATCH] md: write...
52
53
54
55
  	int			fullsync;  /* set to 1 if a full sync is needed,
  					    * (fresh device added).
  					    * Cleared when a sync completes.
  					    */
69335ef3b   NeilBrown   md/raid10: prepar...
56
57
58
  	int			have_replacement; /* There is at least one
  						   * replacement device.
  						   */
0a27ec96b   NeilBrown   [PATCH] md: impro...
59
  	wait_queue_head_t	wait_barrier;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
60

69335ef3b   NeilBrown   md/raid10: prepar...
61
62
  	mempool_t		*r10bio_pool;
  	mempool_t		*r10buf_pool;
4443ae10c   NeilBrown   [PATCH] md: auto-...
63
  	struct page		*tmppage;
dab8b2924   Trela, Maciej   md: Add support f...
64
65
66
67
  
  	/* When taking over an array from a different personality, we store
  	 * the new thread here until we fully activate the array.
  	 */
2b8bf3451   NeilBrown   md: remove typede...
68
  	struct md_thread	*thread;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
69
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
70
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
72
73
74
75
   * this is our 'private' RAID10 bio.
   *
   * it contains information about what kind of IO operations were started
   * for this RAID10 operation, and about their status:
   */
9f2c9d12b   NeilBrown   md: remove typede...
76
  struct r10bio {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
78
79
80
81
82
  	atomic_t		remaining; /* 'have we finished' count,
  					    * used from IRQ handlers
  					    */
  	sector_t		sector;	/* virtual sector number */
  	int			sectors;
  	unsigned long		state;
fd01b88c7   NeilBrown   md: remove typede...
83
  	struct mddev		*mddev;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
  	/*
  	 * original bio going to /dev/mdx
  	 */
  	struct bio		*master_bio;
  	/*
  	 * if the IO is in READ direction, then this is where we read
  	 */
  	int			read_slot;
  
  	struct list_head	retry_list;
  	/*
  	 * if the IO is in WRITE direction, then multiple bios are used,
  	 * one for each copy.
  	 * When resyncing we also use one for each copy.
  	 * When reconstructing, we use 2 bios, one for read, one for write.
  	 * We choose the number when they are allocated.
69335ef3b   NeilBrown   md/raid10: prepar...
100
  	 * We sometimes need an extra bio to write to the replacement.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
101
102
  	 */
  	struct {
69335ef3b   NeilBrown   md/raid10: prepar...
103
104
105
106
107
108
109
110
111
  		struct bio	*bio;
  		union {
  			struct bio	*repl_bio; /* used for resync and
  						    * writes */
  			struct md_rdev	*rdev;	   /* used for reads
  						    * (read_slot >= 0) */
  		};
  		sector_t	addr;
  		int		devnum;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112
113
  	} devs[0];
  };
0eb3ff12a   NeilBrown   [PATCH] md: raid1...
114
115
116
117
118
119
  /* when we get a read error on a read-only array, we redirect to another
   * device without failing the first device, or trying to over-write to
   * correct the read error.  To keep track of bad blocks on a per-bio
   * level, we store IO_BLOCKED in the appropriate 'bios' pointer
   */
  #define IO_BLOCKED ((struct bio*)1)
749c55e94   NeilBrown   md/raid10: clear ...
120
121
122
123
124
125
126
  /* When we successfully write to a known bad-block, we need to remove the
   * bad-block marking which must be done from process context.  So we record
   * the success by setting devs[n].bio to IO_MADE_GOOD
   */
  #define IO_MADE_GOOD ((struct bio *)2)
  
  #define BIO_SPECIAL(bio) ((unsigned long)bio <= 2)
0eb3ff12a   NeilBrown   [PATCH] md: raid1...
127

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128
  /* bits for r10bio.state */
69335ef3b   NeilBrown   md/raid10: prepar...
129
130
131
132
133
  enum r10bio_state {
  	R10BIO_Uptodate,
  	R10BIO_IsSync,
  	R10BIO_IsRecover,
  	R10BIO_Degraded,
856e08e23   NeilBrown   md/raid10: avoid ...
134
135
136
  /* Set ReadError on bios that experience a read error
   * so that raid10d knows what to do with them.
   */
69335ef3b   NeilBrown   md/raid10: prepar...
137
  	R10BIO_ReadError,
749c55e94   NeilBrown   md/raid10: clear ...
138
139
140
  /* If a write for this request means we can clear some
   * known-bad-block records, we set this flag.
   */
69335ef3b   NeilBrown   md/raid10: prepar...
141
142
143
  	R10BIO_MadeGood,
  	R10BIO_WriteError,
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
144
  #endif