X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-zfs%2Fosd_quota.c;h=4ef1ad5f633b4e78289e666f0d26dd2c0eac6502;hb=refs%2Fchanges%2F94%2F15294%2F28;hp=d9867145facd3a5f40cc95478e1df69d0745d8e5;hpb=0754bc8f2623bea184111af216f7567608db35b6;p=fs%2Flustre-release.git diff --git a/lustre/osd-zfs/osd_quota.c b/lustre/osd-zfs/osd_quota.c index d986714..4ef1ad5 100644 --- a/lustre/osd-zfs/osd_quota.c +++ b/lustre/osd-zfs/osd_quota.c @@ -92,6 +92,7 @@ static int osd_acct_index_lookup(const struct lu_env *env, { struct osd_thread_info *info = osd_oti_get(env); char *buf = info->oti_buf; + size_t buflen = sizeof(info->oti_buf); struct lquota_acct_rec *rec = (struct lquota_acct_rec *)dtrec; struct osd_object *obj = osd_dt_obj(dtobj); struct osd_device *osd = osd_obj2dev(obj); @@ -102,44 +103,44 @@ static int osd_acct_index_lookup(const struct lu_env *env, rec->bspace = rec->ispace = 0; /* convert the 64-bit uid/gid into a string */ - sprintf(buf, "%llx", *((__u64 *)dtkey)); + snprintf(buf, buflen, "%llx", *((__u64 *)dtkey)); /* fetch DMU object ID (DMU_USERUSED_OBJECT/DMU_GROUPUSED_OBJECT) to be * used */ oid = osd_quota_fid2dmu(lu_object_fid(&dtobj->do_lu)); /* disk usage (in bytes) is maintained by DMU. * 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. */ - rc = -zap_lookup(osd->od_os, oid, buf, sizeof(uint64_t), 1, + * not associated with any dmu_but_t (see dnode_special_open()). */ + rc = zap_lookup(osd->od_os, oid, buf, sizeof(uint64_t), 1, &rec->bspace); - if (rc == -ENOENT) + if (rc == -ENOENT) { /* user/group has not created anything yet */ CDEBUG(D_QUOTA, "%s: id %s not found in DMU accounting ZAP\n", osd->od_svname, buf); - else if (rc) + } else if (rc) { RETURN(rc); + } - if (osd->od_quota_iused_est) { + if (!osd_dmu_userobj_accounting_available(osd)) { if (rec->bspace != 0) /* estimate #inodes in use */ rec->ispace = osd_objset_user_iused(osd, rec->bspace); - RETURN(+1); + rc = 1; + } else { + snprintf(buf, buflen, OSD_DMU_USEROBJ_PREFIX "%llx", + *((__u64 *)dtkey)); + rc = zap_lookup(osd->od_os, oid, buf, sizeof(uint64_t), 1, + &rec->ispace); + if (rc == -ENOENT) { + CDEBUG(D_QUOTA, + "%s: id %s not found dnode accounting\n", + osd->od_svname, buf); + } else if (rc == 0) { + rc = 1; + } } - /* 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, - buf, sizeof(uint64_t), 1, &rec->ispace); - if (rc == -ENOENT) - /* user/group has not created any file yet */ - CDEBUG(D_QUOTA, "%s: id %s not found in accounting ZAP\n", - osd->od_svname, buf); - else if (rc) - RETURN(rc); - - RETURN(+1); + RETURN(rc); } /** @@ -197,7 +198,7 @@ static void osd_it_acct_fini(const struct lu_env *env, struct dt_it *di) ENTRY; osd_zap_cursor_fini(it->oiq_zc); - lu_object_put(env, &it->oiq_obj->oo_dt.do_lu); + osd_object_put(env, it->oiq_obj); OBD_FREE_PTR(it); EXIT; @@ -329,7 +330,7 @@ static int osd_it_acct_rec(const struct lu_env *env, if (rc) RETURN(rc); - if (osd->od_quota_iused_est) { + if (!osd_dmu_userobj_accounting_available(osd)) { if (rec->bspace != 0) /* estimate #inodes in use */ rec->ispace = osd_objset_user_iused(osd, rec->bspace); @@ -343,7 +344,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 */