Skip to content

Commit eecfc63

Browse files
Boaz HarroshTrond Myklebust
authored andcommitted
pnfs-obj: move to ore 02: move to ORE
In this patch we are actually moving to the ORE. (Object Raid Engine). objio_state holds a pointer to an ore_io_state. Once we have an ore_io_state at hand we can call the ore for reading/writing. We register on the done path to kick off the nfs io_done mechanism. Again for Ease of reviewing the old code is "#if 0" but is not removed so the diff command works better. The old code will be removed in the next patch. fs/exofs/Kconfig::ORE is modified to also be auto-included if PNFS_OBJLAYOUT is set. Since we now depend on ORE. (See comments in fs/exofs/Kconfig) Signed-off-by: Boaz Harrosh <bharrosh@panasas.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent af4f5b5 commit eecfc63

2 files changed

Lines changed: 60 additions & 75 deletions

File tree

‎fs/exofs/Kconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# selected by any of the users.
66
config ORE
77
tristate
8-
depends on EXOFS_FS
8+
depends on EXOFS_FS || PNFS_OBJLAYOUT
99
select ASYNC_XOR
1010
default SCSI_OSD_ULD
1111

‎fs/nfs/objlayout/objio_osd.c‎

Lines changed: 59 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,6 @@
4444

4545
#define NFSDBG_FACILITY NFSDBG_PNFS_LD
4646

47-
#define _LLU(x) ((unsigned long long)x)
48-
49-
enum { BIO_MAX_PAGES_KMALLOC =
50-
(PAGE_SIZE - sizeof(struct bio)) / sizeof(struct bio_vec),
51-
};
52-
5347
struct objio_dev_ent {
5448
struct nfs4_deviceid_node id_node;
5549
struct ore_dev od;
@@ -124,37 +118,13 @@ OBJIO_LSEG(struct pnfs_layout_segment *lseg)
124118
return container_of(lseg, struct objio_segment, lseg);
125119
}
126120

127-
struct objio_state;
128-
typedef int (*objio_done_fn)(struct objio_state *ios);
129-
130121
struct objio_state {
131122
/* Generic layer */
132123
struct objlayout_io_res oir;
133124

134-
struct page **pages;
135-
unsigned pgbase;
136-
unsigned nr_pages;
137-
unsigned long count;
138-
loff_t offset;
139125
bool sync;
140-
141-
struct ore_layout *layout;
142-
struct ore_components *oc;
143-
144-
struct kref kref;
145-
objio_done_fn done;
146-
void *private;
147-
148-
unsigned long length;
149-
unsigned numdevs; /* Actually used devs in this IO */
150-
/* A per-device variable array of size numdevs */
151-
struct _objio_per_comp {
152-
struct bio *bio;
153-
struct osd_request *or;
154-
unsigned long length;
155-
u64 offset;
156-
unsigned dev;
157-
} per_dev[];
126+
/*FIXME: Support for extra_bytes at ore_get_rw_state() */
127+
struct ore_io_state *ios;
158128
};
159129

160130
/* Send and wait for a get_device_info of devices in the layout,
@@ -374,47 +344,50 @@ void objio_free_lseg(struct pnfs_layout_segment *lseg)
374344
}
375345

376346
static int
377-
objio_alloc_io_state(struct pnfs_layout_hdr *pnfs_layout_type,
347+
objio_alloc_io_state(struct pnfs_layout_hdr *pnfs_layout_type, bool is_reading,
378348
struct pnfs_layout_segment *lseg, struct page **pages, unsigned pgbase,
379349
loff_t offset, size_t count, void *rpcdata, gfp_t gfp_flags,
380350
struct objio_state **outp)
381351
{
382352
struct objio_segment *objio_seg = OBJIO_LSEG(lseg);
383-
struct objio_state *ios;
353+
struct ore_io_state *ios;
354+
int ret;
384355
struct __alloc_objio_state {
385356
struct objio_state objios;
386-
struct _objio_per_comp per_dev[objio_seg->oc.numdevs];
387357
struct pnfs_osd_ioerr ioerrs[objio_seg->oc.numdevs];
388358
} *aos;
389359

390360
aos = kzalloc(sizeof(*aos), gfp_flags);
391361
if (unlikely(!aos))
392362
return -ENOMEM;
393363

394-
ios = &aos->objios;
395-
396-
ios->layout = &objio_seg->layout;
397-
ios->oc = &objio_seg->oc;
398364
objlayout_init_ioerrs(&aos->objios.oir, objio_seg->oc.numdevs,
399365
aos->ioerrs, rpcdata, pnfs_layout_type);
400366

367+
ret = ore_get_rw_state(&objio_seg->layout, &objio_seg->oc, is_reading,
368+
offset, count, &ios);
369+
if (unlikely(ret)) {
370+
kfree(aos);
371+
return ret;
372+
}
373+
401374
ios->pages = pages;
402375
ios->pgbase = pgbase;
403-
ios->nr_pages = (pgbase + count + PAGE_SIZE - 1) >> PAGE_SHIFT;
404-
ios->offset = offset;
405-
ios->count = count;
406-
ios->sync = 0;
376+
ios->private = aos;
407377
BUG_ON(ios->nr_pages > (pgbase + count + PAGE_SIZE - 1) >> PAGE_SHIFT);
408378

409-
*outp = ios;
379+
aos->objios.sync = 0;
380+
aos->objios.ios = ios;
381+
*outp = &aos->objios;
410382
return 0;
411383
}
412384

413385
void objio_free_result(struct objlayout_io_res *oir)
414386
{
415-
struct objio_state *ios = container_of(oir, struct objio_state, oir);
387+
struct objio_state *objios = container_of(oir, struct objio_state, oir);
416388

417-
kfree(ios);
389+
ore_put_io_state(objios->ios);
390+
kfree(objios);
418391
}
419392

420393
enum pnfs_osd_errno osd_pri_2_pnfs_err(enum osd_err_priority oep)
@@ -447,7 +420,7 @@ enum pnfs_osd_errno osd_pri_2_pnfs_err(enum osd_err_priority oep)
447420
}
448421
}
449422

450-
static void __on_dev_error(struct objio_state *ios, bool is_write,
423+
static void __on_dev_error(struct ore_io_state *ios,
451424
struct ore_dev *od, unsigned dev_index, enum osd_err_priority oep,
452425
u64 dev_offset, u64 dev_len)
453426
{
@@ -465,9 +438,10 @@ static void __on_dev_error(struct objio_state *ios, bool is_write,
465438

466439
objlayout_io_set_result(&objios->oir, comp,
467440
&pooid, osd_pri_2_pnfs_err(oep),
468-
dev_offset, dev_len, is_write);
441+
dev_offset, dev_len, !ios->reading);
469442
}
470443

444+
#if 0
471445
static void _clear_bio(struct bio *bio)
472446
{
473447
struct bio_vec *bv;
@@ -786,26 +760,28 @@ static int _io_exec(struct objio_state *ios)
786760

787761
return ret;
788762
}
763+
#endif
789764

790765
/*
791766
* read
792767
*/
793-
static int _read_done(struct objio_state *ios)
768+
static void _read_done(struct ore_io_state *ios, void *private)
794769
{
770+
struct objio_state *objios = private;
795771
ssize_t status;
796-
int ret = _io_check(ios, false);
772+
int ret = ore_check_io(ios, &__on_dev_error);
797773

798-
_io_free(ios);
774+
/* FIXME: _io_free(ios) can we dealocate the libosd resources; */
799775

800776
if (likely(!ret))
801777
status = ios->length;
802778
else
803779
status = ret;
804780

805-
objlayout_read_done(&ios->oir, status, ios->sync);
806-
return ret;
781+
objlayout_read_done(&objios->oir, status, objios->sync);
807782
}
808783

784+
#if 0
809785
static int _read_mirrors(struct objio_state *ios, unsigned cur_comp)
810786
{
811787
struct osd_request *or = NULL;
@@ -860,49 +836,50 @@ static int _read_exec(struct objio_state *ios)
860836
_io_free(ios);
861837
return ret;
862838
}
839+
#endif
863840

