Whamcloud - gitweb
LU-14687 llite: Return errors for aio
[fs/lustre-release.git] / lustre / quota / lquota_disk.c
index aa4d358..4353f1a 100644 (file)
@@ -50,6 +50,7 @@
 
 #define DEBUG_SUBSYSTEM S_LQUOTA
 
+#include <obd_class.h>
 #include "lquota_internal.h"
 
 #define LQUOTA_MODE (S_IFREG | S_IRUGO | S_IWUSR)
@@ -128,7 +129,7 @@ static inline int lquota_disk_slv_filename(const struct lu_fid *glb_fid,
        name++;
 
        /* the filename is composed of the most signicant bits of the global
-        * FID, that's to say the oid which encodes the pool id, pool type and
+        * FID, that's to say the oid which encodes the pool type and
         * quota type, followed by the export UUID */
        sprintf(filename, "0x%x-%s", glb_fid->f_oid, name);
 
@@ -247,8 +248,7 @@ struct dt_object *lquota_disk_glb_find_create(const struct lu_env *env,
        idx_feat = &dt_quota_glb_features;
 
        /* the filename is composed of the most signicant bits of the FID,
-        * that's to say the oid which encodes the pool id, pool type and quota
-        * type */
+        * that's to say the oid which encodes the pool type and quota type */
        sprintf(qti->qti_buf, "0x%x", fid->f_oid);
 
        if (local) {
@@ -381,7 +381,7 @@ struct dt_object *lquota_disk_slv_find_create(const struct lu_env *env,
 {
        struct lquota_thread_info       *qti = lquota_info(env);
        struct dt_object                *slv_idx;
-       int                              rc;
+       int                              rc, type;
        ENTRY;
 
        LASSERT(uuid != NULL);
@@ -394,19 +394,29 @@ struct dt_object *lquota_disk_slv_find_create(const struct lu_env *env,
        if (rc)
                RETURN(ERR_PTR(rc));
 
+       if (lu_device_is_md(dev->dd_lu_dev.ld_site->ls_top_dev))
+               type = LDD_F_SV_TYPE_MDT;
+       else
+               type = LDD_F_SV_TYPE_OST;
+
        /* Slave indexes uses the FID_SEQ_QUOTA sequence since they can be read
         * through the network */
        qti->qti_fid.f_seq = FID_SEQ_QUOTA;
        qti->qti_fid.f_ver = 0;
        if (local) {
-               int type;
+               int pool_type, qtype;
 
-               rc = lquota_extract_fid(glb_fid, NULL, NULL, &type);
+               rc = lquota_extract_fid(glb_fid, &pool_type, &qtype);
                if (rc)
                        RETURN(ERR_PTR(rc));
 
                /* use predefined fid in the reserved oid list */
-               qti->qti_fid.f_oid = qtype2slv_oid(type);
+               if ((type == LDD_F_SV_TYPE_MDT && pool_type == LQUOTA_RES_MD) ||
+                   (type == LDD_F_SV_TYPE_OST && pool_type == LQUOTA_RES_DT))
+                       qti->qti_fid.f_oid = qtype2slv_oid(qtype);
+               else
+                       qti->qti_fid.f_oid = pool_type << 16 |
+                                                       qtype2slv_oid(qtype);
 
                slv_idx = local_index_find_or_create_with_fid(env, dev,
                                                              &qti->qti_fid,
@@ -531,7 +541,7 @@ int lquota_disk_for_each_slv(const struct lu_env *env, struct dt_object *parent,
                if (qti->qti_fid.f_seq != FID_SEQ_QUOTA)
                        goto next;
 
-               rc = func(env, glb_fid, (char *)key, &qti->qti_fid, arg);
+               rc = func(env, glb_fid, qti->qti_buf, &qti->qti_fid, arg);
                if (rc)
                        break;
 next:
@@ -660,11 +670,11 @@ int lquota_disk_write(const struct lu_env *env, struct thandle *th,
 
        if (rec != NULL) {
                /* insert record with updated quota settings */
-               rc = dt_insert(env, obj, rec, key, th, 1);
+               rc = dt_insert(env, obj, rec, key, th);
                if (rc) {
                        /* try to insert the old one */
                        rc = dt_insert(env, obj, (struct dt_rec *)&qti->qti_rec,
-                                      key, th, 1);
+                                      key, th);
                        LASSERTF(rc == 0, "failed to insert record in quota "
                                 "index "DFID"\n",
                                 PFID(lu_object_fid(&obj->do_lu)));
@@ -782,7 +792,7 @@ int lquota_disk_write_glb(const struct lu_env *env, struct dt_object *obj,
                rc = 0;
        }
 
-       rc = dt_insert(env, obj, (struct dt_rec *)rec, key, th, 1);
+       rc = dt_insert(env, obj, (struct dt_rec *)rec, key, th);
 out_lock:
        dt_write_unlock(env, obj);
 out: