b3ba9dc0aa
- adjust fs size to correct size (bnc#744593) - man page documentation updates - do not package obsolete utilities - mkfs: store correct size of device in superblock (bnc#730103) - updated restriper/balance commands to match kernel version - device scanning fixes for dm and multipath (bnc#749540) OBS-URL: https://build.opensuse.org/package/show/filesystems/btrfsprogs?expand=0&rev=121
106 lines
4.2 KiB
Diff
106 lines
4.2 KiB
Diff
From 7e2b203768ae87b3614149e99e00afe4fa9394ab Mon Sep 17 00:00:00 2001
|
|
From: Jan Kara <jack@suse.cz>
|
|
Date: Thu, 26 Jan 2012 17:03:05 +0100
|
|
Subject: [PATCH] mkfs: Handle creation of filesystem larger than the first
|
|
device
|
|
|
|
make_btrfs() function takes a size of filesystem as an argument. It uses this
|
|
value to set the size of the first device as well which is wrong for
|
|
filesystems larger than this device. It results in 'attemp to access beyond end
|
|
of device' messages from the kernel. So add size of the first device as an
|
|
argument to make_btrfs().
|
|
|
|
CC: David Sterba <dsterba@suse.cz>
|
|
Signed-off-by: Jan Kara <jack@suse.cz>
|
|
---
|
|
convert.c | 2 +-
|
|
mkfs.c | 6 ++++--
|
|
utils.c | 4 ++--
|
|
utils.h | 2 +-
|
|
4 files changed, 8 insertions(+), 6 deletions(-)
|
|
|
|
Index: btrfs-progs-v0.19-118-gfdb6c04/convert.c
|
|
===================================================================
|
|
--- btrfs-progs-v0.19-118-gfdb6c04.orig/convert.c
|
|
+++ btrfs-progs-v0.19-118-gfdb6c04/convert.c
|
|
@@ -2374,7 +2374,7 @@ int do_convert(const char *devname, int
|
|
goto fail;
|
|
}
|
|
ret = make_btrfs(fd, devname, ext2_fs->super->s_volume_name,
|
|
- blocks, total_bytes, blocksize, blocksize,
|
|
+ blocks, total_bytes, total_bytes, blocksize, blocksize,
|
|
blocksize, blocksize);
|
|
if (ret) {
|
|
fprintf(stderr, "unable to create initial ctree\n");
|
|
Index: btrfs-progs-v0.19-118-gfdb6c04/mkfs.c
|
|
===================================================================
|
|
--- btrfs-progs-v0.19-118-gfdb6c04.orig/mkfs.c
|
|
+++ btrfs-progs-v0.19-118-gfdb6c04/mkfs.c
|
|
@@ -1290,6 +1290,10 @@ int main(int ac, char **av)
|
|
ret = btrfs_prepare_device(fd, file, zero_end, &dev_block_count, &mixed);
|
|
if (block_count == 0)
|
|
block_count = dev_block_count;
|
|
+ else if (block_count > dev_block_count) {
|
|
+ fprintf(stderr, "%s is smaller than requested size\n", file);
|
|
+ exit(1);
|
|
+ }
|
|
} else {
|
|
ac = 0;
|
|
file = av[optind++];
|
|
@@ -1302,8 +1306,10 @@ int main(int ac, char **av)
|
|
first_file = file;
|
|
source_dir_size = size_sourcedir(source_dir, sectorsize,
|
|
&num_of_meta_chunks, &size_of_data);
|
|
- if(block_count < source_dir_size)
|
|
+ if (block_count < source_dir_size)
|
|
block_count = source_dir_size;
|
|
+ dev_block_count = block_count;
|
|
+
|
|
ret = zero_output_file(fd, block_count, sectorsize);
|
|
if (ret) {
|
|
fprintf(stderr, "unable to zero the output file\n");
|
|
@@ -1329,7 +1335,7 @@ int main(int ac, char **av)
|
|
leafsize * i;
|
|
}
|
|
|
|
- ret = make_btrfs(fd, file, label, blocks, block_count,
|
|
+ ret = make_btrfs(fd, file, label, blocks, block_count, dev_block_count,
|
|
nodesize, leafsize,
|
|
sectorsize, stripesize);
|
|
if (ret) {
|
|
Index: btrfs-progs-v0.19-118-gfdb6c04/utils.c
|
|
===================================================================
|
|
--- btrfs-progs-v0.19-118-gfdb6c04.orig/utils.c
|
|
+++ btrfs-progs-v0.19-118-gfdb6c04/utils.c
|
|
@@ -74,7 +74,7 @@ static u64 reference_root_table[] = {
|
|
};
|
|
|
|
int make_btrfs(int fd, const char *device, const char *label,
|
|
- u64 blocks[7], u64 num_bytes, u32 nodesize,
|
|
+ u64 blocks[7], u64 num_bytes, u64 dev_num_bytes, u32 nodesize,
|
|
u32 leafsize, u32 sectorsize, u32 stripesize)
|
|
{
|
|
struct btrfs_super_block super;
|
|
@@ -276,7 +276,7 @@ int make_btrfs(int fd, const char *devic
|
|
dev_item = btrfs_item_ptr(buf, nritems, struct btrfs_dev_item);
|
|
btrfs_set_device_id(buf, dev_item, 1);
|
|
btrfs_set_device_generation(buf, dev_item, 0);
|
|
- btrfs_set_device_total_bytes(buf, dev_item, num_bytes);
|
|
+ btrfs_set_device_total_bytes(buf, dev_item, dev_num_bytes);
|
|
btrfs_set_device_bytes_used(buf, dev_item,
|
|
BTRFS_MKFS_SYSTEM_GROUP_SIZE);
|
|
btrfs_set_device_io_align(buf, dev_item, sectorsize);
|
|
Index: btrfs-progs-v0.19-118-gfdb6c04/utils.h
|
|
===================================================================
|
|
--- btrfs-progs-v0.19-118-gfdb6c04.orig/utils.h
|
|
+++ btrfs-progs-v0.19-118-gfdb6c04/utils.h
|
|
@@ -22,7 +22,7 @@
|
|
#define BTRFS_MKFS_SYSTEM_GROUP_SIZE (4 * 1024 * 1024)
|
|
|
|
int make_btrfs(int fd, const char *device, const char *label,
|
|
- u64 blocks[6], u64 num_bytes, u32 nodesize,
|
|
+ u64 blocks[6], u64 num_bytes, u64 dev_num_bytes, u32 nodesize,
|
|
u32 leafsize, u32 sectorsize, u32 stripesize);
|
|
int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
|
|
struct btrfs_root *root, u64 objectid);
|