From: wangdi Date: Tue, 4 Apr 2006 08:27:04 +0000 (+0000) Subject: Branch: b_new_cmd X-Git-Tag: v1_8_0_110~486^2~2103 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=4bbf93229609e6fc46770173baafe9817d611b5c;p=fs%2Flustre-release.git Branch: b_new_cmd 1.move share structure to mdd 2.some minor fixes --- diff --git a/lustre/include/linux/lvfs.h b/lustre/include/linux/lvfs.h index a6fc13d..76a5569 100644 --- a/lustre/include/linux/lvfs.h +++ b/lustre/include/linux/lvfs.h @@ -27,7 +27,7 @@ #include #include -#define lu_fid_NAMELEN (16 + 1 + 8 + 1) +#define LU_FID_NAMELEN (16 + 1 + 8 + 1) #if defined __KERNEL__ #include diff --git a/lustre/include/linux/lvfs_linux.h b/lustre/include/linux/lvfs_linux.h index 7c31b31..d455307 100644 --- a/lustre/include/linux/lvfs_linux.h +++ b/lustre/include/linux/lvfs_linux.h @@ -25,7 +25,7 @@ struct l_linux_dirent { struct list_head lld_list; ino_t lld_ino; unsigned long lld_off; - char lld_name[LL_FID_NAMELEN]; + char lld_name[LU_FID_NAMELEN]; }; struct l_readdir_callback { struct l_linux_dirent *lrc_dirent; diff --git a/lustre/include/linux/md_object.h b/lustre/include/linux/md_object.h index 146a01d..223763f 100644 --- a/lustre/include/linux/md_object.h +++ b/lustre/include/linux/md_object.h @@ -31,12 +31,35 @@ struct md_device; struct md_device_operations; struct md_object; +/*the context of the mdd ops*/ +struct context { + const char *name; + int name_len; + __u32 mode; + int flags; +}; + struct md_device_operations { - /* get root FID */ - int (*mdo_root_get)(struct md_device *m, struct ll_fid *f); - /* metadata API */ - int (*mdo_mkdir)(struct md_object *o, const char *name, + int (*mdo_root_get)(struct md_device *m, struct lu_fid *f); + int (*mdo_mkdir)(struct md_object *obj, const char *name, struct md_object *child); + + int (*mdo_rename)(struct md_object *spobj, struct md_object *tpobj, + struct md_object *sobj, const char *sname, + struct md_object *tobj, const char *tname, + struct context *uctxt); + int (*mdo_link)(struct md_object *tobj, struct md_object *sobj, + const char *name, struct context *uctxt); + int (*mdo_attr_get)(struct md_object *obj, void *buf, int buf_len, + const char *name, struct context *uctxt); + int (*mdo_attr_set)(struct md_object *obj, void *buf, int buf_len, + const char *name, struct context *uctxt); + int (*mdo_index_insert)(struct md_object *pobj, struct md_object *obj, + const char *name, struct context *uctxt); + int (*mdo_index_delete)(struct md_object *pobj, struct md_object *obj, + const char *name, struct context *uctxt); + int (*mdo_object_create)(struct md_object *pobj, struct md_object *child, + struct context *uctxt); }; struct md_device { diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 1de72da..c0828f0 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -35,6 +35,7 @@ #include #include +#include #include "mdd_internal.h" @@ -181,11 +182,12 @@ __mdd_object_create(struct mdd_device *mdd, struct mdd_object *pobj, } static int -mdd_object_create(struct md_object *pobj, struct mdd_object *child, +mdd_object_create(struct md_object *pobj, struct md_object *child, struct context *uctxt) { struct mdd_device *mdd = mdo2mdd(pobj); struct mdd_object *mdd_pobj = mdo2mddo(pobj); + struct mdd_object *mdd_child = mdo2mddo(child); void *handle = NULL; int rc; ENTRY; @@ -194,7 +196,7 @@ mdd_object_create(struct md_object *pobj, struct mdd_object *child, if (!handle) RETURN(-ENOMEM); - rc = __mdd_object_create(mdd, mdd_pobj, child, uctxt, handle); + rc = __mdd_object_create(mdd, mdd_pobj, mdd_child, uctxt, handle); mdd_trans_stop(mdd, handle); @@ -307,7 +309,7 @@ mdd_object_dec_check(struct mdd_device *mdd, struct mdd_object *obj) } -static struct ll_fid *mdd_object_getfid(struct mdd_object *obj) +static struct lu_fid *mdd_object_getfid(struct mdd_object *obj) { return &(obj->mod_obj.mo_lu.lo_header->loh_fid); } @@ -361,7 +363,7 @@ __mdd_index_insert(struct mdd_device *mdd, struct mdd_object *pobj, mdd_lock(mdd, obj, WRITE_LOCK); rc = mdd_child_ops(mdd)->osd_index_insert(mdd_object_child(pobj), - mdd_object_getfid(obj), name, + mdd_object_getfid(obj), name, uctxt, handle); mdd_unlock(mdd, pobj, WRITE_LOCK); mdd_unlock(mdd, obj, WRITE_LOCK); @@ -371,10 +373,10 @@ __mdd_index_insert(struct mdd_device *mdd, struct mdd_object *pobj, } static int -mdd_index_insert(struct mdd_device *mdd, struct md_object *pobj, - struct md_object *obj, const char *name, +mdd_index_insert(struct md_object *pobj, struct md_object *obj, const char *name, struct context *uctxt) { + struct mdd_device *mdd = mdo2mdd(pobj); int rc; void *handle = NULL; ENTRY; @@ -402,7 +404,7 @@ __mdd_index_delete(struct mdd_device *mdd, struct mdd_object *pobj, mdd_lock(mdd, pobj, WRITE_LOCK); mdd_lock(mdd, obj, WRITE_LOCK); - rc = mdd_child_ops(mdd)->osd_insert_delete(mdd_object_child(pobj), + rc = mdd_child_ops(mdd)->osd_index_delete(mdd_object_child(pobj), mdd_object_getfid(obj), name, uctxt, handle); mdd_unlock(mdd, pobj, WRITE_LOCK); diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index e9ba65d..b52b44a 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -7,48 +7,11 @@ #define LUSTRE_MDD_NAME "mdd" #define LUSTRE_OSD_NAME "osd" -#define WRITE_LOCK 1 -/*the context of the mdd ops*/ -struct context { - const char *name; - int name_len; - __u32 mode; - int flags; +enum { + WRITE_LOCK = 1, + READ_LOCK = 2, }; -struct osd_device_operations { - int (*osd_object_lock)(struct lu_object *lu, __u32 mode); - int (*osd_object_unlock)(struct lu_object *lu, __u32 mode); - void* (*osd_trans_start)(struct lu_object *lu); - void (*osd_trans_stop)(struct lu_object *lu); - int (*osd_object_create)(struct lu_object *plu, struct lu_object *child, - struct context *context, void *handle); - int (*osd_object_destroy)(struct lu_object *lu, void *handle); - void (*osd_object_get)(struct lu_object *lu); - int (*osd_attr_get)(struct lu_object *lu, void *buf, int buf_len, - const char *name, struct context *context); - int (*osd_attr_set)(struct lu_object *lu, void *buf, int buf_len, - const char *name, struct context *context, - void *handle); - int (*osd_object_dec_check)(struct lu_object *lu); - int (*osd_index_insert)(struct lu_object *lu, struct lu_fid *fid, - const char *name, struct context *uctxt, - void *handle); - int (*osd_insert_delete)(struct lu_object *lu, struct lu_fid *fid, - const char *name, struct context *uctxt, - void *handle); -}; - -struct osd_device { - struct lu_device osd_lu_dev; - struct osd_device_operations *osd_ops; -}; - - -struct md_device { - struct lu_device md_lu_dev; - struct md_device_operations *md_ops; -}; struct mdd_device { /* NB this field MUST be first */ @@ -75,43 +38,45 @@ struct mdd_device { mdd_fl_acl:1; }; -struct md_object { - struct lu_object mo_lu; -}; - struct mdd_object { struct md_object mod_obj; }; +/*these osd stuff should be moved to somewhere later*/ struct osd_object { struct lu_object oo_lu; struct dentry *oo_dentry; }; -struct md_device_operations { - int (*mdo_root_get)(struct md_device *m, struct ll_fid *f); - int (*mdo_mkdir)(struct md_object *obj, const char *name, - struct md_object *child); - - int (*mdo_rename)(struct md_object *spobj, struct md_object *tpobj, - struct md_object *sobj, const char *sname, - struct md_object *tobj, const char *tname, - struct context *uctxt); - int (*mdo_link)(struct md_object *tobj, struct md_object *sobj, - const char *name, struct context *uctxt); - int (*mdo_attr_get)(struct md_object *obj, void *buf, int buf_len, - const char *name, struct context *uctxt); - int (*mdo_attr_set)(struct md_object *obj, void *buf, int buf_len, - const char *name, struct context *uctxt); - int (*mdo_index_insert)(struct mdd_device *mdd, struct md_object *pobj, - struct md_object *obj, const char *name, - struct context *uctxt); - int (*mdo_index_delete)(struct md_object *pobj, struct md_object *obj, - const char *name, struct context *uctxt); - int (*mdo_object_create)(struct md_object *pobj, struct mdd_object *child, - struct context *uctxt); +struct osd_device_operations { + int (*osd_object_lock)(struct lu_object *lu, __u32 mode); + int (*osd_object_unlock)(struct lu_object *lu, __u32 mode); + void* (*osd_trans_start)(struct lu_object *lu); + void (*osd_trans_stop)(struct lu_object *lu); + int (*osd_object_create)(struct lu_object *plu, struct lu_object *child, + struct context *context, void *handle); + int (*osd_object_destroy)(struct lu_object *lu, void *handle); + void (*osd_object_get)(struct lu_object *lu); + int (*osd_attr_get)(struct lu_object *lu, void *buf, int buf_len, + const char *name, struct context *context); + int (*osd_attr_set)(struct lu_object *lu, void *buf, int buf_len, + const char *name, struct context *context, + void *handle); + int (*osd_object_dec_check)(struct lu_object *lu); + int (*osd_index_insert)(struct lu_object *lu, struct lu_fid *fid, + const char *name, struct context *uctxt, + void *handle); + int (*osd_index_delete)(struct lu_object *lu, struct lu_fid *fid, + const char *name, struct context *uctxt, + void *handle); +}; + +struct osd_device { + struct lu_device osd_lu_dev; + struct osd_device_operations *osd_ops; }; + int mdd_object_put(struct mdd_device *mdd, struct mdd_object *obj); void mdd_object_get(struct mdd_device *mdd, struct mdd_object *obj); #endif diff --git a/lustre/mds/mds_fs.c b/lustre/mds/mds_fs.c index c277e94..4fb2949 100644 --- a/lustre/mds/mds_fs.c +++ b/lustre/mds/mds_fs.c @@ -644,7 +644,7 @@ int mds_obd_create(struct obd_export *exp, struct obdo *oa, struct file *filp; struct dentry *new_child; struct lvfs_run_ctxt saved; - char fidname[LL_FID_NAMELEN]; + char fidname[LU_FID_NAMELEN]; void *handle; struct lvfs_ucred ucred = { 0 }; int rc = 0, err, namelen; @@ -730,7 +730,7 @@ int mds_obd_destroy(struct obd_export *exp, struct obdo *oa, struct obd_device *obd = exp->exp_obd; struct lvfs_run_ctxt saved; struct lvfs_ucred ucred = { 0 }; - char fidname[lu_fid_NAMELEN]; + char fidname[LU_FID_NAMELEN]; struct dentry *de; void *handle; int err, namelen, rc = 0; diff --git a/lustre/mds/mds_open.c b/lustre/mds/mds_open.c index 4a00898..3d98bc2 100644 --- a/lustre/mds/mds_open.c +++ b/lustre/mds/mds_open.c @@ -763,7 +763,7 @@ static int mds_open_by_fid(struct ptlrpc_request *req, struct lu_fid *fid, { struct mds_obd *mds = mds_req2mds(req); struct dentry *dchild; - char fidname[lu_fid_NAMELEN]; + char fidname[LU_FID_NAMELEN]; int fidlen = 0, rc; void *handle = NULL; ENTRY; @@ -1158,7 +1158,7 @@ int mds_mfd_close(struct ptlrpc_request *req, int offset,struct obd_device *obd, struct mds_file_data *mfd, int unlink_orphan) { struct inode *inode = mfd->mfd_dentry->d_inode; - char fidname[lu_fid_NAMELEN]; + char fidname[LU_FID_NAMELEN]; int last_orphan, fidlen, rc = 0, cleanup_phase = 0; struct dentry *pending_child = NULL; struct mds_obd *mds = &obd->u.mds; diff --git a/lustre/mds/mds_reint.c b/lustre/mds/mds_reint.c index ab46538..bc65e86 100644 --- a/lustre/mds/mds_reint.c +++ b/lustre/mds/mds_reint.c @@ -1355,7 +1355,7 @@ static int mds_orphan_add_link(struct mds_update_record *rec, struct inode *pending_dir = mds->mds_pending_dir->d_inode; struct inode *inode = dentry->d_inode; struct dentry *pending_child; - char fidname[lu_fid_NAMELEN]; + char fidname[LU_FID_NAMELEN]; int fidlen = 0, rc, mode; ENTRY; diff --git a/lustre/mds/mds_unlink_open.c b/lustre/mds/mds_unlink_open.c index 925967a..08d2510 100644 --- a/lustre/mds/mds_unlink_open.c +++ b/lustre/mds/mds_unlink_open.c @@ -179,7 +179,7 @@ int mds_cleanup_pending(struct obd_device *obd) struct inode *child_inode, *pending_dir = mds->mds_pending_dir->d_inode; struct l_linux_dirent *dirent, *n; struct list_head dentry_list; - char d_name[LL_FID_NAMELEN]; + char d_name[LU_FID_NAMELEN]; unsigned long inum; int i = 0, rc = 0, item = 0, namlen; ENTRY;