diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2011-10-31 17:47:32 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-11-02 23:56:05 -0400 |
commit | 96218556b03d3c6505e2880a097338bf277fd783 (patch) | |
tree | 0e6d80437979a158af20b73b8d2cd985478e553d /fs/nfs/objlayout | |
parent | e6c40fe3f4c4967f1cb486191ed4a5d5f55f3f7e (diff) |
pnfs-obj: Get rid of objlayout_{alloc,free}_io_state
This is part of moving objio_osd to use the ORE.
objlayout_io_state had two functions:
1. It was used in the error reporting mechanism at layout_return.
This function is kept intact.
(Later patch will rename objlayout_io_state => objlayout_io_res)
2. Carrier of rw io members into the objio_read/write_paglist API.
This is removed in this patch.
The {r,w}data received from NFS are passed directly to the
objio_{read,write}_paglist API. The io_engine is now allocating
it's own IO state as part of the read/write. The minimal
functionality that was part of the generic allocation is passed
to the io_engine.
So part of this patch is rename of:
ios->ol_state.foo => ios->foo
At objlayout_{read,write}_done an objlayout_io_state is passed that
denotes the result of the IO. (Hence the later name change).
If the IO is successful objlayout calls an objio_free_result() API
immediately (Which for objio_osd causes the release of the io_state).
If the IO ended in an error it is hanged onto until reported in
layout_return and is released later through the objio_free_result()
API. (All this is not new just renamed and cleaned)
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/objlayout')
-rw-r--r-- | fs/nfs/objlayout/objio_osd.c | 94 | ||||
-rw-r--r-- | fs/nfs/objlayout/objlayout.c | 124 | ||||
-rw-r--r-- | fs/nfs/objlayout/objlayout.h | 36 |
3 files changed, 112 insertions, 142 deletions
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c index 0c7c9ec24e67..48eb91aad554 100644 --- a/fs/nfs/objlayout/objio_osd.c +++ b/fs/nfs/objlayout/objio_osd.c | |||
@@ -148,6 +148,13 @@ struct objio_state { | |||
148 | /* Generic layer */ | 148 | /* Generic layer */ |
149 | struct objlayout_io_state ol_state; | 149 | struct objlayout_io_state ol_state; |
150 | 150 | ||
151 | struct page **pages; | ||
152 | unsigned pgbase; | ||
153 | unsigned nr_pages; | ||
154 | unsigned long count; | ||
155 | loff_t offset; | ||
156 | bool sync; | ||
157 | |||
151 | struct objio_segment *layout; | 158 | struct objio_segment *layout; |
152 | 159 | ||
153 | struct kref kref; | 160 | struct kref kref; |
@@ -394,30 +401,43 @@ void objio_free_lseg(struct pnfs_layout_segment *lseg) | |||
394 | kfree(objio_seg); | 401 | kfree(objio_seg); |
395 | } | 402 | } |
396 | 403 | ||
397 | int objio_alloc_io_state(struct pnfs_layout_segment *lseg, | 404 | static int |
398 | struct objlayout_io_state **outp, | 405 | objio_alloc_io_state(struct pnfs_layout_hdr *pnfs_layout_type, |
399 | gfp_t gfp_flags) | 406 | struct pnfs_layout_segment *lseg, struct page **pages, unsigned pgbase, |
407 | loff_t offset, size_t count, void *rpcdata, gfp_t gfp_flags, | ||
408 | struct objio_state **outp) | ||
400 | { | 409 | { |
401 | struct objio_segment *objio_seg = OBJIO_LSEG(lseg); | 410 | struct objio_segment *objio_seg = OBJIO_LSEG(lseg); |
402 | struct objio_state *ios; | 411 | struct objio_state *ios; |
403 | const unsigned first_size = sizeof(*ios) + | 412 | struct __alloc_objio_state { |
404 | objio_seg->num_comps * sizeof(ios->per_dev[0]); | 413 | struct objio_state objios; |
405 | const unsigned sec_size = objio_seg->num_comps * | 414 | struct _objio_per_comp per_dev[objio_seg->num_comps]; |
406 | sizeof(ios->ol_state.ioerrs[0]); | 415 | struct pnfs_osd_ioerr ioerrs[objio_seg->num_comps]; |
407 | 416 | } *aos; | |
408 | ios = kzalloc(first_size + sec_size, gfp_flags); | 417 | |
409 | if (unlikely(!ios)) | 418 | aos = kzalloc(sizeof(*aos), gfp_flags); |
419 | if (unlikely(!aos)) | ||
410 | return -ENOMEM; | 420 | return -ENOMEM; |
411 | 421 | ||
412 | ios->layout = objio_seg; | 422 | ios = &aos->objios; |
413 | ios->ol_state.ioerrs = ((void *)ios) + first_size; | ||
414 | ios->ol_state.num_comps = objio_seg->num_comps; | ||
415 | 423 | ||
416 | *outp = &ios->ol_state; | 424 | ios->layout = objio_seg; |
425 | objlayout_init_ioerrs(&aos->objios.ol_state, objio_seg->num_comps, | ||
426 | aos->ioerrs, rpcdata, pnfs_layout_type); | ||
427 | |||
428 | ios->pages = pages; | ||
429 | ios->pgbase = pgbase; | ||
430 | ios->nr_pages = (pgbase + count + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
431 | ios->offset = offset; | ||
432 | ios->count = count; | ||
433 | ios->sync = 0; | ||
434 | BUG_ON(ios->nr_pages > (pgbase + count + PAGE_SIZE - 1) >> PAGE_SHIFT); | ||
435 | |||
436 | *outp = ios; | ||
417 | return 0; | 437 | return 0; |
418 | } | 438 | } |
419 | 439 | ||
420 | void objio_free_io_state(struct objlayout_io_state *ol_state) | 440 | void objio_free_result(struct objlayout_io_state *ol_state) |
421 | { | 441 | { |
422 | struct objio_state *ios = container_of(ol_state, struct objio_state, | 442 | struct objio_state *ios = container_of(ol_state, struct objio_state, |
423 | ol_state); | 443 | ol_state); |
@@ -598,7 +618,7 @@ static int _add_stripe_unit(struct objio_state *ios, unsigned *cur_pg, | |||
598 | if (per_dev->bio == NULL) { | 618 | if (per_dev->bio == NULL) { |
599 | unsigned pages_in_stripe = ios->layout->group_width * | 619 | unsigned pages_in_stripe = ios->layout->group_width * |
600 | (ios->layout->stripe_unit / PAGE_SIZE); | 620 | (ios->layout->stripe_unit / PAGE_SIZE); |
601 | unsigned bio_size = (ios->ol_state.nr_pages + pages_in_stripe) / | 621 | unsigned bio_size = (ios->nr_pages + pages_in_stripe) / |
602 | ios->layout->group_width; | 622 | ios->layout->group_width; |
603 | 623 | ||
604 | if (BIO_MAX_PAGES_KMALLOC < bio_size) | 624 | if (BIO_MAX_PAGES_KMALLOC < bio_size) |
@@ -615,11 +635,11 @@ static int _add_stripe_unit(struct objio_state *ios, unsigned *cur_pg, | |||
615 | unsigned pglen = min_t(unsigned, PAGE_SIZE - pgbase, cur_len); | 635 | unsigned pglen = min_t(unsigned, PAGE_SIZE - pgbase, cur_len); |
616 | unsigned added_len; | 636 | unsigned added_len; |
617 | 637 | ||
618 | BUG_ON(ios->ol_state.nr_pages <= pg); | 638 | BUG_ON(ios->nr_pages <= pg); |
619 | cur_len -= pglen; | 639 | cur_len -= pglen; |
620 | 640 | ||
621 | added_len = bio_add_pc_page(q, per_dev->bio, | 641 | added_len = bio_add_pc_page(q, per_dev->bio, |
622 | ios->ol_state.pages[pg], pglen, pgbase); | 642 | ios->pages[pg], pglen, pgbase); |
623 | if (unlikely(pglen != added_len)) | 643 | if (unlikely(pglen != added_len)) |
624 | return -ENOMEM; | 644 | return -ENOMEM; |
625 | pgbase = 0; | 645 | pgbase = 0; |
@@ -660,7 +680,7 @@ static int _prepare_one_group(struct objio_state *ios, u64 length, | |||
660 | cur_len = stripe_unit - si->unit_off; | 680 | cur_len = stripe_unit - si->unit_off; |
661 | page_off = si->unit_off & ~PAGE_MASK; | 681 | page_off = si->unit_off & ~PAGE_MASK; |
662 | BUG_ON(page_off && | 682 | BUG_ON(page_off && |
663 | (page_off != ios->ol_state.pgbase)); | 683 | (page_off != ios->pgbase)); |
664 | } else { /* dev > si->dev */ | 684 | } else { /* dev > si->dev */ |
665 | per_dev->offset = si->obj_offset - si->unit_off; | 685 | per_dev->offset = si->obj_offset - si->unit_off; |
666 | cur_len = stripe_unit; | 686 | cur_len = stripe_unit; |
@@ -693,8 +713,8 @@ out: | |||
693 | 713 | ||
694 | static int _io_rw_pagelist(struct objio_state *ios, gfp_t gfp_flags) | 714 | static int _io_rw_pagelist(struct objio_state *ios, gfp_t gfp_flags) |
695 | { | 715 | { |
696 | u64 length = ios->ol_state.count; | 716 | u64 length = ios->count; |
697 | u64 offset = ios->ol_state.offset; | 717 | u64 offset = ios->offset; |
698 | struct _striping_info si; | 718 | struct _striping_info si; |
699 | unsigned last_pg = 0; | 719 | unsigned last_pg = 0; |
700 | int ret = 0; | 720 | int ret = 0; |
@@ -748,7 +768,7 @@ static int _io_exec(struct objio_state *ios) | |||
748 | int ret = 0; | 768 | int ret = 0; |
749 | unsigned i; | 769 | unsigned i; |
750 | objio_done_fn saved_done_fn = ios->done; | 770 | objio_done_fn saved_done_fn = ios->done; |
751 | bool sync = ios->ol_state.sync; | 771 | bool sync = ios->sync; |
752 | 772 | ||
753 | if (sync) { | 773 | if (sync) { |
754 | ios->done = _sync_done; | 774 | ios->done = _sync_done; |
@@ -792,7 +812,7 @@ static int _read_done(struct objio_state *ios) | |||
792 | else | 812 | else |
793 | status = ret; | 813 | status = ret; |
794 | 814 | ||
795 | objlayout_read_done(&ios->ol_state, status, ios->ol_state.sync); | 815 | objlayout_read_done(&ios->ol_state, status, ios->sync); |
796 | return ret; | 816 | return ret; |
797 | } | 817 | } |
798 | 818 | ||
@@ -854,12 +874,18 @@ err: | |||
854 | return ret; | 874 | return ret; |
855 | } | 875 | } |
856 | 876 | ||
857 | int objio_read_pagelist(struct objlayout_io_state *ol_state) | 877 | int objio_read_pagelist(struct nfs_read_data *rdata) |
858 | { | 878 | { |
859 | struct objio_state *ios = container_of(ol_state, struct objio_state, | 879 | struct objio_state *ios; |
860 | ol_state); | ||
861 | int ret; | 880 | int ret; |
862 | 881 | ||
882 | ret = objio_alloc_io_state(NFS_I(rdata->inode)->layout, | ||
883 | rdata->lseg, rdata->args.pages, rdata->args.pgbase, | ||
884 | rdata->args.offset, rdata->args.count, rdata, | ||
885 | GFP_KERNEL, &ios); | ||
886 | if (unlikely(ret)) | ||
887 | return ret; | ||
888 | |||
863 | ret = _io_rw_pagelist(ios, GFP_KERNEL); | 889 | ret = _io_rw_pagelist(ios, GFP_KERNEL); |
864 | if (unlikely(ret)) | 890 | if (unlikely(ret)) |
865 | return ret; | 891 | return ret; |
@@ -886,7 +912,7 @@ static int _write_done(struct objio_state *ios) | |||
886 | status = ret; | 912 | status = ret; |
887 | } | 913 | } |
888 | 914 | ||
889 | objlayout_write_done(&ios->ol_state, status, ios->ol_state.sync); | 915 | objlayout_write_done(&ios->ol_state, status, ios->sync); |
890 | return ret; | 916 | return ret; |
891 | } | 917 | } |
892 | 918 | ||
@@ -976,12 +1002,20 @@ err: | |||
976 | return ret; | 1002 | return ret; |
977 | } | 1003 | } |
978 | 1004 | ||
979 | int objio_write_pagelist(struct objlayout_io_state *ol_state, bool stable) | 1005 | int objio_write_pagelist(struct nfs_write_data *wdata, int how) |
980 | { | 1006 | { |
981 | struct objio_state *ios = container_of(ol_state, struct objio_state, | 1007 | struct objio_state *ios; |
982 | ol_state); | ||
983 | int ret; | 1008 | int ret; |
984 | 1009 | ||
1010 | ret = objio_alloc_io_state(NFS_I(wdata->inode)->layout, | ||
1011 | wdata->lseg, wdata->args.pages, wdata->args.pgbase, | ||
1012 | wdata->args.offset, wdata->args.count, wdata, GFP_NOFS, | ||
1013 | &ios); | ||
1014 | if (unlikely(ret)) | ||
1015 | return ret; | ||
1016 | |||
1017 | ios->sync = 0 != (how & FLUSH_SYNC); | ||
1018 | |||
985 | /* TODO: ios->stable = stable; */ | 1019 | /* TODO: ios->stable = stable; */ |
986 | ret = _io_rw_pagelist(ios, GFP_NOFS); | 1020 | ret = _io_rw_pagelist(ios, GFP_NOFS); |
987 | if (unlikely(ret)) | 1021 | if (unlikely(ret)) |
diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c index 99c807df11dc..a82053ae5595 100644 --- a/fs/nfs/objlayout/objlayout.c +++ b/fs/nfs/objlayout/objlayout.c | |||
@@ -156,59 +156,23 @@ last_byte_offset(u64 start, u64 len) | |||
156 | return end > start ? end - 1 : NFS4_MAX_UINT64; | 156 | return end > start ? end - 1 : NFS4_MAX_UINT64; |
157 | } | 157 | } |
158 | 158 | ||
159 | static struct objlayout_io_state * | 159 | void _fix_verify_io_params(struct pnfs_layout_segment *lseg, |
160 | objlayout_alloc_io_state(struct pnfs_layout_hdr *pnfs_layout_type, | 160 | struct page ***p_pages, unsigned *p_pgbase, |
161 | struct page **pages, | 161 | u64 offset, unsigned long count) |
162 | unsigned pgbase, | ||
163 | loff_t offset, | ||
164 | size_t count, | ||
165 | struct pnfs_layout_segment *lseg, | ||
166 | void *rpcdata, | ||
167 | gfp_t gfp_flags) | ||
168 | { | 162 | { |
169 | struct objlayout_io_state *state; | ||
170 | u64 lseg_end_offset; | 163 | u64 lseg_end_offset; |
171 | 164 | ||
172 | dprintk("%s: allocating io_state\n", __func__); | ||
173 | if (objio_alloc_io_state(lseg, &state, gfp_flags)) | ||
174 | return NULL; | ||
175 | |||
176 | BUG_ON(offset < lseg->pls_range.offset); | 165 | BUG_ON(offset < lseg->pls_range.offset); |
177 | lseg_end_offset = end_offset(lseg->pls_range.offset, | 166 | lseg_end_offset = end_offset(lseg->pls_range.offset, |
178 | lseg->pls_range.length); | 167 | lseg->pls_range.length); |
179 | BUG_ON(offset >= lseg_end_offset); | 168 | BUG_ON(offset >= lseg_end_offset); |
180 | if (offset + count > lseg_end_offset) { | 169 | WARN_ON(offset + count > lseg_end_offset); |
181 | count = lseg->pls_range.length - | ||
182 | (offset - lseg->pls_range.offset); | ||
183 | dprintk("%s: truncated count %Zd\n", __func__, count); | ||
184 | } | ||
185 | 170 | ||
186 | if (pgbase > PAGE_SIZE) { | 171 | if (*p_pgbase > PAGE_SIZE) { |
187 | pages += pgbase >> PAGE_SHIFT; | 172 | dprintk("%s: pgbase(0x%x) > PAGE_SIZE\n", __func__, *p_pgbase); |
188 | pgbase &= ~PAGE_MASK; | 173 | *p_pages += *p_pgbase >> PAGE_SHIFT; |
174 | *p_pgbase &= ~PAGE_MASK; | ||
189 | } | 175 | } |
190 | |||
191 | INIT_LIST_HEAD(&state->err_list); | ||
192 | state->lseg = lseg; | ||
193 | state->rpcdata = rpcdata; | ||
194 | state->pages = pages; | ||
195 | state->pgbase = pgbase; | ||
196 | state->nr_pages = (pgbase + count + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
197 | state->offset = offset; | ||
198 | state->count = count; | ||
199 | state->sync = 0; | ||
200 | |||
201 | return state; | ||
202 | } | ||
203 | |||
204 | static void | ||
205 | objlayout_free_io_state(struct objlayout_io_state *state) | ||
206 | { | ||
207 | dprintk("%s: freeing io_state\n", __func__); | ||
208 | if (unlikely(!state)) | ||
209 | return; | ||
210 | |||
211 | objio_free_io_state(state); | ||
212 | } | 176 | } |
213 | 177 | ||
214 | /* | 178 | /* |
@@ -217,12 +181,10 @@ objlayout_free_io_state(struct objlayout_io_state *state) | |||
217 | static void | 181 | static void |
218 | objlayout_iodone(struct objlayout_io_state *state) | 182 | objlayout_iodone(struct objlayout_io_state *state) |
219 | { | 183 | { |
220 | dprintk("%s: state %p status\n", __func__, state); | ||
221 | |||
222 | if (likely(state->status >= 0)) { | 184 | if (likely(state->status >= 0)) { |
223 | objlayout_free_io_state(state); | 185 | objio_free_result(state); |
224 | } else { | 186 | } else { |
225 | struct objlayout *objlay = OBJLAYOUT(state->lseg->pls_layout); | 187 | struct objlayout *objlay = state->objlay; |
226 | 188 | ||
227 | spin_lock(&objlay->lock); | 189 | spin_lock(&objlay->lock); |
228 | objlay->delta_space_valid = OBJ_DSU_INVALID; | 190 | objlay->delta_space_valid = OBJ_DSU_INVALID; |
@@ -289,15 +251,15 @@ objlayout_read_done(struct objlayout_io_state *state, ssize_t status, bool sync) | |||
289 | { | 251 | { |
290 | struct nfs_read_data *rdata = state->rpcdata; | 252 | struct nfs_read_data *rdata = state->rpcdata; |
291 | 253 | ||
292 | state->status = status; | 254 | state->status = rdata->task.tk_status = status; |
293 | dprintk("%s: Begin status=%zd eof=%d\n", __func__, | ||
294 | status, rdata->res.eof); | ||
295 | rdata->task.tk_status = status; | ||
296 | if (status >= 0) | 255 | if (status >= 0) |
297 | rdata->res.count = status; | 256 | rdata->res.count = status; |
298 | objlayout_iodone(state); | 257 | objlayout_iodone(state); |
299 | /* must not use state after this point */ | 258 | /* must not use state after this point */ |
300 | 259 | ||
260 | dprintk("%s: Return status=%zd eof=%d sync=%d\n", __func__, | ||
261 | status, rdata->res.eof, sync); | ||
262 | |||
301 | if (sync) | 263 | if (sync) |
302 | pnfs_ld_read_done(rdata); | 264 | pnfs_ld_read_done(rdata); |
303 | else { | 265 | else { |
@@ -314,7 +276,6 @@ objlayout_read_pagelist(struct nfs_read_data *rdata) | |||
314 | { | 276 | { |
315 | loff_t offset = rdata->args.offset; | 277 | loff_t offset = rdata->args.offset; |
316 | size_t count = rdata->args.count; | 278 | size_t count = rdata->args.count; |
317 | struct objlayout_io_state *state; | ||
318 | int err; | 279 | int err; |
319 | loff_t eof; | 280 | loff_t eof; |
320 | 281 | ||
@@ -331,20 +292,14 @@ objlayout_read_pagelist(struct nfs_read_data *rdata) | |||
331 | } | 292 | } |
332 | 293 | ||
333 | rdata->res.eof = (offset + count) >= eof; | 294 | rdata->res.eof = (offset + count) >= eof; |
295 | _fix_verify_io_params(rdata->lseg, &rdata->args.pages, | ||
296 | &rdata->args.pgbase, | ||
297 | rdata->args.offset, rdata->args.count); | ||
334 | 298 | ||
335 | state = objlayout_alloc_io_state(NFS_I(rdata->inode)->layout, | ||
336 | rdata->args.pages, rdata->args.pgbase, | ||
337 | offset, count, | ||
338 | rdata->lseg, rdata, | ||
339 | GFP_KERNEL); | ||
340 | if (unlikely(!state)) { | ||
341 | err = -ENOMEM; | ||
342 | goto out; | ||
343 | } | ||
344 | dprintk("%s: inode(%lx) offset 0x%llx count 0x%Zx eof=%d\n", | 299 | dprintk("%s: inode(%lx) offset 0x%llx count 0x%Zx eof=%d\n", |
345 | __func__, rdata->inode->i_ino, offset, count, rdata->res.eof); | 300 | __func__, rdata->inode->i_ino, offset, count, rdata->res.eof); |
346 | 301 | ||
347 | err = objio_read_pagelist(state); | 302 | err = objio_read_pagelist(rdata); |
348 | out: | 303 | out: |
349 | if (unlikely(err)) { | 304 | if (unlikely(err)) { |
350 | rdata->pnfs_error = err; | 305 | rdata->pnfs_error = err; |
@@ -374,23 +329,18 @@ void | |||
374 | objlayout_write_done(struct objlayout_io_state *state, ssize_t status, | 329 | objlayout_write_done(struct objlayout_io_state *state, ssize_t status, |
375 | bool sync) | 330 | bool sync) |
376 | { | 331 | { |
377 | struct nfs_write_data *wdata; | 332 | struct nfs_write_data *wdata = state->rpcdata; |
378 | 333 | ||
379 | dprintk("%s: Begin\n", __func__); | 334 | state->status = wdata->task.tk_status = status; |
380 | wdata = state->rpcdata; | ||
381 | state->status = status; | ||
382 | wdata->task.tk_status = status; | ||
383 | if (status >= 0) { | 335 | if (status >= 0) { |
384 | wdata->res.count = status; | 336 | wdata->res.count = status; |
385 | wdata->verf.committed = state->committed; | 337 | wdata->verf.committed = state->committed; |
386 | dprintk("%s: Return status %d committed %d\n", | 338 | } |
387 | __func__, wdata->task.tk_status, | ||
388 | wdata->verf.committed); | ||
389 | } else | ||
390 | dprintk("%s: Return status %d\n", | ||
391 | __func__, wdata->task.tk_status); | ||
392 | objlayout_iodone(state); | 339 | objlayout_iodone(state); |
393 | /* must not use state after this point */ | 340 | /* must not use oir after this point */ |
341 | |||
342 | dprintk("%s: Return status %zd committed %d sync=%d\n", __func__, | ||
343 | status, wdata->verf.committed, sync); | ||
394 | 344 | ||
395 | if (sync) | 345 | if (sync) |
396 | pnfs_ld_write_done(wdata); | 346 | pnfs_ld_write_done(wdata); |
@@ -407,25 +357,13 @@ enum pnfs_try_status | |||
407 | objlayout_write_pagelist(struct nfs_write_data *wdata, | 357 | objlayout_write_pagelist(struct nfs_write_data *wdata, |
408 | int how) | 358 | int how) |
409 | { | 359 | { |
410 | struct objlayout_io_state *state; | ||
411 | int err; | 360 | int err; |
412 | 361 | ||
413 | state = objlayout_alloc_io_state(NFS_I(wdata->inode)->layout, | 362 | _fix_verify_io_params(wdata->lseg, &wdata->args.pages, |
414 | wdata->args.pages, | 363 | &wdata->args.pgbase, |
415 | wdata->args.pgbase, | 364 | wdata->args.offset, wdata->args.count); |
416 | wdata->args.offset, | ||
417 | wdata->args.count, | ||
418 | wdata->lseg, wdata, | ||
419 | GFP_NOFS); | ||
420 | if (unlikely(!state)) { | ||
421 | err = -ENOMEM; | ||
422 | goto out; | ||
423 | } | ||
424 | 365 | ||
425 | state->sync = how & FLUSH_SYNC; | 366 | err = objio_write_pagelist(wdata, how); |
426 | |||
427 | err = objio_write_pagelist(state, how & FLUSH_STABLE); | ||
428 | out: | ||
429 | if (unlikely(err)) { | 367 | if (unlikely(err)) { |
430 | wdata->pnfs_error = err; | 368 | wdata->pnfs_error = err; |
431 | dprintk("%s: Returned Error %d\n", __func__, err); | 369 | dprintk("%s: Returned Error %d\n", __func__, err); |
@@ -564,7 +502,7 @@ encode_accumulated_error(struct objlayout *objlay, __be32 *p) | |||
564 | merge_ioerr(&accumulated_err, ioerr); | 502 | merge_ioerr(&accumulated_err, ioerr); |
565 | } | 503 | } |
566 | list_del(&state->err_list); | 504 | list_del(&state->err_list); |
567 | objlayout_free_io_state(state); | 505 | objio_free_result(state); |
568 | } | 506 | } |
569 | 507 | ||
570 | pnfs_osd_xdr_encode_ioerr(p, &accumulated_err); | 508 | pnfs_osd_xdr_encode_ioerr(p, &accumulated_err); |
@@ -632,7 +570,7 @@ objlayout_encode_layoutreturn(struct pnfs_layout_hdr *pnfslay, | |||
632 | goto loop_done; | 570 | goto loop_done; |
633 | } | 571 | } |
634 | list_del(&state->err_list); | 572 | list_del(&state->err_list); |
635 | objlayout_free_io_state(state); | 573 | objio_free_result(state); |
636 | } | 574 | } |
637 | loop_done: | 575 | loop_done: |
638 | spin_unlock(&objlay->lock); | 576 | spin_unlock(&objlay->lock); |
diff --git a/fs/nfs/objlayout/objlayout.h b/fs/nfs/objlayout/objlayout.h index 4edac9b6ac0c..d7b2ccfa2132 100644 --- a/fs/nfs/objlayout/objlayout.h +++ b/fs/nfs/objlayout/objlayout.h | |||
@@ -75,14 +75,7 @@ OBJLAYOUT(struct pnfs_layout_hdr *lo) | |||
75 | * embedded in objects provider io_state data structure | 75 | * embedded in objects provider io_state data structure |
76 | */ | 76 | */ |
77 | struct objlayout_io_state { | 77 | struct objlayout_io_state { |
78 | struct pnfs_layout_segment *lseg; | 78 | struct objlayout *objlay; |
79 | |||
80 | struct page **pages; | ||
81 | unsigned pgbase; | ||
82 | unsigned nr_pages; | ||
83 | unsigned long count; | ||
84 | loff_t offset; | ||
85 | bool sync; | ||
86 | 79 | ||
87 | void *rpcdata; | 80 | void *rpcdata; |
88 | int status; /* res */ | 81 | int status; /* res */ |
@@ -99,6 +92,18 @@ struct objlayout_io_state { | |||
99 | struct pnfs_osd_ioerr *ioerrs; | 92 | struct pnfs_osd_ioerr *ioerrs; |
100 | }; | 93 | }; |
101 | 94 | ||
95 | static inline | ||
96 | void objlayout_init_ioerrs(struct objlayout_io_state *oir, unsigned num_comps, | ||
97 | struct pnfs_osd_ioerr *ioerrs, void *rpcdata, | ||
98 | struct pnfs_layout_hdr *pnfs_layout_type) | ||
99 | { | ||
100 | oir->objlay = OBJLAYOUT(pnfs_layout_type); | ||
101 | oir->rpcdata = rpcdata; | ||
102 | INIT_LIST_HEAD(&oir->err_list); | ||
103 | oir->num_comps = num_comps; | ||
104 | oir->ioerrs = ioerrs; | ||
105 | } | ||
106 | |||
102 | /* | 107 | /* |
103 | * Raid engine I/O API | 108 | * Raid engine I/O API |
104 | */ | 109 | */ |
@@ -109,15 +114,10 @@ extern int objio_alloc_lseg(struct pnfs_layout_segment **outp, | |||
109 | gfp_t gfp_flags); | 114 | gfp_t gfp_flags); |
110 | extern void objio_free_lseg(struct pnfs_layout_segment *lseg); | 115 | extern void objio_free_lseg(struct pnfs_layout_segment *lseg); |
111 | 116 | ||
112 | extern int objio_alloc_io_state( | 117 | extern void objio_free_result(struct objlayout_io_state *state); |
113 | struct pnfs_layout_segment *lseg, | ||
114 | struct objlayout_io_state **outp, | ||
115 | gfp_t gfp_flags); | ||
116 | extern void objio_free_io_state(struct objlayout_io_state *state); | ||
117 | 118 | ||
118 | extern int objio_read_pagelist(struct objlayout_io_state *ol_state); | 119 | extern int objio_read_pagelist(struct nfs_read_data *rdata); |
119 | extern int objio_write_pagelist(struct objlayout_io_state *ol_state, | 120 | extern int objio_write_pagelist(struct nfs_write_data *wdata, int how); |
120 | bool stable); | ||
121 | 121 | ||
122 | /* | 122 | /* |
123 | * callback API | 123 | * callback API |
@@ -127,10 +127,8 @@ extern void objlayout_io_set_result(struct objlayout_io_state *state, | |||
127 | int osd_error, u64 offset, u64 length, bool is_write); | 127 | int osd_error, u64 offset, u64 length, bool is_write); |
128 | 128 | ||
129 | static inline void | 129 | static inline void |
130 | objlayout_add_delta_space_used(struct objlayout_io_state *state, s64 space_used) | 130 | objlayout_add_delta_space_used(struct objlayout *objlay, s64 space_used) |
131 | { | 131 | { |
132 | struct objlayout *objlay = OBJLAYOUT(state->lseg->pls_layout); | ||
133 | |||
134 | /* If one of the I/Os errored out and the delta_space_used was | 132 | /* If one of the I/Os errored out and the delta_space_used was |
135 | * invalid we render the complete report as invalid. Protocol mandate | 133 | * invalid we render the complete report as invalid. Protocol mandate |
136 | * the DSU be accurate or not reported. | 134 | * the DSU be accurate or not reported. |