Whamcloud - gitweb
LU-13366 lod: check for extension size at instantiation time
[fs/lustre-release.git] / lustre / osp / osp_dev.c
index 4315731..04ad620 100644 (file)
@@ -501,7 +501,8 @@ static int osp_disconnect(struct osp_device *d)
  */
 static int osp_update_init(struct osp_device *osp)
 {
-       struct task_struct      *task;
+       struct task_struct *task;
+       int rc;
 
        ENTRY;
 
@@ -514,7 +515,6 @@ static int osp_update_init(struct osp_device *osp)
        if (osp->opd_update == NULL)
                RETURN(-ENOMEM);
 
-       init_waitqueue_head(&osp->opd_update_thread.t_ctl_waitq);
        init_waitqueue_head(&osp->opd_update->ou_waitq);
        spin_lock_init(&osp->opd_update->ou_lock);
        INIT_LIST_HEAD(&osp->opd_update->ou_list);
@@ -522,12 +522,22 @@ static int osp_update_init(struct osp_device *osp)
        osp->opd_update->ou_version = 1;
        osp->opd_update->ou_generation = 0;
 
+       rc = lu_env_init(&osp->opd_update->ou_env,
+                        osp->opd_dt_dev.dd_lu_dev.ld_type->ldt_ctx_tags);
+       if (rc < 0) {
+               CERROR("%s: init env error: rc = %d\n", osp->opd_obd->obd_name,
+                      rc);
+               OBD_FREE_PTR(osp->opd_update);
+               osp->opd_update = NULL;
+               RETURN(rc);
+       }
        /* start thread handling sending updates to the remote MDT */
-       task = kthread_run(osp_send_update_thread, osp,
-                          "osp_up%u-%u", osp->opd_index, osp->opd_group);
+       task = kthread_create(osp_send_update_thread, osp,
+                             "osp_up%u-%u", osp->opd_index, osp->opd_group);
        if (IS_ERR(task)) {
                int rc = PTR_ERR(task);
 
+               lu_env_fini(&osp->opd_update->ou_env);
                OBD_FREE_PTR(osp->opd_update);
                osp->opd_update = NULL;
                CERROR("%s: can't start precreate thread: rc = %d\n",
@@ -535,9 +545,8 @@ static int osp_update_init(struct osp_device *osp)
                RETURN(rc);
        }
 
-       wait_event_idle(osp->opd_update_thread.t_ctl_waitq,
-                       osp_send_update_thread_running(osp) ||
-                       osp_send_update_thread_stopped(osp));
+       osp->opd_update->ou_update_task = task;
+       wake_up_process(task);
 
        RETURN(0);
 }
@@ -559,11 +568,8 @@ static void osp_update_fini(const struct lu_env *env, struct osp_device *osp)
        if (ou == NULL)
                return;
 
-       osp->opd_update_thread.t_flags = SVC_STOPPING;
-       wake_up(&ou->ou_waitq);
-
-       wait_event(osp->opd_update_thread.t_ctl_waitq,
-                  osp->opd_update_thread.t_flags & SVC_STOPPED);
+       kthread_stop(ou->ou_update_task);
+       lu_env_fini(&ou->ou_env);
 
        /* Remove the left osp thandle from the list */
        spin_lock(&ou->ou_lock);
@@ -705,10 +711,41 @@ static int osp_recovery_complete(const struct lu_env *env,
        RETURN(0);
 }
 
+/**
+ * Implementation of lu_device_operations::ldo_fid_alloc() for OSP
+ *
+ * Allocate FID from remote MDT.
+ *
+ * see include/lu_object.h for the details.
+ */
+static int osp_fid_alloc(const struct lu_env *env, struct lu_device *d,
+                        struct lu_fid *fid, struct lu_object *parent,
+                        const struct lu_name *name)
+{
+       struct osp_device *osp = lu2osp_dev(d);
+       struct client_obd *cli = &osp->opd_obd->u.cli;
+       struct lu_client_seq *seq = cli->cl_seq;
+       int rc;
+
+       ENTRY;
+
+       /* Sigh, fid client is not ready yet */
+       if (!osp->opd_obd->u.cli.cl_seq)
+               RETURN(-ENOTCONN);
+
+       if (!osp->opd_obd->u.cli.cl_seq->lcs_exp)
+               RETURN(-ENOTCONN);
+
+       rc = seq_client_alloc_fid(env, seq, fid);
+
+       RETURN(rc);
+}
+
 const struct lu_device_operations osp_lu_ops = {
        .ldo_object_alloc       = osp_object_alloc,
        .ldo_process_config     = osp_process_config,
        .ldo_recovery_complete  = osp_recovery_complete,
+       .ldo_fid_alloc          = osp_fid_alloc,
 };
 
 /**
@@ -752,10 +789,10 @@ static int osp_statfs(const struct lu_env *env, struct dt_device *dev,
        if (d->opd_pre == NULL)
                RETURN(0);
 
-       CDEBUG(D_OTHER,
-              "%s: %llu blocks, %llu free, %llu avail, %u reserved mb low, %u reserved mb high, %llu files, %llu free files\n",
-              d->opd_obd->obd_name,
-              sfs->os_blocks, sfs->os_bfree, sfs->os_bavail,
+       CDEBUG(D_OTHER, "%s: %llu blocks, %llu free, %llu avail, "
+              "%u bsize, %u reserved mb low, %u reserved mb high, "
+              "%llu files, %llu free files\n", d->opd_obd->obd_name,
+              sfs->os_blocks, sfs->os_bfree, sfs->os_bavail, sfs->os_bsize,
               d->opd_reserved_mb_low, d->opd_reserved_mb_high,
               sfs->os_files, sfs->os_ffree);
 
@@ -1257,10 +1294,8 @@ static struct lu_device *osp_device_free(const struct lu_env *env,
 {
        struct osp_device *osp = lu2osp_dev(lu);
 
-       if (atomic_read(&lu->ld_ref) && lu->ld_site) {
-               LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, D_ERROR, NULL);
-               lu_site_print(env, lu->ld_site, &msgdata, lu_cdebug_printer);
-       }
+       lu_site_print(env, lu->ld_site, &lu->ld_ref, D_ERROR,
+                     lu_cdebug_printer);
        dt_device_fini(&osp->opd_dt_dev);
        OBD_FREE_PTR(osp);
 
@@ -1681,7 +1716,7 @@ static int osp_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
                break;
        default:
                CERROR("%s: unrecognized ioctl %#x by %s\n", obd->obd_name,
-                      cmd, current_comm());
+                      cmd, current->comm);
                rc = -ENOTTY;
        }
        module_put(THIS_MODULE);
@@ -1783,44 +1818,6 @@ static int osp_obd_set_info_async(const struct lu_env *env,
        RETURN(0);
 }
 
-/**
- * Implementation of obd_ops: o_fid_alloc
- *
- * Allocate a FID. There are two cases in which OSP performs
- * FID allocation.
- *
- * 1. FID precreation for data objects, which is done in
- *    osp_precreate_fids() instead of this function.
- * 2. FID allocation for each sub-stripe of a striped directory.
- *    Similar to other FID clients, OSP requests the sequence
- *    from its corresponding remote MDT, which in turn requests
- *    sequences from the sequence controller (MDT0).
- *
- * \param[in] env      execution environment
- * \param[in] exp      export of the OSP
- * \param[out] fid     FID being allocated
- * \param[in] unused   necessary for the interface but unused.
- *
- * \retval 0           0 FID allocated successfully.
- * \retval 1           1 FID allocated successfully and new sequence
- *                      requested from seq meta server
- * \retval negative    negative errno if FID allocation failed.
- */
-static int osp_fid_alloc(const struct lu_env *env, struct obd_export *exp,
-                        struct lu_fid *fid, struct md_op_data *unused)
-{
-       struct client_obd       *cli = &exp->exp_obd->u.cli;
-       struct osp_device       *osp = lu2osp_dev(exp->exp_obd->obd_lu_dev);
-       struct lu_client_seq    *seq = cli->cl_seq;
-       ENTRY;
-
-       LASSERT(osp->opd_obd->u.cli.cl_seq != NULL);
-       /* Sigh, fid client is not ready yet */
-       LASSERT(osp->opd_obd->u.cli.cl_seq->lcs_exp != NULL);
-
-       RETURN(seq_client_alloc_fid(env, seq, fid));
-}
-
 /* context key constructor/destructor: mdt_key_init, mdt_key_fini */
 LU_KEY_INIT_FINI(osp, struct osp_thread_info);
 static void osp_key_exit(const struct lu_context *ctx,
@@ -1882,7 +1879,6 @@ static const struct obd_ops osp_obd_device_ops = {
        .o_statfs       = osp_obd_statfs,
        .o_fid_init     = client_fid_init,
        .o_fid_fini     = client_fid_fini,
-       .o_fid_alloc    = osp_fid_alloc,
 };
 
 /**