From: nikita Date: Sun, 7 May 2006 22:53:34 +0000 (+0000) Subject: add some rough transaction support to osd X-Git-Tag: v1_8_0_110~486^2~1858 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=5fbdc6ecc654df8594e48122ba69d8e965f99c65;p=fs%2Flustre-release.git add some rough transaction support to osd --- diff --git a/lustre/include/linux/dt_object.h b/lustre/include/linux/dt_object.h index 3c77566..48643a6 100644 --- a/lustre/include/linux/dt_object.h +++ b/lustre/include/linux/dt_object.h @@ -200,8 +200,8 @@ struct dt_index_operations { }; struct dt_device { - struct lu_device dd_lu_dev; - struct dt_device_operations *dd_ops; + struct lu_device dd_lu_dev; + struct dt_device_operations *dd_ops; }; static inline int lu_device_is_dt(const struct lu_device *d) @@ -217,9 +217,9 @@ static inline struct dt_device * lu2dt_dev(struct lu_device *l) struct dt_object { struct lu_object do_lu; - struct dt_object_operations *do_ops; - struct dt_body_operations *do_body_ops; - struct dt_index_operations *do_index_ops; + struct dt_object_operations *do_ops; + struct dt_body_operations *do_body_ops; + struct dt_index_operations *do_index_ops; }; struct txn_param { @@ -232,4 +232,8 @@ struct txn_param { #define TXN_PARAM(...) ((struct txn_param)TXN_PARAM_INIT(__VA_ARGS__)) +struct thandle { + struct dt_device *th_dev; +}; + #endif /* __LINUX_DT_OBJECT_H */ diff --git a/lustre/osd/Makefile.in b/lustre/osd/Makefile.in index abe785b..3953e3c 100644 --- a/lustre/osd/Makefile.in +++ b/lustre/osd/Makefile.in @@ -1,4 +1,6 @@ MODULES := osd osd-objs := osd_handler.o osd_oi.o +EXTRA_PRE_CFLAGS := -I@LINUX@/fs -I@LUSTRE@ -I@LUSTRE@/ldiskfs + @INCLUDE_RULES@ diff --git a/lustre/osd/osd_handler.c b/lustre/osd/osd_handler.c index 27f4432..e85ff94 100644 --- a/lustre/osd/osd_handler.c +++ b/lustre/osd/osd_handler.c @@ -36,6 +36,15 @@ /* LUSTRE_VERSION_CODE */ #include /* + * XXX temporary stuff: direct access to ldiskfs/jdb. Interface between osd + * and file system is not yet specified. + */ +/* handle_t, journal_start(), journal_stop() */ +#include +/* LDISKFS_SB() */ +#include + +/* * struct OBD_{ALLOC,FREE}*() * OBD_FAIL_CHECK */ @@ -91,6 +100,7 @@ static struct inode *osd_iget (struct osd_thread_info *info, struct osd_device *dev, const struct osd_inode_id *id); static struct super_block *osd_sb (const struct osd_device *dev); +static journal_t *osd_journal (const struct osd_device *dev); static struct lu_device_type_operations osd_device_type_ops; static struct lu_device_type osd_device_type; @@ -104,6 +114,11 @@ static struct dt_object_operations osd_obj_ops; static struct dt_body_operations osd_body_ops; static struct dt_index_operations osd_index_ops; +struct osd_thandle { + struct thandle ot_super; + handle_t *ot_handle; +}; + /* * DT methods. */ @@ -220,7 +235,7 @@ static int osd_statfs(struct lu_context *ctx, ENTRY; - memset(sfs, 0, sizeof(*sfs)); + memset(sfs, 0, sizeof *sfs); result = sb->s_op->statfs(sb, sfs); RETURN (result); @@ -230,12 +245,53 @@ static struct thandle *osd_trans_start(struct lu_context *ctx, struct dt_device *d, struct txn_param *p) { - RETURN (NULL); + struct osd_device *dev = osd_dt_dev(d); + handle_t *handle; + struct osd_thandle *oh; + struct thandle *result; + + ENTRY; + + OBD_ALLOC_PTR(oh); + if (oh != NULL) { + /* + * XXX temporary stuff. Some abstraction layer should be used. + */ + /* + * XXX Here, run transaction start hook, so that modules can + * change @p. + */ + handle = journal_start(osd_journal(dev), p->tp_credits); + if (!IS_ERR(handle)) { + result = &oh->ot_super; + result->th_dev = d; + lu_device_get(&d->dd_lu_dev); + } else { + OBD_FREE_PTR(oh); + result = (void *)handle; + } + } else + result = ERR_PTR(-ENOMEM); + + RETURN(result); } -static void osd_trans_stop(struct lu_context *ctx, - struct thandle *th) +static void osd_trans_stop(struct lu_context *ctx, struct thandle *th) { + int result; + struct osd_thandle *oh; + + ENTRY; + oh = container_of0(th, struct osd_thandle, ot_super); + /* + * XXX temporary stuff. Some abstraction layer should be used. + */ + /* + * XXX Here, run transaction stop hook. + */ + result = journal_stop(oh->ot_handle); + if (result != 0) + CERROR("Failure to stop transaction: %d\n", result); EXIT; } @@ -274,7 +330,7 @@ static int osd_object_create(struct lu_context *ctxt, struct dt_object *dt, if (lu_object_exists(ctxt, &dt->do_lu)) RETURN(-EEXIST); else { - + const struct osd_inode_id i_id = { .oii_ino = fid_seq(lf), .oii_gen = fid_oid(lf) @@ -623,6 +679,11 @@ static struct super_block *osd_sb(const struct osd_device *dev) return dev->od_mount->lmi_mnt->mnt_sb; } +static journal_t *osd_journal(const struct osd_device *dev) +{ + return LDISKFS_SB(osd_sb(dev))->s_journal; +} + static struct lu_object_operations osd_lu_obj_ops = { .loo_object_init = osd_object_init, .loo_object_delete = osd_object_delete,