864841
int objio_read_pagelist(struct nfs_read_data *rdata)
865842
{
866-
struct objio_state *ios;
843+
struct objio_state *objios;
867844
int ret;
868845

869-
ret = objio_alloc_io_state(NFS_I(rdata->inode)->layout,
846+
ret = objio_alloc_io_state(NFS_I(rdata->inode)->layout, true,
870847
rdata->lseg, rdata->args.pages, rdata->args.pgbase,
871848
rdata->args.offset, rdata->args.count, rdata,
872-
GFP_KERNEL, &ios);
873-
if (unlikely(ret))
874-
return ret;
875-
876-
ret = _io_rw_pagelist(ios, GFP_KERNEL);
849+
GFP_KERNEL, &objios);
877850
if (unlikely(ret))
878851
return ret;
879852

880-
return _read_exec(ios);
853+
objios->ios->done = _read_done;
854+
dprintk("%s: offset=0x%llx length=0x%x\n", __func__,
855+
rdata->args.offset, rdata->args.count);
856+
return ore_read(objios->ios);
881857
}
882858

883859
/*
884860
* write
885861
*/
886-
static int _write_done(struct objio_state *ios)
862+
static void _write_done(struct ore_io_state *ios, void *private)
887863
{
864+
struct objio_state *objios = private;
888865
ssize_t status;
889-
int ret = _io_check(ios, true);
866+
int ret = ore_check_io(ios, &__on_dev_error);
890867

891-
_io_free(ios);
868+
/* FIXME: _io_free(ios) can we dealocate the libosd resources; */
892869

893870
if (likely(!ret)) {
894871
/* FIXME: should be based on the OSD's persistence model
895872
* See OSD2r05 Section 4.13 Data persistence model */
896-
ios->oir.committed = NFS_FILE_SYNC;
873+
objios->oir.committed = NFS_FILE_SYNC;
897874
status = ios->length;
898875
} else {
899876
status = ret;
900877
}
901878

902-
objlayout_write_done(&ios->oir, status, ios->sync);
903-
return ret;
879+
objlayout_write_done(&objios->oir, status, objios->sync);
904880
}
905881

882+
#if 0
906883
static int _write_mirrors(struct objio_state *ios, unsigned cur_comp)
907884
{
908885
struct _objio_per_comp *master_dev = &ios->per_dev[cur_comp];
@@ -984,27 +961,35 @@ static int _write_exec(struct objio_state *ios)
984961
_io_free(ios);
985962
return ret;
986963
}
964+
#endif
987965

988966
int objio_write_pagelist(struct nfs_write_data *wdata, int how)
989967
{
990-
struct objio_state *ios;
968+
struct objio_state *objios;
991969
int ret;
992970

993-
ret = objio_alloc_io_state(NFS_I(wdata->inode)->layout,
971+
ret = objio_alloc_io_state(NFS_I(wdata->inode)->layout, false,
994972
wdata->lseg, wdata->args.pages, wdata->args.pgbase,
995973
wdata->args.offset, wdata->args.count, wdata, GFP_NOFS,
996-
&ios);
974+
&objios);
997975
if (unlikely(ret))
998976
return ret;
999977

1000-
ios->sync = 0 != (how & FLUSH_SYNC);
978+
objios->sync = 0 != (how & FLUSH_SYNC);
1001979

1002-
/* TODO: ios->stable = stable; */
1003-
ret = _io_rw_pagelist(ios, GFP_NOFS);
980+
if (!objios->sync)
981+
objios->ios->done = _write_done;
982+
983+
dprintk("%s: offset=0x%llx length=0x%x\n", __func__,
984+
wdata->args.offset, wdata->args.count);
985+
ret = ore_write(objios->ios);
1004986
if (unlikely(ret))
1005987
return ret;
1006988

1007-
return _write_exec(ios);
989+
if (objios->sync)
990+
_write_done(objios->ios, objios);
991+
992+
return 0;
1008993
}
1009994

1010995
static bool objio_pg_test(struct nfs_pageio_descriptor *pgio,

0 commit comments

Comments
 (0)