From patchwork Tue Mar 11 10:29:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Shilong X-Patchwork-Id: 3810791 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BFC74BF540 for ; Tue, 11 Mar 2014 10:31:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0410D202A1 for ; Tue, 11 Mar 2014 10:31:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1E7392022A for ; Tue, 11 Mar 2014 10:31:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753831AbaCKKbP (ORCPT ); Tue, 11 Mar 2014 06:31:15 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:22248 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1752904AbaCKKbM (ORCPT ); Tue, 11 Mar 2014 06:31:12 -0400 X-IronPort-AV: E=Sophos;i="4.97,629,1389715200"; d="scan'208";a="9678362" Received: from unknown (HELO tang.cn.fujitsu.com) ([10.167.250.3]) by song.cn.fujitsu.com with ESMTP; 11 Mar 2014 18:27:18 +0800 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id s2BAV9Qg024881 for ; Tue, 11 Mar 2014 18:31:09 +0800 Received: from wangs.fnst.cn.fujitsu.com ([10.167.226.104]) by fnstmail02.fnst.cn.fujitsu.com (Lotus Domino Release 8.5.3) with ESMTP id 2014031118282638-554761 ; Tue, 11 Mar 2014 18:28:26 +0800 From: Wang Shilong To: linux-btrfs@vger.kernel.org Subject: [PATCH 1/2] Btrfs-progs: mkfs: don't create extent for an empty file Date: Tue, 11 Mar 2014 18:29:08 +0800 Message-Id: <1394533749-3138-1-git-send-email-wangsl.fnst@cn.fujitsu.com> X-Mailer: git-send-email 1.9.0 X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/03/11 18:28:26, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2014/03/11 18:28:27, Serialize complete at 2014/03/11 18:28:27 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);