Whamcloud - gitweb
- CROW-related fixes from b_hd_mdref
[fs/lustre-release.git] / lustre / osc / osc_request.c
index 4c49b3a..2d565f6 100644 (file)
@@ -268,17 +268,21 @@ static int osc_setattr(struct obd_export *exp, struct obdo *oa,
 
         request->rq_replen = lustre_msg_size(1, &size);
 
-        rc = ptlrpc_queue_wait(request);
-        if (rc)
-                GOTO(out, rc);
-
-        body = lustre_swab_repbuf(request, 0, sizeof(*body),
-                                  lustre_swab_ost_body);
-        if (body == NULL)
-                GOTO(out, rc = -EPROTO);
+        if (oti != NULL && (oti->oti_flags & OBD_MODE_ASYNC)) {
+                ptlrpcd_add_req(request);
+                rc = 0;
+        } else {
+                rc = ptlrpc_queue_wait(request);
+                if (rc)
+                        GOTO(out, rc);
 
-        memcpy(oa, &body->oa, sizeof(*oa));
+                body = lustre_swab_repbuf(request, 0, sizeof(*body),
+                                          lustre_swab_ost_body);
+                if (body == NULL)
+                        GOTO(out, rc = -EPROTO);
 
+                memcpy(oa, &body->oa, sizeof(*oa));
+        }
         EXIT;
 out:
         ptlrpc_req_finished(request);
@@ -288,6 +292,7 @@ out:
 int osc_real_create(struct obd_export *exp, struct obdo *oa,
                     struct lov_stripe_md **ea, struct obd_trans_info *oti)
 {
+        struct osc_creator *oscc = &exp->exp_obd->u.cli.cl_oscc;
         struct ptlrpc_request *request;
         struct ost_body *body;
         struct lov_stripe_md *lsm;
@@ -333,6 +338,16 @@ int osc_real_create(struct obd_export *exp, struct obdo *oa,
                 GOTO (out_req, rc = -EPROTO);
         }
 
+        if ((oa->o_valid & OBD_MD_FLFLAGS) && oa->o_flags == OBD_FL_DELORPHAN) {
+                struct obd_import *imp = class_exp2cliimp(exp);
+                /* MDS declares last known object, OSS responses
+                 * with next possible object -bzzz */
+                spin_lock(&oscc->oscc_lock);
+                oscc->oscc_next_id = body->oa.o_id;
+                spin_unlock(&oscc->oscc_lock);
+                CDEBUG(D_HA, "%s: set nextid "LPD64" after recovery\n",
+                       imp->imp_target_uuid.uuid, oa->o_id);
+        }
         memcpy(oa, &body->oa, sizeof(*oa));
 
         /* This should really be sent by the OST */
@@ -417,7 +432,8 @@ static int osc_punch(struct obd_export *exp, struct obdo *oa,
 }
 
 static int osc_sync(struct obd_export *exp, struct obdo *oa,
-                    struct lov_stripe_md *md, obd_size start, obd_size end)
+                    struct lov_stripe_md *md, obd_size start,
+                    obd_size end)
 {
         struct ptlrpc_request *request;
         struct ost_body *body;
@@ -492,8 +508,7 @@ static int osc_destroy(struct obd_export *exp, struct obdo *oa,
         memcpy(&body->oa, oa, sizeof(*oa));
         request->rq_replen = lustre_msg_size(1, &size);
 
-        if (oti != NULL && oti->oti_async) {
-                /* asynchrounous destroy */
+        if (oti != NULL && (oti->oti_flags & OBD_MODE_ASYNC)) {
                 ptlrpcd_add_req(request);
                 rc = 0;
         } else {
@@ -642,7 +657,7 @@ static int check_write_rcs(struct ptlrpc_request *request,
                            int requested_nob, int niocount,
                            obd_count page_count, struct brw_page *pga)
 {
-        int    *remote_rcs, i;
+        int *remote_rcs, i;
 
         /* return error if any niobuf was in error */
         remote_rcs = lustre_swab_repbuf(request, 1,
@@ -653,7 +668,7 @@ static int check_write_rcs(struct ptlrpc_request *request,
         }
         if (lustre_msg_swabbed(request->rq_repmsg))
                 for (i = 0; i < niocount; i++)
-                        __swab32s(&remote_rcs[i]);
+                        __swab32s((__u32 *)&remote_rcs[i]);
 
         for (i = 0; i < niocount; i++) {
                 if (remote_rcs[i] < 0)
@@ -1264,7 +1279,6 @@ static int brw_interpret_oap(struct ptlrpc_request *request,
 
         osc_wake_cache_waiters(cli);
         osc_check_rpcs(cli);
-
         spin_unlock(&cli->cl_loi_list_lock);
 
         obdo_free(aa->aa_oa);
@@ -2424,6 +2438,12 @@ static int osc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm,
         rc = ldlm_lock_match(obd->obd_namespace, 0, &res_id, type, policy, mode,
                              lockh);
         if (rc == 1) {
+                if (ptlrpcs_check_cred(obd->u.cli.cl_import)) {
+                        /* return immediately if no credential held */
+                        ldlm_lock_decref(lockh, mode);
+                        RETURN(-EACCES);
+                }
+
                 osc_set_data_with_check(lockh, data);
                 if (*flags & LDLM_FL_HAS_INTENT) {
                         /* I would like to be able to ASSERT here that rss <=
@@ -2450,6 +2470,12 @@ static int osc_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm,
                 rc = ldlm_lock_match(obd->obd_namespace, 0, &res_id, type,
                                      policy, LCK_PW, lockh);
                 if (rc == 1) {
+                        if (ptlrpcs_check_cred(obd->u.cli.cl_import)) {
+                                /* return immediately if no credential held */
+                                ldlm_lock_decref(lockh, LCK_PW);
+                                RETURN(-EACCES);
+                        }
+
                         /* FIXME: This is not incredibly elegant, but it might
                          * be more elegant than adding another parameter to
                          * lock_match.  I want a second opinion. */
@@ -2604,7 +2630,8 @@ static int osc_cancel(struct obd_export *exp, struct lov_stripe_md *md,
 }
 
 static int osc_cancel_unused(struct obd_export *exp,
-                             struct lov_stripe_md *lsm, int flags, void *opaque)
+                             struct lov_stripe_md *lsm,
+                             int flags, void *opaque)
 {
         struct obd_device *obd = class_exp2obd(exp);
         struct ldlm_res_id res_id = { .name = {0} }, *resp = NULL;
@@ -2803,7 +2830,7 @@ out:
         return err;
 }
 
-static int osc_get_info(struct obd_export *exp, obd_count keylen,
+static int osc_get_info(struct obd_export *exp, __u32 keylen,
                         void *key, __u32 *vallen, void *val)
 {
         ENTRY;
@@ -2822,11 +2849,11 @@ static int osc_get_info(struct obd_export *exp, obd_count keylen,
                 char *bufs[1] = {key};
                 int rc;
                 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
-                                      OST_GET_INFO, 1, &keylen, bufs);
+                                      OST_GET_INFO, 1, (int *)&keylen, bufs);
                 if (req == NULL)
                         RETURN(-ENOMEM);
 
-                req->rq_replen = lustre_msg_size(1, vallen);
+                req->rq_replen = lustre_msg_size(1, (int *)vallen);
                 rc = ptlrpc_queue_wait(req);
                 if (rc)
                         GOTO(out, rc);
@@ -2854,26 +2881,6 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
         int rc = 0;
         ENTRY;
 
-        if (keylen == strlen("next_id") &&
-            memcmp(key, "next_id", strlen("next_id")) == 0) {
-                if (vallen != sizeof(obd_id))
-                        RETURN(-EINVAL);
-               obd->u.cli.cl_oscc.oscc_next_id = *((obd_id*)val) + 1;
-                CDEBUG(D_HA, "%s: set oscc_next_id = "LPU64"\n",
-                       exp->exp_obd->obd_name,
-                       obd->u.cli.cl_oscc.oscc_next_id);
-
-                RETURN(0);
-        }
-
-        if (keylen == strlen("growth_count") &&
-            memcmp(key, "growth_count", strlen("growth_count")) == 0) {
-                if (vallen != sizeof(int))
-                        RETURN(-EINVAL);
-               obd->u.cli.cl_oscc.oscc_max_grow_count = *((int*)val);
-                RETURN(0);
-        }
-
         if (keylen == strlen("unlinked") &&
             memcmp(key, "unlinked", keylen) == 0) {
                 struct osc_creator *oscc = &obd->u.cli.cl_oscc;
@@ -2902,7 +2909,8 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
                 RETURN(0);
         }
 
-        if (keylen == strlen("async") && memcmp(key, "async", keylen) == 0) {
+        if (keylen == strlen("async") &&
+            memcmp(key, "async", keylen) == 0) {
                 struct client_obd *cl = &obd->u.cli;
                 if (vallen != sizeof(int))
                         RETURN(-EINVAL);
@@ -2912,7 +2920,8 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
                 RETURN(0);
         }
 
-        if (keylen == strlen("sec") && memcmp(key, "sec", keylen) == 0) {
+        if (keylen == strlen("sec") &&
+            memcmp(key, "sec", keylen) == 0) {
                 struct client_obd *cli = &exp->exp_obd->u.cli;
 
                 if (vallen == strlen("null") &&
@@ -2937,16 +2946,28 @@ static int osc_set_info(struct obd_export *exp, obd_count keylen,
                 RETURN(-EINVAL);
         }
 
-        if (keylen < strlen("mds_conn") || memcmp(key, "mds_conn", keylen) != 0)
+        if (keylen == strlen("flush_cred") &&
+            memcmp(key, "flush_cred", keylen) == 0) {
+                struct client_obd *cli = &exp->exp_obd->u.cli;
+
+                if (cli->cl_import)
+                        ptlrpcs_import_flush_creds(cli->cl_import,
+                                                   *((uid_t *) val));
+                RETURN(0);
+        }
+
+        if (keylen < strlen("mds_conn") ||
+            memcmp(key, "mds_conn", keylen) != 0)
                 RETURN(-EINVAL);
 
-        ctxt = llog_get_context(&exp->exp_obd->obd_llogs, LLOG_UNLINK_ORIG_CTXT);
+        ctxt = llog_get_context(&exp->exp_obd->obd_llogs,
+                                LLOG_UNLINK_ORIG_CTXT);
         if (ctxt) {
                 if (rc == 0)
                         rc = llog_initiator_connect(ctxt);
                 else
-                        CERROR("cannot establish the connect for ctxt %p: %d\n",
-                               ctxt, rc);
+                        CERROR("cannot establish the connect for "
+                               "ctxt %p: %d\n", ctxt, rc);
         }
 
         imp->imp_server_timeout = 1;
@@ -2962,6 +2983,7 @@ static struct llog_operations osc_size_repl_logops = {
 };
 
 static struct llog_operations osc_unlink_orig_logops;
+
 static int osc_llog_init(struct obd_device *obd, struct obd_llogs *llogs,
                          struct obd_device *tgt, int count,
                          struct llog_catid *catid)
@@ -2999,7 +3021,6 @@ static int osc_llog_finish(struct obd_device *obd,
         RETURN(rc);
 }
 
-
 static int osc_connect(struct lustre_handle *exph,
                        struct obd_device *obd, struct obd_uuid *cluuid,
                        struct obd_connect_data *data,