Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Fri, 14 Apr 2006 17:03:22 +0000 (17:03 +0000)
committerwangdi <wangdi>
Fri, 14 Apr 2006 17:03:22 +0000 (17:03 +0000)
update fld prototype

17 files changed:
lustre/Makefile.in
lustre/autoMakefile.am
lustre/autoconf/lustre-core.m4
lustre/fld/Makefile.in [new file with mode: 0644]
lustre/fld/autoMakefile.am [new file with mode: 0644]
lustre/fld/fld_internal.h
lustre/fld/fld_seq.c [new file with mode: 0644]
lustre/include/linux/lustre_idl.h
lustre/include/linux/md_object.h
lustre/include/linux/obd_support.h
lustre/mdc/mdc_lib.c
lustre/mdc/mdc_reint.c
lustre/mdc/mdc_request.c
lustre/mdd/mdd_handler.c
lustre/mdt/mdt_handler.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/ptlrpc_module.c

index 486ffd8..bddd8f3 100644 (file)
@@ -10,7 +10,7 @@ subdir-m += obdecho
 subdir-m += mgc
 
 @SERVER_TRUE@subdir-m += mds obdfilter ost mgs mdt cmm mdd osd
-@CLIENT_TRUE@subdir-m += mdc llite 
+@CLIENT_TRUE@subdir-m += mdc llite fld
 @QUOTA_TRUE@subdir-m += quota
 
 @INCLUDE_RULES@
index af8ba3c..1d54946 100644 (file)
@@ -10,7 +10,7 @@ ALWAYS_SUBDIRS := include fid lvfs obdclass ldlm ptlrpc osc lov obdecho \
 
 SERVER_SUBDIRS := ldiskfs obdfilter ost mds mgs mdt cmm mdd osd
 
-CLIENT_SUBDIRS := mdc llite
+CLIENT_SUBDIRS := mdc llite fld
 
 QUOTA_SUBDIRS := quota
 
index 0fbbd58..ad599f7 100644 (file)
@@ -695,6 +695,8 @@ lustre/cmm/Makefile
 lustre/cmm/autoMakefile
 lustre/mdd/Makefile
 lustre/mdd/autoMakefile
+lustre/fld/Makefile
+lustre/fld/autoMakefile
 lustre/obdclass/Makefile
 lustre/obdclass/autoMakefile
 lustre/obdecho/Makefile
diff --git a/lustre/fld/Makefile.in b/lustre/fld/Makefile.in
new file mode 100644 (file)
index 0000000..15fd645
--- /dev/null
@@ -0,0 +1,4 @@
+MODULES := fld 
+fld-objs := fld_seq.o
+
+@INCLUDE_RULES@
diff --git a/lustre/fld/autoMakefile.am b/lustre/fld/autoMakefile.am
new file mode 100644 (file)
index 0000000..5d8bf36
--- /dev/null
@@ -0,0 +1,11 @@
+# Copyright (C) 2001  Cluster File Systems, Inc.
+#
+# This code is issued under the GNU General Public License.
+# See the file COPYING in this distribution
+
+if MODULES
+modulefs_DATA = fld$(KMODEXT)
+endif
+
+MOSTLYCLEANFILES := @MOSTLYCLEANFILES@ 
+DIST_SOURCES := $(fld-objs:%.o=%.c) 
index 56a39f9..e83829f 100644 (file)
  *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  *   license text for more details.
  */
-#ifndef _MDD_INTERNAL_H
-#define _MDD_INTERNAL_H
+#ifndef _FLD_INTERNAL_H
+#define _FLD_INTERNAL_H
 
 struct fld_cache {
-        struct hlist_node fld_hash;
+        struct hlist_node fld_list;
         __u64             fld_mds;
         __u64             fld_seq;
-}
+};
 struct fld_cache_info {
-        struct hlist_head *fld_list;
+        struct hlist_head *fld_hash;
         spinlock_t fld_lock;
         int fld_hash_mask;
-}
-#define FLD_CREATE 0
-#define FLD_DELETE 1
-#define FLD_GET 3
+};
 #endif
