From 3bb703dcaec52b187526e5a0a5faf145ab18a716 Mon Sep 17 00:00:00 2001 From: Wang Shilong Date: Tue, 11 Mar 2014 18:29:08 +0800 Subject: Btrfs-progs: mkfs: don't create extent for an empty file Steps to reproduce: # mkdir -p /tmp/test # touch /tmp/test/file # mkfs.btrfs -f /dev/sda13 -r /tmp/test # btrfs check /dev/sda13 For an empty file, don't create extent data for it. Signed-off-by: Wang Shilong Signed-off-by: David Sterba Signed-off-by: Chris Mason --- mkfs.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'mkfs.c') diff --git a/mkfs.c b/mkfs.c index 2dc90c24..2f7dfef7 100644 --- a/mkfs.c +++ b/mkfs.c @@ -619,6 +619,9 @@ static int add_file_items(struct btrfs_trans_handle *trans, struct extent_buffer *eb = NULL; int fd; + if (st->st_size == 0) + return 0; + fd = open(path_name, O_RDONLY); if (fd == -1) { fprintf(stderr, "%s open failed\n", path_name); -- cgit v1.2.3