* functionality of ->o_precleanup() and ->o_cleanup() they override. Hence,
* obd_precleanup() and obd_cleanup() call both lu_device and obd operations.
*/
-
-#define DECLARE_LU_VARS(ldt, d) \
- struct lu_device_type *ldt; \
- struct lu_device *d
-
static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)
{
int rc;
- DECLARE_LU_VARS(ldt, d);
+ struct lu_device_type *ldt = obd->obd_type->typ_lu;
+ struct lu_device *d;
+
ENTRY;
- ldt = obd->obd_type->typ_lu;
if (ldt != NULL) {
struct lu_context session_ctx;
struct lu_env env;
static inline int obd_precleanup(struct obd_device *obd)
{
int rc;
- DECLARE_LU_VARS(ldt, d);
+ struct lu_device_type *ldt = obd->obd_type->typ_lu;
+ struct lu_device *d = obd->obd_lu_dev;
+
ENTRY;
- OBD_CHECK_DEV(obd);
- ldt = obd->obd_type->typ_lu;
- d = obd->obd_lu_dev;
if (ldt != NULL && d != NULL) {
struct lu_env env;
static inline int obd_cleanup(struct obd_device *obd)
{
int rc;
- DECLARE_LU_VARS(ldt, d);
- ENTRY;
-
- OBD_CHECK_DEV(obd);
+ struct lu_device_type *ldt = obd->obd_type->typ_lu;
+ struct lu_device *d = obd->obd_lu_dev;
- ldt = obd->obd_type->typ_lu;
- d = obd->obd_lu_dev;
+ ENTRY;
if (ldt != NULL && d != NULL) {
struct lu_env env;
obd_process_config(struct obd_device *obd, int datalen, void *data)
{
int rc;
- DECLARE_LU_VARS(ldt, d);
- ENTRY;
+ struct lu_device_type *ldt = obd->obd_type->typ_lu;
+ struct lu_device *d = obd->obd_lu_dev;
- OBD_CHECK_DEV(obd);
+ ENTRY;
obd->obd_process_conf = 1;
- ldt = obd->obd_type->typ_lu;
- d = obd->obd_lu_dev;
if (ldt != NULL && d != NULL) {
struct lu_env env;
extern int obd_sysctl_init(void);
extern void obd_sysctl_clean(void);
-/* uuid.c */
typedef __u8 class_uuid_t[16];
-void class_uuid_unparse(class_uuid_t in, struct obd_uuid *out);
+static inline void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out)
+{
+ snprintf(out->uuid, sizeof(out->uuid), "%02x%02x%02x%02x-%02x%02x-"
+ "%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ uu[14], uu[15], uu[12], uu[13], uu[10], uu[11], uu[8], uu[9],
+ uu[6], uu[7], uu[4], uu[5], uu[2], uu[3], uu[0], uu[1]);
+}
/* lustre_peer.c */
int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index);
default: all
obdclass-all-objs := llog.o llog_cat.o llog_obd.o llog_swab.o llog_osd.o
-obdclass-all-objs += class_obd.o debug.o genops.o uuid.o llog_ioctl.o
+obdclass-all-objs += class_obd.o debug.o genops.o llog_ioctl.o
obdclass-all-objs += lprocfs_status.o lprocfs_counters.o
obdclass-all-objs += lustre_handles.o lustre_peer.o local_storage.o
obdclass-all-objs += statfs_pack.o obdo.o obd_config.o obd_mount.o
void *ce_debug;
};
+static void cl_env_inc(enum cache_stats_item item)
+{
#ifdef CONFIG_DEBUG_PAGESTATE_TRACKING
-#define CL_ENV_INC(counter) atomic_inc(&cl_env_stats.cs_stats[CS_##counter])
-
-#define CL_ENV_DEC(counter) do { \
- LASSERT(atomic_read(&cl_env_stats.cs_stats[CS_##counter]) > 0); \
- atomic_dec(&cl_env_stats.cs_stats[CS_##counter]); \
-} while (0)
-#else
-#define CL_ENV_INC(counter)
-#define CL_ENV_DEC(counter)
+ atomic_inc(&cl_env_stats.cs_stats[item]);
#endif
+}
+
+static void cl_env_dec(enum cache_stats_item item)
+{
+#ifdef CONFIG_DEBUG_PAGESTATE_TRACKING
+ LASSERT(atomic_read(&cl_env_stats.cs_stats[item]) > 0);
+ atomic_dec(&cl_env_stats.cs_stats[item]);
+#endif
+}
static void cl_env_init0(struct cl_env *cle, void *debug)
{
cle->ce_ref = 1;
cle->ce_debug = debug;
- CL_ENV_INC(busy);
+ cl_env_inc(CS_busy);
}
static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug)
OBD_SLAB_FREE_PTR(cle, cl_env_kmem);
env = ERR_PTR(rc);
} else {
- CL_ENV_INC(create);
- CL_ENV_INC(total);
+ cl_env_inc(CS_create);
+ cl_env_inc(CS_total);
}
} else
env = ERR_PTR(-ENOMEM);
static void cl_env_fini(struct cl_env *cle)
{
- CL_ENV_DEC(total);
- lu_context_fini(&cle->ce_lu.le_ctx);
- lu_context_fini(&cle->ce_ses);
- OBD_SLAB_FREE_PTR(cle, cl_env_kmem);
+ cl_env_dec(CS_total);
+ lu_context_fini(&cle->ce_lu.le_ctx);
+ lu_context_fini(&cle->ce_ses);
+ OBD_SLAB_FREE_PTR(cle, cl_env_kmem);
}
static struct lu_env *cl_env_obtain(void *debug)
if (--cle->ce_ref == 0) {
int cpu = get_cpu();
- CL_ENV_DEC(busy);
- cle->ce_debug = NULL;
- cl_env_exit(cle);
- /*
- * Don't bother to take a lock here.
- *
- * Return environment to the cache only when it was allocated
- * with the standard tags.
- */
+ cl_env_dec(CS_busy);
+ cle->ce_debug = NULL;
+ cl_env_exit(cle);
+ /*
+ * Don't bother to take a lock here.
+ *
+ * Return environment to the cache only when it was allocated
+ * with the standard tags.
+ */
if (cl_envs[cpu].cec_count < cl_envs_cached_max &&
(env->le_ctx.lc_tags & ~LCT_HAS_EXIT) == LCT_CL_THREAD &&
(env->le_ses->lc_tags & ~LCT_HAS_EXIT) == LCT_SESSION) {
cle->ce_ref--;
LASSERT(cle->ce_ref == 0);
- CL_ENV_DEC(busy);
+ cl_env_dec(CS_busy);
cle->ce_debug = NULL;
put_cpu();
#endif /* !CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK */
/* Disable page statistic by default due to huge performance penalty. */
+static void cs_page_inc(const struct cl_object *obj,
+ enum cache_stats_item item)
+{
#ifdef CONFIG_DEBUG_PAGESTATE_TRACKING
-#define CS_PAGE_INC(o, item) \
- atomic_inc(&cl_object_site(o)->cs_pages.cs_stats[CS_##item])
-#define CS_PAGE_DEC(o, item) \
- atomic_dec(&cl_object_site(o)->cs_pages.cs_stats[CS_##item])
-#define CS_PAGESTATE_INC(o, state) \
- atomic_inc(&cl_object_site(o)->cs_pages_state[state])
-#define CS_PAGESTATE_DEC(o, state) \
- atomic_dec(&cl_object_site(o)->cs_pages_state[state])
-#else
-#define CS_PAGE_INC(o, item)
-#define CS_PAGE_DEC(o, item)
-#define CS_PAGESTATE_INC(o, state)
-#define CS_PAGESTATE_DEC(o, state)
+ atomic_inc(&cl_object_site(obj)->cs_pages.cs_stats[item]);
#endif
+}
+
+static void cs_page_dec(const struct cl_object *obj,
+ enum cache_stats_item item)
+{
+#ifdef CONFIG_DEBUG_PAGESTATE_TRACKING
+ atomic_dec(&cl_object_site(obj)->cs_pages.cs_stats[item]);
+#endif
+}
+
+static void cs_pagestate_inc(const struct cl_object *obj,
+ enum cl_page_state state)
+{
+#ifdef CONFIG_DEBUG_PAGESTATE_TRACKING
+ atomic_inc(&cl_object_site(obj)->cs_pages_state[state]);
+#endif
+}
+
+static void cs_pagestate_dec(const struct cl_object *obj,
+ enum cl_page_state state)
+{
+#ifdef CONFIG_DEBUG_PAGESTATE_TRACKING
+ atomic_dec(&cl_object_site(obj)->cs_pages_state[state]);
+#endif
+}
/**
* Internal version of cl_page_get().
if (unlikely(slice->cpl_ops->cpo_fini != NULL))
slice->cpl_ops->cpo_fini(env, slice);
}
- CS_PAGE_DEC(obj, total);
- CS_PAGESTATE_DEC(obj, page->cp_state);
+ cs_page_dec(obj, CS_total);
+ cs_pagestate_dec(obj, page->cp_state);
lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page);
cl_object_put(env, obj);
lu_ref_fini(&page->cp_reference);
}
}
if (result == 0) {
- CS_PAGE_INC(o, total);
- CS_PAGE_INC(o, create);
- CS_PAGESTATE_DEC(o, CPS_CACHED);
+ cs_page_inc(o, CS_total);
+ cs_page_inc(o, CS_create);
+ cs_pagestate_dec(o, CPS_CACHED);
}
} else {
page = ERR_PTR(-ENOMEM);
ENTRY;
hdr = cl_object_header(o);
- CS_PAGE_INC(o, lookup);
+ cs_page_inc(o, CS_lookup);
CDEBUG(D_PAGE, "%lu@"DFID" %p %lx %d\n",
idx, PFID(&hdr->coh_lu.loh_fid), vmpage, vmpage->private, type);
*/
page = cl_vmpage_page(vmpage, o);
if (page != NULL) {
- CS_PAGE_INC(o, hit);
+ cs_page_inc(o, CS_hit);
RETURN(page);
}
}
PASSERT(env, page, page->cp_state == old);
PASSERT(env, page, equi(state == CPS_OWNED, page->cp_owner != NULL));
- CS_PAGESTATE_DEC(page->cp_obj, page->cp_state);
- CS_PAGESTATE_INC(page->cp_obj, state);
+ cs_pagestate_dec(page->cp_obj, page->cp_state);
+ cs_pagestate_inc(page->cp_obj, state);
cl_page_state_set_trust(page, state);
EXIT;
}
RETURN(err);
} /* class_handle_ioctl */
-#define OBD_INIT_CHECK
-#ifdef OBD_INIT_CHECK
static int obd_init_checks(void)
{
__u64 u64val, div64val;
return ret;
}
-#else
-#define obd_init_checks() do {} while(0)
-#endif
static int __init obdclass_init(void)
{
#include <md_object.h>
#include <obd_support.h>
-#define lustre_get_group_info(group_info) do { \
- atomic_inc(&(group_info)->usage); \
-} while (0)
-
-#define lustre_put_group_info(group_info) do { \
- if (atomic_dec_and_test(&(group_info)->usage)) \
- groups_free(group_info); \
-} while (0)
-
/*
* groups_search() is copied from linux kernel!
* A simple bsearch.
if (!group_info)
return 0;
- lustre_get_group_info(group_info);
+ atomic_inc(&group_info->usage);
rc = lustre_groups_search(group_info, grp);
- lustre_put_group_info(group_info);
+ if (atomic_dec_and_test(&group_info->usage))
+ groups_free(group_info);
}
return rc;
}
*/
#define DEBUG_SUBSYSTEM S_CLASS
-#define D_KUC D_OTHER
#include <obd_support.h>
#include <lustre_kernelcomm.h>
if (rc < 0)
CWARN("message send failed (%d)\n", rc);
else
- CDEBUG(D_KUC, "Sent message rc=%d, fp=%p\n", rc, filp);
+ CDEBUG(D_HSM, "Sent message rc=%d, fp=%p\n", rc, filp);
return rc;
}
list_add(®->kr_chain, &kkuc_groups[group]);
up_write(&kg_sem);
- CDEBUG(D_KUC, "Added uid=%d fp=%p to group %d\n", uid, filp, group);
+ CDEBUG(D_HSM, "Added uid=%d fp=%p to group %d\n", uid, filp, group);
return 0;
}
list_for_each_entry_safe(reg, next, &kkuc_groups[group], kr_chain) {
if ((uid == 0) || (uid == reg->kr_uid)) {
list_del(®->kr_chain);
- CDEBUG(D_KUC, "Removed uid=%d fp=%p from group %d\n",
+ CDEBUG(D_HSM, "Removed uid=%d fp=%p from group %d\n",
reg->kr_uid, reg->kr_fp, group);
if (reg->kr_fp != NULL)
fput(reg->kr_fp);
+++ /dev/null
-/*
- * 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.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- *
- * Copyright (c) 2014, Intel Corporation.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- *
- * lustre/obdclass/uuid.c
- *
- * Public include file for the UUID library
- */
-
-#define DEBUG_SUBSYSTEM S_CLASS
-
-#include <libcfs/libcfs.h>
-#include <obd_support.h>
-#include <obd_class.h>
-
-static inline size_t consume(size_t nob, __u8 **ptr)
-{
- size_t value;
-
- LASSERT(nob <= sizeof(value));
-
- for (value = 0; nob > 0; --nob)
- value = (value << 8) | *((*ptr)++);
- return value;
-}
-
-#define CONSUME(val, ptr) (val) = consume(sizeof(val), (ptr))
-
-static void uuid_unpack(class_uuid_t in, __u16 *uu, size_t nr)
-{
- __u8 *ptr = in;
-
- LASSERT(nr * sizeof(*uu) == sizeof(class_uuid_t));
-
- while (nr-- > 0)
- CONSUME(uu[nr], &ptr);
-}
-
-void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out)
-{
- /* uu as an array of __u16's */
- __u16 uuid[sizeof(class_uuid_t) / sizeof(__u16)];
-
- CLASSERT(ARRAY_SIZE(uuid) == 8);
-
- uuid_unpack(uu, uuid, ARRAY_SIZE(uuid));
- sprintf(out->uuid, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x",
- uuid[0], uuid[1], uuid[2], uuid[3],
- uuid[4], uuid[5], uuid[6], uuid[7]);
-}
-EXPORT_SYMBOL(class_uuid_unparse);