struct ldlm_lock_desc *new, void *data,
int flag);
+static inline struct ldlm_res_id *osc_build_res_name(__u64 id, __u64 gr,
+ struct ldlm_res_id *name)
+{
+ memset(name, 0, sizeof *name);
+ name->name[0] = id;
+ name->name[1] = gr;
+ return name;
+}
+
+static inline int osc_res_name_eq(__u64 id, __u64 gr, struct ldlm_res_id *name)
+{
+ return name->name[0] == id && name->name[1] == gr;
+}
+
#endif
struct lov_stripe_md *lsm;
} key = { .name = KEY_LOCK_TO_STRIPE, .lock = lock, .lsm = lsm };
__u32 stripe, vallen = sizeof(stripe);
+ struct lov_oinfo *loinfo;
int rc;
ENTRY;
LASSERT(stripe < lsm->lsm_stripe_count);
check:
- if (lsm->lsm_oinfo[stripe]->loi_id != lock->l_resource->lr_name.name[0]||
- lsm->lsm_oinfo[stripe]->loi_gr != lock->l_resource->lr_name.name[2]){
+ loinfo = lsm->lsm_oinfo[stripe];
+ if (!osc_res_name_eq(loinfo->loi_id, loinfo->loi_gr,
+ &lock->l_resource->lr_name)){
LDLM_ERROR(lock, "resource doesn't match object "LPU64"/"LPU64,
- lsm->lsm_oinfo[stripe]->loi_id,
- lsm->lsm_oinfo[stripe]->loi_gr);
+ loinfo->loi_id, loinfo->loi_gr);
RETURN(-ELDLM_NO_LOCK_DATA);
}
continue;
if (lov->lov_tgts[loi->loi_ost_idx]->ltd_exp ==
data->lock->l_conn_export &&
- loi->loi_id == res_id->name[0] &&
- loi->loi_gr == res_id->name[2]) {
+ osc_res_name_eq(loi->loi_id, loi->loi_gr, res_id)) {
*stripe = i;
GOTO(out, rc = 0);
}
{
struct lustre_handle lockh;
int flags = LDLM_AST_DISCARD_DATA, rc;
- struct ldlm_res_id res_id = { .name = { objid, 0, group, 0} };
+ struct ldlm_res_id res_id;
ldlm_policy_data_t policy = { .l_extent = { 0, OBD_OBJECT_EOF } };
-
ENTRY;
+
+ osc_build_res_name(objid, group, &res_id);
/* Tell the clients that the object is gone now and that they should
* throw away any cached pages. */
rc = ldlm_cli_enqueue_local(obd->obd_namespace, &res_id, LDLM_EXTENT,
int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
struct obd_trans_info *oti)
{
- struct ldlm_res_id res_id = { .name = { oinfo->oi_oa->o_id, 0,
- oinfo->oi_oa->o_gr, 0 } };
+ struct ldlm_res_id res_id;
struct filter_mod_data *fmd;
struct lvfs_run_ctxt saved;
struct filter_obd *filter;
int rc;
ENTRY;
+ osc_build_res_name(oinfo->oi_oa->o_id, oinfo->oi_oa->o_gr, &res_id);
rc = filter_auth_capa(exp, NULL, oinfo_mdsno(oinfo),
oinfo_capa(oinfo), CAPA_OPC_META_WRITE);
if (rc)
#include <linux/version.h>
#include <obd_class.h>
+#include <obd_ost.h>
#include <lustre_fsfilt.h>
#include "filter_internal.h"
struct obd_trans_info *oti, int rc)
{
struct inode *inode = NULL;
- struct ldlm_res_id res_id = { .name = { obj->ioo_id, 0,
- obj->ioo_gr, 0} };
+ struct ldlm_res_id res_id;
struct ldlm_resource *resource = NULL;
struct ldlm_namespace *ns = exp->exp_obd->obd_namespace;
ENTRY;
+ osc_build_res_name(obj->ioo_id, obj->ioo_gr, &res_id);
/* If oa != NULL then filter_preprw_read updated the inode atime
* and we should update the lvb so that other glimpses will also
* get the updated value. bug 5972 */
LASSERT(res);
LASSERT_SEM_LOCKED(&res->lr_lvb_sem);
- /* we only want lvb's for object resources */
- /* check for internal locks: these have name[1] != 0 */
- if (res->lr_name.name[1])
- RETURN(0);
-
if (res->lr_lvb_data)
RETURN(0);
obd = res->lr_namespace->ns_lvbp;
LASSERT(obd != NULL);
- dentry = filter_fid2dentry(obd, NULL, res->lr_name.name[2],
+ dentry = filter_fid2dentry(obd, NULL, res->lr_name.name[1],
res->lr_name.name[0]);
if (IS_ERR(dentry)) {
rc = PTR_ERR(dentry);
LASSERT(res);
- /* we only want lvb's for object resources */
- /* check for internal locks: these have name[1] != 0 */
- if (res->lr_name.name[1])
- RETURN(0);
-
down(&res->lr_lvb_sem);
lvb = res->lr_lvb_data;
if (lvb == NULL) {
obd = res->lr_namespace->ns_lvbp;
LASSERT(obd);
- dentry = filter_fid2dentry(obd, NULL, res->lr_name.name[2],
+ dentry = filter_fid2dentry(obd, NULL, res->lr_name.name[1],
res->lr_name.name[0]);
if (IS_ERR(dentry))
GOTO(out, rc = PTR_ERR(dentry));
int lock_flags)
{
struct ldlm_namespace *ns = exp->exp_obd->obd_namespace;
- struct ldlm_res_id res_id = { .name = { oa->o_id, 0, oa->o_gr, 0 } };
- struct ldlm_resource *res = ldlm_resource_get(ns, NULL, &res_id, 0, 0);
+ struct ldlm_res_id res_id;
+ struct ldlm_resource *res;
int count;
ENTRY;
+ osc_build_res_name(oa->o_id, oa->o_gr, &res_id);
+ res = ldlm_resource_get(ns, NULL, &res_id, 0, 0);
if (res == NULL)
RETURN(0);
struct lustre_handle *lockh)
{
struct osc_async_page *oap;
- struct ldlm_res_id oid = {{0}};
+ struct ldlm_res_id oid;
int rc = 0;
ENTRY;
/* If the page was marked as notcacheable - don't add to any locks */
if (!nocache) {
- oid.name[0] = loi->loi_id;
- oid.name[2] = loi->loi_gr;
+ osc_build_res_name(loi->loi_id, loi->loi_gr, &oid);
/* This is the only place where we can call cache_add_extent
without oap_lock, because this page is locked now, and
the lock we are adding it to is referenced, so cannot lose
static int osc_change_cbdata(struct obd_export *exp, struct lov_stripe_md *lsm,
ldlm_iterator_t replace, void *data)
{
- struct ldlm_res_id res_id = { .name = {0} };
+ struct ldlm_res_id res_id;
struct obd_device *obd = class_exp2obd(exp);
- res_id.name[0] = lsm->lsm_object_id;
- res_id.name[2] = lsm->lsm_object_gr;
-
+ osc_build_res_name(lsm->lsm_object_id, lsm->lsm_object_gr, &res_id);
ldlm_resource_iterate(obd->obd_namespace, &res_id, replace, data);
return 0;
}
struct ldlm_enqueue_info *einfo,
struct ptlrpc_request_set *rqset)
{
- struct ldlm_res_id res_id = { .name = {0} };
+ struct ldlm_res_id res_id;
struct obd_device *obd = exp->exp_obd;
struct ptlrpc_request *req = NULL;
int intent = oinfo->oi_flags & LDLM_FL_HAS_INTENT;
int rc;
ENTRY;
- res_id.name[0] = oinfo->oi_md->lsm_object_id;
- res_id.name[2] = oinfo->oi_md->lsm_object_gr;
+ osc_build_res_name(oinfo->oi_md->lsm_object_id,
+ oinfo->oi_md->lsm_object_gr, &res_id);
/* Filesystem lock extents are extended to page boundaries so that
* dealing with the page cache is a little smoother. */
oinfo->oi_policy.l_extent.start -=
__u32 type, ldlm_policy_data_t *policy, __u32 mode,
int *flags, void *data, struct lustre_handle *lockh)
{
- struct ldlm_res_id res_id = { .name = {0} };
+ struct ldlm_res_id res_id;
struct obd_device *obd = exp->exp_obd;
int lflags = *flags;
ldlm_mode_t rc;
ENTRY;
- res_id.name[0] = lsm->lsm_object_id;
- res_id.name[2] = lsm->lsm_object_gr;
-
+ osc_build_res_name(lsm->lsm_object_id, lsm->lsm_object_gr, &res_id);
+
if (OBD_FAIL_CHECK(OBD_FAIL_OSC_MATCH))
RETURN(-EIO);
void *opaque)
{
struct obd_device *obd = class_exp2obd(exp);
- struct ldlm_res_id res_id = { .name = {0} }, *resp = NULL;
+ struct ldlm_res_id res_id, *resp = NULL;
if (lsm != NULL) {
- res_id.name[0] = lsm->lsm_object_id;
- res_id.name[2] = lsm->lsm_object_gr;
- resp = &res_id;
+ resp = osc_build_res_name(lsm->lsm_object_id,
+ lsm->lsm_object_gr, &res_id);
}
return ldlm_cli_cancel_unused(obd->obd_namespace, resp, flags, opaque);
struct lov_stripe_md *lsm, int join)
{
struct obd_device *obd = class_exp2obd(exp);
- struct ldlm_res_id res_id = { .name = {0} }, *resp = NULL;
+ struct ldlm_res_id res_id, *resp = NULL;
if (lsm != NULL) {
- res_id.name[0] = lsm->lsm_object_id;
- res_id.name[2] = lsm->lsm_object_gr;
- resp = &res_id;
+ resp = osc_build_res_name(lsm->lsm_object_id,
+ lsm->lsm_object_gr, &res_id);
}
return ldlm_cli_join_lru(obd->obd_namespace, resp, join);
struct lustre_handle *lh)
{
int flags;
- struct ldlm_res_id res_id = { .name = { oa->o_id, 0, oa->o_gr, 0} };
+ struct ldlm_res_id res_id;
ldlm_policy_data_t policy;
__u64 start;
__u64 finis;
ENTRY;
+ osc_build_res_name(oa->o_id, oa->o_gr, &res_id);
LASSERT(!lustre_handle_is_used(lh));
if (!(oa->o_valid & OBD_MD_FLFLAGS) ||
{
int flags = 0;
int nrbufs = obj->ioo_bufcnt;
- struct ldlm_res_id res_id = { .name = { obj->ioo_id, 0,
- obj->ioo_gr, 0} };
+ struct ldlm_res_id res_id;
ldlm_policy_data_t policy;
int i;
-
ENTRY;
+ osc_build_res_name(obj->ioo_id, obj->ioo_gr, &res_id);
LASSERT(mode == LCK_PR || mode == LCK_PW);
LASSERT(!lustre_handle_is_used(lh));
static void ost_prolong_locks(struct obd_export *exp, struct obd_ioobj *obj,
struct niobuf_remote *nb, ldlm_mode_t mode)
{
- struct ldlm_res_id res_id = { .name = { obj->ioo_id, 0,
- obj->ioo_gr, 0} };
+ struct ldlm_res_id res_id;
int nrbufs = obj->ioo_bufcnt;
struct ost_prolong_data opd;
-
ENTRY;
+ osc_build_res_name(obj->ioo_id, obj->ioo_gr, &res_id);
+
opd.opd_mode = mode;
opd.opd_exp = exp;
opd.opd_policy.l_extent.start = nb[0].offset & CFS_PAGE_MASK;