Whamcloud - gitweb
Branch HEAD
authorhuanghua <huanghua>
Tue, 22 Jul 2008 05:36:43 +0000 (05:36 +0000)
committerhuanghua <huanghua>
Tue, 22 Jul 2008 05:36:43 +0000 (05:36 +0000)
b=16368
i=adilger
i=alex.zhuravlev

- put object group in ldlm_res_id.name[1]

lustre/include/obd_ost.h
lustre/llite/file.c
lustre/lov/lov_obd.c
lustre/obdfilter/filter.c
lustre/obdfilter/filter_io.c
lustre/obdfilter/filter_lvb.c
lustre/osc/osc_request.c
lustre/ost/ost_handler.c

index 1cbff28..cdf96c7 100644 (file)
@@ -38,4 +38,18 @@ int osc_extent_blocking_cb(struct ldlm_lock *lock,
                            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
index 9d90d51..5517b45 100644 (file)
@@ -750,6 +750,7 @@ static int ll_lock_to_stripe_offset(struct inode *inode, struct ldlm_lock *lock)
                 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;
 
@@ -765,11 +766,11 @@ static int ll_lock_to_stripe_offset(struct inode *inode, struct ldlm_lock *lock)
         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);
         }
 
index 3c8de91..975282d 100644 (file)
@@ -2531,8 +2531,7 @@ static int lov_get_info(struct obd_export *exp, __u32 keylen,
                                 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);
                         }
index 9a9a3a7..82685b6 100644 (file)
@@ -1497,10 +1497,11 @@ static int filter_prepare_destroy(struct obd_device *obd, obd_id objid,
 {
         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,
@@ -3209,8 +3210,7 @@ out_unlock:
 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;
@@ -3219,6 +3219,7 @@ int filter_setattr(struct obd_export *exp, struct obd_info *oinfo,
         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)
index 1fbf7a7..ff30ea9 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/version.h>
 
 #include <obd_class.h>
+#include <obd_ost.h>
 #include <lustre_fsfilt.h>
 #include "filter_internal.h"
 
@@ -717,12 +718,12 @@ static int filter_commitrw_read(struct obd_export *exp, struct obdo *oa,
                                 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 */
index 06e0ee2..387fc97 100644 (file)
@@ -53,11 +53,6 @@ static int filter_lvbo_init(struct ldlm_resource *res)
         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);
 
@@ -71,7 +66,7 @@ static int filter_lvbo_init(struct ldlm_resource *res)
         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);
@@ -119,11 +114,6 @@ static int filter_lvbo_update(struct ldlm_resource *res, struct lustre_msg *m,
 
         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) {
@@ -172,7 +162,7 @@ static int filter_lvbo_update(struct ldlm_resource *res, struct lustre_msg *m,
         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));
index a52db0d..53a8e57 100644 (file)
@@ -618,11 +618,13 @@ static int osc_resource_get_unused(struct obd_export *exp, struct obdo *oa,
                                    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);
 
@@ -2636,7 +2638,7 @@ int osc_prep_async_page(struct obd_export *exp, struct lov_stripe_md *lsm,
                         struct lustre_handle *lockh)
 {
         struct osc_async_page *oap;
-        struct ldlm_res_id oid = {{0}};
+        struct ldlm_res_id oid;
         int rc = 0;
         ENTRY;
 
@@ -2665,8 +2667,7 @@ int osc_prep_async_page(struct obd_export *exp, struct lov_stripe_md *lsm,
 
         /* 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
@@ -3045,12 +3046,10 @@ static void osc_set_data_with_check(struct lustre_handle *lockh, void *data,
 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;
 }
@@ -3132,7 +3131,7 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo,
                        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;
@@ -3140,9 +3139,9 @@ static int osc_enqueue(struct obd_export *exp, struct obd_info *oinfo,
         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 -=
@@ -3250,15 +3249,14 @@ static int osc_match(struct obd_export *exp, struct lov_stripe_md *lsm,
                      __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);
 
@@ -3305,12 +3303,11 @@ static int osc_cancel_unused(struct obd_export *exp,
                              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);
@@ -3320,12 +3317,11 @@ static int osc_join_lru(struct obd_export *exp,
                         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);
index 6a0c402..1f56469 100644 (file)
@@ -209,13 +209,14 @@ static int ost_punch_lock_get(struct obd_export *exp, struct obdo *oa,
                               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) ||
@@ -562,13 +563,12 @@ static int ost_brw_lock_get(int mode, struct obd_export *exp,
 {
         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));
 
@@ -651,13 +651,13 @@ static int ost_prolong_locks_iter(struct ldlm_lock *lock, void *data)
 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;