diff --git a/lustre/fld/fld_seq.c b/lustre/fld/fld_seq.c
new file mode 100644 (file)
index 0000000..087c041
--- /dev/null
@@ -0,0 +1,283 @@
+/* -*- MODE: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
+ * vim:expandtab:shiftwidth=8:tabstop=8:
+ *
+ *  fld/fld.c 
+ *
+ *  Copyright (C) 2006 Cluster File Systems, Inc.
+ *
+ *   This file is part of the Lustre file system, http://www.lustre.org
+ *   Lustre is a trademark of Cluster File Systems, Inc.
+ *
+ *   You may have signed or agreed to another license before downloading
+ *   this software.  If so, you are bound by the terms and conditions
+ *   of that agreement, and the following does not apply to you.  See the
+ *   LICENSE file included with this distribution for more information.
+ *
+ *   If you did not agree to a different license, then this copy of Lustre
+ *   is open source software; you can redistribute it and/or modify it
+ *   under the terms of version 2 of the GNU General Public License as
+ *   published by the Free Software Foundation.
+ *
+ *   In either case, Lustre is distributed in the hope that it will be
+ *   useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ *   of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   license text for more details.
+ */
+#ifndef EXPORT_SYMTAB
+# define EXPORT_SYMTAB
+#endif
+#define DEBUG_SUBSYSTEM S_LLITE
+
+#include <linux/module.h>
+
+#include <linux/obd.h>
+#include <linux/obd_class.h>
+#include <linux/lustre_ver.h>
+#include <linux/obd_support.h>
+#include <linux/lprocfs_status.h>
+
+#include <linux/md_object.h>
+#include "fld_internal.h"
+/*XXX maybe these 2 items should go to sbi*/
+struct fld_cache_info *fld_cache = NULL;
+
+static int dht_mdt_hash(__u64 seq)
+{
+        return 0; 
+}
+struct obd_export* get_fld_exp(struct obd_export *exp, __u64 seq)
+{
+        int seq_mds;
+        seq_mds = dht_mdt_hash(seq);
+        CDEBUG(D_INFO, "mds number %d\n", seq_mds);
+       
+        /*get exp according to lu_seq*/
+        return exp;
+}
+enum {
+        FLD_HTABLE_BITS = 8,
+        FLD_HTABLE_SIZE = (1 << FLD_HTABLE_BITS),
+        FLD_HTABLE_MASK = FLD_HTABLE_SIZE - 1
+};
+
+static __u32 fld_hash(__u64 lu_seq)
+{
+        return lu_seq;
+}
+
+
+static int fld_cache_insert(struct fld_cache_info *fld_cache, __u64 lu_seq, 
+                            __u64 mds_num)
+{
+        struct fld_cache *fld;
+        struct hlist_head *bucket;
+        struct hlist_node *scan;
+        int rc = 0;
+        ENTRY;
+
+        bucket = fld_cache->fld_hash + (fld_hash(lu_seq) &
+                                        fld_cache->fld_hash_mask);
+
+        OBD_ALLOC_PTR(fld);
+        if (!fld)
+                RETURN(-ENOMEM);
+
+        INIT_HLIST_NODE(&fld->fld_list);
+        fld->fld_mds = mds_num;
+        fld->fld_seq = lu_seq; 
+
+        spin_lock(&fld_cache->fld_lock); 
+        hlist_for_each_entry(fld, scan, bucket, fld_list) {
+                if (fld->fld_seq == lu_seq) {
+                        spin_unlock(&fld_cache->fld_lock);
+                        GOTO(exit, rc = -EEXIST);
+                }
+        }
+        hlist_add_head(&fld->fld_list, bucket);
+        spin_unlock(&fld_cache->fld_lock);
+exit:
+        if (rc != 0) 
+                OBD_FREE(fld, sizeof(*fld));
+        RETURN(rc);
+}
+
+static struct fld_cache* 
+fld_cache_lookup(struct fld_cache_info *fld_cache, __u64 lu_seq)
+{
+        struct hlist_head *bucket;
+        struct hlist_node *scan;
+        struct fld_cache *fld;
+        ENTRY;
+
+        bucket = fld_cache->fld_hash + (fld_hash(lu_seq) &
+                                        fld_cache->fld_hash_mask);
+       
+        spin_lock(&fld_cache->fld_lock); 
+        hlist_for_each_entry(fld, scan, bucket, fld_list) {
+                if (fld->fld_seq == lu_seq) {
+                        spin_unlock(&fld_cache->fld_lock);
+                        RETURN(fld);
+                }
+        }
+        spin_unlock(&fld_cache->fld_lock);
+
+        RETURN(NULL);
+}
+
+static void fld_cache_delete(struct fld_cache_info *fld_cache, __u64 lu_seq)
+{
+        struct hlist_head *bucket;
+        struct hlist_node *scan;
+        struct fld_cache *fld;
+        ENTRY;
+
+        bucket = fld_cache->fld_hash + (fld_hash(lu_seq) &
+                                        fld_cache->fld_hash_mask);
+       
+        spin_lock(&fld_cache->fld_lock); 
+        hlist_for_each_entry(fld, scan, bucket, fld_list) {
+                if (fld->fld_seq == lu_seq) {
+                        hlist_del_init(&fld->fld_list);
+                        spin_unlock(&fld_cache->fld_lock);
+                        EXIT;
+                        return;
+                }
+        }
+        spin_unlock(&fld_cache->fld_lock);
+        return;
+}
+
+int fld_create(struct obd_export *exp, __u64 seq, __u64 mds_num)
+{
+        struct obd_export *fld_exp;
+        struct md_fld      md_fld; 
+        __u32 rc;
+        ENTRY;
+
+        fld_exp = get_fld_exp(exp, seq);
+        if (!fld_exp)
+                RETURN(-EINVAL);
+
+        md_fld.mf_seq = seq;
+        md_fld.mf_mds = mds_num;
+
+        rc = obd_set_info(fld_exp, strlen("fld_create"), "fld_create", 
+                          sizeof(struct md_fld), &md_fld);
+        fld_cache_insert(fld_cache, seq, mds_num);
+
+        RETURN(rc);
+}
+
+int fld_delete(struct obd_export *exp, __u64 seq, __u64 mds_num)
+{
+        struct obd_export *fld_exp;
+        struct md_fld      md_fld; 
+        __u32 rc;
+        
+        fld_cache_delete(fld_cache, seq);
+
+        fld_exp = get_fld_exp(exp, seq);
+        if (!fld_exp)
+                RETURN(-EINVAL);
+
+        md_fld.mf_seq = seq;
+        md_fld.mf_mds = mds_num;
+
+        rc = obd_set_info(fld_exp, strlen("fld_delete"), "fld_delete",
+                          sizeof(struct md_fld), &md_fld);
+
+        RETURN(rc);
+}
+
+int fld_get(struct obd_export *exp, __u64 lu_seq, __u64 *mds_num)
+{
+        struct obd_export *fld_exp;
+        struct md_fld      md_fld; 
+        int    vallen, rc;
+        fld_exp = get_fld_exp(exp, lu_seq);
+        if (!fld_exp);
+                RETURN(-EINVAL);
+
+        md_fld.mf_seq = lu_seq;
+       
+        vallen = sizeof(struct md_fld);
+        rc = obd_get_info(fld_exp, strlen("fld_delete"), "fld_delete",
+                          &vallen, &md_fld);
+
+        *mds_num = md_fld.mf_mds;
+        RETURN(rc);
+}
+
+/*lookup fid in the namespace of pfid according to the name*/
+int fld_lookup(struct obd_export *exp, __u64 lu_seq, __u64 *mds_num)
+{
+        struct fld_cache *fld; 
+        int rc;
+        ENTRY;
+
+        /*lookup it in the cache*/
+        fld = fld_cache_lookup(fld_cache, lu_seq);
+        if (fld != NULL) {
+                *mds_num = fld->fld_mds;
+                RETURN(0);
+        }
+        /*can not find it in the cache*/ 
+        rc = fld_get(exp, lu_seq, mds_num);
+        if (rc)
+                RETURN(rc); 
+       
+        rc = fld_cache_insert(fld_cache, lu_seq, *mds_num);
+        RETURN(rc);
+}
+
+static int fld_init(void)
+{
+        ENTRY;
+
+        OBD_ALLOC_PTR(fld_cache);
+        if (fld_cache == NULL)
+                RETURN(-ENOMEM);        
+       
+        /*init fld cache info*/
+        fld_cache->fld_hash_mask = FLD_HTABLE_MASK;
+        OBD_ALLOC(fld_cache->fld_hash, FLD_HTABLE_SIZE * 
+                                       sizeof fld_cache->fld_hash[0]);
+        spin_lock_init(&fld_cache->fld_lock);
+        
+        RETURN(0);
+}
+
+static int fld_fini(void)
+{
+        if (fld_cache != NULL) {
+                OBD_FREE(fld_cache->fld_hash, FLD_HTABLE_SIZE *
+                                              sizeof fld_cache->fld_hash[0]);
+                OBD_FREE_PTR(fld_cache);
+        }
+        return 0;        
+}
+
+static int __init fld_mod_init(void)
+{
+        fld_init();
+        return 0;
+}
+
+static void __exit fld_mod_exit(void)
+{
+        fld_fini();
+        return;
+}
+
+MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
+MODULE_DESCRIPTION("Lustre fld Prototype");
+MODULE_LICENSE("GPL");
+
+cfs_module(mdd, "0.0.2", fld_mod_init, fld_mod_exit);
index d91363b..961113a 100644 (file)
@@ -560,6 +560,7 @@ typedef enum {
         MDS_QUOTACTL     = 48,
         MDS_GETXATTR     = 49,
         MDS_SETXATTR     = 50,
+        MDS_GET_INFO     = 51,
         MDS_LAST_OPC
 } mds_cmd_t;
 
