Whamcloud - gitweb
LU-1187 lmv: Locate right MDT in lmv.
[fs/lustre-release.git] / lustre / osd-ldiskfs / osd_quota_fmt.c
index 25db1ce..575d78b 100644 (file)
@@ -21,7 +21,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2011, 2012, Whamcloud, Inc.
+ * Copyright (c) 2012, Intel Corporation.
  * Use is subject to license terms.
  *
  * Lustre administrative quota format.
@@ -64,6 +64,29 @@ static ssize_t quota_read_blk(const struct lu_env *env,
        ENTRY;
 
        memset(buf, 0, LUSTRE_DQBLKSIZE);
+
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2,7,50,0)
+       /* type is set as -1 when reading old admin quota file */
+       if (type != USRQUOTA && type != GRPQUOTA) {
+               struct lu_buf   lu_buffer;
+               loff_t          pos;
+
+               lu_buffer.lb_buf = buf;
+               lu_buffer.lb_len = LUSTRE_DQBLKSIZE;
+               pos = blk << LUSTRE_DQBLKSIZE_BITS;
+
+               ret = dt_record_read(env, &obj->oo_dt, &lu_buffer, &pos);
+
+               if (ret == 0)
+                       ret = LUSTRE_DQBLKSIZE;
+               else if (ret == -EBADR || ret == -EFAULT)
+                       ret = 0;
+               RETURN(ret);
+       }
+#else
+#warning "remove old quota compatibility code"
+#endif
+
        ret = sb->s_op->quota_read(sb, type, buf, LUSTRE_DQBLKSIZE,
                                   blk << LUSTRE_DQBLKSIZE_BITS);
 
@@ -157,7 +180,7 @@ loff_t find_tree_dqentry(const struct lu_env *env,
 
        if (!buf)
                RETURN(-ENOMEM);
-       ret = quota_read_blk(env, obj, 0, blk, buf);
+       ret = quota_read_blk(env, obj, type, blk, buf);
        if (ret < 0) {
                CERROR("Can't read quota tree block %u.\n", blk);
                GOTO(out_buf, ret);