Skip to content

Commit 769ba8d

Browse files
author
Boaz Harrosh
committed
ore: RAID5 Write
This is finally the RAID5 Write support. The bigger part of this patch is not the XOR engine itself, But the read4write logic, which is a complete mini prepare_for_striping reading engine that can read scattered pages of a stripe into cache so it can be used for XOR calculation. That is, if the write was not stripe aligned. The main algorithm behind the XOR engine is the 2 dimensional array: struct __stripe_pages_2d. A drawing might save 1000 words --- __stripe_pages_2d | n = pages_in_stripe_unit; w = group_width - parity; | pages array presented to the XOR lib | | V | __1_page_stripe[0].pages --> [c0][c1]..[cw][c_par] <---| | | __1_page_stripe[1].pages --> [c0][c1]..[cw][c_par] <--- | ... | ... | __1_page_stripe[n].pages --> [c0][c1]..[cw][c_par] ^ | data added columns first then row --- The pages are put on this array columns first. .i.e: p0-of-c0, p1-of-c0, ... pn-of-c0, p0-of-c1, ... So we are doing a corner turn of the pages. Note that pages will zigzag down and left. but are put sequentially in growing order. So when the time comes to XOR the stripe, only the beginning and end of the array need be checked. We scan the array and any NULL spot will be field by pages-to-be-read. The FS that wants to support RAID5 needs to supply an operations-vector that searches a given page in cache, and specifies if the page is uptodate or need reading. All these pages to be read are put on a slave ore_io_state and synchronously read. All the pages of a stripe are read in one IO, using the scatter gather mechanism. In write we constrain our IO to only be incomplete on a single stripe. Meaning either the complete IO is within a single stripe so we might have pages to read from both beginning or end of the strip. Or we have some reading to do at beginning but end at strip boundary. The left over pages are pushed to the next IO by the API already established by previous work, where an IO offset/length combination presented to the ORE might get the length truncated and the user must re-submit the leftover pages. (Both exofs and NFS support this) But any ORE user should make it's best effort to align it's IO before hand and avoid complications. A cached ore_layout->stripe_size member can be used for that calculation. (NOTE: that ORE demands that stripe_size may not be bigger then 32bit) What else? Well read it and tell me. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
1 parent a1fec1d commit 769ba8d

5 files changed

Lines changed: 587 additions & 16 deletions

File tree

‎fs/exofs/Kconfig‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
# Note ORE needs to "select ASYNC_XOR". So Not to force multiple selects
2+
# for every ORE user we do it like this. Any user should add itself here
3+
# at the "depends on EXOFS_FS || ..." with an ||. The dependencies are
4+
# selected here, and we default to "ON". So in effect it is like been
5+
# selected by any of the users.
16
config ORE
27
tristate
8+
depends on EXOFS_FS
9+
select ASYNC_XOR
10+
default SCSI_OSD_ULD
311

412
config EXOFS_FS
513
tristate "exofs: OSD based file system support"
614
depends on SCSI_OSD_ULD
7-
select ORE
815
help
916
EXOFS is a file system that uses an OSD storage device,
1017
as its backing storage.

‎fs/exofs/ore.c‎

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ int ore_verify_layout(unsigned total_comps, struct ore_layout *layout)
9595
layout->max_io_length =
9696
(BIO_MAX_PAGES_KMALLOC * PAGE_SIZE - layout->stripe_unit) *
9797
layout->group_width;
98+
if (layout->parity) {
99+
unsigned stripe_length =
100+
(layout->group_width - layout->parity) *
101+
layout->stripe_unit;
102+
103+
layout->max_io_length /= stripe_length;
104+
layout->max_io_length *= stripe_length;
105+
}
98106
return 0;
99107
}
100108
EXPORT_SYMBOL(ore_verify_layout);
@@ -118,7 +126,7 @@ static struct osd_dev *_ios_od(struct ore_io_state *ios, unsigned index)
118126
return ore_comp_dev(ios->oc, index);
119127
}
120128

