Whamcloud - gitweb
LU-2154 osp: precreate logic to use last assigned id
[fs/lustre-release.git] / lustre / osp / osp_dev.c
index cf9ee4f..5fcca70 100644 (file)
@@ -212,7 +212,7 @@ int osp_disconnect(struct osp_device *d)
        (void)ptlrpc_pinger_del_import(imp);
 
        rc = ptlrpc_disconnect_import(imp, 0);
-       if (rc)
+       if (rc && rc != -ETIMEDOUT)
                CERROR("%s: can't disconnect: rc = %d\n",
                       d->opd_obd->obd_name, rc);
 
@@ -319,19 +319,8 @@ static int osp_statfs(const struct lu_env *env, struct dt_device *dev,
 
        ENTRY;
 
-       if (unlikely(d->opd_imp_active == 0)) {
-               /*
-                * in case of inactive OST we return nulls
-                * so that caller can understand this device
-                * is unusable for new objects
-                *
-                * XXX: shouldn't we take normal statfs and fill
-                * just few specific fields with zeroes?
-                */
-               memset(sfs, 0, sizeof(*sfs));
-               sfs->os_bsize = 4096;
-               RETURN(0);
-       }
+       if (unlikely(d->opd_imp_active == 0))
+               RETURN(-ENOTCONN);
 
        /* return recently updated data */
        *sfs = d->opd_statfs;
@@ -341,9 +330,12 @@ static int osp_statfs(const struct lu_env *env, struct dt_device *dev,
         * how many objects are available for immediate creation
         */
        cfs_spin_lock(&d->opd_pre_lock);
-       sfs->os_ffree = d->opd_pre_last_created - d->opd_pre_next;
+       sfs->os_fprecreated = d->opd_pre_last_created - d->opd_pre_used_id;
+       sfs->os_fprecreated -= d->opd_pre_reserved;
        cfs_spin_unlock(&d->opd_pre_lock);
 
+       LASSERT(sfs->os_fprecreated <= OST_MAX_PRECREATE);
+
        CDEBUG(D_OTHER, "%s: "LPU64" blocks, "LPU64" free, "LPU64" avail, "
               LPU64" files, "LPU64" free files\n", d->opd_obd->obd_name,
               sfs->os_blocks, sfs->os_bfree, sfs->os_bavail,
@@ -584,6 +576,10 @@ static struct lu_device *osp_device_free(const struct lu_env *env,
 
        ENTRY;
 
+       if (cfs_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);
+       }
        dt_device_fini(&m->opd_dt_dev);
        OBD_FREE_PTR(m);
        RETURN(NULL);
@@ -709,6 +705,10 @@ static int osp_obd_connect(const struct lu_env *env, struct obd_export **exp,
                                 OBD_CONNECT_SKIP_ORPHAN |
                                 OBD_CONNECT_VERSION |
                                 OBD_CONNECT_FID;
+
+       if (is_osp_on_ost(osp->opd_obd->obd_name))
+               ocd->ocd_connect_flags |= OBD_CONNECT_LIGHTWEIGHT;
+
        ocd->ocd_version = LUSTRE_VERSION_CODE;
        LASSERT(data->ocd_connect_flags & OBD_CONNECT_INDEX);
        ocd->ocd_index = data->ocd_index;