114572d558
- remove debugging printf from 0001-Btrfs-progs-add-a-btrfs-select-super-command-to-over.patch (forwarded request 76766 from dsterba) OBS-URL: https://build.opensuse.org/request/show/76976 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/btrfsprogs?expand=0&rev=22
152 lines
4.5 KiB
Diff
152 lines
4.5 KiB
Diff
From 74da7aa43f7ace05794d755a428bf8520d61e8fd Mon Sep 17 00:00:00 2001
|
|
From: "Zhong, Xin" <xin.zhong@intel.com>
|
|
Date: Tue, 21 Jun 2011 09:45:59 +0800
|
|
Subject: [PATCH 31/32] btrfs-progs: Improvement for making btrfs image from
|
|
source directory.
|
|
|
|
* Initialize ret in btrfs_csum_file_block
|
|
* Do not abort when xattr is not supported in the source directory
|
|
* Remove size limitation of 256M
|
|
* Alloc data chunk in a smaller size (8M) to make btrfs image smaller
|
|
* Let user specify the btrfs image name
|
|
Depends on below patch from samsung guys:
|
|
http://marc.info/?l=linux-btrfs&m=127858068226025&w=2
|
|
|
|
Signed-off-by: Zhong, Xin <xin.zhong@intel.com>
|
|
---
|
|
file-item.c | 2 +-
|
|
mkfs.c | 33 +++++++++++++++++----------------
|
|
2 files changed, 18 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/file-item.c b/file-item.c
|
|
index 47f6ad2..c746b44 100644
|
|
--- a/file-item.c
|
|
+++ b/file-item.c
|
|
@@ -193,7 +193,7 @@ int btrfs_csum_file_block(struct btrfs_trans_handle *trans,
|
|
struct btrfs_root *root, u64 alloc_end,
|
|
u64 bytenr, char *data, size_t len)
|
|
{
|
|
- int ret;
|
|
+ int ret = 0;
|
|
struct btrfs_key file_key;
|
|
struct btrfs_key found_key;
|
|
u64 next_offset = (u64)-1;
|
|
diff --git a/mkfs.c b/mkfs.c
|
|
index f2953db..3a49bab 100644
|
|
--- a/mkfs.c
|
|
+++ b/mkfs.c
|
|
@@ -553,6 +553,8 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
|
|
|
|
ret = llistxattr(file_name, xattr_list, XATTR_LIST_MAX);
|
|
if (ret < 0) {
|
|
+ if(errno == ENOTSUP)
|
|
+ return 0;
|
|
fprintf(stderr, "get a list of xattr failed for %s\n",
|
|
file_name);
|
|
return ret;
|
|
@@ -567,8 +569,11 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
|
|
|
|
ret = getxattr(file_name, cur_name, cur_value, XATTR_SIZE_MAX);
|
|
if (ret < 0) {
|
|
- fprintf(stderr, "get a xattr value failed for %s\n",
|
|
- cur_name);
|
|
+ if(errno == ENOTSUP)
|
|
+ return 0;
|
|
+ fprintf(stderr, "get a xattr value failed for %s attr %s\n",
|
|
+ file_name, cur_name);
|
|
+ return ret;
|
|
}
|
|
|
|
ret = btrfs_insert_xattr_item(trans, root, cur_name,
|
|
@@ -584,7 +589,6 @@ static int add_xattr_item(struct btrfs_trans_handle *trans,
|
|
|
|
return ret;
|
|
}
|
|
-
|
|
static int custom_alloc_extent(struct btrfs_root *root, u64 num_bytes,
|
|
u64 hint_byte, struct btrfs_key *ins)
|
|
{
|
|
@@ -957,7 +961,8 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
|
|
cur_inum, cur_file->d_name);
|
|
if (ret) {
|
|
fprintf(stderr, "add_xattr_item failed\n");
|
|
- goto fail;
|
|
+ if(ret != -ENOTSUP)
|
|
+ goto fail;
|
|
}
|
|
|
|
if (S_ISDIR(st.st_mode)) {
|
|
@@ -1019,7 +1024,7 @@ static int create_chunks(struct btrfs_trans_handle *trans,
|
|
u64 chunk_size;
|
|
u64 meta_type = BTRFS_BLOCK_GROUP_METADATA;
|
|
u64 data_type = BTRFS_BLOCK_GROUP_DATA;
|
|
- u64 minimum_data_chunk_size = 64 * 1024 * 1024;
|
|
+ u64 minimum_data_chunk_size = 8 * 1024 * 1024;
|
|
u64 i;
|
|
int ret;
|
|
|
|
@@ -1094,7 +1099,6 @@ static u64 size_sourcedir(char *dir_name, u64 sectorsize,
|
|
char path[512];
|
|
char *file_name = "temp_file";
|
|
FILE *file;
|
|
- u64 minimum_data_size = 256 * 1024 * 1024; /* 256MB */
|
|
u64 default_chunk_size = 8 * 1024 * 1024; /* 8MB */
|
|
u64 allocated_meta_size = 8 * 1024 * 1024; /* 8MB */
|
|
u64 allocated_total_size = 20 * 1024 * 1024; /* 20MB */
|
|
@@ -1133,9 +1137,6 @@ static u64 size_sourcedir(char *dir_name, u64 sectorsize,
|
|
|
|
*num_of_meta_chunks_ret = num_of_meta_chunks;
|
|
|
|
- if (total_size < minimum_data_size)
|
|
- total_size = minimum_data_size;
|
|
-
|
|
return total_size;
|
|
}
|
|
|
|
@@ -1189,9 +1190,9 @@ int main(int ac, char **av)
|
|
|
|
char *source_dir = NULL;
|
|
int source_dir_set = 0;
|
|
- char *output = "output.img";
|
|
u64 num_of_meta_chunks = 0;
|
|
u64 size_of_data = 0;
|
|
+ u64 source_dir_size = 0;
|
|
char *pretty_buf;
|
|
|
|
while(1) {
|
|
@@ -1256,8 +1257,6 @@ int main(int ac, char **av)
|
|
fprintf(stderr, "Illegal nodesize %u\n", nodesize);
|
|
exit(1);
|
|
}
|
|
- if (source_dir_set)
|
|
- ac++;
|
|
ac = ac - optind;
|
|
if (ac == 0)
|
|
print_usage();
|
|
@@ -1288,16 +1287,18 @@ int main(int ac, char **av)
|
|
block_count = dev_block_count;
|
|
} else {
|
|
ac = 0;
|
|
- file = output;
|
|
- fd = open_target(output);
|
|
+ file = av[optind++];
|
|
+ fd = open_target(file);
|
|
if (fd < 0) {
|
|
fprintf(stderr, "unable to open the %s\n", file);
|
|
exit(1);
|
|
}
|
|
|
|
first_file = file;
|
|
- block_count = size_sourcedir(source_dir, sectorsize,
|
|
- &num_of_meta_chunks, &size_of_data);
|
|
+ source_dir_size = size_sourcedir(source_dir, sectorsize,
|
|
+ &num_of_meta_chunks, &size_of_data);
|
|
+ if(block_count < source_dir_size)
|
|
+ block_count = source_dir_size;
|
|
ret = zero_output_file(fd, block_count, sectorsize);
|
|
if (ret) {
|
|
fprintf(stderr, "unable to zero the output file\n");
|
|
--
|
|
1.7.5.2.353.g5df3e
|
|
|