diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2011-10-31 17:45:46 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-11-02 23:56:03 -0400 |
commit | e6c40fe3f4c4967f1cb486191ed4a5d5f55f3f7e (patch) | |
tree | a7747effb21709bfbb0b3ded2e85253f37e7711e /fs/nfs | |
parent | 4cdc685c7d06f659ef6c336d4242005cdd8df401 (diff) |
pnfs-obj: Return PNFS_NOT_ATTEMPTED in case of read/write_pagelist
objlayout driver was always returning PNFS_ATTEMPTED from it's
read/write_pagelist operations. Even on error. Fix that.
Start by establishing an error return API from io-engine, by
not returning ssize_t (length-or-error) but returning "int"
0=OK, 0>Error. And clean up all return types in io-engine.
Then if io-engine returned error return PNFS_NOT_ATTEMPTED
to generic layer. (With a dprint)
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/objlayout/objio_osd.c | 32 | ||||
-rw-r--r-- | fs/nfs/objlayout/objlayout.c | 36 | ||||
-rw-r--r-- | fs/nfs/objlayout/objlayout.h | 4 |
3 files changed, 37 insertions, 35 deletions
diff --git a/fs/nfs/objlayout/objio_osd.c b/fs/nfs/objlayout/objio_osd.c index d0cda12fddc3..0c7c9ec24e67 100644 --- a/fs/nfs/objlayout/objio_osd.c +++ b/fs/nfs/objlayout/objio_osd.c | |||
@@ -142,7 +142,7 @@ OBJIO_LSEG(struct pnfs_layout_segment *lseg) | |||
142 | } | 142 | } |
143 | 143 | ||
144 | struct objio_state; | 144 | struct objio_state; |
145 | typedef ssize_t (*objio_done_fn)(struct objio_state *ios); | 145 | typedef int (*objio_done_fn)(struct objio_state *ios); |
146 | 146 | ||
147 | struct objio_state { | 147 | struct objio_state { |
148 | /* Generic layer */ | 148 | /* Generic layer */ |
@@ -720,7 +720,7 @@ out: | |||
720 | return 0; | 720 | return 0; |
721 | } | 721 | } |
722 | 722 | ||
723 | static ssize_t _sync_done(struct objio_state *ios) | 723 | static int _sync_done(struct objio_state *ios) |
724 | { | 724 | { |
725 | struct completion *waiting = ios->private; | 725 | struct completion *waiting = ios->private; |
726 | 726 | ||
@@ -742,10 +742,10 @@ static void _done_io(struct osd_request *or, void *p) | |||
742 | kref_put(&ios->kref, _last_io); | 742 | kref_put(&ios->kref, _last_io); |
743 | } | 743 | } |
744 | 744 | ||
745 | static ssize_t _io_exec(struct objio_state *ios) | 745 | static int _io_exec(struct objio_state *ios) |
746 | { | 746 | { |
747 | DECLARE_COMPLETION_ONSTACK(wait); | 747 | DECLARE_COMPLETION_ONSTACK(wait); |
748 | ssize_t status = 0; /* sync status */ | 748 | int ret = 0; |
749 | unsigned i; | 749 | unsigned i; |
750 | objio_done_fn saved_done_fn = ios->done; | 750 | objio_done_fn saved_done_fn = ios->done; |
751 | bool sync = ios->ol_state.sync; | 751 | bool sync = ios->ol_state.sync; |
@@ -771,16 +771,16 @@ static ssize_t _io_exec(struct objio_state *ios) | |||
771 | 771 | ||
772 | if (sync) { | 772 | if (sync) { |
773 | wait_for_completion(&wait); | 773 | wait_for_completion(&wait); |
774 | status = saved_done_fn(ios); | 774 | ret = saved_done_fn(ios); |
775 | } | 775 | } |
776 | 776 | ||
777 | return status; | 777 | return ret; |
778 | } | 778 | } |
779 | 779 | ||
780 | /* | 780 | /* |
781 | * read | 781 | * read |
782 | */ | 782 | */ |
783 | static ssize_t _read_done(struct objio_state *ios) | 783 | static int _read_done(struct objio_state *ios) |
784 | { | 784 | { |
785 | ssize_t status; | 785 | ssize_t status; |
786 | int ret = _io_check(ios, false); | 786 | int ret = _io_check(ios, false); |
@@ -793,7 +793,7 @@ static ssize_t _read_done(struct objio_state *ios) | |||
793 | status = ret; | 793 | status = ret; |
794 | 794 | ||
795 | objlayout_read_done(&ios->ol_state, status, ios->ol_state.sync); | 795 | objlayout_read_done(&ios->ol_state, status, ios->ol_state.sync); |
796 | return status; | 796 | return ret; |
797 | } | 797 | } |
798 | 798 | ||
799 | static int _read_mirrors(struct objio_state *ios, unsigned cur_comp) | 799 | static int _read_mirrors(struct objio_state *ios, unsigned cur_comp) |
@@ -833,7 +833,7 @@ err: | |||
833 | return ret; | 833 | return ret; |
834 | } | 834 | } |
835 | 835 | ||
836 | static ssize_t _read_exec(struct objio_state *ios) | 836 | static int _read_exec(struct objio_state *ios) |
837 | { | 837 | { |
838 | unsigned i; | 838 | unsigned i; |
839 | int ret; | 839 | int ret; |
@@ -847,14 +847,14 @@ static ssize_t _read_exec(struct objio_state *ios) | |||
847 | } | 847 | } |
848 | 848 | ||
849 | ios->done = _read_done; | 849 | ios->done = _read_done; |
850 | return _io_exec(ios); /* In sync mode exec returns the io status */ | 850 | return _io_exec(ios); |
851 | 851 | ||
852 | err: | 852 | err: |
853 | _io_free(ios); | 853 | _io_free(ios); |
854 | return ret; | 854 | return ret; |
855 | } | 855 | } |
856 | 856 | ||
857 | ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state) | 857 | int objio_read_pagelist(struct objlayout_io_state *ol_state) |
858 | { | 858 | { |
859 | struct objio_state *ios = container_of(ol_state, struct objio_state, | 859 | struct objio_state *ios = container_of(ol_state, struct objio_state, |
860 | ol_state); | 860 | ol_state); |
@@ -870,7 +870,7 @@ ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state) | |||
870 | /* | 870 | /* |
871 | * write | 871 | * write |
872 | */ | 872 | */ |
873 | static ssize_t _write_done(struct objio_state *ios) | 873 | static int _write_done(struct objio_state *ios) |
874 | { | 874 | { |
875 | ssize_t status; | 875 | ssize_t status; |
876 | int ret = _io_check(ios, true); | 876 | int ret = _io_check(ios, true); |
@@ -887,7 +887,7 @@ static ssize_t _write_done(struct objio_state *ios) | |||
887 | } | 887 | } |
888 | 888 | ||
889 | objlayout_write_done(&ios->ol_state, status, ios->ol_state.sync); | 889 | objlayout_write_done(&ios->ol_state, status, ios->ol_state.sync); |
890 | return status; | 890 | return ret; |
891 | } | 891 | } |
892 | 892 | ||
893 | static int _write_mirrors(struct objio_state *ios, unsigned cur_comp) | 893 | static int _write_mirrors(struct objio_state *ios, unsigned cur_comp) |
@@ -955,7 +955,7 @@ err: | |||
955 | return ret; | 955 | return ret; |
956 | } | 956 | } |
957 | 957 | ||
958 | static ssize_t _write_exec(struct objio_state *ios) | 958 | static int _write_exec(struct objio_state *ios) |
959 | { | 959 | { |
960 | unsigned i; | 960 | unsigned i; |
961 | int ret; | 961 | int ret; |
@@ -969,14 +969,14 @@ static ssize_t _write_exec(struct objio_state *ios) | |||
969 | } | 969 | } |
970 | 970 | ||
971 | ios->done = _write_done; | 971 | ios->done = _write_done; |
972 | return _io_exec(ios); /* In sync mode exec returns the io->status */ | 972 | return _io_exec(ios); |
973 | 973 | ||
974 | err: | 974 | err: |
975 | _io_free(ios); | 975 | _io_free(ios); |
976 | return ret; | 976 | return ret; |
977 | } | 977 | } |
978 | 978 | ||
979 | ssize_t objio_write_pagelist(struct objlayout_io_state *ol_state, bool stable) | 979 | int objio_write_pagelist(struct objlayout_io_state *ol_state, bool stable) |
980 | { | 980 | { |
981 | struct objio_state *ios = container_of(ol_state, struct objio_state, | 981 | struct objio_state *ios = container_of(ol_state, struct objio_state, |
982 | ol_state); | 982 | ol_state); |
diff --git a/fs/nfs/objlayout/objlayout.c b/fs/nfs/objlayout/objlayout.c index 1300736e0fb4..99c807df11dc 100644 --- a/fs/nfs/objlayout/objlayout.c +++ b/fs/nfs/objlayout/objlayout.c | |||
@@ -315,16 +315,13 @@ objlayout_read_pagelist(struct nfs_read_data *rdata) | |||
315 | loff_t offset = rdata->args.offset; | 315 | loff_t offset = rdata->args.offset; |
316 | size_t count = rdata->args.count; | 316 | size_t count = rdata->args.count; |
317 | struct objlayout_io_state *state; | 317 | struct objlayout_io_state *state; |
318 | ssize_t status = 0; | 318 | int err; |
319 | loff_t eof; | 319 | loff_t eof; |
320 | 320 | ||
321 | dprintk("%s: Begin inode %p offset %llu count %d\n", | ||
322 | __func__, rdata->inode, offset, (int)count); | ||
323 | |||
324 | eof = i_size_read(rdata->inode); | 321 | eof = i_size_read(rdata->inode); |
325 | if (unlikely(offset + count > eof)) { | 322 | if (unlikely(offset + count > eof)) { |
326 | if (offset >= eof) { | 323 | if (offset >= eof) { |
327 | status = 0; | 324 | err = 0; |
328 | rdata->res.count = 0; | 325 | rdata->res.count = 0; |
329 | rdata->res.eof = 1; | 326 | rdata->res.eof = 1; |
330 | /*FIXME: do we need to call pnfs_ld_read_done() */ | 327 | /*FIXME: do we need to call pnfs_ld_read_done() */ |
@@ -341,14 +338,19 @@ objlayout_read_pagelist(struct nfs_read_data *rdata) | |||
341 | rdata->lseg, rdata, | 338 | rdata->lseg, rdata, |
342 | GFP_KERNEL); | 339 | GFP_KERNEL); |
343 | if (unlikely(!state)) { | 340 | if (unlikely(!state)) { |
344 | status = -ENOMEM; | 341 | err = -ENOMEM; |
345 | goto out; | 342 | goto out; |
346 | } | 343 | } |
344 | dprintk("%s: inode(%lx) offset 0x%llx count 0x%Zx eof=%d\n", | ||
345 | __func__, rdata->inode->i_ino, offset, count, rdata->res.eof); | ||
347 | 346 | ||
348 | status = objio_read_pagelist(state); | 347 | err = objio_read_pagelist(state); |
349 | out: | 348 | out: |
350 | dprintk("%s: Return status %Zd\n", __func__, status); | 349 | if (unlikely(err)) { |
351 | rdata->pnfs_error = status; | 350 | rdata->pnfs_error = err; |
351 | dprintk("%s: Returned Error %d\n", __func__, err); | ||
352 | return PNFS_NOT_ATTEMPTED; | ||
353 | } | ||
352 | return PNFS_ATTEMPTED; | 354 | return PNFS_ATTEMPTED; |
353 | } | 355 | } |
354 | 356 | ||
@@ -406,10 +408,7 @@ objlayout_write_pagelist(struct nfs_write_data *wdata, | |||
406 | int how) | 408 | int how) |
407 | { | 409 | { |
408 | struct objlayout_io_state *state; | 410 | struct objlayout_io_state *state; |
409 | ssize_t status; | 411 | int err; |
410 | |||
411 | dprintk("%s: Begin inode %p offset %llu count %u\n", | ||
412 | __func__, wdata->inode, wdata->args.offset, wdata->args.count); | ||
413 | 412 | ||
414 | state = objlayout_alloc_io_state(NFS_I(wdata->inode)->layout, | 413 | state = objlayout_alloc_io_state(NFS_I(wdata->inode)->layout, |
415 | wdata->args.pages, | 414 | wdata->args.pages, |
@@ -419,16 +418,19 @@ objlayout_write_pagelist(struct nfs_write_data *wdata, | |||
419 | wdata->lseg, wdata, | 418 | wdata->lseg, wdata, |
420 | GFP_NOFS); | 419 | GFP_NOFS); |
421 | if (unlikely(!state)) { | 420 | if (unlikely(!state)) { |
422 | status = -ENOMEM; | 421 | err = -ENOMEM; |
423 | goto out; | 422 | goto out; |
424 | } | 423 | } |
425 | 424 | ||
426 | state->sync = how & FLUSH_SYNC; | 425 | state->sync = how & FLUSH_SYNC; |
427 | 426 | ||
428 | status = objio_write_pagelist(state, how & FLUSH_STABLE); | 427 | err = objio_write_pagelist(state, how & FLUSH_STABLE); |
429 | out: | 428 | out: |
430 | dprintk("%s: Return status %Zd\n", __func__, status); | 429 | if (unlikely(err)) { |
431 | wdata->pnfs_error = status; | 430 | wdata->pnfs_error = err; |
431 | dprintk("%s: Returned Error %d\n", __func__, err); | ||
432 | return PNFS_NOT_ATTEMPTED; | ||
433 | } | ||
432 | return PNFS_ATTEMPTED; | 434 | return PNFS_ATTEMPTED; |
433 | } | 435 | } |
434 | 436 | ||
diff --git a/fs/nfs/objlayout/objlayout.h b/fs/nfs/objlayout/objlayout.h index ffb884c6fef0..4edac9b6ac0c 100644 --- a/fs/nfs/objlayout/objlayout.h +++ b/fs/nfs/objlayout/objlayout.h | |||
@@ -115,8 +115,8 @@ extern int objio_alloc_io_state( | |||
115 | gfp_t gfp_flags); | 115 | gfp_t gfp_flags); |
116 | extern void objio_free_io_state(struct objlayout_io_state *state); | 116 | extern void objio_free_io_state(struct objlayout_io_state *state); |
117 | 117 | ||
118 | extern ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state); | 118 | extern int objio_read_pagelist(struct objlayout_io_state *ol_state); |
119 | extern ssize_t objio_write_pagelist(struct objlayout_io_state *ol_state, | 119 | extern int objio_write_pagelist(struct objlayout_io_state *ol_state, |
120 | bool stable); | 120 | bool stable); |
121 | 121 | ||
122 | /* | 122 | /* |