From patchwork Mon Mar 30 16:48:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 1264095 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.a=rsa-sha256 header.s=default header.b=V7XtLU0E; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48rdhY2PKpz9sNg for ; Tue, 31 Mar 2020 03:49:01 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A0FE980369; Mon, 30 Mar 2020 18:48:53 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="V7XtLU0E"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 4267281885; Mon, 30 Mar 2020 18:48:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail.nic.cz (lists.nic.cz [217.31.204.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 918B18019A for ; Mon, 30 Mar 2020 18:48:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=marek.behun@nic.cz Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id AE69B140CF8; Mon, 30 Mar 2020 18:48:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1585586928; bh=P7uZjeRRrDdwVBGAC/9WwkehBLB3fZgrWEKUjjDYZJU=; h=From:To:Date; b=V7XtLU0EAz0lBFu/mocuGWYKsVRJaTQUZ4fvGa5/a9CcEK5YtDy+zHywptZzyjF4e +Q4mhWaoYZ1Al+w/QPCrCiC9tURDPADOLESBug8c5l0jW1Du2Q7/5WTue98RLWuuL7 ck/t4iMWVzjiAN+Dk5pU2jXBhbgM7eTC1hLLy2wM= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Cc: Tom Rini , =?utf-8?q?Marek_Beh=C3=BAn?= Subject: [PATCH v2] fs: btrfs: support sparse extents Date: Mon, 30 Mar 2020 18:48:42 +0200 Message-Id: <20200330164842.12391-1-marek.behun@nic.cz> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-Spamd-Bar: / X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean When logical address of a regular extent is 0, the extent is sparse and consists of all zeros. Without this when sparse extents are used in a file reading fails with Cannot map logical address 0 to physical Signed-off-by: Marek BehĂșn --- fs/btrfs/extent-io.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/btrfs/extent-io.c b/fs/btrfs/extent-io.c index 66d0e1c7d6..2e4599cf64 100644 --- a/fs/btrfs/extent-io.c +++ b/fs/btrfs/extent-io.c @@ -78,6 +78,12 @@ u64 btrfs_read_extent_reg(struct btrfs_path *path, if (size > dlen - offset) size = dlen - offset; + /* sparse extent */ + if (extent->disk_bytenr == 0) { + memset(out, 0, size); + return size; + } + physical = btrfs_map_logical_to_physical(extent->disk_bytenr); if (physical == -1ULL) return -1ULL;