Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
LU-11128 ptlrpc: add debugging for idle connections
[fs/lustre-release.git]
/
lustre
/
osc
/
osc_object.c
diff --git
a/lustre/osc/osc_object.c
b/lustre/osc/osc_object.c
index
7d32893
..
6b44d63
100644
(file)
--- a/
lustre/osc/osc_object.c
+++ b/
lustre/osc/osc_object.c
@@
-23,7
+23,7
@@
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 201
5
, Intel Corporation.
+ * Copyright (c) 2011, 201
7
, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
*/
/*
* This file is part of Lustre, http://www.lustre.org/
@@
-49,14
+49,24
@@
* Object operations.
*
*/
* Object operations.
*
*/
+static void osc_obj_build_res_name(struct osc_object *osc,
+ struct ldlm_res_id *resname)
+{
+ ostid_build_res_name(&osc->oo_oinfo->loi_oi, resname);
+}
-static int osc_object_init(const struct lu_env *env, struct lu_object *obj,
- const struct lu_object_conf *conf)
+static const struct osc_object_operations osc_object_ops = {
+ .oto_build_res_name = osc_obj_build_res_name,
+ .oto_dlmlock_at_pgoff = osc_obj_dlmlock_at_pgoff,
+};
+
+int osc_object_init(const struct lu_env *env, struct lu_object *obj,
+ const struct lu_object_conf *conf)
{
struct osc_object *osc = lu2osc(obj);
const struct cl_object_conf *cconf = lu2cl_conf(conf);
{
struct osc_object *osc = lu2osc(obj);
const struct cl_object_conf *cconf = lu2cl_conf(conf);
-
osc->oo_oinfo = cconf->u.coc_oinfo;
+ osc->oo_oinfo = cconf->u.coc_oinfo;
#ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
mutex_init(&osc->oo_debug_mutex);
#endif
#ifdef CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK
mutex_init(&osc->oo_debug_mutex);
#endif
@@
-80,12
+90,15
@@
static int osc_object_init(const struct lu_env *env, struct lu_object *obj,
atomic_set(&osc->oo_nr_ios, 0);
init_waitqueue_head(&osc->oo_io_waitq);
atomic_set(&osc->oo_nr_ios, 0);
init_waitqueue_head(&osc->oo_io_waitq);
+ LASSERT(osc->oo_obj_ops != NULL);
+
cl_object_page_init(lu2cl(obj), sizeof(struct osc_page));
return 0;
}
cl_object_page_init(lu2cl(obj), sizeof(struct osc_page));
return 0;
}
+EXPORT_SYMBOL(osc_object_init);
-
static
void osc_object_free(const struct lu_env *env, struct lu_object *obj)
+void osc_object_free(const struct lu_env *env, struct lu_object *obj)
{
struct osc_object *osc = lu2osc(obj);
{
struct osc_object *osc = lu2osc(obj);
@@
-107,22
+120,24
@@
static void osc_object_free(const struct lu_env *env, struct lu_object *obj)
lu_object_fini(obj);
OBD_SLAB_FREE_PTR(osc, osc_object_kmem);
}
lu_object_fini(obj);
OBD_SLAB_FREE_PTR(osc, osc_object_kmem);
}
+EXPORT_SYMBOL(osc_object_free);
int osc_lvb_print(const struct lu_env *env, void *cookie,
int osc_lvb_print(const struct lu_env *env, void *cookie,
-
lu_printer_t p, const struct ost_lvb *lvb)
+ lu_printer_t p, const struct ost_lvb *lvb)
{
return (*p)(env, cookie, "size: %llu mtime: %llu atime: %llu "
"ctime: %llu blocks: %llu",
lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime,
lvb->lvb_ctime, lvb->lvb_blocks);
}
{
return (*p)(env, cookie, "size: %llu mtime: %llu atime: %llu "
"ctime: %llu blocks: %llu",
lvb->lvb_size, lvb->lvb_mtime, lvb->lvb_atime,
lvb->lvb_ctime, lvb->lvb_blocks);
}
+EXPORT_SYMBOL(osc_lvb_print);
-
static
int osc_object_print(const struct lu_env *env, void *cookie,
-
lu_printer_t p, const struct lu_object *obj)
+int osc_object_print(const struct lu_env *env, void *cookie,
+ lu_printer_t p, const struct lu_object *obj)
{
{
- struct osc_object
*osc
= lu2osc(obj);
- struct lov_oinfo
*oinfo = osc->oo_oinfo;
- struct osc_async_rc *ar
= &oinfo->loi_ar;
+ struct osc_object
*osc
= lu2osc(obj);
+ struct lov_oinfo *oinfo = osc->oo_oinfo;
+ struct osc_async_rc *ar = &oinfo->loi_ar;
(*p)(env, cookie, "id: "DOSTID" "
"idx: %d gen: %d kms_valid: %u kms %llu "
(*p)(env, cookie, "id: "DOSTID" "
"idx: %d gen: %d kms_valid: %u kms %llu "
@@
-133,20
+148,22
@@
static int osc_object_print(const struct lu_env *env, void *cookie,
osc_lvb_print(env, cookie, p, &oinfo->loi_lvb);
return 0;
}
osc_lvb_print(env, cookie, p, &oinfo->loi_lvb);
return 0;
}
+EXPORT_SYMBOL(osc_object_print);
-
static
int osc_attr_get(const struct lu_env *env, struct cl_object *obj,
-
struct cl_attr *attr)
+int osc_attr_get(const struct lu_env *env, struct cl_object *obj,
+ struct cl_attr *attr)
{
{
-
struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
+ struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
-
cl_lvb2attr(attr, &oinfo->loi_lvb);
-
attr->cat_kms = oinfo->loi_kms_valid ? oinfo->loi_kms : 0;
-
return 0;
+ cl_lvb2attr(attr, &oinfo->loi_lvb);
+ attr->cat_kms = oinfo->loi_kms_valid ? oinfo->loi_kms : 0;
+ return 0;
}
}
+EXPORT_SYMBOL(osc_attr_get);
-
static
int osc_attr_update(const struct lu_env *env, struct cl_object *obj,
-
const struct cl_attr *attr, unsigned valid)
+int osc_attr_update(const struct lu_env *env, struct cl_object *obj,
+ const struct cl_attr *attr, unsigned valid)
{
struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
struct ost_lvb *lvb = &oinfo->loi_lvb;
{
struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
struct ost_lvb *lvb = &oinfo->loi_lvb;
@@
-168,17
+185,18
@@
static int osc_attr_update(const struct lu_env *env, struct cl_object *obj,
}
return 0;
}
}
return 0;
}
+EXPORT_SYMBOL(osc_attr_update);
-
static int osc_object_glimpse(const struct lu_env *env
,
-
const struct cl_object *obj,
struct ost_lvb *lvb)
+
int osc_object_glimpse(const struct lu_env *env, const struct cl_object *obj
,
+ struct ost_lvb *lvb)
{
{
-
struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
+ struct lov_oinfo *oinfo = cl2osc(obj)->oo_oinfo;
- ENTRY;
- lvb->lvb_size = oinfo->loi_kms;
- lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks;
- RETURN(0);
+ lvb->lvb_size = oinfo->loi_kms;
+ lvb->lvb_blocks = oinfo->loi_lvb.lvb_blocks;
+ return 0;
}
}
+EXPORT_SYMBOL(osc_object_glimpse);
static int osc_object_ast_clear(struct ldlm_lock *lock, void *data)
{
static int osc_object_ast_clear(struct ldlm_lock *lock, void *data)
{
@@
-189,18
+207,19
@@
static int osc_object_ast_clear(struct ldlm_lock *lock, void *data)
RETURN(LDLM_ITER_CONTINUE);
}
RETURN(LDLM_ITER_CONTINUE);
}
-
static
int osc_object_prune(const struct lu_env *env, struct cl_object *obj)
+int osc_object_prune(const struct lu_env *env, struct cl_object *obj)
{
{
- struct osc_object
*osc = cl2osc(obj);
- struct ldlm_res_id
*resname = &osc_env_info(env)->oti_resname;
+ struct osc_object *osc = cl2osc(obj);
+ struct ldlm_res_id *resname = &osc_env_info(env)->oti_resname;
/* DLM locks don't hold a reference of osc_object so we have to
* clear it before the object is being destroyed. */
/* DLM locks don't hold a reference of osc_object so we have to
* clear it before the object is being destroyed. */
- os
tid_build_res_name(&osc->oo_oinfo->loi_oi
, resname);
+ os
c_build_res_name(osc
, resname);
ldlm_resource_iterate(osc_export(osc)->exp_obd->obd_namespace, resname,
osc_object_ast_clear, osc);
return 0;
}
ldlm_resource_iterate(osc_export(osc)->exp_obd->obd_namespace, resname,
osc_object_ast_clear, osc);
return 0;
}
+EXPORT_SYMBOL(osc_object_prune);
static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj,
struct ll_fiemap_info_key *fmkey,
static int osc_object_fiemap(const struct lu_env *env, struct cl_object *obj,
struct ll_fiemap_info_key *fmkey,
@@
-287,24
+306,11
@@
drop_lock:
RETURN(rc);
}
RETURN(rc);
}
-void osc_object_set_contended(struct osc_object *obj)
-{
- obj->oo_contention_time = cfs_time_current();
- /* mb(); */
- obj->oo_contended = 1;
-}
-
-void osc_object_clear_contended(struct osc_object *obj)
-{
- obj->oo_contended = 0;
-}
-
int osc_object_is_contended(struct osc_object *obj)
{
int osc_object_is_contended(struct osc_object *obj)
{
- struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
- int osc_contention_time = dev->od_contention_time;
- cfs_time_t cur_time = cfs_time_current();
- cfs_time_t retry_time;
+ struct osc_device *dev = lu2osc_dev(obj->oo_cl.co_lu.lo_dev);
+ time64_t osc_contention_time = dev->od_contention_time;
+ ktime_t retry_time;
if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
return 1;
if (OBD_FAIL_CHECK(OBD_FAIL_OSC_OBJECT_CONTENTION))
return 1;
@@
-312,18
+318,19
@@
int osc_object_is_contended(struct osc_object *obj)
if (!obj->oo_contended)
return 0;
if (!obj->oo_contended)
return 0;
-
/*
-
* I like copy-paste. the code is copied from
-
* ll_file_is_contended.
-
*/
-
retry_time = cfs_time_add
(obj->oo_contention_time,
-
cfs_time_seconds(osc_contention_time)
);
-
if (cfs_time_after(cur_time
, retry_time)) {
-
osc_object_clear_contended(obj);
-
return 0;
-
}
-
return 1;
+ /*
+ * I like copy-paste. the code is copied from
+ * ll_file_is_contended.
+ */
+
retry_time = ktime_add_ns
(obj->oo_contention_time,
+
osc_contention_time * NSEC_PER_SEC
);
+
if (ktime_after(ktime_get()
, retry_time)) {
+ osc_object_clear_contended(obj);
+ return 0;
+ }
+ return 1;
}
}
+EXPORT_SYMBOL(osc_object_is_contended);
/**
* Implementation of struct cl_object_operations::coo_req_attr_set() for osc
/**
* Implementation of struct cl_object_operations::coo_req_attr_set() for osc
@@
-436,6
+443,7
@@
struct lu_object *osc_object_alloc(const struct lu_env *env,
lu_object_init(obj, NULL, dev);
osc->oo_cl.co_ops = &osc_ops;
obj->lo_ops = &osc_lu_obj_ops;
lu_object_init(obj, NULL, dev);
osc->oo_cl.co_ops = &osc_ops;
obj->lo_ops = &osc_lu_obj_ops;
+ osc->oo_obj_ops = &osc_object_ops;
} else
obj = NULL;
return obj;
} else
obj = NULL;
return obj;
@@
-455,12
+463,12
@@
int osc_object_invalidate(const struct lu_env *env, struct osc_object *osc)
osc_cache_truncate_start(env, osc, 0, NULL);
/* Discard all caching pages */
osc_cache_truncate_start(env, osc, 0, NULL);
/* Discard all caching pages */
- osc_lock_discard_pages(env, osc, 0, CL_PAGE_EOF,
CLM_WRITE
);
+ osc_lock_discard_pages(env, osc, 0, CL_PAGE_EOF,
true
);
/* Clear ast data of dlm lock. Do this after discarding all pages */
osc_object_prune(env, osc2cl(osc));
RETURN(0);
}
/* Clear ast data of dlm lock. Do this after discarding all pages */
osc_object_prune(env, osc2cl(osc));
RETURN(0);
}
-
+EXPORT_SYMBOL(osc_object_invalidate);
/** @} osc */
/** @} osc */