Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / lustre / mdd / mdd_object.c
index 1efe365..0cf918a 100644 (file)
@@ -67,6 +67,15 @@ static int mdd_xattr_get(const struct lu_env *env,
                          struct md_object *obj, struct lu_buf *buf,
                          const char *name);
 
+int mdd_data_get(const struct lu_env *env, struct mdd_object *obj,
+                 void **data)
+{
+        LASSERTF(mdd_object_exists(obj), "FID is "DFID"\n",
+                 PFID(mdd_object_fid(obj)));
+        mdo_data_get(env, obj, data);
+        return 0;
+}
+
 int mdd_la_get(const struct lu_env *env, struct mdd_object *obj,
                struct lu_attr *la, struct lustre_capa *capa)
 {
@@ -155,7 +164,11 @@ struct lu_buf *mdd_buf_alloc(const struct lu_env *env, ssize_t len)
         return buf;
 }
 
-/* preserve old data */
+/** Increase the size of the \a mti_big_buf.
+ * preserves old data in buffer
+ * old buffer remains unchanged on error
+ * \retval 0 or -ENOMEM
+ */
 int mdd_buf_grow(const struct lu_env *env, ssize_t len)
 {
         struct lu_buf *oldbuf = &mdd_env_info(env)->mti_big_buf;
@@ -423,12 +436,10 @@ static int mdd_path_current(const struct lu_env *env,
                 /* Get parent fid and object name */
                 mdd_read_lock(env, mdd_obj, MOR_TGT_CHILD);
                 buf = mdd_links_get(env, mdd_obj);
-                if (IS_ERR(buf))
-                        GOTO(out, rc = PTR_ERR(buf));
                 mdd_read_unlock(env, mdd_obj);
                 mdd_object_put(env, mdd_obj);
-                if (rc < 0)
-                        GOTO(out, rc);
+                if (IS_ERR(buf))
+                        GOTO(out, rc = PTR_ERR(buf));
 
                 leh = buf->lb_buf;
                 lee = (struct link_ea_entry *)(leh + 1); /* link #0 */
@@ -1244,15 +1255,19 @@ static int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
                         /* get file quota for new owner */
                         lquota_chkquota(mds_quota_interface_ref, obd,
                                         qnids[USRQUOTA], qnids[GRPQUOTA], 1,
-                                        &inode_pending, NULL, 0);
+                                        &inode_pending, NULL, 0, NULL, 0);
                         block_count = (la_tmp->la_blocks + 7) >> 3;
-                        if (block_count)
+                        if (block_count) {
+                                void *data = NULL;
+                                mdd_data_get(env, mdd_obj, &data);
                                 /* get block quota for new owner */
                                 lquota_chkquota(mds_quota_interface_ref, obd,
                                                 qnids[USRQUOTA],
                                                 qnids[GRPQUOTA],
                                                 block_count, &block_pending,
-                                                NULL, LQUOTA_FLAGS_BLK);
+                                                NULL, LQUOTA_FLAGS_BLK,
+                                                data, 1);
+                        }
                 }
         }
 #endif
@@ -1307,11 +1322,11 @@ cleanup:
                 if (inode_pending)
                         lquota_pending_commit(mds_quota_interface_ref, obd,
                                               qnids[USRQUOTA], qnids[GRPQUOTA],
-                                              1, 0);
+                                              inode_pending, 0);
                 if (block_pending)
                         lquota_pending_commit(mds_quota_interface_ref, obd,
                                               qnids[USRQUOTA], qnids[GRPQUOTA],
-                                              block_count, 1);
+                                              block_pending, 1);
                 /* Trigger dqrel/dqacq for original owner and new owner.
                  * If failed, the next call for lquota_chkquota will
                  * process it. */
@@ -1561,7 +1576,8 @@ static int mdd_object_create(const struct lu_env *env,
                 mdd_quota_wrapper(&ma->ma_attr, qids);
                 /* get file quota for child */
                 lquota_chkquota(mds_quota_interface_ref, obd, qids[USRQUOTA],
-                                qids[GRPQUOTA], 1, &inode_pending, NULL, 0);
+                                qids[GRPQUOTA], 1, &inode_pending, NULL, 0,
+                                NULL, 0);
                 switch (ma->ma_attr.la_mode & S_IFMT) {
                 case S_IFLNK:
                 case S_IFDIR:
@@ -1576,7 +1592,7 @@ static int mdd_object_create(const struct lu_env *env,
                         lquota_chkquota(mds_quota_interface_ref, obd,
                                         qids[USRQUOTA], qids[GRPQUOTA],
                                         block_count, &block_pending, NULL,
-                                        LQUOTA_FLAGS_BLK);
+                                        LQUOTA_FLAGS_BLK, NULL, 0);
         }
 #endif
 
@@ -1646,11 +1662,11 @@ out_pending:
                 if (inode_pending)
                         lquota_pending_commit(mds_quota_interface_ref, obd,
                                               qids[USRQUOTA], qids[GRPQUOTA],
-                                              1, 0);
+                                              inode_pending, 0);
                 if (block_pending)
                         lquota_pending_commit(mds_quota_interface_ref, obd,
                                               qids[USRQUOTA], qids[GRPQUOTA],
-                                              block_count, 1);
+                                              block_pending, 1);
                 /* Trigger dqacq on the owner of child. If failed,
                  * the next call for lquota_chkquota will process it. */
                 lquota_adjust(mds_quota_interface_ref, obd, qids, 0, rc,