Whamcloud - gitweb
LU-1330 obdclass: splits server-side object stack from client
authorLiu Xuezhao <xuezhao.liu@emc.com>
Fri, 22 Mar 2013 15:07:59 +0000 (10:07 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 26 Mar 2013 05:01:52 +0000 (01:01 -0400)
1. removes client-side dependencies of server object stack:
md_object.h/md_local_object.c, and dt_object.h/dt_object.c.
2. removes client-side dependencies of lustre_idmap.h/idmap.c
3. splits some server-side acl handlings

Signed-off-by: Liu Xuezhao <xuezhao.liu@emc.com>
Signed-off-by: John L. Hammond <john.hammond@intel.com>
Change-Id: Ie3a3cd998ef7b2d7d1090673a7c2d8f1152ca976
Reviewed-on: http://review.whamcloud.com/2676
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
19 files changed:
lustre/include/cl_object.h
lustre/include/dt_object.h
lustre/include/linux/lustre_acl.h
lustre/include/lu_object.h
lustre/include/lustre_eacl.h
lustre/include/lustre_idmap.h
lustre/include/md_object.h
lustre/llite/llite_internal.h
lustre/llite/llite_rmtacl.c
lustre/llite/xattr.c
lustre/mdc/mdc_request.c
lustre/mdd/mdd_object.c
lustre/mdd/mdd_permission.c
lustre/obdclass/Makefile.in
lustre/obdclass/acl.c
lustre/obdclass/class_obd.c
lustre/obdclass/idmap.c
lustre/obdclass/lu_object.c
lustre/obdclass/lu_ucred.c [new file with mode: 0644]

index f647b14..1d1387a 100644 (file)
@@ -3277,4 +3277,7 @@ struct cl_device *cl_type_setup(const struct lu_env *env, struct lu_site *site,
                                 struct lu_device *next);
 /** @} clio */
 
+int cl_global_init(void);
+void cl_global_fini(void);
+
 #endif /* _LINUX_CL_OBJECT_H */
index fdd45bd..2d7c0df 100644 (file)
@@ -1474,4 +1474,7 @@ static inline struct dt_thread_info *dt_info(const struct lu_env *env)
        return dti;
 }
 
+int dt_global_init(void);
+void dt_global_fini(void);
+
 #endif /* __LUSTRE_DT_OBJECT_H */
index 58d67ba..f763512 100644 (file)
@@ -34,7 +34,7 @@
  * This file is part of Lustre, http://www.lustre.org/
  * Lustre is a trademark of Sun Microsystems, Inc.
  *
- * lustre/lustre/include/lustre_idmap.h
+ * lustre/lustre/include/lustre_acl.h
  *
  * MDS data structures.
  * See also lustre_idl.h for wire formats of requests.
index d3b2089..2475d01 100644 (file)
 #define __LUSTRE_LU_OBJECT_H
 
 #include <stdarg.h>
-
-/*
- * struct lu_fid
- */
 #include <libcfs/libcfs.h>
-
 #include <lustre/lustre_idl.h>
-
 #include <lu_ref.h>
 
 struct seq_file;
@@ -398,6 +392,11 @@ struct lu_device_type_operations {
         void (*ldto_stop)(struct lu_device_type *t);
 };
 
+static inline int lu_device_is_md(const struct lu_device *d)
+{
+       return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_MD);
+}
+
 /**
  * Flags for the object layers.
  */
@@ -1278,26 +1277,6 @@ int  lu_env_refill_by_tags(struct lu_env *env, __u32 ctags, __u32 stags);
 
 /** @} lu_context */
 
-struct lu_ucred {
-       __u32               uc_valid;
-       __u32               uc_o_uid;
-       __u32               uc_o_gid;
-       __u32               uc_o_fsuid;
-       __u32               uc_o_fsgid;
-       __u32               uc_uid;
-       __u32               uc_gid;
-       __u32               uc_fsuid;
-       __u32               uc_fsgid;
-       __u32               uc_suppgids[2];
-       cfs_cap_t           uc_cap;
-       __u32               uc_umask;
-       cfs_group_info_t   *uc_ginfo;
-       struct md_identity *uc_identity;
-};
-struct lu_ucred *lu_ucred(const struct lu_env *env);
-struct lu_ucred *lu_ucred_check(const struct lu_env *env);
-struct lu_ucred *lu_ucred_assert(const struct lu_env *env);
-
 /**
  * Output site statistical counters into a buffer. Suitable for
  * ll_rd_*()-style functions.
index d775fef..917e52c 100644 (file)
 
 #include <linux/posix_acl_xattr.h>
 
-#include <lustre_idmap.h>
-#include <md_object.h>
-#include <lu_object.h>
-
 typedef struct {
         __u16                   e_tag;
         __u16                   e_perm;
@@ -74,6 +70,11 @@ typedef struct {
 #define CFS_ACL_XATTR_COUNT(size, prefix) \
         (((size) - sizeof(prefix ## _header)) / sizeof(prefix ## _entry))
 
+#ifdef HAVE_SERVER_SUPPORT
+struct lu_ucred;
+struct lu_attr;
+struct lustre_idmap_table;
+
 extern int lustre_posix_acl_permission(struct lu_ucred *mu, struct lu_attr *la,
                                       int want, posix_acl_xattr_entry *entry,
                                       int count);
@@ -84,22 +85,25 @@ extern int lustre_posix_acl_create_masq(posix_acl_xattr_entry *entry,
 extern int lustre_posix_acl_equiv_mode(posix_acl_xattr_entry *entry, mode_t *mode_p,
                                       int count);
 
-extern ext_acl_xattr_header *
-lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size);
-extern int
-lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size,
-                              posix_acl_xattr_header **out);
 extern int
 lustre_posix_acl_xattr_id2client(struct lu_ucred *mu,
                                 struct lustre_idmap_table *t,
                                 posix_acl_xattr_header *header,
                                 int size, int flags);
-extern void
-lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size);
+
 extern int
 lustre_ext_acl_xattr_id2server(struct lu_ucred *mu,
                               struct lustre_idmap_table *t,
                               ext_acl_xattr_header *header);
+#endif /* HAVE_SERVER_SUPPORT */
+
+extern ext_acl_xattr_header *
+lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size);
+extern int
+lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, int size,
+                             posix_acl_xattr_header **out);
+extern void
+lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size);
 extern void
 lustre_ext_acl_xattr_free(ext_acl_xattr_header *header);
 extern int
index 7f19dfd..b64a71b 100644 (file)
@@ -47,7 +47,7 @@
  * @{
  */
 
-#include <md_object.h>
+#include <libcfs/libcfs.h>
 
 #define CFS_NGROUPS_PER_BLOCK   ((int)(CFS_PAGE_SIZE / sizeof(gid_t)))
 
@@ -78,6 +78,8 @@ struct lustre_idmap_table {
        cfs_list_t      lit_idmaps[CFS_IDMAP_N_HASHES][CFS_IDMAP_HASHSIZE];
 };
 
+struct lu_ucred;
+
 extern void lustre_groups_from_list(cfs_group_info_t *ginfo, gid_t *glist);
 extern void lustre_groups_sort(cfs_group_info_t *group_info);
 extern int lustre_in_group_p(struct lu_ucred *mu, gid_t grp);
index 7f4f4ff..383831b 100644 (file)
@@ -480,11 +480,6 @@ struct seq_server_site {
        struct lu_client_seq *ss_client_seq;
 };
 
-static inline int lu_device_is_md(const struct lu_device *d)
-{
-        return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_MD);
-}
-
 static inline struct md_device *lu2md_dev(const struct lu_device *d)
 {
         LASSERT(IS_ERR(d) || lu_device_is_md(d));
@@ -904,10 +899,40 @@ int llo_local_objects_setup(const struct lu_env *env,
                              struct md_device * md,
                              struct dt_device * dt);
 
+int llo_global_init(void);
+void llo_global_fini(void);
+
 int lustre_buf2som(void *buf, int rc, struct md_som_data *msd);
 int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh);
 void lustre_hsm2buf(void *buf, struct md_hsm *mh);
 
