Skip to content

Commit e6c40fe

Browse files
Boaz HarroshTrond Myklebust
authored andcommitted
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>
1 parent 4cdc685 commit e6c40fe

3 files changed

Lines changed: 37 additions & 35 deletions

File tree

‎fs/nfs/objlayout/objio_osd.c‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ OBJIO_LSEG(struct pnfs_layout_segment *lseg)
142142
}
143143

144144
struct objio_state;
145-
typedef ssize_t (*objio_done_fn)(struct objio_state *ios);
145+
typedef int (*objio_done_fn)(struct objio_state *ios);
146146

147147
struct objio_state {
148148
/* Generic layer */
@@ -720,7 +720,7 @@ static int _io_rw_pagelist(struct objio_state *ios, gfp_t gfp_flags)
720720
return 0;
721721
}
722722

723-
static ssize_t _sync_done(struct objio_state *ios)
723+
static int _sync_done(struct objio_state *ios)
724724
{
725725
struct completion *waiting = ios->private;
726726

@@ -742,10 +742,10 @@ static void _done_io(struct osd_request *or, void *p)
742742
kref_put(&ios->kref, _last_io);
743743
}
744744

745-
static ssize_t _io_exec(struct objio_state *ios)
745+
static int _io_exec(struct objio_state *ios)
746746
{
747747
DECLARE_COMPLETION_ONSTACK(wait);
748-
ssize_t status = 0; /* sync status */
748+
int ret = 0;
749749
unsigned i;
750750
objio_done_fn saved_done_fn = ios->done;
751751
bool sync = ios->ol_state.sync;
@@ -771,16 +771,16 @@ static ssize_t _io_exec(struct objio_state *ios)
771771

772772
if (sync) {
773773
wait_for_completion(&wait);
774-
status = saved_done_fn(ios);
774+
ret = saved_done_fn(ios);
775775
}
776776

777-
return status;
777+
return ret;
778778
}
779779

780780
/*
781781
* read
782782
*/
783-
static ssize_t _read_done(struct objio_state *ios)
783+
static int _read_done(struct objio_state *ios)
784784
{
785785
ssize_t status;
786786
int ret = _io_check(ios, false);
@@ -793,7 +793,7 @@ static ssize_t _read_done(struct objio_state *ios)
793793
status = ret;
794794

795795
objlayout_read_done(&ios->ol_state, status, ios->ol_state.sync);
796-
return status;
796+
return ret;
797797
}
798798

799799
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)
833833
return ret;
834834
}
835835

836-
static ssize_t _read_exec(struct objio_state *ios)
836+
static int _read_exec(struct objio_state *ios)
837837
{
838838
unsigned i;
839839
int ret;
@@ -847,14 +847,14 @@ static ssize_t _read_exec(struct objio_state *ios)
847847
}
848848

849849
ios->done = _read_done;
850-
return _io_exec(ios); /* In sync mode exec returns the io status */
850+
return _io_exec(ios);
851851

852852
err:
853853
_io_free(ios);
854854
return ret;
855855
}
856856

857-
ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state)
857+
int objio_read_pagelist(struct objlayout_io_state *ol_state)
858858
{
859859
struct objio_state *ios = container_of(ol_state, struct objio_state,
860860
ol_state);
@@ -870,7 +870,7 @@ ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state)
870870
/*
871871
* write
872872
*/
873-
static ssize_t _write_done(struct objio_state *ios)
873+
static int _write_done(struct objio_state *ios)
874874
{
875875
ssize_t status;
876876
int ret = _io_check(ios, true);
@@ -887,7 +887,7 @@ static ssize_t _write_done(struct objio_state *ios)
887887
}
888888

889889
objlayout_write_done(&ios->ol_state, status, ios->ol_state.sync);
890-
return status;
890+
return ret;
891891
}
892892

893893
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)
955955
return ret;
956956
}
957957

958-
static ssize_t _write_exec(struct objio_state *ios)
958+
static int _write_exec(struct objio_state *ios)
959959
{
960960
unsigned i;
961961
int ret;
@@ -969,14 +969,14 @@ static ssize_t _write_exec(struct objio_state *ios)
969969
}
970970

