Whamcloud - gitweb
LU-8726 osd-ldiskfs: bypass read for benchmarking
[fs/lustre-release.git] / lustre / osd-zfs / osd_quota.c
index 3247ddd..d9ac3e7 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  * Use is subject to license terms.
  *
  * Author: Johann Lombardi <johann@whamcloud.com>
@@ -49,15 +49,16 @@ uint64_t osd_quota_fid2dmu(const struct lu_fid *fid)
 static uint64_t osd_objset_user_iused(struct osd_device *osd, uint64_t uidbytes)
 {
        uint64_t refdbytes, availbytes, usedobjs, availobjs;
-       uint64_t uidobjs;
+       uint64_t uidobjs, bshift;
 
        /* get fresh statfs info */
        dmu_objset_space(osd->od_os, &refdbytes, &availbytes,
                         &usedobjs, &availobjs);
 
        /* estimate the number of objects based on the disk usage */
+       bshift = fls64(osd->od_max_blksz) - 1;
        uidobjs = osd_objs_count_estimate(refdbytes, usedobjs,
-                                         uidbytes >> SPA_MAXBLOCKSHIFT);
+                                         uidbytes >> bshift, bshift);
        if (uidbytes > 0)
                /* if we have at least 1 byte, we have at least one dnode ... */
                uidobjs = max_t(uint64_t, uidobjs, 1);
@@ -80,7 +81,6 @@ static uint64_t osd_objset_user_iused(struct osd_device *osd, uint64_t uidbytes)
  * \param dtrec - is the record to fill with space usage information
  * \param dtkey - is the id the of the user or group for which we would
  *                like to access disk usage.
- * \param capa - is the capability, not used.
  *
  * \retval +ve - success : exact match
  * \retval -ve - failure
@@ -88,8 +88,7 @@ static uint64_t osd_objset_user_iused(struct osd_device *osd, uint64_t uidbytes)
 static int osd_acct_index_lookup(const struct lu_env *env,
                                struct dt_object *dtobj,
                                struct dt_rec *dtrec,
-                               const struct dt_key *dtkey,
-                               struct lustre_capa *capa)
+                               const struct dt_key *dtkey)
 {
        struct osd_thread_info  *info = osd_oti_get(env);
        char                    *buf  = info->oti_buf;
@@ -112,7 +111,7 @@ static int osd_acct_index_lookup(const struct lu_env *env,
         * DMU_USERUSED_OBJECT/DMU_GROUPUSED_OBJECT are special objects which
         * not associated with any dmu_but_t (see dnode_special_open()).
         * As a consequence, we cannot use udmu_zap_lookup() here since it
-        * requires a valid oo_db. */
+        * requires a valid oo_dn. */
        rc = -zap_lookup(osd->od_os, oid, buf, sizeof(uint64_t), 1,
                        &rec->bspace);
        if (rc == -ENOENT)
@@ -131,7 +130,7 @@ static int osd_acct_index_lookup(const struct lu_env *env,
 
        /* as for inode accounting, it is not maintained by DMU, so we just
         * use our own ZAP to track inode usage */
-       rc = -zap_lookup(osd->od_os, obj->oo_db->db_object,
+       rc = -zap_lookup(osd->od_os, obj->oo_dn->dn_object,
                         buf, sizeof(uint64_t), 1, &rec->ispace);
        if (rc == -ENOENT)
                /* user/group has not created any file yet */
@@ -148,12 +147,10 @@ static int osd_acct_index_lookup(const struct lu_env *env,
  *
  * \param  dt    - osd index object
  * \param  attr  - not used
- * \param  capa  - BYPASS_CAPA
  */
 static struct dt_it *osd_it_acct_init(const struct lu_env *env,
                                      struct dt_object *dt,
-                                     __u32 attr,
-                                     struct lustre_capa *capa)
+                                     __u32 attr)
 {
        struct osd_thread_info  *info = osd_oti_get(env);
        struct osd_it_quota     *it;
@@ -167,14 +164,9 @@ static struct dt_it *osd_it_acct_init(const struct lu_env *env,
        if (info == NULL)
                RETURN(ERR_PTR(-ENOMEM));
 
-       if (info->oti_it_inline) {
-               OBD_ALLOC_PTR(it);
-               if (it == NULL)
-                       RETURN(ERR_PTR(-ENOMEM));
-       } else {
-               it = &info->oti_it_quota;
-               info->oti_it_inline = 1;
-       }
+       OBD_ALLOC_PTR(it);
+       if (it == NULL)
+               RETURN(ERR_PTR(-ENOMEM));
 
        memset(it, 0, sizeof(*it));
        it->oiq_oid = osd_quota_fid2dmu(lu_object_fid(lo));
@@ -182,11 +174,7 @@ static struct dt_it *osd_it_acct_init(const struct lu_env *env,
        /* initialize zap cursor */
        rc = osd_zap_cursor_init(&it->oiq_zc, osd->od_os, it->oiq_oid, 0);
        if (rc != 0) {
-               if (it != &info->oti_it_quota)
-                       OBD_FREE_PTR(it);
-               else
-                       info->oti_it_inline = 0;
-
+               OBD_FREE_PTR(it);
                RETURN(ERR_PTR(rc));
        }
 
@@ -205,16 +193,12 @@ static struct dt_it *osd_it_acct_init(const struct lu_env *env,
  */
 static void osd_it_acct_fini(const struct lu_env *env, struct dt_it *di)
 {
-       struct osd_thread_info  *info   = osd_oti_get(env);
        struct osd_it_quota     *it     = (struct osd_it_quota *)di;
        ENTRY;
 
        osd_zap_cursor_fini(it->oiq_zc);
        lu_object_put(env, &it->oiq_obj->oo_dt.do_lu);
-       if (it != &info->oti_it_quota)
-               OBD_FREE_PTR(it);
-       else
-               info->oti_it_inline = 0;
+       OBD_FREE_PTR(it);
 
        EXIT;
 }
@@ -359,7 +343,7 @@ static int osd_it_acct_rec(const struct lu_env *env,
 
        /* inode accounting is not maintained by DMU, so we use our own ZAP to
         * track inode usage */
-       rc = -zap_lookup(osd->od_os, it->oiq_obj->oo_db->db_object,
+       rc = -zap_lookup(osd->od_os, it->oiq_obj->oo_dn->dn_object,
                         za->za_name, sizeof(uint64_t), 1, &rec->ispace);
        if (rc == -ENOENT)
                /* user/group has not created any file yet */