[PATCH] md: add write-behind support for md/raid1
If a device is flagged 'WriteMostly' and the array has a bitmap, and the bitmap superblock indicates that write_behind is allowed, then write_behind is enabled for WriteMostly devices. Write requests will be acknowledges as complete to the caller (via b_end_io) when all non-WriteMostly devices have completed the write, but will not be cleared from the bitmap until all devices complete. This requires memory allocation to make a local copy of the data being written. If there is insufficient memory, then we fall-back on normal write semantics. Signed-Off-By: Paul Clements <paul.clements@steeleye.com> Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:

committed by
Linus Torvalds

parent
8ddf9efe67
commit
4b6d287f62
@@ -7,7 +7,7 @@
|
||||
#define BITMAP_H 1
|
||||
|
||||
#define BITMAP_MAJOR 3
|
||||
#define BITMAP_MINOR 38
|
||||
#define BITMAP_MINOR 39
|
||||
|
||||
/*
|
||||
* in-memory bitmap:
|
||||
@@ -147,8 +147,9 @@ typedef struct bitmap_super_s {
|
||||
__u32 state; /* 48 bitmap state information */
|
||||
__u32 chunksize; /* 52 the bitmap chunk size in bytes */
|
||||
__u32 daemon_sleep; /* 56 seconds between disk flushes */
|
||||
__u32 write_behind; /* 60 number of outstanding write-behind writes */
|
||||
|
||||
__u8 pad[256 - 60]; /* set to zero */
|
||||
__u8 pad[256 - 64]; /* set to zero */
|
||||
} bitmap_super_t;
|
||||
|
||||
/* notes:
|
||||
@@ -226,6 +227,9 @@ struct bitmap {
|
||||
|
||||
unsigned long flags;
|
||||
|
||||
unsigned long max_write_behind; /* write-behind mode */
|
||||
atomic_t behind_writes;
|
||||
|
||||
/*
|
||||
* the bitmap daemon - periodically wakes up and sweeps the bitmap
|
||||
* file, cleaning up bits and flushing out pages to disk as necessary
|
||||
@@ -260,9 +264,10 @@ int bitmap_setallbits(struct bitmap *bitmap);
|
||||
void bitmap_write_all(struct bitmap *bitmap);
|
||||
|
||||
/* these are exported */
|
||||
int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors);
|
||||
void bitmap_endwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectors,
|
||||
int success);
|
||||
int bitmap_startwrite(struct bitmap *bitmap, sector_t offset,
|
||||
unsigned long sectors, int behind);
|
||||
void bitmap_endwrite(struct bitmap *bitmap, sector_t offset,
|
||||
unsigned long sectors, int success, int behind);
|
||||
int bitmap_start_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int degraded);
|
||||
void bitmap_end_sync(struct bitmap *bitmap, sector_t offset, int *blocks, int aborted);
|
||||
void bitmap_close_sync(struct bitmap *bitmap);
|
||||
|
@@ -275,6 +275,9 @@ struct mddev_s
|
||||
atomic_t writes_pending;
|
||||
request_queue_t *queue; /* for plugging ... */
|
||||
|
||||
atomic_t write_behind; /* outstanding async IO */
|
||||
unsigned int max_write_behind; /* 0 = sync */
|
||||
|
||||
struct bitmap *bitmap; /* the bitmap for the device */
|
||||
struct file *bitmap_file; /* the bitmap file */
|
||||
long bitmap_offset; /* offset from superblock of
|
||||
|
@@ -80,6 +80,9 @@ struct r1bio_s {
|
||||
atomic_t remaining; /* 'have we finished' count,
|
||||
* used from IRQ handlers
|
||||
*/
|
||||
atomic_t behind_remaining; /* number of write-behind ios remaining
|
||||
* in this BehindIO request
|
||||
*/
|
||||
sector_t sector;
|
||||
int sectors;
|
||||
unsigned long state;
|
||||
@@ -107,4 +110,14 @@ struct r1bio_s {
|
||||
#define R1BIO_Uptodate 0
|
||||
#define R1BIO_IsSync 1
|
||||
#define R1BIO_Degraded 2
|
||||
#define R1BIO_BehindIO 3
|
||||
/* For write-behind requests, we call bi_end_io when
|
||||
* the last non-write-behind device completes, providing
|
||||
* any write was successful. Otherwise we call when
|
||||
* any write-behind write succeeds, otherwise we call
|
||||
* with failure when last write completes (and all failed).
|
||||
* Record that bi_end_io was called with this flag...
|
||||
*/
|
||||
#define R1BIO_Returned 4
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user