Commit e6c40fe3 authored by Boaz Harrosh's avatar Boaz Harrosh Committed by Trond Myklebust

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: default avatarBoaz Harrosh <bharrosh@panasas.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 4cdc685c
...@@ -142,7 +142,7 @@ OBJIO_LSEG(struct pnfs_layout_segment *lseg) ...@@ -142,7 +142,7 @@ OBJIO_LSEG(struct pnfs_layout_segment *lseg)
} }
struct objio_state; struct objio_state;
typedef ssize_t (*objio_done_fn)(struct objio_state *ios); typedef int (*objio_done_fn)(struct objio_state *ios);
struct objio_state { struct objio_state {
/* Generic layer */ /* Generic layer */
...@@ -720,7 +720,7 @@ static int _io_rw_pagelist(struct objio_state *ios, gfp_t gfp_flags) ...@@ -720,7 +720,7 @@ static int _io_rw_pagelist(struct objio_state *ios, gfp_t gfp_flags)
return 0; return 0;
} }
static ssize_t _sync_done(struct objio_state *ios) static int _sync_done(struct objio_state *ios)
{ {
struct completion *waiting = ios->private; struct completion *waiting = ios->private;
...@@ -742,10 +742,10 @@ static void _done_io(struct osd_request *or, void *p) ...@@ -742,10 +742,10 @@ static void _done_io(struct osd_request *or, void *p)
kref_put(&ios->kref, _last_io); kref_put(&ios->kref, _last_io);
} }
static ssize_t _io_exec(struct objio_state *ios) static int _io_exec(struct objio_state *ios)
{ {
DECLARE_COMPLETION_ONSTACK(wait); DECLARE_COMPLETION_ONSTACK(wait);
ssize_t status = 0; /* sync status */ int ret = 0;
unsigned i; unsigned i;
objio_done_fn saved_done_fn = ios->done; objio_done_fn saved_done_fn = ios->done;
bool sync = ios->ol_state.sync; bool sync = ios->ol_state.sync;
...@@ -771,16 +771,16 @@ static ssize_t _io_exec(struct objio_state *ios) ...@@ -771,16 +771,16 @@ static ssize_t _io_exec(struct objio_state *ios)
if (sync) { if (sync) {
wait_for_completion(&wait); wait_for_completion(&wait);
status = saved_done_fn(ios); ret = saved_done_fn(ios);
} }
return status; return ret;
} }
/* /*
* read * read
*/ */
static ssize_t _read_done(struct objio_state *ios) static int _read_done(struct objio_state *ios)
{ {
ssize_t status; ssize_t status;
int ret = _io_check(ios, false); int ret = _io_check(ios, false);
...@@ -793,7 +793,7 @@ static ssize_t _read_done(struct objio_state *ios) ...@@ -793,7 +793,7 @@ static ssize_t _read_done(struct objio_state *ios)
status = ret; status = ret;
objlayout_read_done(&ios->ol_state, status, ios->ol_state.sync); objlayout_read_done(&ios->ol_state, status, ios->ol_state.sync);
return status; return ret;
} }
static int _read_mirrors(struct objio_state *ios, unsigned cur_comp) static int _read_mirrors(struct objio_state *ios, unsigned cur_comp)
...@@ -833,7 +833,7 @@ static int _read_mirrors(struct objio_state *ios, unsigned cur_comp) ...@@ -833,7 +833,7 @@ static int _read_mirrors(struct objio_state *ios, unsigned cur_comp)
return ret; return ret;
} }
static ssize_t _read_exec(struct objio_state *ios) static int _read_exec(struct objio_state *ios)
{ {
unsigned i; unsigned i;
int ret; int ret;
...@@ -847,14 +847,14 @@ static ssize_t _read_exec(struct objio_state *ios) ...@@ -847,14 +847,14 @@ static ssize_t _read_exec(struct objio_state *ios)
} }
ios->done = _read_done; ios->done = _read_done;
return _io_exec(ios); /* In sync mode exec returns the io status */ return _io_exec(ios);
err: err:
_io_free(ios); _io_free(ios);
return ret; return ret;
} }
ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state) int objio_read_pagelist(struct objlayout_io_state *ol_state)
{ {
struct objio_state *ios = container_of(ol_state, struct objio_state, struct objio_state *ios = container_of(ol_state, struct objio_state,
ol_state); ol_state);
...@@ -870,7 +870,7 @@ ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state) ...@@ -870,7 +870,7 @@ ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state)
/* /*
* write * write
*/ */
static ssize_t _write_done(struct objio_state *ios) static int _write_done(struct objio_state *ios)
{ {
ssize_t status; ssize_t status;
int ret = _io_check(ios, true); int ret = _io_check(ios, true);
...@@ -887,7 +887,7 @@ static ssize_t _write_done(struct objio_state *ios) ...@@ -887,7 +887,7 @@ static ssize_t _write_done(struct objio_state *ios)
} }
objlayout_write_done(&ios->ol_state, status, ios->ol_state.sync); objlayout_write_done(&ios->ol_state, status, ios->ol_state.sync);
return status; return ret;
} }
static int _write_mirrors(struct objio_state *ios, unsigned cur_comp) static int _write_mirrors(struct objio_state *ios, unsigned cur_comp)
...@@ -955,7 +955,7 @@ static int _write_mirrors(struct objio_state *ios, unsigned cur_comp) ...@@ -955,7 +955,7 @@ static int _write_mirrors(struct objio_state *ios, unsigned cur_comp)
return ret; return ret;
} }
static ssize_t _write_exec(struct objio_state *ios) static int _write_exec(struct objio_state *ios)
{ {
unsigned i; unsigned i;
int ret; int ret;
...@@ -969,14 +969,14 @@ static ssize_t _write_exec(struct objio_state *ios) ...@@ -969,14 +969,14 @@ static ssize_t _write_exec(struct objio_state *ios)
} }
ios->done = _write_done; ios->done = _write_done;
return _io_exec(ios); /* In sync mode exec returns the io->status */ return _io_exec(ios);
err: err:
_io_free(ios); _io_free(ios);
return ret; return ret;
} }
ssize_t objio_write_pagelist(struct objlayout_io_state *ol_state, bool stable) int objio_write_pagelist(struct objlayout_io_state *ol_state, bool stable)
{ {
struct objio_state *ios = container_of(ol_state, struct objio_state, struct objio_state *ios = container_of(ol_state, struct objio_state,
ol_state); ol_state);
......
...@@ -315,16 +315,13 @@ objlayout_read_pagelist(struct nfs_read_data *rdata) ...@@ -315,16 +315,13 @@ objlayout_read_pagelist(struct nfs_read_data *rdata)
loff_t offset = rdata->args.offset; loff_t offset = rdata->args.offset;
size_t count = rdata->args.count; size_t count = rdata->args.count;
struct objlayout_io_state *state; struct objlayout_io_state *state;
ssize_t status = 0; int err;
loff_t eof; loff_t eof;
dprintk("%s: Begin inode %p offset %llu count %d\n",
__func__, rdata->inode, offset, (int)count);
eof = i_size_read(rdata->inode); eof = i_size_read(rdata->inode);
if (unlikely(offset + count > eof)) { if (unlikely(offset + count > eof)) {
if (offset >= eof) { if (offset >= eof) {
status = 0; err = 0;
rdata->res.count = 0; rdata->res.count = 0;
rdata->res.eof = 1; rdata->res.eof = 1;
/*FIXME: do we need to call pnfs_ld_read_done() */ /*FIXME: do we need to call pnfs_ld_read_done() */
...@@ -341,14 +338,19 @@ objlayout_read_pagelist(struct nfs_read_data *rdata) ...@@ -341,14 +338,19 @@ objlayout_read_pagelist(struct nfs_read_data *rdata)
rdata->lseg, rdata, rdata->lseg, rdata,
GFP_KERNEL); GFP_KERNEL);
if (unlikely(!state)) { if (unlikely(!state)) {
status = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
dprintk("%s: inode(%lx) offset 0x%llx count 0x%Zx eof=%d\n",
__func__, rdata->inode->i_ino, offset, count, rdata->res.eof);
status = objio_read_pagelist(state); err = objio_read_pagelist(state);
out: out:
dprintk("%s: Return status %Zd\n", __func__, status); if (unlikely(err)) {
rdata->pnfs_error = status; rdata->pnfs_error = err;
dprintk("%s: Returned Error %d\n", __func__, err);
return PNFS_NOT_ATTEMPTED;
}
return PNFS_ATTEMPTED; return PNFS_ATTEMPTED;
} }
...@@ -406,10 +408,7 @@ objlayout_write_pagelist(struct nfs_write_data *wdata, ...@@ -406,10 +408,7 @@ objlayout_write_pagelist(struct nfs_write_data *wdata,
int how) int how)
{ {
struct objlayout_io_state *state; struct objlayout_io_state *state;
ssize_t status; int err;
dprintk("%s: Begin inode %p offset %llu count %u\n",
__func__, wdata->inode, wdata->args.offset, wdata->args.count);
state = objlayout_alloc_io_state(NFS_I(wdata->inode)->layout, state = objlayout_alloc_io_state(NFS_I(wdata->inode)->layout,
wdata->args.pages, wdata->args.pages,
...@@ -419,16 +418,19 @@ objlayout_write_pagelist(struct nfs_write_data *wdata, ...@@ -419,16 +418,19 @@ objlayout_write_pagelist(struct nfs_write_data *wdata,
wdata->lseg, wdata, wdata->lseg, wdata,
GFP_NOFS); GFP_NOFS);
if (unlikely(!state)) { if (unlikely(!state)) {
status = -ENOMEM; err = -ENOMEM;
goto out; goto out;
} }
state->sync = how & FLUSH_SYNC; state->sync = how & FLUSH_SYNC;
status = objio_write_pagelist(state, how & FLUSH_STABLE); err = objio_write_pagelist(state, how & FLUSH_STABLE);
out: out:
dprintk("%s: Return status %Zd\n", __func__, status); if (unlikely(err)) {
wdata->pnfs_error = status; wdata->pnfs_error = err;
dprintk("%s: Returned Error %d\n", __func__, err);
return PNFS_NOT_ATTEMPTED;
}
return PNFS_ATTEMPTED; return PNFS_ATTEMPTED;
} }
......
...@@ -115,8 +115,8 @@ extern int objio_alloc_io_state( ...@@ -115,8 +115,8 @@ extern int objio_alloc_io_state(
gfp_t gfp_flags); gfp_t gfp_flags);
extern void objio_free_io_state(struct objlayout_io_state *state); extern void objio_free_io_state(struct objlayout_io_state *state);
extern ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state); extern int objio_read_pagelist(struct objlayout_io_state *ol_state);
extern ssize_t objio_write_pagelist(struct objlayout_io_state *ol_state, extern int objio_write_pagelist(struct objlayout_io_state *ol_state,
bool stable); bool stable);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment