Whamcloud - gitweb
- handle empty page in cmm_split_remove_page() at Tom's suggestion;
authoryury <yury>
Mon, 30 Oct 2006 10:07:45 +0000 (10:07 +0000)
committeryury <yury>
Mon, 30 Oct 2006 10:07:45 +0000 (10:07 +0000)
- fixes about le_to_cpu in mdt_write_dir_page()

lustre/cmm/cmm_split.c
lustre/mdt/mdt_handler.c

index cb538a0..8277337 100644 (file)
@@ -430,6 +430,13 @@ static int cmm_split_remove_page(const struct lu_env *env,
 
         kmap(rdpg->rp_pages[0]);
         dp = page_address(rdpg->rp_pages[0]);
+
+        /* If page is empty return zero len. */
+        if (lu_dirent_start(dp) == NULL) {
+                *len = 0;
+                GOTO(unmap, rc = 0);
+        }
+        
         for (ent = lu_dirent_start(dp); ent != NULL;
              ent = lu_dirent_next(ent)) {
                 if (ent->lde_hash < hash_end) {
@@ -444,10 +451,10 @@ static int cmm_split_remove_page(const struct lu_env *env,
                                 *len = (int)((__u32)ent - (__u32)dp);
                         else
                                 *len = 0;
-                        GOTO(unmap, rc);
+                        GOTO(unmap, 0);
                 }
         }
-        *len = CFS_PAGE_SIZE;
+        *len =  CFS_PAGE_SIZE;
         EXIT;
 unmap:
         kunmap(rdpg->rp_pages[0]);
index 0b0aad0..ed66076 100644 (file)
@@ -1061,23 +1061,23 @@ static int mdt_write_dir_page(struct mdt_thread_info *info, struct page *page,
                 struct lu_fid *lf = &ent->lde_fid;
                 char *name;
 
-                if (le32_to_cpu(ent->lde_namelen) == 0)
+                if (le16_to_cpu(ent->lde_namelen) == 0)
                         continue;
                 
                 is_dir = le32_to_cpu(ent->lde_hash) & MAX_HASH_HIGHEST_BIT;
-                OBD_ALLOC(name, le32_to_cpu(ent->lde_namelen) + 1);
+                OBD_ALLOC(name, le16_to_cpu(ent->lde_namelen) + 1);
                 if (name == NULL)
                         GOTO(out, rc = -ENOMEM);
                 
-                memcpy(name, ent->lde_name, le32_to_cpu(ent->lde_namelen));
+                memcpy(name, ent->lde_name, le16_to_cpu(ent->lde_namelen));
                 rc = mdo_name_insert(info->mti_env,
                                      md_object_next(&object->mot_obj),
                                      name, lf, is_dir);
-                OBD_FREE(name, le32_to_cpu(ent->lde_namelen) + 1);
+                OBD_FREE(name, le16_to_cpu(ent->lde_namelen) + 1);
                 if (rc)
                         GOTO(out, rc);
 
-                offset += le32_to_cpu(ent->lde_reclen);
+                offset += le16_to_cpu(ent->lde_reclen);
                 if (offset >= size)
                         break;
         }