+struct lu_ucred {
+       __u32               uc_valid;
+       __u32               uc_o_uid;
+       __u32               uc_o_gid;
+       __u32               uc_o_fsuid;
+       __u32               uc_o_fsgid;
+       __u32               uc_uid;
+       __u32               uc_gid;
+       __u32               uc_fsuid;
+       __u32               uc_fsgid;
+       __u32               uc_suppgids[2];
+       cfs_cap_t           uc_cap;
+       __u32               uc_umask;
+       cfs_group_info_t   *uc_ginfo;
+       struct md_identity *uc_identity;
+};
+
+struct lu_ucred *lu_ucred(const struct lu_env *env);
+
+struct lu_ucred *lu_ucred_check(const struct lu_env *env);
+
+struct lu_ucred *lu_ucred_assert(const struct lu_env *env);
+
+int lu_ucred_global_init(void);
+
+void lu_ucred_global_fini(void);
+
 #define md_cap_t(x) (x)
 
 #define MD_CAP_TO_MASK(x) (1 << (x))
index 6d41614..52e40b5 100644 (file)
@@ -36,9 +36,6 @@
 
 #ifndef LLITE_INTERNAL_H
 #define LLITE_INTERNAL_H
-
-#include <lustre_acl.h>
-
 #include <lustre_debug.h>
 #include <lustre_ver.h>
 #include <lustre_disk.h>  /* for s2sbi */
index db6ef1e..8eca4a3 100644 (file)
@@ -45,6 +45,7 @@
 #ifdef CONFIG_FS_POSIX_ACL
 
 #include <lustre_lite.h>
+#include <lustre_eacl.h>
 #include "llite_internal.h"
 
 static inline __u32 rce_hashfunc(uid_t id)
index 24a89eb..f9e425d 100644 (file)
@@ -47,7 +47,7 @@
 #include <lustre_lite.h>
 #include <lustre_dlm.h>
 #include <lustre_ver.h>
-#include <lustre_acl.h>
+#include <lustre_eacl.h>
 
 #include "llite_internal.h"
 
index fd087a5..9f3dea4 100644 (file)
@@ -48,7 +48,6 @@
 #include <lustre_acl.h>
 #include <obd_class.h>
 #include <lustre_fid.h>
-#include <md_object.h>
 #include <lprocfs_status.h>
 #include <lustre_param.h>
 #include <lustre_log.h>
index 80a7091..8ab38ac 100644 (file)
@@ -50,7 +50,7 @@
 /* fid_be_cpu(), fid_cpu_to_be(). */
 #include <lustre_fid.h>
 #include <obd_lov.h>
-
+#include <lustre_idmap.h>
 #include <lustre_param.h>
 #include <lustre_mds.h>
 #include <lustre/lustre_idl.h>
index cea5d3b..d62d516 100644 (file)
@@ -47,7 +47,7 @@
 #include <lustre_ver.h>
 #include <lprocfs_status.h>
 #include <lustre_mds.h>
-
+#include <lustre_idmap.h>
 #include "mdd_internal.h"
 
 #ifdef CONFIG_FS_POSIX_ACL
index 053a725..c3e1507 100644 (file)
@@ -17,6 +17,7 @@ obdclass-all-objs += lu_object.o dt_object.o capa.o
 obdclass-all-objs += cl_object.o cl_page.o cl_lock.o cl_io.o lu_ref.o
 obdclass-all-objs += acl.o idmap.o
 obdclass-all-objs += md_local_object.o md_attrs.o linkea.o
+obdclass-all-objs += lu_ucred.o
 
 obdclass-objs := $(obdclass-linux-objs) $(obdclass-all-objs)
 
index 7b0ffcc..b16289c 100644 (file)
  */
 
 #define DEBUG_SUBSYSTEM S_SEC
-
+#include <lu_object.h>
 #include <lustre_acl.h>
 #include <lustre_eacl.h>
 #include <obd_support.h>
+#ifdef HAVE_SERVER_SUPPORT
+# include <lustre_idmap.h>
+# include <md_object.h>
+#endif /* HAVE_SERVER_SUPPORT */
 
 #ifdef CONFIG_FS_POSIX_ACL
 
@@ -92,6 +96,7 @@ static inline void lustre_posix_acl_cpu_to_le(posix_acl_xattr_entry *d,
         d->e_id         = cpu_to_le32(s->e_id);
 }
 
+#ifdef HAVE_SERVER_SUPPORT
 /*
  * Check permission based on POSIX ACL.
  */
@@ -308,6 +313,136 @@ int lustre_posix_acl_create_masq(posix_acl_xattr_entry *entry, __u32 *pmode,
 }
 EXPORT_SYMBOL(lustre_posix_acl_create_masq);
 
+/*
+ * Convert server-side uid/gid in the posix ACL items to the client-side ones.
+ * convert rule:
+ * @CFS_IC_NOTHING
+ *  nothing to be converted.
+ * @CFS_IC_ALL
+ *  mapped ids are converted to client-side ones,
+ *  unmapped ones are converted to "nobody".
+ * @CFS_IC_MAPPED
+ *  only mapped ids are converted to "nobody".
+ * @CFS_IC_UNMAPPED
+ *  only unmapped ids are converted to "nobody".
+ */
+int lustre_posix_acl_xattr_id2client(struct lu_ucred *mu,
+                                    struct lustre_idmap_table *t,
+                                    posix_acl_xattr_header *header,
+                                    int size, int flags)
+{
+       int count, i;
+       __u32 id;
+       ENTRY;
+
+       if (unlikely(size < 0))
+               RETURN(-EINVAL);
+       else if (!size)
+               RETURN(0);
+
+       if (unlikely(flags == CFS_IC_NOTHING))
+               RETURN(0);
+
+       count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr);
+       for (i = 0; i < count; i++) {
+               id = le32_to_cpu(header->a_entries[i].e_id);
+               switch (le16_to_cpu(header->a_entries[i].e_tag)) {
+               case ACL_USER_OBJ:
+               case ACL_GROUP_OBJ:
+               case ACL_MASK:
+               case ACL_OTHER:
+                       if (id != ACL_UNDEFINED_ID)
+                               RETURN(-EIO);
+                       break;
+               case ACL_USER:
+                       id = lustre_idmap_lookup_uid(mu, t, 1, id);
+                       if (flags == CFS_IC_ALL) {
+                               if (id == CFS_IDMAP_NOTFOUND)
+                                       id = NOBODY_UID;
+                               header->a_entries[i].e_id = cpu_to_le32(id);
+                       } else if (flags == CFS_IC_MAPPED) {
+                               if (id != CFS_IDMAP_NOTFOUND)
+                                       header->a_entries[i].e_id =
+                                               cpu_to_le32(NOBODY_UID);
+                       } else if (flags == CFS_IC_UNMAPPED) {
+                               if (id == CFS_IDMAP_NOTFOUND)
+                                       header->a_entries[i].e_id =
+                                               cpu_to_le32(NOBODY_UID);
+                       }
+                       break;
+               case ACL_GROUP:
+                       id = lustre_idmap_lookup_gid(mu, t, 1, id);
+                       if (flags == CFS_IC_ALL) {
+                               if (id == CFS_IDMAP_NOTFOUND)
+                                       id = NOBODY_GID;
+                               header->a_entries[i].e_id = cpu_to_le32(id);
+                       } else if (flags == CFS_IC_MAPPED) {
+                               if (id != CFS_IDMAP_NOTFOUND)
+                                       header->a_entries[i].e_id =
+                                               cpu_to_le32(NOBODY_GID);
+                       } else if (flags == CFS_IC_UNMAPPED) {
+                               if (id == CFS_IDMAP_NOTFOUND)
+                                       header->a_entries[i].e_id =
+                                               cpu_to_le32(NOBODY_GID);
+                       }
+                       break;
+               default:
+                       RETURN(-EIO);
+               }
+       }
+
+       RETURN(0);
+}
+EXPORT_SYMBOL(lustre_posix_acl_xattr_id2client);
+
+/*
+ * Converts client-side uid/gid in the extended ACL items to server-side ones.
+ * convert rule:
+ *  mapped ids are converted to server-side ones,
+ *  unmapped ones cause "EPERM" error.
+ */
+int lustre_ext_acl_xattr_id2server(struct lu_ucred *mu,
+                                  struct lustre_idmap_table *t,
+                                  ext_acl_xattr_header *header)
+{
+       int i, count = le32_to_cpu(header->a_count);
+       __u32 id;
+       ENTRY;
+
+       for (i = 0; i < count; i++) {
+               id = le32_to_cpu(header->a_entries[i].e_id);
+               switch (le16_to_cpu(header->a_entries[i].e_tag)) {
+               case ACL_USER_OBJ:
+               case ACL_GROUP_OBJ:
+               case ACL_MASK:
+               case ACL_OTHER:
+                       if (id != ACL_UNDEFINED_ID)
+                               RETURN(-EIO);
+                       break;
+               case ACL_USER:
+                       id = lustre_idmap_lookup_uid(mu, t, 0, id);
+                       if (id == CFS_IDMAP_NOTFOUND)
+                               RETURN(-EPERM);
+                       else
+                               header->a_entries[i].e_id = cpu_to_le32(id);
+                       break;
+               case ACL_GROUP:
+                       id = lustre_idmap_lookup_gid(mu, t, 0, id);
+                       if (id == CFS_IDMAP_NOTFOUND)
+                               RETURN(-EPERM);
+                       else
+                               header->a_entries[i].e_id = cpu_to_le32(id);
+                       break;
+               default:
+                       RETURN(-EIO);
+               }
+       }
+
+       RETURN(0);
+}
+EXPORT_SYMBOL(lustre_ext_acl_xattr_id2server);
+#endif /* HAVE_SERVER_SUPPORT */
+
 /* if "new_count == 0", then "new = {a_version, NULL}", NOT NULL. */
 static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header,
                                                int old_count, int new_count)
@@ -455,87 +590,6 @@ _out:
 EXPORT_SYMBOL(lustre_posix_acl_xattr_filter);
 
 /*
- * Convert server-side uid/gid in the posix ACL items to the client-side ones.
- * convert rule:
- * @CFS_IC_NOTHING
- *  nothing to be converted.
- * @CFS_IC_ALL
- *  mapped ids are converted to client-side ones,
- *  unmapped ones are converted to "nobody".
- * @CFS_IC_MAPPED
- *  only mapped ids are converted to "nobody".
- * @CFS_IC_UNMAPPED
- *  only unmapped ids are converted to "nobody".
- */
-int lustre_posix_acl_xattr_id2client(struct lu_ucred *mu,
-                                    struct lustre_idmap_table *t,
-                                    posix_acl_xattr_header *header,
-                                    int size, int flags)
-{
-        int count, i;
-        __u32 id;
-        ENTRY;
-
-        if (unlikely(size < 0))
-                RETURN(-EINVAL);
-        else if (!size)
-                RETURN(0);
-
-        if (unlikely(flags == CFS_IC_NOTHING))
-                RETURN(0);
-
-        count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr);
-        for (i = 0; i < count; i++) {
-                id = le32_to_cpu(header->a_entries[i].e_id);
-                switch (le16_to_cpu(header->a_entries[i].e_tag)) {
-                case ACL_USER_OBJ:
-                case ACL_GROUP_OBJ:
-                case ACL_MASK:
-                case ACL_OTHER:
-                        if (id != ACL_UNDEFINED_ID)
-                                RETURN(-EIO);
-                        break;
-                case ACL_USER:
-                        id = lustre_idmap_lookup_uid(mu, t, 1, id);
-                        if (flags == CFS_IC_ALL) {
-                                if (id == CFS_IDMAP_NOTFOUND)
-                                        id = NOBODY_UID;
-                                header->a_entries[i].e_id = cpu_to_le32(id);
-                        } else if (flags == CFS_IC_MAPPED) {
-                                if (id != CFS_IDMAP_NOTFOUND)
-                                        header->a_entries[i].e_id =
-                                                        cpu_to_le32(NOBODY_UID);
-                        } else if (flags == CFS_IC_UNMAPPED) {
-                                if (id == CFS_IDMAP_NOTFOUND)
-                                        header->a_entries[i].e_id =
-                                                        cpu_to_le32(NOBODY_UID);
-                        }
-                        break;
-                case ACL_GROUP:
-                        id = lustre_idmap_lookup_gid(mu, t, 1, id);
-                        if (flags == CFS_IC_ALL) {
-                                if (id == CFS_IDMAP_NOTFOUND)
-                                        id = NOBODY_GID;
-                                header->a_entries[i].e_id = cpu_to_le32(id);
-                        } else if (flags == CFS_IC_MAPPED) {
-                                if (id != CFS_IDMAP_NOTFOUND)
-                                        header->a_entries[i].e_id =
-                                                        cpu_to_le32(NOBODY_GID);
-                        } else if (flags == CFS_IC_UNMAPPED) {
-                                if (id == CFS_IDMAP_NOTFOUND)
-                                        header->a_entries[i].e_id =
-                                                        cpu_to_le32(NOBODY_GID);
-                        }
-                        break;
-                 default:
-                        RETURN(-EIO);
-                }
-        }
-    RETURN(0);
-}
-EXPORT_SYMBOL(lustre_posix_acl_xattr_id2client);
-
-/*
  * Release the posix ACL space.
  */
 void lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size)
@@ -545,53 +599,6 @@ void lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size)
 EXPORT_SYMBOL(lustre_posix_acl_xattr_free);
 
 /*
- * Converts client-side uid/gid in the extended ACL items to server-side ones.
- * convert rule:
- *  mapped ids are converted to server-side ones,
- *  unmapped ones cause "EPERM" error.
- */
-int lustre_ext_acl_xattr_id2server(struct lu_ucred *mu,
-                                  struct lustre_idmap_table *t,
-                                  ext_acl_xattr_header *header)
-
-{
-        int i, count = le32_to_cpu(header->a_count);
-        __u32 id;
-        ENTRY;
-
-        for (i = 0; i < count; i++) {
-                id = le32_to_cpu(header->a_entries[i].e_id);
-                switch (le16_to_cpu(header->a_entries[i].e_tag)) {
-                case ACL_USER_OBJ:
-                case ACL_GROUP_OBJ:
-                case ACL_MASK:
-                case ACL_OTHER:
-                        if (id != ACL_UNDEFINED_ID)
-                                RETURN(-EIO);
-                        break;
-                case ACL_USER:
-                        id = lustre_idmap_lookup_uid(mu, t, 0, id);
-                        if (id == CFS_IDMAP_NOTFOUND)
-                                RETURN(-EPERM);
-                        else
-                                header->a_entries[i].e_id = cpu_to_le32(id);
-                        break;
-                case ACL_GROUP:
-                        id = lustre_idmap_lookup_gid(mu, t, 0, id);
-                        if (id == CFS_IDMAP_NOTFOUND)
-                                RETURN(-EPERM);
-                        else
-                                header->a_entries[i].e_id = cpu_to_le32(id);
-                        break;
-                default:
-                        RETURN(-EIO);
-                }
-        }
-        RETURN(0);
-}
-EXPORT_SYMBOL(lustre_ext_acl_xattr_id2server);
-
-/*
  * Release the extended ACL space.
  */
 void lustre_ext_acl_xattr_free(ext_acl_xattr_header *header)
index 3470ba6..c72a189 100644 (file)
 #include <lprocfs_status.h>
 #include <lustre/lustre_build_version.h>
 #include <libcfs/list.h>
