Whamcloud - gitweb
filefrag: Lustre changes to filefrag FIEMAP handling
[tools/e2fsprogs.git] / misc / mk_hugefiles.c
index 7f1be2e..5f56a79 100644 (file)
@@ -357,8 +357,9 @@ static errcode_t mk_hugefile(ext2_filsys fs, blk64_t num,
        if (retval)
                goto errout;
        size = (__u64) count * fs->blocksize;
-       inode.i_size = size & 0xffffffff;
-       inode.i_size_high = (size >> 32);
+       retval = ext2fs_inode_size_set(fs, &inode, size);
+       if (retval)
+               goto errout;
 
        retval = ext2fs_write_new_inode(fs, *ino, &inode);
        if (retval)
@@ -436,7 +437,6 @@ static blk64_t get_start_block(ext2_filsys fs, blk64_t slack)
                                                blk, last_blk, &next);
                if (retval)
                        next = last_blk;
-               next--;
 
                if (next - blk > slack) {
                        blk += slack;
@@ -489,9 +489,18 @@ errcode_t mk_hugefiles(ext2_filsys fs, const char *device_name)
        t = get_string_from_profile(fs_types, "hugefiles_align", "0");
        align = parse_num_blocks2(t, fs->super->s_log_block_size);
        free(t);
-       if (get_bool_from_profile(fs_types, "hugefiles_align_disk", 0))
+       if (get_bool_from_profile(fs_types, "hugefiles_align_disk", 0)) {
                part_offset = get_partition_start(device_name) /
                        (fs->blocksize / 512);
+               if (part_offset % EXT2FS_CLUSTER_RATIO(fs)) {
+                       fprintf(stderr,
+                               _("Partition offset of %llu (%uk) blocks "
+                                 "not compatible with cluster size %u.\n"),
+                               part_offset, fs->blocksize,
+                               EXT2_CLUSTER_SIZE(fs->super));
+                       exit(1);
+               }
+       }
        num_blocks = round_up_align(num_blocks, align, 0);
        zero_hugefile = get_bool_from_profile(fs_types, "zero_hugefiles",
                                              zero_hugefile);