From: Liu Xuezhao Date: Fri, 22 Mar 2013 15:07:59 +0000 (-0500) Subject: LU-1330 obdclass: splits server-side object stack from client X-Git-Tag: 2.3.64~81 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=16e0fe6eab3e54aa7beddb75bf7dae05645408e9;hp=783de3e99d0a2185d26bc67a9ca852b08a760cf6 LU-1330 obdclass: splits server-side object stack from client 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 Signed-off-by: John L. Hammond Change-Id: Ie3a3cd998ef7b2d7d1090673a7c2d8f1152ca976 Reviewed-on: http://review.whamcloud.com/2676 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Nathaniel Clark --- diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index f647b14..1d1387a 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -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 */ diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index fdd45bd..2d7c0df 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -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 */ diff --git a/lustre/include/linux/lustre_acl.h b/lustre/include/linux/lustre_acl.h index 58d67ba..f763512 100644 --- a/lustre/include/linux/lustre_acl.h +++ b/lustre/include/linux/lustre_acl.h @@ -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. diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index d3b2089..2475d01 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -38,14 +38,8 @@ #define __LUSTRE_LU_OBJECT_H #include - -/* - * struct lu_fid - */ #include - #include - #include 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. diff --git a/lustre/include/lustre_eacl.h b/lustre/include/lustre_eacl.h index d775fef..917e52c 100644 --- a/lustre/include/lustre_eacl.h +++ b/lustre/include/lustre_eacl.h @@ -52,10 +52,6 @@ #include -#include -#include -#include - 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 diff --git a/lustre/include/lustre_idmap.h b/lustre/include/lustre_idmap.h index 7f19dfd..b64a71b 100644 --- a/lustre/include/lustre_idmap.h +++ b/lustre/include/lustre_idmap.h @@ -47,7 +47,7 @@ * @{ */ -#include +#include #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); diff --git a/lustre/include/md_object.h b/lustre/include/md_object.h index 7f4f4ff..383831b 100644 --- a/lustre/include/md_object.h +++ b/lustre/include/md_object.h @@ -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)) diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index 6d41614..52e40b5 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -36,9 +36,6 @@ #ifndef LLITE_INTERNAL_H #define LLITE_INTERNAL_H - -#include - #include #include #include /* for s2sbi */ diff --git a/lustre/llite/llite_rmtacl.c b/lustre/llite/llite_rmtacl.c index db6ef1e..8eca4a3 100644 --- a/lustre/llite/llite_rmtacl.c +++ b/lustre/llite/llite_rmtacl.c @@ -45,6 +45,7 @@ #ifdef CONFIG_FS_POSIX_ACL #include +#include #include "llite_internal.h" static inline __u32 rce_hashfunc(uid_t id) diff --git a/lustre/llite/xattr.c b/lustre/llite/xattr.c index 24a89eb..f9e425d 100644 --- a/lustre/llite/xattr.c +++ b/lustre/llite/xattr.c @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include "llite_internal.h" diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index fd087a5..9f3dea4 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 80a7091..8ab38ac 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -50,7 +50,7 @@ /* fid_be_cpu(), fid_cpu_to_be(). */ #include #include - +#include #include #include #include diff --git a/lustre/mdd/mdd_permission.c b/lustre/mdd/mdd_permission.c index cea5d3b..d62d516 100644 --- a/lustre/mdd/mdd_permission.c +++ b/lustre/mdd/mdd_permission.c @@ -47,7 +47,7 @@ #include #include #include - +#include #include "mdd_internal.h" #ifdef CONFIG_FS_POSIX_ACL diff --git a/lustre/obdclass/Makefile.in b/lustre/obdclass/Makefile.in index 053a725..c3e1507 100644 --- a/lustre/obdclass/Makefile.in +++ b/lustre/obdclass/Makefile.in @@ -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) diff --git a/lustre/obdclass/acl.c b/lustre/obdclass/acl.c index 7b0ffcc..b16289c 100644 --- a/lustre/obdclass/acl.c +++ b/lustre/obdclass/acl.c @@ -41,10 +41,14 @@ */ #define DEBUG_SUBSYSTEM S_SEC - +#include #include #include #include +#ifdef HAVE_SERVER_SUPPORT +# include +# include +#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) diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 3470ba6..c72a189 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -48,6 +48,11 @@ #include #include #include +#include +#ifdef HAVE_SERVER_SUPPORT +# include +# include +#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(); diff --git a/lustre/obdclass/idmap.c b/lustre/obdclass/idmap.c index e5cf37d..eb31028 100644 --- a/lustre/obdclass/idmap.c +++ b/lustre/obdclass/idmap.c @@ -43,6 +43,7 @@ #define DEBUG_SUBSYSTEM S_SEC #include +#include #include #define lustre_get_group_info(group_info) do { \ diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 38f29c0..a77898c 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -57,6 +57,7 @@ #include #include #include +#include #include 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 index 0000000..cfa7a56 --- /dev/null +++ b/lustre/obdclass/lu_ucred.c @@ -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 + */ + +#define DEBUG_SUBSYSTEM S_CLASS + +#include +#include +#include +#include + +/* 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); +}