@@ -1072,6 +1073,11 @@ extern void lustre_swab_lmv_desc (struct lmv_desc *ld);
 extern void lustre_swab_cmm_desc (struct cmm_desc *ld);
 /*end adding MDT by huanghua@clusterfs.com*/
 
+struct md_fld {
+        __u64 mf_seq;
+        __u64 mf_mds;
+};
+extern void lustre_swab_md_fld (struct md_fld *mf);
 extern void lustre_swab_lov_desc (struct lov_desc *ld);
 
 /*
index 9abe2a9..0687893 100644 (file)
@@ -84,6 +84,12 @@ struct md_device_operations {
                             struct md_device *m, struct lu_fid *f);
         int (*mdo_statfs)(struct lu_context *ctx,
                           struct md_device *m, struct kstatfs *sfs);
+
+        int (*mdo_get_info)(struct lu_context *ctx, struct md_device *m, 
+                            __u32 keylen, void *key, __u32 *vallen, void *val);
+        
+        int (*mdo_set_info)(struct lu_context *ctx, struct md_device *m, 
+                            __u32 keylen, void *key, __u32 vallen, void *val);
 };
 
 struct md_device {
@@ -138,4 +144,5 @@ static inline void md_device_fini(struct md_device *md)
 {
        lu_device_fini(&md->md_lu_dev);
 }
+
 #endif /* _LINUX_MD_OBJECT_H */
index 55ab3a4..5c73460 100644 (file)
@@ -101,6 +101,8 @@ extern wait_queue_head_t obd_race_waitq;
 #define OBD_FAIL_MDS_SETXATTR_WRITE      0x134
 #define OBD_FAIL_MDS_SET_INFO_NET        0x135
 #define OBD_FAIL_MDS_SET_INFO_PACK       0x136
+#define OBD_FAIL_MDS_GET_INFO_NET        0x137
+#define OBD_FAIL_MDS_GET_INFO_PACK       0x138
 
 #define OBD_FAIL_OST                     0x200
 #define OBD_FAIL_OST_CONNECT_NET         0x201
index d216d2b..26e06d7 100644 (file)
@@ -74,18 +74,6 @@ void mdc_pack_req_body(struct ptlrpc_request *req, int offset,
         b->eadatasize = ea_size;
         mdc_pack_body(b);
 }
-
-#ifdef FLD_PROTO_TYPE
-void mdc_fld_pack(struct ptlrpc_request *req, int offset, __u64 mds_num, 
-                  __u64 seq_num, int op)
-{
-        struct mdt_body *b = lustre_msg_buf(req->rq_reqmsg, offset, sizeof(*b));
-
-        b->size = seq_num;
-        b->valid = mds_num;
-        b->fsuid = op; 
-}
-#endif
 /* packing of MDS records */
 void mdc_create_pack(struct ptlrpc_request *req, int offset,
                      struct mdc_op_data *op_data, const void *data, int datalen,
index 30934ce..9b1f7fa 100644 (file)
@@ -155,35 +155,6 @@ int mdc_create(struct obd_export *exp, struct mdc_op_data *op_data,
         RETURN(rc);
 }
 
-#ifdef FLD_PROTO_TYPE
-int mdc_fld_req(struct obd_export *exp, __u64 mds_num, __u64 seq_num, int op)
-{
-        struct obd_device *obd = exp->exp_obd;
-        struct ptlrpc_request *req;
-        int size[] = { sizeof(struct mdt_body)};
-        int rc, level, bufcount = 1;
-        ENTRY;
-
-        req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
-                              MDS_FLD_OP, bufcount, size, NULL);
-        if (req == NULL)
-                RETURN(-ENOMEM);
-
-        /* mdc_create_pack fills msg->bufs[1] with name
-         * and msg->bufs[2] with tgt, for symlinks or lov MD data */
-        mdc_fld_pack(req, MDS_REQ_REC_OFF, mds_num, seq_num, op);
-
-        size[0] = sizeof(struct mdt_body);
-        req->rq_replen = lustre_msg_size(1, size);
-
-        level = LUSTRE_IMP_FULL;
-        rc = mdc_reint(req, obd->u.cli.cl_rpc_lock, level);
-
-        ptlrpc_req_finished(req);
-        RETURN(rc);
-}
-#endif
-
 int mdc_unlink(struct obd_export *exp, struct mdc_op_data *data,
                struct ptlrpc_request **request)
 {
index 6c8812a..bf87f64 100644 (file)
@@ -38,6 +38,7 @@
 
 #include <linux/obd_class.h>
 #include <linux/lustre_mdc.h>
+#include <linux/md_object.h>
 #include <linux/lustre_acl.h>
 #include <linux/lustre_dlm.h>
 #include <linux/lprocfs_status.h>
@@ -850,7 +851,26 @@ int mdc_set_info(struct obd_export *exp, obd_count keylen,
                 ptlrpc_req_finished(req);
                 RETURN(rc);
         }
+        if (KEY_IS("fld_create") || KEY_IS("fld_delete")) {
+                struct ptlrpc_request *req;
+                int size[2] = {keylen, vallen};
+                char *bufs[2] = {key, val};
+                ENTRY;
 
+                req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, 
+                                      MDS_SET_INFO, 2, size, bufs);
+                if (req == NULL)
+                        RETURN(-ENOMEM);
+                
+                req->rq_replen = lustre_msg_size(0, NULL);
+                rc = ptlrpc_queue_wait(req);
+                if (rc)
+                        GOTO(out_req, rc);
+out_req:
+                ptlrpc_req_finished(req);
+                RETURN(rc);
+
+        }
         RETURN(rc);
 }
 