971971
ios->done = _write_done;
972-
return _io_exec(ios); /* In sync mode exec returns the io->status */
972+
return _io_exec(ios);
973973

974974
err:
975975
_io_free(ios);
976976
return ret;
977977
}
978978

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)
980980
{
981981
struct objio_state *ios = container_of(ol_state, struct objio_state,
982982
ol_state);

‎fs/nfs/objlayout/objlayout.c‎

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -315,16 +315,13 @@ objlayout_read_pagelist(struct nfs_read_data *rdata)
315315
loff_t offset = rdata->args.offset;
316316
size_t count = rdata->args.count;
317317
struct objlayout_io_state *state;
318-
ssize_t status = 0;
318+
int err;
319319
loff_t eof;
320320

321-
dprintk("%s: Begin inode %p offset %llu count %d\n",
322-
__func__, rdata->inode, offset, (int)count);
323-
324321
eof = i_size_read(rdata->inode);
325322
if (unlikely(offset + count > eof)) {
326323
if (offset >= eof) {
327-
status = 0;
324+
err = 0;
328325
rdata->res.count = 0;
329326
rdata->res.eof = 1;
330327
/*FIXME: do we need to call pnfs_ld_read_done() */
@@ -341,14 +338,19 @@ objlayout_read_pagelist(struct nfs_read_data *rdata)
341338
rdata->lseg, rdata,
342339
GFP_KERNEL);
343340
if (unlikely(!state)) {
344-
status = -ENOMEM;
341+
err = -ENOMEM;
345342
goto out;
346343
}
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);
347346

348-
status = objio_read_pagelist(state);
347+
err = objio_read_pagelist(state);
349348
out:
350-
dprintk("%s: Return status %Zd\n", __func__, status);
351-
rdata->pnfs_error = status;
349+
if (unlikely(err)) {
350+
rdata->pnfs_error = err;
351+
dprintk("%s: Returned Error %d\n", __func__, err);
352+
return PNFS_NOT_ATTEMPTED;
353+
}
352354
return PNFS_ATTEMPTED;
353355
}
354356

@@ -406,10 +408,7 @@ objlayout_write_pagelist(struct nfs_write_data *wdata,
406408
int how)
407409
{
408410
struct objlayout_io_state *state;
409-
ssize_t status;
410-
411-
dprintk("%s: Begin inode %p offset %llu count %u\n",
412-
__func__, wdata->inode, wdata->args.offset, wdata->args.count);
411+
int err;
413412

414413
state = objlayout_alloc_io_state(NFS_I(wdata->inode)->layout,
415414
wdata->args.pages,
@@ -419,16 +418,19 @@ objlayout_write_pagelist(struct nfs_write_data *wdata,
419418
wdata->lseg, wdata,
420419
GFP_NOFS);
421420
if (unlikely(!state)) {
422-
status = -ENOMEM;
421+
err = -ENOMEM;
423422
goto out;
424423
}
425424

426425
state->sync = how & FLUSH_SYNC;
427426

428-
status = objio_write_pagelist(state, how & FLUSH_STABLE);
427+
err = objio_write_pagelist(state, how & FLUSH_STABLE);
429428
out:
430-
dprintk("%s: Return status %Zd\n", __func__, status);
431-
wdata->pnfs_error = status;
429+
if (unlikely(err)) {
430+
wdata->pnfs_error = err;
431+
dprintk("%s: Returned Error %d\n", __func__, err);
432+
return PNFS_NOT_ATTEMPTED;
433+
}
432434
return PNFS_ATTEMPTED;
433435
}
434436

‎fs/nfs/objlayout/objlayout.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ extern int objio_alloc_io_state(
115115
gfp_t gfp_flags);
116116
extern void objio_free_io_state(struct objlayout_io_state *state);
117117

118-
extern ssize_t objio_read_pagelist(struct objlayout_io_state *ol_state);
119-
extern ssize_t objio_write_pagelist(struct objlayout_io_state *ol_state,
118+
extern int objio_read_pagelist(struct objlayout_io_state *ol_state);
119+
extern int objio_write_pagelist(struct objlayout_io_state *ol_state,
120120
bool stable);
121121

122122
/*

0 commit comments

Comments
 (0)