Whamcloud - gitweb
LU-12616 obclass: fix MDS start/stop race
[fs/lustre-release.git] / lustre / osp / osp_precreate.c
index 125cc82..b806159 100644 (file)
@@ -114,9 +114,9 @@ static void osp_statfs_timer_cb(cfs_timer_cb_arg_t data)
  * \retval negative    negated errno on error
  */
 static int osp_statfs_interpret(const struct lu_env *env,
-                               struct ptlrpc_request *req,
-                               union ptlrpc_async_args *aa, int rc)
+                               struct ptlrpc_request *req, void *args, int rc)
 {
+       union ptlrpc_async_args *aa = args;
        struct obd_import *imp = req->rq_import;
        struct obd_statfs *msfs;
        struct osp_device *d;
@@ -205,7 +205,7 @@ static int osp_statfs_update(const struct lu_env *env, struct osp_device *d)
                req->rq_request_portal = OST_CREATE_PORTAL;
        ptlrpc_at_set_req_timeout(req);
 
-       req->rq_interpret_reply = (ptlrpc_interpterer_t)osp_statfs_interpret;
+       req->rq_interpret_reply = osp_statfs_interpret;
        aa = ptlrpc_req_async_args(req);
        aa->pointer_arg[0] = d;
 
@@ -385,6 +385,7 @@ int osp_write_last_oid_seq_files(struct lu_env *env, struct osp_device *osp,
        struct lu_buf      *lb_oid = &oti->osi_lb;
        struct lu_buf      *lb_oseq = &oti->osi_lb2;
        loff_t             oid_off;
+       u64                oid;
        loff_t             oseq_off;
        struct thandle    *th;
        int                   rc;
@@ -395,13 +396,12 @@ int osp_write_last_oid_seq_files(struct lu_env *env, struct osp_device *osp,
 
        /* Note: through f_oid is only 32 bits, it will also write 64 bits
         * for oid to keep compatibility with the previous version. */
-       lb_oid->lb_buf = &fid->f_oid;
-       lb_oid->lb_len = sizeof(u64);
-       oid_off = sizeof(u64) * osp->opd_index;
+       oid = fid->f_oid;
+       osp_objid_buf_prep(lb_oid, &oid_off,
+                          &oid, osp->opd_index);
 
-       lb_oseq->lb_buf = &fid->f_seq;
-       lb_oseq->lb_len = sizeof(u64);
-       oseq_off = sizeof(u64) * osp->opd_index;
+       osp_objseq_buf_prep(lb_oseq, &oseq_off,
+                           &fid->f_seq, osp->opd_index);
 
        th = dt_trans_create(env, osp->opd_storage);
        if (IS_ERR(th))
@@ -494,6 +494,7 @@ static int osp_precreate_rollover_new_seq(struct lu_env *env,
        /* Update last_xxx to the new seq */
        spin_lock(&osp->opd_pre_lock);
        osp->opd_last_used_fid = *fid;
+       osp_fid_to_obdid(fid, &osp->opd_last_id);
        osp->opd_gap_start_fid = *fid;
        osp->opd_pre_used_fid = *fid;
        osp->opd_pre_last_created_fid = *fid;
@@ -624,15 +625,9 @@ static int osp_precreate_send(const struct lu_env *env, struct osp_device *d)
 
        *fid = d->opd_pre_last_created_fid;
        rc = osp_precreate_fids(env, d, fid, &grow);
-       if (rc == 1) {
+       if (rc == 1)
                /* Current seq has been used up*/
-               if (!osp_is_fid_client(d)) {
-                       osp_pre_update_status(d, -ENOSPC);
-                       rc = -ENOSPC;
-               }
-               wake_up(&d->opd_pre_waitq);
-               GOTO(out_req, rc);
-       }
+               GOTO(out_req, rc = -ENOSPC);
 
        if (!osp_is_fid_client(d)) {
                /* Non-FID client will always send seq 0 because of
@@ -665,7 +660,7 @@ static int osp_precreate_send(const struct lu_env *env, struct osp_device *d)
 
 ready:
        if (osp_fid_diff(fid, &d->opd_pre_used_fid) <= 0) {
-               CERROR("%s: precreate fid "DFID" < local used fid "DFID
+               CERROR("%s: precreate fid "DFID" <= local used fid "DFID
                       ": rc = %d\n", d->opd_obd->obd_name,
                       PFID(fid), PFID(&d->opd_pre_used_fid), -ESTALE);
                GOTO(out_req, rc = -ESTALE);
@@ -1013,6 +1008,13 @@ void osp_pre_update_status(struct osp_device *d, int rc)
                else if (msfs->os_ffree > 64)
                        msfs->os_state &= ~OS_STATE_ENOINO;
 
+               CDEBUG(D_INFO, "%s: status: %llu blocks, %llu "
+                      "free, %llu avail, %llu MB avail, %u "
+                      "hwm -> %d: rc = %d\n",
+                      d->opd_obd->obd_name, msfs->os_blocks,
+                      msfs->os_bfree, msfs->os_bavail,
+                      available, d->opd_reserved_mb_high,
+                      d->opd_pre_status, rc);
                if (available < d->opd_reserved_mb_low)
                        msfs->os_state |= OS_STATE_ENOSPC;
                else if (available > d->opd_reserved_mb_high)
@@ -1250,8 +1252,7 @@ static int osp_precreate_thread(void *_arg)
                         */
                        rc = osp_precreate_cleanup_orphans(&env, d);
                        if (rc != 0) {
-                               schedule_timeout_interruptible(
-                                       msecs_to_jiffies(MSEC_PER_SEC));
+                               schedule_timeout_interruptible(cfs_time_seconds(1));
                                continue;
                        }
                }
@@ -1473,7 +1474,7 @@ int osp_precreate_reserve(const struct lu_env *env, struct osp_device *d)
                        if (atomic_read(&d->opd_sync_changes) && synced == 0) {
                                /* force local commit to release space */
                                dt_commit_async(env, d->opd_storage);
-                               osp_sync_force(env, d);
+                               osp_sync_check_for_work(d);
                                synced = 1;
                        }
                        if (atomic_read(&d->opd_sync_rpcs_in_progress)) {
@@ -1610,8 +1611,6 @@ int osp_object_truncate(const struct lu_env *env, struct dt_object *dt,
        if (req == NULL)
                RETURN(-ENOMEM);
 
-       /* XXX: capa support? */
-       /* osc_set_capa_size(req, &RMF_CAPA1, capa); */
        rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_PUNCH);
        if (rc) {
                ptlrpc_request_free(req);
@@ -1705,6 +1704,7 @@ int osp_init_precreate(struct osp_device *d)
        d->opd_pre_used_fid.f_oid = 1;
        fid_zero(&d->opd_pre_last_created_fid);
        d->opd_pre_last_created_fid.f_oid = 1;
+       d->opd_last_id = 0;
        d->opd_pre_reserved = 0;
        d->opd_got_disconnected = 1;
        d->opd_pre_create_slow = 0;