+#include <cl_object.h>
+#ifdef HAVE_SERVER_SUPPORT
+# include <dt_object.h>
+# include <md_object.h>
+#endif /* HAVE_SERVER_SUPPORT */
 #include "llog_internal.h"
 
 #ifndef __KERNEL__
@@ -601,6 +606,24 @@ int init_obdclass(void)
         if (err)
                 return err;
 
+       err = cl_global_init();
+       if (err != 0)
+               return err;
+
+#if defined(__KERNEL__) && defined(HAVE_SERVER_SUPPORT)
+       err = dt_global_init();
+       if (err != 0)
+               return err;
+
+       err = lu_ucred_global_init();
+       if (err != 0)
+               return err;
+
+       err = llo_global_init();
+       if (err != 0)
+               return err;
+#endif
+
        err = llog_info_init();
        if (err)
                return err;
@@ -678,6 +701,12 @@ static void cleanup_obdclass(void)
                 }
         }
        llog_info_fini();
+#ifdef HAVE_SERVER_SUPPORT
+       llo_global_fini();
+       lu_ucred_global_fini();
+       dt_global_fini();
+#endif
+       cl_global_fini();
         lu_global_fini();
 
         obd_cleanup_caches();
index e5cf37d..eb31028 100644 (file)
@@ -43,6 +43,7 @@
 #define DEBUG_SUBSYSTEM S_SEC
 
 #include <lustre_idmap.h>
+#include <md_object.h>
 #include <obd_support.h>
 
 #define lustre_get_group_info(group_info) do {             \
index 38f29c0..a77898c 100644 (file)
@@ -57,6 +57,7 @@
 #include <lustre_disk.h>
 #include <lustre_fid.h>
 #include <lu_object.h>
+#include <lu_ref.h>
 #include <libcfs/list.h>
 
 static void lu_object_free(const struct lu_env *env, struct lu_object *o);
@@ -1949,63 +1950,6 @@ static int lu_cache_shrink(int nr, unsigned int gfp_mask)
 }
 #endif /* __KERNEL__ */
 
-int  cl_global_init(void);
-void cl_global_fini(void);
-int  lu_ref_global_init(void);
-void lu_ref_global_fini(void);
-
-int dt_global_init(void);
-void dt_global_fini(void);
-
-int llo_global_init(void);
-void llo_global_fini(void);
-
-/* context key constructor/destructor: lu_ucred_key_init, lu_ucred_key_fini */
-LU_KEY_INIT_FINI(lu_ucred, struct lu_ucred);
-
-static struct lu_context_key lu_ucred_key = {
-       .lct_tags = LCT_SESSION,
-       .lct_init = lu_ucred_key_init,
-       .lct_fini = lu_ucred_key_fini
-};
-
-/**
- * Get ucred key if session exists and ucred key is allocated on it.
- * Return NULL otherwise.
- */
-struct lu_ucred *lu_ucred(const struct lu_env *env)
-{
-       if (!env->le_ses)
-               return NULL;
-       return lu_context_key_get(env->le_ses, &lu_ucred_key);
-}
-EXPORT_SYMBOL(lu_ucred);
-
-/**
- * Get ucred key and check if it is properly initialized.
- * Return NULL otherwise.
- */
-struct lu_ucred *lu_ucred_check(const struct lu_env *env)
-{
-       struct lu_ucred *uc = lu_ucred(env);
-       if (uc && uc->uc_valid != UCRED_OLD && uc->uc_valid != UCRED_NEW)
-               return NULL;
-       return uc;
-}
-EXPORT_SYMBOL(lu_ucred_check);
-
-/**
- * Get ucred key, which must exist and must be properly initialized.
- * Assert otherwise.
- */
-struct lu_ucred *lu_ucred_assert(const struct lu_env *env)
-{
-       struct lu_ucred *uc = lu_ucred_check(env);
-       LASSERT(uc != NULL);
-       return uc;
-}
-EXPORT_SYMBOL(lu_ucred_assert);
-
 /**
  * Initialization of global lu_* data.
  */
@@ -2024,11 +1968,6 @@ int lu_global_init(void)
         if (result != 0)
                 return result;
 
