From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4940C77B75 for ; Tue, 18 Apr 2023 14:37:36 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 14EE6860B4; Tue, 18 Apr 2023 16:36:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=codewreck.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=codewreck.org header.i=@codewreck.org header.b="PtKi0OBM"; dkim=pass (2048-bit key) header.d=codewreck.org header.i=@codewreck.org header.b="nBqGqTT9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 00B1185644; Tue, 18 Apr 2023 04:41:51 +0200 (CEST) Received: from nautica.notk.org (ipv6.notk.org [IPv6:2001:41d0:1:7a93::1]) (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 A277D85644 for ; Tue, 18 Apr 2023 04:41:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=codewreck.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=asmadeus@codewreck.org Received: by nautica.notk.org (Postfix, from userid 108) id 434B9C01E; Tue, 18 Apr 2023 04:41:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1681785709; bh=KddbRCzfq6VIU/ykR2SKbAHvO6vb0GTeFRqjvXUtYrE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PtKi0OBM1tNvni3DrLXriJpg7pQQ9FEaW8rqX0Vpa+J7HBsDBUOCJBeAWnCGOZvoL t6oHnux/EYeSIXj/cTad3DIeOpsiwJhY+DOjTRiUIkWaZPIc8vqTT1U/8PiIMX6MYV SKUiBuxhuLYKiCRlG6OZgu8gJ7ZQ2LXjvg6mdCQMaE+WxMpqmrDirhHNFYd06QzU+i XTY4MLP9x1fZgsB/l4cySWAv+0BF7A7u7E1VRoY4KZ07wUFJP0+mlJuLPYLrUP0qPB Eun8nnpLSbflsOkJd48+2jy560Lv7NqUwDpGE3/lWJQtYT1C5dfqj7KDuJysbmTCx+ wBpDV0NfJbWIA== Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id AB5C2C009; Tue, 18 Apr 2023 04:41:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1681785708; bh=KddbRCzfq6VIU/ykR2SKbAHvO6vb0GTeFRqjvXUtYrE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nBqGqTT9wIaSiAl/XLBrtAj/7NApgPm098Y9FkIpBlR6/DAdVAK+UqQj6ZML6B/Fs TKR7J1g/fQul53+w1IW0Wn37W8x2DumlqPdyoktSuPvmbw9exdnUfT5Q/HTieIoW92 XSNA5ngB0X9GpkmUVwRiyS4VQtUubt/daPQm+xXrcXyhrU3EKzpq6ZHnsLMMHozhTM gJmFbqM/Q0HBA0tkrG0c4LxjU9odoOMmdSJyBWCuq8TxHdfCfiISyelExdt1HlAtDH J8qIXYAAst+ExAn3hK3EKA1/H/QIQOCb5BSDaZp4dnTyPCuQmBbpppMa5zF8A78Pi6 x27TgniLir89g== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id f593bbb0; Tue, 18 Apr 2023 02:41:43 +0000 (UTC) Date: Tue, 18 Apr 2023 11:41:27 +0900 From: Dominique Martinet To: Qu Wenruo Cc: Marek =?utf-8?B?QmVow7pu?= , Qu Wenruo , linux-btrfs@vger.kernel.org, u-boot@lists.denx.de, Dominique Martinet Subject: Re: [PATCH U-BOOT 2/3] btrfs: btrfs_file_read: allow opportunistic read until the end Message-ID: References: <20230418-btrfs-extent-reads-v1-0-47ba9839f0cc@codewreck.org> <20230418-btrfs-extent-reads-v1-2-47ba9839f0cc@codewreck.org> <6c82ddd9-0e3d-4213-5cd3-af7ad69ebe48@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <6c82ddd9-0e3d-4213-5cd3-af7ad69ebe48@gmx.com> X-Mailman-Approved-At: Tue, 18 Apr 2023 16:36:34 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean Qu Wenruo wrote on Tue, Apr 18, 2023 at 10:02:00AM +0800: > > /* Read the tailing unaligned part*/ > > Can we remove this part completely? > > IIRC if we read until the target end, the unaligned end part can be > completely removed then. The "Read the aligned part" loop stops at aligned_end: > while (cur < aligned_end) So it should be possible that the last aligned extent we consider does not contain data until the end, e.g. an offset that ends with the aligned end: 0 4096 4123 [extent1-----|extent2] In this case the main loop will only read extent1 and we need the "trailing unaligned part" if for extent2. I have a feeling the loop could just be updated to go to the end `while (cur < end)` as it doesn't seem to care about the end alignment... Should I update v2 to do that instead? This made me look at the "Read out the leading unaligned part" initial part, and its check only looks at the sector size but it probably has the same problem -- we want to make sure we read any leftover from a previous extent e.g. this file: 0 4096 8192 [extent1------------------|extent2] and reading from 4k with a sectorsize of 4k is probably bad will enter the aligned main loop right away... And I think that'll fail?... Actually not quite sure what's expecting what to be aligned in there, but I just tried some partial reads from non-zero offsets and my board resets almost all the time so I guess I've found something else to dig into. This isn't a priority for me right now but I'll look a bit more when I have more time if you haven't first. -- Dominique Martinet | Asmadeus