Whamcloud - gitweb
LU-4221 osd: add case LCFG_PARAM to osd_process_config
[fs/lustre-release.git] / lustre / osd-zfs / udmu.c
index 1bb5d2a..ce3df6a 100644 (file)
@@ -28,7 +28,7 @@
  * Use is subject to license terms.
  */
 /*
- * Copyright (c) 2011, 2012 Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  * Use is subject to license terms.
  */
 /*
@@ -45,6 +45,9 @@
  * Author: Mike Pershin <tappro@whamcloud.com>
  */
 
+#include <lustre/lustre_idl.h>  /* OBD_OBJECT_EOF */
+#include <lustre/lustre_user.h> /* struct obd_statfs */
+
 #include <sys/dnode.h>
 #include <sys/dbuf.h>
 #include <sys/spa.h>
@@ -58,9 +61,6 @@
 #include <sys/sa_impl.h>
 #include <sys/txg.h>
 
-#include <lustre/lustre_idl.h>  /* OBD_OBJECT_EOF */
-#include <lustre/lustre_user.h> /* struct obd_statfs */
-
 #include "udmu.h"
 
 int udmu_blk_insert_cost(void)
@@ -149,7 +149,7 @@ int udmu_objset_open(char *osname, udmu_objset_t *uos)
        dmu_objset_space(uos->os, &refdbytes, &availbytes, &usedobjs,
                         &availobjs);
        uos->objects = usedobjs;
-       cfs_spin_lock_init(&uos->lock);
+       spin_lock_init(&uos->lock);
 
 out:
        if (error && uos->os != NULL)
@@ -198,7 +198,7 @@ static uint64_t udmu_objs_count_estimate(uint64_t refdbytes,
        CLASSERT(OSD_DNODE_EST_BLKSHIFT > 0);
 
        est_refdblocks = (refdbytes >> SPA_MAXBLOCKSHIFT) +
-               (OSD_DNODE_EST_COUNT << OSD_DNODE_EST_BLKSHIFT);
+                        (OSD_DNODE_EST_COUNT >> OSD_DNODE_EST_BLKSHIFT);
        est_usedobjs   = usedobjs + OSD_DNODE_EST_COUNT;
 
        /* Average space/dnode more than maximum dnode size, use max dnode
@@ -341,122 +341,6 @@ uint64_t udmu_objset_user_iused(udmu_objset_t *uos, uint64_t uidbytes)
        return uidobjs;
 }
 
-/* Get the objset name.
-   buf must have at least MAXNAMELEN bytes */
-void udmu_objset_name_get(udmu_objset_t *uos, char *buf)
-{
-       dmu_objset_name(uos->os, buf);
-}
-
-static int udmu_userprop_setup(udmu_objset_t *uos, const char *prop_name,
-               char **os_name, char **real_prop)
-{
-       if (os_name != NULL) {
-               *os_name = kmem_alloc(MAXNAMELEN, KM_SLEEP);
-               udmu_objset_name_get(uos, *os_name);
-       }
-
-       *real_prop = kmem_alloc(MAXNAMELEN, KM_SLEEP);
-
-       if (snprintf(*real_prop, MAXNAMELEN, "lustre:%s", prop_name) >=
-                       MAXNAMELEN) {
-               if (os_name != NULL)
-                       kmem_free(*os_name, MAXNAMELEN);
-               kmem_free(*real_prop, MAXNAMELEN);
-
-               CERROR("property name too long: %s\n", prop_name);
-               return ENAMETOOLONG;
-       }
-
-       return 0;
-}
-
-static void udmu_userprop_cleanup(char **os_name, char **real_prop)
-{
-       if (os_name != NULL)
-               kmem_free(*os_name, MAXNAMELEN);
-       kmem_free(*real_prop, MAXNAMELEN);
-}
-
-/* Set ZFS user property 'prop_name' of objset 'uos' to string 'val' */
-int udmu_userprop_set_str(udmu_objset_t *uos, const char *prop_name,
-               const char *val)
-{
-       char *os_name;
-       char *real_prop;
-       int rc;
-
-       rc = udmu_userprop_setup(uos, prop_name, &os_name, &real_prop);
-       if (rc != 0)
-               return rc;
-
-       rc = dsl_prop_set(os_name, real_prop, ZPROP_SRC_LOCAL, 1,
-                       strlen(val) + 1, val);
-       udmu_userprop_cleanup(&os_name, &real_prop);
-
-       return rc;
-}
-
-/* Get ZFS user property 'prop_name' of objset 'uos' into buffer 'buf' of size
-   'buf_size' */
-int udmu_userprop_get_str(udmu_objset_t *uos, const char *prop_name, char *buf,
-                               size_t buf_size)
-{
-       char *real_prop;
-       char *nvp_val;
-       size_t nvp_len;
-       nvlist_t *nvl = NULL;
-       nvlist_t *nvl_val;
-       nvpair_t *elem = NULL;
-       int rc;
-
-       rc = udmu_userprop_setup(uos, prop_name, NULL, &real_prop);
-       if (rc != 0)
-               return rc;
-
-       /* We can't just pass buf_size to dsl_prop_get() because it expects the
-          exact value size (zap_lookup() requirement), so we must get all props
-          and extract the one we want. */
-       rc = dsl_prop_get_all(uos->os, &nvl);
-       if (rc != 0) {
-               nvl = NULL;
-               goto out;
-       }
-
-       while ((elem = nvlist_next_nvpair(nvl, elem)) != NULL) {
-               const char *name = nvpair_name(elem);
-               if (strcmp(name, real_prop) != 0)
-                       continue;
-
-               /* Got the property we were looking for, but the val is not the
-                  string yet, it's an nvlist */
-
-               rc = nvpair_value_nvlist(elem, &nvl_val);
-               if (rc != 0)
-                       goto out;
-
-               rc = nvlist_lookup_string(nvl_val, ZPROP_VALUE, &nvp_val);
-               if (rc != 0)
-                       goto out;
-
-               nvp_len = strlen(nvp_val);
-               if (buf_size < nvp_len + 1) {
-                       rc = EOVERFLOW;
-                       goto out;
-               }
-               strcpy(buf, nvp_val);
-               goto out;
-       }
-       /* Not found */
-       rc = ENOENT;
-out:
-       if (nvl != NULL)
-               nvlist_free(nvl);
-       udmu_userprop_cleanup(NULL, &real_prop);
-
-       return rc;
-}
-
 /* We don't actually have direct access to the zap_hashbits() function
  * so just pretend like we do for now.  If this ever breaks we can look at
  * it at that time. */