All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Btrfs-progs: mkfs: don't create extent for an empty file
@ 2014-03-11 10:29 Wang Shilong
  2014-03-11 10:29 ` [PATCH 2/2] Btrfs-progs: mkfs: make sure we can deal with hard links with -r option Wang Shilong
  0 siblings, 1 reply; 4+ messages in thread
From: Wang Shilong @ 2014-03-11 10:29 UTC (permalink / raw)
  To: linux-btrfs

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>
---
 mkfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mkfs.c b/mkfs.c
index 2dc90c2..2f7dfef 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);
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-03-13 11:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-11 10:29 [PATCH 1/2] Btrfs-progs: mkfs: don't create extent for an empty file Wang Shilong
2014-03-11 10:29 ` [PATCH 2/2] Btrfs-progs: mkfs: make sure we can deal with hard links with -r option Wang Shilong
2014-03-12 16:21   ` David Sterba
2014-03-13 11:24     ` Wang Shilong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.