raid5-cache.c (51039cd066553689bb82a588b25a6eba7d453837) raid5-cache.c (c1b9919849866b96dc435f025beaa307dc76ca27)
1/*
2 * Copyright (C) 2015 Shaohua Li <shli@fb.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT

--- 257 unchanged lines hidden (view full) ---

266 bio->bi_end_io = r5l_log_endio;
267 bio->bi_private = io;
268
269 bio_list_add(&io->bios, bio);
270 atomic_inc(&io->pending_io);
271 return bio;
272}
273
1/*
2 * Copyright (C) 2015 Shaohua Li <shli@fb.com>
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms and conditions of the GNU General Public License,
6 * version 2, as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope it will be useful, but WITHOUT

--- 257 unchanged lines hidden (view full) ---

266 bio->bi_end_io = r5l_log_endio;
267 bio->bi_private = io;
268
269 bio_list_add(&io->bios, bio);
270 atomic_inc(&io->pending_io);
271 return bio;
272}
273
274static void r5_reserve_log_entry(struct r5l_log *log, struct r5l_io_unit *io)
275{
276 log->log_start = r5l_ring_add(log, log->log_start, BLOCK_SECTORS);
277
278 /*
279 * If we filled up the log device start from the beginning again,
280 * which will require a new bio.
281 *
282 * Note: for this to work properly the log size needs to me a multiple
283 * of BLOCK_SECTORS.
284 */
285 if (log->log_start == 0)
286 io->current_bio = NULL;
287
288 io->log_end = log->log_start;
289}
290
274static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
275{
276 struct r5l_io_unit *io;
277 struct r5l_meta_block *block;
278
279 /* We can't handle memory allocate failure so far */
280 io = kmem_cache_zalloc(log->io_kc, GFP_NOIO | __GFP_NOFAIL);
281 io->log = log;

--- 12 unchanged lines hidden (view full) ---

294 io->log_start = log->log_start;
295 io->meta_offset = sizeof(struct r5l_meta_block);
296 io->seq = log->seq;
297
298 io->current_bio = r5l_bio_alloc(log, io);
299 bio_add_page(io->current_bio, io->meta_page, PAGE_SIZE, 0);
300
301 log->seq++;
291static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log)
292{
293 struct r5l_io_unit *io;
294 struct r5l_meta_block *block;
295
296 /* We can't handle memory allocate failure so far */
297 io = kmem_cache_zalloc(log->io_kc, GFP_NOIO | __GFP_NOFAIL);
298 io->log = log;

--- 12 unchanged lines hidden (view full) ---

311 io->log_start = log->log_start;
312 io->meta_offset = sizeof(struct r5l_meta_block);
313 io->seq = log->seq;
314
315 io->current_bio = r5l_bio_alloc(log, io);
316 bio_add_page(io->current_bio, io->meta_page, PAGE_SIZE, 0);
317
318 log->seq++;
302 log->log_start = r5l_ring_add(log, log->log_start, BLOCK_SECTORS);
303 io->log_end = log->log_start;
304 /* current bio hit disk end */
305 if (log->log_start == 0)
306 io->current_bio = NULL;
319 r5_reserve_log_entry(log, io);
307
308 spin_lock_irq(&log->io_list_lock);
309 list_add_tail(&io->log_sibling, &log->running_ios);
310 spin_unlock_irq(&log->io_list_lock);
311
312 return io;
313}
314

--- 37 unchanged lines hidden (view full) ---

352alloc_bio:
353 if (!io->current_bio)
354 io->current_bio = r5l_bio_alloc(log, io);
355
356 if (!bio_add_page(io->current_bio, page, PAGE_SIZE, 0)) {
357 io->current_bio = NULL;
358 goto alloc_bio;
359 }
320
321 spin_lock_irq(&log->io_list_lock);
322 list_add_tail(&io->log_sibling, &log->running_ios);
323 spin_unlock_irq(&log->io_list_lock);
324
325 return io;
326}
327

--- 37 unchanged lines hidden (view full) ---

365alloc_bio:
366 if (!io->current_bio)
367 io->current_bio = r5l_bio_alloc(log, io);
368
369 if (!bio_add_page(io->current_bio, page, PAGE_SIZE, 0)) {
370 io->current_bio = NULL;
371 goto alloc_bio;
372 }
360 log->log_start = r5l_ring_add(log, log->log_start,
361 BLOCK_SECTORS);
362 /* current bio hit disk end */
363 if (log->log_start == 0)
364 io->current_bio = NULL;
365
373
366 io->log_end = log->log_start;
374 r5_reserve_log_entry(log, io);
367}
368
369static void r5l_log_stripe(struct r5l_log *log, struct stripe_head *sh,
370 int data_pages, int parity_pages)
371{
372 int i;
373 int meta_size;
374 struct r5l_io_unit *io;

--- 741 unchanged lines hidden ---
375}
376
377static void r5l_log_stripe(struct r5l_log *log, struct stripe_head *sh,
378 int data_pages, int parity_pages)
379{
380 int i;
381 int meta_size;
382 struct r5l_io_unit *io;

--- 741 unchanged lines hidden ---