Whamcloud - gitweb
LU-6142 tests: Fix style issues for chownmany.c
[fs/lustre-release.git] / lustre / mdt / mdt_som.c
index 8636c61..80438fa 100644 (file)
@@ -75,8 +75,8 @@ int mdt_get_som(struct mdt_thread_info *info, struct mdt_object *obj,
 
        buf->lb_buf = info->mti_xattr_buf;
        buf->lb_len = sizeof(info->mti_xattr_buf);
-       CLASSERT(sizeof(struct lustre_som_attrs) <=
-                sizeof(info->mti_xattr_buf));
+       BUILD_BUG_ON(sizeof(struct lustre_som_attrs) >
+                    sizeof(info->mti_xattr_buf));
        rc = mo_xattr_get(info->mti_env, mdt_object_child(obj), buf,
                          XATTR_NAME_SOM);
        rc = lustre_buf2som(info->mti_xattr_buf, rc, &ma->ma_som);
@@ -85,21 +85,21 @@ int mdt_get_som(struct mdt_thread_info *info, struct mdt_object *obj,
 
                ma->ma_valid |= MA_SOM;
 
-               if ((som->ms_valid & SOM_FL_STRICT)) {
+               CDEBUG(D_INODE, DFID": Reading som attrs: "
+                      "valid: %x, size: %lld, blocks: %lld\n",
+                      PFID(mdt_object_fid(obj)), som->ms_valid,
+                      som->ms_size, som->ms_blocks);
+
+               if (som->ms_valid & SOM_FL_STRICT) {
                        attr->la_valid |= LA_SIZE | LA_BLOCKS;
-                       attr->la_size = som->ms_size;
-                       attr->la_blocks = som->ms_blocks;
 
                        /*
                         * Size on MDS is valid and could be returned
                         * to client.
                         */
+                       attr->la_size = som->ms_size;
+                       attr->la_blocks = som->ms_blocks;
                        info->mti_som_valid = 1;
-
-                       CDEBUG(D_INODE, DFID": Reading som attrs: "
-                              "valid: %x, size: %lld, blocks: %lld\n",
-                              PFID(mdt_object_fid(obj)), som->ms_valid,
-                              som->ms_size, som->ms_blocks);
                }
        } else if (rc == -ENODATA) {
                rc = 0;
@@ -126,7 +126,7 @@ int mdt_set_som(struct mdt_thread_info *info, struct mdt_object *obj,
               PFID(mdt_object_fid(obj)), size, blocks, flag);
 
        som = (struct lustre_som_attrs *)info->mti_xattr_buf;
-       CLASSERT(sizeof(info->mti_xattr_buf) >= sizeof(*som));
+       BUILD_BUG_ON(sizeof(info->mti_xattr_buf) < sizeof(*som));
 
        som->lsa_valid = flag;
        som->lsa_size = size;
@@ -196,23 +196,30 @@ int mdt_lsom_update(struct mdt_thread_info *info,
        if (rc)
                GOTO(out_lock, rc);
 
-       rc = mo_xattr_get(info->mti_env, mdt_object_child(o), &LU_BUF_NULL,
-                         XATTR_NAME_LOV);
-       if (rc < 0 && rc != -ENODATA)
-               GOTO(out_lock, rc);
-       else if (rc > 0) /* has LOV EA*/
-               tmp_ma->ma_valid |= MA_LOV;
+       /**
+        * If mti_big_lmm_used is set, it indicates that mti_big_lmm
+        * should contain valid LOV EA data, and can be used directly.
+        */
+       if (!info->mti_big_lmm_used) {
+               rc = mdt_big_xattr_get(info, o, XATTR_NAME_LOV);
+               if (rc < 0 && rc != -ENODATA)
+                       GOTO(out_lock, rc);
+
+               /* No LOV EA */
+               if (rc == -ENODATA)
+                       GOTO(out_lock, rc = 0);
+
+               rc = 0;
+       }
 
-       rc = 0;
        /**
         * Check if a Lazy Size-on-MDS update is needed. Skip the
-        * file with no LOV EA or unlink files.
+        * file with no LOV EA, unlink files or DoM-only file.
         * MDS only updates LSOM of the file if the size or block
         * size is being increased or the file is being truncated.
         */
-       if ((tmp_ma->ma_valid & MA_LOV) &&
-           !(tmp_ma->ma_valid & MA_INODE &&
-             tmp_ma->ma_attr.la_nlink == 0)) {
+       if (mdt_lmm_dom_entry(info->mti_big_lmm) != LMM_DOM_ONLY &&
+           !(tmp_ma->ma_valid & MA_INODE && tmp_ma->ma_attr.la_nlink == 0)) {
                __u64 size;
                __u64 blocks;
                bool changed = false;