121-
static int _ore_get_io_state(struct ore_layout *layout,
129+
int _ore_get_io_state(struct ore_layout *layout,
122130
struct ore_components *oc, unsigned numdevs,
123131
unsigned sgs_per_dev, unsigned num_par_pages,
124132
struct ore_io_state **pios)
@@ -334,7 +342,7 @@ static void _done_io(struct osd_request *or, void *p)
334342
kref_put(&ios->kref, _last_io);
335343
}
336344

337-
static int ore_io_execute(struct ore_io_state *ios)
345+
int ore_io_execute(struct ore_io_state *ios)
338346
{
339347
DECLARE_COMPLETION_ONSTACK(wait);
340348
bool sync = (ios->done == NULL);
@@ -597,6 +605,8 @@ int _ore_add_stripe_unit(struct ore_io_state *ios, unsigned *cur_pg,
597605
ret = -ENOMEM;
598606
goto out;
599607
}
608+
_add_stripe_page(ios->sp2d, &ios->si, pages[pg]);
609+
600610
pgbase = 0;
601611
++pg;
602612
}
@@ -636,6 +646,7 @@ static int _prepare_for_striping(struct ore_io_state *ios)
636646

637647
dev_order = _dev_order(devs_in_group, mirrors_p1, si->par_dev, dev);
638648
si->cur_comp = dev_order;
649+
si->cur_pg = si->unit_off / PAGE_SIZE;
639650

640651
while (length) {
641652
unsigned comp = dev - first_dev;
@@ -677,14 +688,14 @@ static int _prepare_for_striping(struct ore_io_state *ios)
677688
length -= cur_len;
678689

679690
si->cur_comp = (si->cur_comp + 1) % group_width;
680-
if (unlikely((dev == si->par_dev) ||
681-
(!length && ios->parity_pages))) {
682-
if (!length)
691+
if (unlikely((dev == si->par_dev) || (!length && ios->sp2d))) {
692+
if (!length && ios->sp2d) {
683693
/* If we are writing and this is the very last
684694
* stripe. then operate on parity dev.
685695
*/
686696
dev = si->par_dev;
687-
if (ios->reading)
697+
}
698+
if (ios->sp2d)
688699
/* In writes cur_len just means if it's the
689700
* last one. See _ore_add_parity_unit.
690701
*/
@@ -709,6 +720,7 @@ static int _prepare_for_striping(struct ore_io_state *ios)
709720
devs_in_group + first_dev;
710721
/* Next stripe, start fresh */
711722
si->cur_comp = 0;
723+
si->cur_pg = 0;
712724
}
713725
}
714726
out:
@@ -873,6 +885,14 @@ int ore_write(struct ore_io_state *ios)
873885
int i;
874886
int ret;
875887

888+
if (unlikely(ios->sp2d && !ios->r4w)) {
889+
/* A library is attempting a RAID-write without providing
890+
* a pages lock interface.
891+
*/
892+
WARN_ON_ONCE(1);
893+
return -ENOTSUPP;
894+
}
895+
876896
ret = _prepare_for_striping(ios);
877897
if (unlikely(ret))
878898
return ret;
@@ -888,7 +908,7 @@ int ore_write(struct ore_io_state *ios)
888908
}
889909
EXPORT_SYMBOL(ore_write);
890910

891-
static int _read_mirror(struct ore_io_state *ios, unsigned cur_comp)
911+
int _ore_read_mirror(struct ore_io_state *ios, unsigned cur_comp)
892912
{
893913
struct osd_request *or;
894914
struct ore_per_dev_state *per_dev = &ios->per_dev[cur_comp];
@@ -952,7 +972,7 @@ int ore_read(struct ore_io_state *ios)
952972
return ret;
953973

954974
for (i = 0; i < ios->numdevs; i += ios->layout->mirrors_p1) {
955-
ret = _read_mirror(ios, i);
975+
ret = _ore_read_mirror(ios, i);
956976
if (unlikely(ret))
957977
return ret;
958978
}

0 commit comments

Comments
 (0)