Whamcloud - gitweb
LU-6910 osp: add procfs values for OST reserved size
[fs/lustre-release.git] / lustre / osp / osp_dev.c
index 528e589..2a9d30f 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -752,7 +752,17 @@ static int osp_statfs(const struct lu_env *env, struct dt_device *dev,
               LPU64" files, "LPU64" free files\n", d->opd_obd->obd_name,
               sfs->os_blocks, sfs->os_bfree, sfs->os_bavail,
               sfs->os_files, sfs->os_ffree);
-       RETURN(0);
+
+       /* ENOSPC could be for two reasons,
+        * 1) not enough inodes 2) not enough blocks
+        * for 1) lod should use preallocated objects
+        * and for 2) shouldn`t. So, here for ENOSPC
+        * different values is returned to spend preallocated.
+        */
+       if (d->opd_pre_status == -ENOSPC && sfs->os_ffree < 32)
+               RETURN(0);
+
+       RETURN(d->opd_pre_status);
 }
 
 static int osp_sync_timeout(void *data)
@@ -1586,6 +1596,7 @@ static int osp_import_event(struct obd_device *obd, struct obd_import *imp,
                break;
        case IMP_EVENT_INACTIVE:
                d->opd_imp_active = 0;
+               d->opd_imp_connected = 0;
                if (d->opd_connect_mdt)
                        break;
 
@@ -1689,23 +1700,6 @@ static int osp_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
 }
 
 
-static int osp_set_info_async(const struct lu_env *env,
-                             struct obd_export *exp,
-                             u32 keylen, void *key,
-                             u32 vallen, void *val,
-                             struct ptlrpc_request_set *set)
-{
-       ENTRY;
-
-       if (KEY_IS(KEY_SPTLRPC_CONF)) {
-               sptlrpc_conf_client_adapt(exp->exp_obd);
-               RETURN(0);
-       }
-
-       CERROR("Unknown key %s\n", (char *)key);
-       RETURN(-EINVAL);
-}
-
 /**
  * Implementation of obd_ops::o_get_info
  *
@@ -1748,6 +1742,58 @@ static int osp_obd_get_info(const struct lu_env *env, struct obd_export *exp,
        RETURN(rc);
 }
 
+static int osp_obd_set_info_async(const struct lu_env *env,
+                                 struct obd_export *exp,
+                                 u32 keylen, void *key,
+                                 u32 vallen, void *val,
+                                 struct ptlrpc_request_set *set)
+{
+       struct obd_device       *obd = exp->exp_obd;
+       struct obd_import       *imp = obd->u.cli.cl_import;
+       struct osp_device       *osp;
+       struct ptlrpc_request   *req;
+       char                    *tmp;
+       int                      rc;
+
+       if (KEY_IS(KEY_SPTLRPC_CONF)) {
+               sptlrpc_conf_client_adapt(exp->exp_obd);
+               RETURN(0);
+       }
+
+       LASSERT(set != NULL);
+       if (!obd->obd_set_up || obd->obd_stopping)
+               RETURN(-EAGAIN);
+       osp = lu2osp_dev(obd->obd_lu_dev);
+
+       req = ptlrpc_request_alloc(imp, &RQF_OBD_SET_INFO);
+       if (req == NULL)
+               RETURN(-ENOMEM);
+
+       req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_KEY,
+                            RCL_CLIENT, keylen);
+       req_capsule_set_size(&req->rq_pill, &RMF_SETINFO_VAL,
+                            RCL_CLIENT, vallen);
+       if (osp->opd_connect_mdt)
+               rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_SET_INFO);
+       else
+               rc = ptlrpc_request_pack(req, LUSTRE_OST_VERSION, OST_SET_INFO);
+       if (rc) {
+               ptlrpc_request_free(req);
+               RETURN(rc);
+       }
+
+       tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_KEY);
+       memcpy(tmp, key, keylen);
+       tmp = req_capsule_client_get(&req->rq_pill, &RMF_SETINFO_VAL);
+       memcpy(tmp, val, vallen);
+
+       ptlrpc_request_set_replen(req);
+       ptlrpc_set_add_req(set, req);
+       ptlrpc_check_set(NULL, set);
+
+       RETURN(0);
+}
+
 /**
  * Implementation of obd_ops: o_fid_alloc
  *
@@ -1841,13 +1887,13 @@ static struct obd_ops osp_obd_device_ops = {
        .o_connect      = osp_obd_connect,
        .o_disconnect   = osp_obd_disconnect,
        .o_get_info     = osp_obd_get_info,
+       .o_set_info_async = osp_obd_set_info_async,
        .o_import_event = osp_import_event,
        .o_iocontrol    = osp_iocontrol,
        .o_statfs       = osp_obd_statfs,
        .o_fid_init     = client_fid_init,
        .o_fid_fini     = client_fid_fini,
        .o_fid_alloc    = osp_fid_alloc,
-       .o_set_info_async   = osp_set_info_async,
 };
 
 struct llog_operations osp_mds_ost_orig_logops;
@@ -1864,7 +1910,7 @@ struct llog_operations osp_mds_ost_orig_logops;
  * \retval 0           0 if initialization succeeds.
  * \retval negative    negative errno if initialization failed.
  */
-static int __init osp_mod_init(void)
+static int __init osp_init(void)
 {
        struct obd_type *type;
        int rc;
@@ -1916,17 +1962,17 @@ static int __init osp_mod_init(void)
  * This callback is called when kernel unloads OSP module from memory, and
  * it will deregister OSP and LWP device type from obd_types (\see class_obd.c).
  */
-static void __exit osp_mod_exit(void)
+static void __exit osp_exit(void)
 {
        class_unregister_type(LUSTRE_LWP_NAME);
        class_unregister_type(LUSTRE_OSP_NAME);
        lu_kmem_fini(osp_caches);
 }
 
-MODULE_AUTHOR("Intel, Inc. <http://www.intel.com/>");
-MODULE_DESCRIPTION("Lustre OST Proxy Device ("LUSTRE_OSP_NAME")");
+MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
+MODULE_DESCRIPTION("Lustre OSD Storage Proxy ("LUSTRE_OSP_NAME")");
 MODULE_VERSION(LUSTRE_VERSION_STRING);
 MODULE_LICENSE("GPL");
 
-module_init(osp_mod_init);
-module_exit(osp_mod_exit);
+module_init(osp_init);
+module_exit(osp_exit);