X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-zfs%2Fudmu.c;h=ce3df6ae58fa81f4f8f83c9dbd0c6394220af2e1;hb=b1491d26271f074dc6f99cde037403337c0b2151;hp=1bb5d2a1298449c4f9626b0aab30c7106d639ebe;hpb=a6179606f842d8fb0961296011ed70d383cc0f4e;p=fs%2Flustre-release.git diff --git a/lustre/osd-zfs/udmu.c b/lustre/osd-zfs/udmu.c index 1bb5d2a..ce3df6a 100644 --- a/lustre/osd-zfs/udmu.c +++ b/lustre/osd-zfs/udmu.c @@ -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 */ +#include /* OBD_OBJECT_EOF */ +#include /* struct obd_statfs */ + #include #include #include @@ -58,9 +61,6 @@ #include #include -#include /* OBD_OBJECT_EOF */ -#include /* 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. */