summaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2016-11-18 19:46:50 -0500
committerShaohua Li <shli@fb.com>2016-11-18 20:13:49 -0500
commit3bddb7f8f264ec58dc86e11ca97341c24f9d38f6 (patch)
tree350e69ab8b594d2ce9eaa833e04294a939b8c044 /drivers/md/raid5.c
parent5aabf7c49d9ebe54a318976276b187637177a03e (diff)
md/r5cache: handle FLUSH and FUA
With raid5 cache, we committing data from journal device. When there is flush request, we need to flush journal device's cache. This was not needed in raid5 journal, because we will flush the journal before committing data to raid disks. This is similar to FUA, except that we also need flush journal for FUA. Otherwise, corruptions in earlier meta data will stop recovery from reaching FUA data. slightly changed the code by Shaohua Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index aa4968c04055..dbab8c7eccb0 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -5248,6 +5248,7 @@ static void raid5_make_request(struct mddev *mddev, struct bio * bi)
5248 int remaining; 5248 int remaining;
5249 DEFINE_WAIT(w); 5249 DEFINE_WAIT(w);
5250 bool do_prepare; 5250 bool do_prepare;
5251 bool do_flush = false;
5251 5252
5252 if (unlikely(bi->bi_opf & REQ_PREFLUSH)) { 5253 if (unlikely(bi->bi_opf & REQ_PREFLUSH)) {
5253 int ret = r5l_handle_flush_request(conf->log, bi); 5254 int ret = r5l_handle_flush_request(conf->log, bi);
@@ -5259,6 +5260,11 @@ static void raid5_make_request(struct mddev *mddev, struct bio * bi)
5259 return; 5260 return;
5260 } 5261 }
5261 /* ret == -EAGAIN, fallback */ 5262 /* ret == -EAGAIN, fallback */
5263 /*
5264 * if r5l_handle_flush_request() didn't clear REQ_PREFLUSH,
5265 * we need to flush journal device
5266 */
5267 do_flush = bi->bi_opf & REQ_PREFLUSH;
5262 } 5268 }
5263 5269
5264 md_write_start(mddev, bi); 5270 md_write_start(mddev, bi);
@@ -5398,6 +5404,12 @@ static void raid5_make_request(struct mddev *mddev, struct bio * bi)
5398 do_prepare = true; 5404 do_prepare = true;
5399 goto retry; 5405 goto retry;
5400 } 5406 }
5407 if (do_flush) {
5408 set_bit(STRIPE_R5C_PREFLUSH, &sh->state);
5409 /* we only need flush for one stripe */
5410 do_flush = false;
5411 }
5412
5401 set_bit(STRIPE_HANDLE, &sh->state); 5413 set_bit(STRIPE_HANDLE, &sh->state);
5402 clear_bit(STRIPE_DELAYED, &sh->state); 5414 clear_bit(STRIPE_DELAYED, &sh->state);
5403 if ((!sh->batch_head || sh == sh->batch_head) && 5415 if ((!sh->batch_head || sh == sh->batch_head) &&