-       LU_CONTEXT_KEY_INIT(&lu_ucred_key);
-       result = lu_context_key_register(&lu_ucred_key);
-       if (result != 0)
-               return result;
-
         /*
          * At this level, we don't know what tags are needed, so allocate them
          * conservatively. This should not be too bad, because this
@@ -2049,17 +1988,6 @@ int lu_global_init(void)
         if (lu_site_shrinker == NULL)
                 return -ENOMEM;
 
-#ifdef __KERNEL__
-       result = dt_global_init();
-       if (result != 0)
-               return result;
-
-       result = llo_global_init();
-       if (result != 0)
-               return result;
-#endif
-        result = cl_global_init();
-
         return result;
 }
 
@@ -2068,18 +1996,12 @@ int lu_global_init(void)
  */
 void lu_global_fini(void)
 {
-        cl_global_fini();
-#ifdef __KERNEL__
-        llo_global_fini();
-        dt_global_fini();
-#endif
         if (lu_site_shrinker != NULL) {
                 cfs_remove_shrinker(lu_site_shrinker);
                 lu_site_shrinker = NULL;
         }
 
-        lu_context_key_degister(&lu_global_key);
-       lu_context_key_degister(&lu_ucred_key);
+       lu_context_key_degister(&lu_global_key);
 
         /*
          * Tear shrinker environment down _after_ de-registering
diff --git a/lustre/obdclass/lu_ucred.c b/lustre/obdclass/lu_ucred.c
new file mode 100644 (file)
index 0000000..cfa7a56
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program 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 GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2012, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/obdclass/lu_object.c
+ *
+ * Lustre Object.
+ * These are the only exported functions, they provide some generic
+ * infrastructure for managing object devices
+ *
+ *   Author: Nikita Danilov <nikita.danilov@sun.com>
+ */
+
+#define DEBUG_SUBSYSTEM S_CLASS
+
+#include <libcfs/libcfs.h>
+#include <obd_support.h>
+#include <lu_object.h>
+#include <md_object.h>
+
+/* context key constructor/destructor: lu_ucred_key_init, lu_ucred_key_fini */
+LU_KEY_INIT_FINI(lu_ucred, struct lu_ucred);
+
+static struct lu_context_key lu_ucred_key = {
+       .lct_tags = LCT_SESSION,
+       .lct_init = lu_ucred_key_init,
+       .lct_fini = lu_ucred_key_fini
+};
+
+/**
+ * Get ucred key if session exists and ucred key is allocated on it.
+ * Return NULL otherwise.
+ */
+struct lu_ucred *lu_ucred(const struct lu_env *env)
+{
+       if (!env->le_ses)
+               return NULL;
+       return lu_context_key_get(env->le_ses, &lu_ucred_key);
+}
+EXPORT_SYMBOL(lu_ucred);
+
+/**
+ * Get ucred key and check if it is properly initialized.
+ * Return NULL otherwise.
+ */
+struct lu_ucred *lu_ucred_check(const struct lu_env *env)
+{
+       struct lu_ucred *uc = lu_ucred(env);
+       if (uc && uc->uc_valid != UCRED_OLD && uc->uc_valid != UCRED_NEW)
+               return NULL;
+       return uc;
+}
+EXPORT_SYMBOL(lu_ucred_check);
+
+/**
+ * Get ucred key, which must exist and must be properly initialized.
+ * Assert otherwise.
+ */
+struct lu_ucred *lu_ucred_assert(const struct lu_env *env)
+{
+       struct lu_ucred *uc = lu_ucred_check(env);
+       LASSERT(uc != NULL);
+       return uc;
+}
+EXPORT_SYMBOL(lu_ucred_assert);
+
+int lu_ucred_global_init(void)
+{
+       LU_CONTEXT_KEY_INIT(&lu_ucred_key);
+       return lu_context_key_register(&lu_ucred_key);
+}
+
+void lu_ucred_global_fini(void)
+{
+       lu_context_key_degister(&lu_ucred_key);
+}