From: rread Date: Sat, 17 Aug 2002 00:50:58 +0000 (+0000) Subject: - cleanup callback data to get striping to work X-Git-Tag: 0.5.5~134 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=670a3dfa26a3eb169713ff717af574b6368392b9;p=fs%2Flustre-release.git - cleanup callback data to get striping to work --- diff --git a/lustre/include/linux/lustre_lib.h b/lustre/include/linux/lustre_lib.h index c1db457..47f3fdc 100644 --- a/lustre/include/linux/lustre_lib.h +++ b/lustre/include/linux/lustre_lib.h @@ -62,13 +62,23 @@ void l_unlock(struct lustre_lock *); /* page.c */ #define CB_PHASE_START 12 #define CB_PHASE_FINISH 13 + +/* + * io_cb_data: io callback data merged into one struct to simplify + * memory managment. This may be turn out to be too simple. + */ +struct io_cb_data; +typedef int (*brw_callback_t)(struct io_cb_data *, int err, int phase); + struct io_cb_data { wait_queue_head_t waitq; atomic_t refcount; int complete; int err; struct ptlrpc_bulk_desc *desc; + brw_callback_t cb; }; + int ll_sync_io_cb(struct io_cb_data *data, int err, int phase); struct io_cb_data *ll_init_cb(void); inline void lustre_put_page(struct page *page); @@ -82,11 +92,6 @@ void set_page_dirty(struct page *page); struct obd_run_ctxt; void push_ctxt(struct obd_run_ctxt *save, struct obd_run_ctxt *new); void pop_ctxt(struct obd_run_ctxt *saved); -#ifdef OBD_CTXT_DEBUG -#define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC -#else -#define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0) -#endif struct dentry *simple_mkdir(struct dentry *dir, char *name, int mode); int lustre_fread(struct file *file, char *str, int len, loff_t *off); int lustre_fwrite(struct file *file, const char *str, int len, loff_t *off); diff --git a/lustre/include/linux/obd.h b/lustre/include/linux/obd.h index 27aed58..0b17ad4 100644 --- a/lustre/include/linux/obd.h +++ b/lustre/include/linux/obd.h @@ -14,6 +14,7 @@ #include #include +#include #include struct obd_type { @@ -23,8 +24,6 @@ struct obd_type { int typ_refcnt; }; -struct io_cb_data; -typedef int (*brw_callback_t)(struct io_cb_data *, int err, int phase); struct brw_page { struct page *pg; obd_size count; @@ -50,6 +49,12 @@ struct obd_run_ctxt { #endif }; +#ifdef OBD_CTXT_DEBUG +#define OBD_SET_CTXT_MAGIC(ctxt) (ctxt)->magic = OBD_RUN_CTXT_MAGIC +#else +#define OBD_SET_CTXT_MAGIC(ctxt) do {} while(0) +#endif + struct filter_obd { char *fo_fstype; struct super_block *fo_sb; diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 296b470..eb2ad6e 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -511,14 +511,8 @@ static int lov_punch(struct lustre_handle *conn, struct obdo *oa, RETURN(rc); } -struct lov_callback_data { - struct io_cb_data cbd; - brw_callback_t cb; -}; - -int lov_osc_brw_callback(struct io_cb_data *data, int err, int phase) +int lov_osc_brw_callback(struct io_cb_data *cbd, int err, int phase) { - struct lov_callback_data *lovcbd = (struct lov_callback_data *)data; int ret = 0; ENTRY; @@ -527,9 +521,9 @@ int lov_osc_brw_callback(struct io_cb_data *data, int err, int phase) if (phase == CB_PHASE_FINISH) { if (err) - lovcbd->cbd.err = err; - if (atomic_dec_and_test(&lovcbd->cbd.refcount)) - ret = lovcbd->cb(&lovcbd->cbd, 0, lovcbd->cbd.err); + cbd->err = err; + if (atomic_dec_and_test(&cbd->refcount)) + ret = cbd->cb(cbd, cbd->err, phase); RETURN(ret); } @@ -541,7 +535,7 @@ static inline int lov_brw(int cmd, struct lustre_handle *conn, struct lov_stripe_md *md, obd_count oa_bufs, struct brw_page *pga, - brw_callback_t callback, struct io_cb_data *data) + brw_callback_t callback, struct io_cb_data *cbd) { int stripe_count = md->lmd_stripe_count; struct obd_export *export = class_conn2export(conn); @@ -554,14 +548,10 @@ static inline int lov_brw(int cmd, struct lustre_handle *conn, } *stripeinfo; struct brw_page *ioarr; int rc, i; - struct lov_callback_data *lov_cb_data; ENTRY; lov = &export->exp_obd->u.lov; - OBD_ALLOC(lov_cb_data, sizeof(*lov_cb_data)); - if (!lov_cb_data) - RETURN(-ENOMEM); OBD_ALLOC(stripeinfo, stripe_count * sizeof(*stripeinfo)); if (!stripeinfo) @@ -597,18 +587,17 @@ static inline int lov_brw(int cmd, struct lustre_handle *conn, stripeinfo[which].subcount++; } - lov_cb_data->cbd = *data; - lov_cb_data->cb = callback; - atomic_set(&lov_cb_data->cbd.refcount, oa_bufs); + cbd->cb = callback; + atomic_set(&cbd->refcount, oa_bufs); for (i=0 ; i < stripe_count ; i++) { int shift = stripeinfo[i].index; - - obd_brw(cmd, &lov->tgts[i].conn, &stripeinfo[i].md, - stripeinfo[i].bufct, &ioarr[shift], - lov_osc_brw_callback, (struct io_cb_data *)lov_cb_data); + if (stripeinfo[i].bufct) + obd_brw(cmd, &lov->tgts[i].conn, &stripeinfo[i].md, + stripeinfo[i].bufct, &ioarr[shift], + lov_osc_brw_callback, cbd); } - rc = callback((struct io_cb_data *)lov_cb_data, 0, CB_PHASE_START); + rc = callback(cbd, 0, CB_PHASE_START); RETURN(rc); } @@ -648,8 +637,8 @@ static int lov_enqueue(struct lustre_handle *conn, struct lov_stripe_md *md, rc = obd_enqueue(&(lov->tgts[i].conn), &submd, parent_lock, type, &sub_ext, sizeof(sub_ext), mode, flags, cb, data, datalen, &(lockhs[i])); // XXX add a lock debug statement here - if (!rc) { - CERROR("Error punch object %Ld subobj %Ld\n", md->lmd_object_id, + if (rc) { + CERROR("Error obd_enqueu object %Ld subobj %Ld\n", md->lmd_object_id, md->lmd_objects[i].l_object_id); } }