Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Tue, 4 Apr 2006 08:27:04 +0000 (08:27 +0000)
committerwangdi <wangdi>
Tue, 4 Apr 2006 08:27:04 +0000 (08:27 +0000)
1.move share structure to mdd
2.some minor fixes

lustre/include/linux/lvfs.h
lustre/include/linux/lvfs_linux.h
lustre/include/linux/md_object.h
lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mds/mds_fs.c
lustre/mds/mds_open.c
lustre/mds/mds_reint.c
lustre/mds/mds_unlink_open.c

index a6fc13d..76a5569 100644 (file)
@@ -27,7 +27,7 @@
 #include <libcfs/kp30.h>
 #include <linux/lustre_ucache.h>
 
-#define lu_fid_NAMELEN (16 + 1 + 8 + 1)
+#define LU_FID_NAMELEN (16 + 1 + 8 + 1)
 
 #if defined __KERNEL__
 #include <linux/lustre_compat25.h>
index 7c31b31..d455307 100644 (file)
@@ -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;
index 146a01d..223763f 100644 (file)
@@ -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 {
index 1de72da..c0828f0 100644 (file)
@@ -35,6 +35,7 @@
 #include <linux/obd_support.h>
 
 #include <linux/lu_object.h>
+#include <linux/md_object.h>
 
 #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);
index e9ba65d..b52b44a 100644 (file)
@@ -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
index c277e94..4fb2949 100644 (file)
@@ -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;
index 4a00898..3d98bc2 100644 (file)
@@ -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;
index ab46538..bc65e86 100644 (file)
@@ -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;
 
index 925967a..08d2510 100644 (file)
@@ -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;