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 38C9CC6FD18 for ; Tue, 18 Apr 2023 14:38:17 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 78A41860BB; Tue, 18 Apr 2023 16:36:56 +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="K0GOh8Qk"; dkim=pass (2048-bit key) header.d=codewreck.org header.i=@codewreck.org header.b="wz2wIcfH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C55BD86043; Tue, 18 Apr 2023 05:53:58 +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 6AEDC8579A for ; Tue, 18 Apr 2023 05:53:56 +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 02E35C01D; Tue, 18 Apr 2023 05:53:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1681790036; bh=Db8qm9pRqZtyNTRYll629dy2U2gd2KOs98jRHg4BZxY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=K0GOh8Qk9XYSxahmiTGG4mTwbb2LJF6DB7kaZmYzfyAiQA+uxF9gILItJ0nWVdDoK GMaOwKsnm27Ukf85L0/x5jwc2PpBZhXZ55LD91VstY6h1b7yql7UC9TUzsvMFEblYZ s8hWgeanWVfmclGXQvshzXP1CkSdQPKibsnebKjdCCIjnhYnqonKlRa1ic21NKie1j OGmzmkidwFbwG55NflZiPcEFikJlGjC9S96PH+o5WWTGsWi6N2nqmQeaY480uTPR08 clFmIuQV1N2XhKq5fki+0Jib2tsfY8A7c4xCfSWAsdntXzLk7q3O8neKgw7d+TcUai ZEv+MT+5mephA== Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id 4EFC6C009; Tue, 18 Apr 2023 05:53:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1681790035; bh=Db8qm9pRqZtyNTRYll629dy2U2gd2KOs98jRHg4BZxY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wz2wIcfHQgI4z0viA/zIeRkNUE1RioyfUaylDtBHkemCXrTHgAa5VvB3++Fnv0vJC vYbM2yV0zDtng5V70D9fnGBZmN7d+8jYe5v9c9TFCka7CglFuU3uwZ0yOdVM+wbLKu 6L/aV2mtrJ9nBMV/ZQGL+tFdGskYqVmrDddsQh2RJEiogiVYWFxwvLWGpWECu70whu 4FY+d8ILanbcE9ceZLWC7MAjCc2vHF5qN/xZ6qP9gFdm7Y8Ve7WDXu+B+ozILsPSP3 EAMQ1O53yvUILnE79yoR7vuTbEcB07ToFniDj8jJR+g9vJCTC1KownlkIYxNYJmmC4 Bvzq29o9INUtQ== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id 747d48f9; Tue, 18 Apr 2023 03:53:50 +0000 (UTC) Date: Tue, 18 Apr 2023 12:53:35 +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> <58fdd612-d2ac-1a77-25e5-59e8f7b668a2@gmx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <58fdd612-d2ac-1a77-25e5-59e8f7b668a2@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 11:21:00AM +0800: > > No, was just thinking the leading part being a separate loop doesn't > > seem to make sense either as the code shouldn't care about sector size > > alignemnt but about full extents. > > The main concern related to the leading unaligned part is, we need to skip > something unaligned from the beginning , while all other situations never > need to skip such case (they at most skip the tailing part). Ok, there is one exception for inline extents apparently.. But I'm not still not convinced the `aligned_start != file_offset` check is enough for that either; I'd say it's unlikely but the inline part can be compressed, so we could have a file which has > 4k (sectorsize) of expanded data, so a read from the 4k offset would skip the special handling and fail (reading the whole extent in dest) Even if that's not possible, reading just the first 10 bytes of an inline extent will be aligned and go through the main loop which just reads the whole extent, so it'll need the same handling as the regular btrfs_read_extent_reg handling at which point it might just as well handle start offset too. That aside taking the loop in order: - lookup_data_extent doesn't care (used in heading/tail) - skipping holes don't care as they explicitely put cursor at start of next extent (or bail out if nothing next) - inline needs fixing anyway as said above - PREALLOC or nothing on disk also goes straight to next and is ok - ah, I see what you meant now, we need to substract the current position within the extent to extent_num_bytes... That's also already a problem, though; to take the same example: 0 8k 16k [extent1 | extent2 ... ] reading from 4k onwards will try to read min(extent_num_bytes, end-cur) = min(8k, 12k) = 8k from the 4k offset which goes over the end of the extent. That could actually be my resets from the previous mail. So either the first check should just lookup the extent and check that extent start matches current offset instead of checking for sectorsize alignment, or we can just fix the loop and remove the first if. -- Dominique Martinet | Asmadeus