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 <wangsl.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <clm@fb.com>
This commit is contained in:
parent
d1fffb0221
commit
3bb703dcae
3
mkfs.c
3
mkfs.c
|
@ -619,6 +619,9 @@ static int add_file_items(struct btrfs_trans_handle *trans,
|
||||||
struct extent_buffer *eb = NULL;
|
struct extent_buffer *eb = NULL;
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
if (st->st_size == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
fd = open(path_name, O_RDONLY);
|
fd = open(path_name, O_RDONLY);
|
||||||
if (fd == -1) {
|
if (fd == -1) {
|
||||||
fprintf(stderr, "%s open failed\n", path_name);
|
fprintf(stderr, "%s open failed\n", path_name);
|
||||||
|
|
Loading…
Reference in New Issue