@@ -872,6 +892,34 @@ int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key,
                 *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize;
                 RETURN(0);
         }
+        if (KEY_IS("fld_get")) {
+                struct ptlrpc_request *req;
+                int size[2] = {keylen, *vallen};
+                char *bufs[2] = {key, val};
+                struct md_fld *reply;
+                ENTRY;
+
+                req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
+                                      MDS_GET_INFO, 2, size, bufs);
+                if (req == NULL)
+                        RETURN(-ENOMEM);
+                
+                req->rq_replen = lustre_msg_size(1, (int *)vallen);
+                rc = ptlrpc_queue_wait(req);
+                if (rc)
+                        GOTO(out_req, rc);
+
+                reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
+                                           lustre_swab_md_fld);
+                if (reply == NULL) {
+                        CERROR("Can't unpack %s\n", (char *)key);
+                        GOTO(out_req, rc = -EPROTO);
+                }
+                *((struct md_fld *)val) = *reply;
+out_req:
+                ptlrpc_req_finished(req);
+                RETURN(rc);
+        }
         RETURN(rc);
 }
 
index 4975055..8d0ca53 100644 (file)
@@ -239,7 +239,6 @@ mdd_object_destroy(struct lu_context *ctxt, struct md_object *obj)
 static void mdd_object_release(struct lu_context *ctxt, struct lu_object *o)
 {
         struct mdd_object *obj = mdd_obj(o);
-
         int rc;
         int nlink;
 
@@ -680,8 +679,134 @@ static int mdd_statfs(struct lu_context *ctx,
         RETURN(rc);
 }
 
-static struct md_device_operations mdd_ops = {
+/*XXX use linked list temp for fld in this prototype*/
+struct fld_list {
+        struct list_head fld_list;
+        spinlock_t       fld_lock;
+};
+struct fld_item{
+        struct list_head fld_list;
+        __u64 fld_seq;
+        __u64 fld_mds;
+};
+
+struct fld_list fld_list_head;
+
+static void mdd_fld_init(struct mdd_device *mdd)
+{
+        INIT_LIST_HEAD(&fld_list_head.fld_list);
+        spin_lock_init(&fld_list_head.fld_lock);
+}
+
+static void mdd_fld_fini(struct mdd_device *mdd)
+{
+        struct list_head *pos, *n;
+       
+        spin_lock(&fld_list_head.fld_lock);
+        list_for_each_safe(pos, n, &fld_list_head.fld_list) {
+                struct fld_item *fld = list_entry(pos, struct fld_item,
+                                                  fld_list);
+                list_del_init(&fld->fld_list);
+                OBD_FREE_PTR(fld);
+        }
+        spin_unlock(&fld_list_head.fld_lock); 
+}
+
+static int mdd_fld_create(struct mdd_device *mdd, __u64 seq_num, __u64 mds_num)
+{
+        struct fld_item *fld;
+        
+        OBD_ALLOC_PTR(fld);
+        fld->fld_seq = seq_num;
+        fld->fld_mds = mds_num;
+        INIT_LIST_HEAD(&fld->fld_list); 
+        spin_lock(&fld_list_head.fld_lock);
+        list_add_tail(&fld_list_head.fld_list, &fld->fld_list);
+        spin_unlock(&fld_list_head.fld_lock);
+        return 0;
+}
+
+static int mdd_fld_delete(struct mdd_device *mdd, __u64 seq_num, __u64 mds_num)
+{
+        struct list_head *pos, *n;
+        spin_lock(&fld_list_head.fld_lock);
+        list_for_each_safe(pos, n, &fld_list_head.fld_list) {
+                struct fld_item *fld = list_entry(pos, struct fld_item,
+                                                  fld_list);
+                if (fld->fld_seq == seq_num) {
+                        LASSERT(fld->fld_mds == mds_num);
+                        list_del_init(&fld->fld_list);
+                        OBD_FREE_PTR(fld);
+                        spin_unlock(&fld_list_head.fld_lock);
+                        RETURN(0);
+                }
+        }
+        spin_unlock(&fld_list_head.fld_lock);
+        RETURN(0);
+}
+
+static int mdd_fld_get(struct mdd_device *mdd, __u64 seq_num, __u64 *mds_num)
+{
+        struct list_head *pos, *n;
+       
+        spin_lock(&fld_list_head.fld_lock);
+        list_for_each_safe(pos, n, &fld_list_head.fld_list) {
+                struct fld_item *fld = list_entry(pos, struct fld_item,
+                                                  fld_list);
+                if (fld->fld_seq == seq_num) {
+                        *mds_num = fld->fld_mds;
+                        spin_unlock(&fld_list_head.fld_lock);
+                        RETURN(0);
+                }
+        }
+        spin_unlock(&fld_list_head.fld_lock);
+        return -ENOENT;
+}
+
+static int mdd_get_info(struct lu_context *ctx, struct md_device *m, 
+                        __u32 keylen, void *key, __u32 *vallen, void *val)
+{
+       struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
+        int rc;
+
+        ENTRY;
+        if (keylen >= strlen("fld_get") && 
+            memcmp(key, "fld_get", 7) == 0) {
+                struct md_fld *mf = val;
+                rc = mdd_fld_get(mdd, mf->mf_seq, &mf->mf_mds);
+                RETURN(rc);
+        } 
+        RETURN(-EINVAL);
+}
+
+static int mdd_set_info(struct lu_context *ctx, struct md_device *m, 
+                        __u32 keylen, void *key, __u32 vallen, void *val)
+{
+       struct mdd_device *mdd = lu2mdd_dev(&m->md_lu_dev);
+        int rc;
+        ENTRY;
+        
+        if (keylen >= strlen("fld_create") && 
+            memcmp(key, "fld_create", 10) == 0) {
+                struct md_fld *mf = val;
+                rc = mdd_fld_create(mdd, mf->mf_seq, mf->mf_mds);
+                RETURN(rc);
+        } 
+        
+        if (keylen >= strlen("fld_delete") && 
+            memcmp(key, "fld_delete", 10) == 0) {
+                struct md_fld *mf = val;
+                rc = mdd_fld_delete(mdd, mf->mf_seq, mf->mf_mds);
+                RETURN(rc);
+        } 
+
+        RETURN(-EINVAL);
+}
+
+struct md_device_operations mdd_ops = {
         .mdo_root_get   = mdd_root_get,
+        .mdo_get_info   = mdd_get_info,
+        .mdo_set_info   = mdd_set_info,
         .mdo_config     = mdd_config,
         .mdo_statfs     = mdd_statfs
 };
@@ -719,7 +844,7 @@ struct lu_device *mdd_device_alloc(struct lu_device_type *t,
                 l = mdd2lu_dev(m);
                l->ld_ops = &mdd_lu_ops;
                 m->mdd_md_dev.md_ops = &mdd_ops;
-
+                mdd_fld_init(m);
                 /* get next layer */
                 obd = class_name2obd(child);
                 if (obd && obd->obd_lu_dev) {
@@ -740,7 +865,8 @@ void mdd_device_free(struct lu_device *lu)
         struct mdd_device *m = lu2mdd_dev(lu);
 
         LASSERT(atomic_read(&lu->ld_ref) == 0);
-       md_device_fini(&m->mdd_md_dev);
+        mdd_fld_fini(m);       
+        md_device_fini(&m->mdd_md_dev);
 
         OBD_FREE_PTR(m);
 }
index 4e237c4..693983f 100644 (file)
@@ -222,6 +222,80 @@ static int mdt_getattr(struct mdt_thread_info *info,
         RETURN(result);
 }
 
+static int mdt_set_info(struct mdt_thread_info *info,
+                        struct ptlrpc_request *req, int offset)
+{
+        struct md_device *next  = info->mti_mdt->mdt_child;
+        char *key;
+        int keylen, rc = 0;
+        ENTRY;
+        
+        key = lustre_msg_buf(req->rq_reqmsg, 0, 1);
+        if (key == NULL) {
+                DEBUG_REQ(D_HA, req, "no set_info key");
+                RETURN(-EFAULT);
+        }
+        keylen = req->rq_reqmsg->buflens[0];
+       
+        if (((keylen >= strlen("fld_create") &&
+            memcmp(key, "fld_create", keylen) == 0)) || 
+            ((keylen >= strlen("fld_delete") &&
+            memcmp(key, "fld_delete", keylen) == 0))) {
+                struct md_fld mf, *p;
+                __u32 size = sizeof(struct md_fld);
+
+                rc = lustre_pack_reply(req, 0, NULL, NULL);
+                if (rc)
+                        RETURN(rc);
+                
+                p = lustre_swab_reqbuf(req, 1, sizeof(mf), lustre_swab_md_fld);
+                mf = *p;
+                rc = next->md_ops->mdo_get_info(&info->mti_ctxt, next, keylen, 
+                                                key, &size, &mf);
+                RETURN(rc); 
+        }
+
+        CDEBUG(D_IOCTL, "invalid key\n");
+        RETURN(-EINVAL);
+
+}
+
+static int mdt_get_info(struct mdt_thread_info *info,
+                        struct ptlrpc_request *req, int offset)
+{
+        struct md_device *next  = info->mti_mdt->mdt_child;
+        char *key;
+        int keylen, rc = 0;
+        ENTRY;
+        
+        key = lustre_msg_buf(req->rq_reqmsg, 0, 1);
+        if (key == NULL) {
+                DEBUG_REQ(D_HA, req, "no set_info key");
+                RETURN(-EFAULT);
+        }
+        keylen = req->rq_reqmsg->buflens[0];
+       
+        if (((keylen >= strlen("fld_get") &&
+            memcmp(key, "fld_get", keylen) == 0))) {
+                struct md_fld mf, *p, *reply;
+                int size = sizeof(*reply);
+               
+                rc = lustre_pack_reply(req, 1, &size, NULL);
+                if (rc)
+                        RETURN(rc);
+                p = lustre_swab_reqbuf(req, 1, sizeof(mf), lustre_swab_md_fld);
+                mf = *p;
+                rc = next->md_ops->mdo_get_info(&info->mti_ctxt, next, keylen, 
+                                                key, &size, &mf);
+                reply = lustre_msg_buf(req->rq_repmsg, 0, size);
+                *reply = mf;
+                RETURN(rc); 
+        }
+
+        CDEBUG(D_IOCTL, "invalid key\n");
+        RETURN(-EINVAL);
+}
+
 static struct lu_device_operations mdt_lu_ops;
 
 static int lu_device_is_mdt(struct lu_device *d)
@@ -315,12 +389,6 @@ static int mdt_sync(struct mdt_thread_info *info,
         return -EOPNOTSUPP;
 }
 
-static int mdt_set_info(struct mdt_thread_info *info,
-                        struct ptlrpc_request *req, int offset)
-{
-        return -EOPNOTSUPP;
-}
-
 static int mdt_handle_quotacheck(struct mdt_thread_info *info,
                                  struct ptlrpc_request *req, int offset)
 {
@@ -1417,6 +1485,7 @@ static struct mdt_handler mdt_mds_ops[] = {
         DEF_MDT_HNDL(0,            PIN,            mdt_pin),
         DEF_MDT_HNDL(HABEO_CORPUS, SYNC,           mdt_sync),
         DEF_MDT_HNDL(0,            SET_INFO,       mdt_set_info),
+        DEF_MDT_HNDL(0,            GET_INFO,       mdt_get_info),
         DEF_MDT_HNDL(0,            QUOTACHECK,     mdt_handle_quotacheck),
         DEF_MDT_HNDL(0,            QUOTACTL,       mdt_handle_quotactl)
 };
index 52ec205..ea358d3 100644 (file)
@@ -927,7 +927,11 @@ void lustre_swab_cmm_desc (struct cmm_desc *ld)
         /* uuid endian insensitive */
 }
 /*end adding MDT by huanghua@clusterfs.com*/
-
+void lustre_swab_md_fld (struct md_fld *mf)
+{
+        __swab64s(&mf->mf_seq);
+        __swab64s(&mf->mf_mds);
+}
 
 static void print_lum (struct lov_user_md *lum)
 {
index 1fddaaf..9cffa87 100644 (file)
@@ -217,6 +217,7 @@ EXPORT_SYMBOL(lustre_swab_ldlm_request);
 EXPORT_SYMBOL(lustre_swab_ldlm_reply);
 EXPORT_SYMBOL(lustre_swab_qdata);
 EXPORT_SYMBOL(lustre_swab_mgs_target_info);
+EXPORT_SYMBOL(lustre_swab_md_fld);
 
 /* recover.c */
 EXPORT_SYMBOL(ptlrpc_run_recovery_over_upcall);