Skip to content

Commit e1042ba

Browse files
author
Boaz Harrosh
committed
exofs: Add offset/length to exofs_get_io_state
In future raid code we will need to know the IO offset/length and if it's a read or write to determine some of the array sizes we'll need. So add a new exofs_get_rw_state() API for use when writeing/reading. All other simple cases are left using the old way. The major change to this is that now we need to call exofs_get_io_state later at inode.c::read_exec and inode.c::write_exec when we actually know these things. So this patch is kept separate so I can test things apart from other changes. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
1 parent 16f75bb commit e1042ba

File tree

3 files changed

+38
-16
lines changed

3 files changed

+38
-16
lines changed

fs/exofs/exofs.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static inline osd_id exofs_oi_objno(struct exofs_i_info *oi)
109109
}
110110

111111
struct exofs_io_state;
112-
typedef void (*exofs_io_done_fn)(struct exofs_io_state *or, void *private);
112+
typedef void (*exofs_io_done_fn)(struct exofs_io_state *ios, void *private);
113113

114114
struct exofs_io_state {
115115
struct kref kref;
@@ -137,6 +137,8 @@ struct exofs_io_state {
137137
unsigned out_attr_len;
138138
struct osd_attr *out_attr;
139139

140+
bool reading;
141+
140142
/* Variable array of size numdevs */
141143
unsigned numdevs;
142144
struct exofs_per_dev_state {
@@ -218,6 +220,8 @@ void exofs_make_credential(u8 cred_a[OSD_CAP_LEN],
218220
int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj,
219221
u64 offset, void *p, unsigned length);
220222

223+
int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading,
224+
u64 offset, u64 length, struct exofs_io_state **ios);
221225
int exofs_get_io_state(struct exofs_layout *layout,
222226
struct exofs_io_state **ios);
223227
void exofs_put_io_state(struct exofs_io_state *ios);

fs/exofs/inode.c

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,6 @@ static int pcol_try_alloc(struct page_collect *pcol)
110110
{
111111
unsigned pages;
112112

113-
if (!pcol->ios) { /* First time allocate io_state */
114-
int ret = exofs_get_io_state(&pcol->sbi->layout, &pcol->ios);
115-
116-
if (ret)
117-
return ret;
118-
}
119-
120113
/* TODO: easily support bio chaining */
121114
pages = exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages);
122115

@@ -269,17 +262,25 @@ static void _unlock_pcol_pages(struct page_collect *pcol, int ret, int rw)
269262
static int read_exec(struct page_collect *pcol)
270263
{
271264
struct exofs_i_info *oi = exofs_i(pcol->inode);
272-
struct exofs_io_state *ios = pcol->ios;
265+
struct exofs_io_state *ios;
273266
struct page_collect *pcol_copy = NULL;
274267
int ret;
275268

276269
if (!pcol->pages)
277270
return 0;
278271

272+
if (!pcol->ios) {
273+
int ret = exofs_get_rw_state(&pcol->sbi->layout, true,
274+
pcol->pg_first << PAGE_CACHE_SHIFT,
275+
pcol->length, &pcol->ios);
276+
277+
if (ret)
278+
return ret;
279+
}
280+
281+
ios = pcol->ios;
279282
ios->pages = pcol->pages;
280283
ios->nr_pages = pcol->nr_pages;
281-
ios->length = pcol->length;
282-
ios->offset = pcol->pg_first << PAGE_CACHE_SHIFT;
283284

284285
if (pcol->read_4_write) {
285286
exofs_oi_read(oi, pcol->ios);
@@ -507,13 +508,21 @@ static void writepages_done(struct exofs_io_state *ios, void *p)
507508
static int write_exec(struct page_collect *pcol)
508509
{
509510
struct exofs_i_info *oi = exofs_i(pcol->inode);
510-
struct exofs_io_state *ios = pcol->ios;
511+
struct exofs_io_state *ios;
511512
struct page_collect *pcol_copy = NULL;
512513
int ret;
513514

514515
if (!pcol->pages)
515516
return 0;
516517

518+
BUG_ON(pcol->ios);
519+
ret = exofs_get_rw_state(&pcol->sbi->layout, false,
520+
pcol->pg_first << PAGE_CACHE_SHIFT,
521+
pcol->length, &pcol->ios);
522+
523+
if (unlikely(ret))
524+
goto err;
525+
517526
pcol_copy = kmalloc(sizeof(*pcol_copy), GFP_KERNEL);
518527
if (!pcol_copy) {
519528
EXOFS_ERR("write_exec: Failed to kmalloc(pcol)\n");
@@ -523,10 +532,9 @@ static int write_exec(struct page_collect *pcol)
523532

524533
*pcol_copy = *pcol;
525534

535+
ios = pcol->ios;
526536
ios->pages = pcol_copy->pages;
527537
ios->nr_pages = pcol_copy->nr_pages;
528-
ios->offset = pcol_copy->pg_first << PAGE_CACHE_SHIFT;
529-
ios->length = pcol_copy->length;
530538
ios->done = writepages_done;
531539
ios->private = pcol_copy;
532540

fs/exofs/ios.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj,
6969
return ret;
7070
}
7171

72-
int exofs_get_io_state(struct exofs_layout *layout,
73-
struct exofs_io_state **pios)
72+
int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading,
73+
u64 offset, u64 length, struct exofs_io_state **pios)
7474
{
7575
struct exofs_io_state *ios;
7676

@@ -87,10 +87,20 @@ int exofs_get_io_state(struct exofs_layout *layout,
8787

8888
ios->layout = layout;
8989
ios->obj.partition = layout->s_pid;
90+
ios->offset = offset;
91+
ios->length = length;
92+
ios->reading = is_reading;
93+
9094
*pios = ios;
9195
return 0;
9296
}
9397

98+
int exofs_get_io_state(struct exofs_layout *layout,
99+
struct exofs_io_state **ios)
100+
{
101+
return exofs_get_rw_state(layout, true, 0, 0, ios);
102+
}
103+
94104
void exofs_put_io_state(struct exofs_io_state *ios)
95105
{
96106
if (ios) {

0 commit comments

Comments
 (0)