Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp220986pxv; Wed, 21 Jul 2021 21:01:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDKscZWCzRJ1BJCWgR/QXf/pa9McjB/mjReUrOF8LDp6TliLbQn5jpHJZESK0cvzat3nZo X-Received: by 2002:a17:906:e099:: with SMTP id gh25mr41306429ejb.346.1626926494703; Wed, 21 Jul 2021 21:01:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626926494; cv=none; d=google.com; s=arc-20160816; b=m9Ut//qWWkDjvwQz6v8WV9ON6/Q3eHwZs/27dDs8kWGjUCmby0+c1bR6lIinVudgz1 p4auDq57tgtjbYzvp0990/B2sTmXg0+QEt6O8AAgLoC31D7mckcGQbUpYQ8vyrdYUL4e gLUrij6F/GYlogM8kdbRgGYZ4nZCgsZSB22upk2vjAU+FIjvU/Ktjq3gYLrjHqIO91Xn YtxU22br3eaOg+ldM+LlrvGbNMza1hQazmbODjij4W3zGAOqLQa1lJT5cXuYUaq7cn5/ uiJk+p/TL9kOc9H/LnJ9WDDkq8DXWF1fRAjXTg5EYmvxb0fyQHxbS0rp1RY/8tkKbaqn fLWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Wlgo+HDD4XVGLL4+0YFLCCYhPxqOV8dpTaeF7KubZV8=; b=OX5eix0tJlwhkwYIjQIMvpgP0McmrdB/e1b0V5cIiHfQDlgEtf2Xu2A/PKfhXXWzZj vvVvXYUooSD+e499nv/M1kZZ2Dsqrxxuk87Dlc8aEOXZohoPJykubdW6opisQ8ozKJ5r nW3DZCdOiLpC9cIUfNE04LLYULUHqfbAQ8Yl1IwQcTrRjr94RgkuRWogra+2uxkTMztG 7YSEaOhJRl4256fUHPNYtn68Cqinw0Qjy9GPCnh/HhCnSxBc3Gu4os+H5YFJBc65VTZm LYa6eXI1xtenY+GIJt73UbCanA1wPT5AhD9rumwvPuyuwJMys9zdm/0tLdn+icklSTPG /Mfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="JQ/huajM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 18si31599356ejj.476.2021.07.21.21.01.10; Wed, 21 Jul 2021 21:01:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="JQ/huajM"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230306AbhGVDTG (ORCPT + 99 others); Wed, 21 Jul 2021 23:19:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229900AbhGVDTF (ORCPT ); Wed, 21 Jul 2021 23:19:05 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8344C061575 for ; Wed, 21 Jul 2021 20:59:40 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id q16so6430329lfa.5 for ; Wed, 21 Jul 2021 20:59:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Wlgo+HDD4XVGLL4+0YFLCCYhPxqOV8dpTaeF7KubZV8=; b=JQ/huajMzCvVKfzB6aXogb7L836C3TbNsinJ3VRro9HWNGJASIrofApytSysWx4L99 SN/GyG1XubEsMr0nMeDuu5DDdYmp88OHzfyCvx0gJx3GTlNqBZLKp3E63TK9hkX29xId ZXCj6I2h60ZWd4i/7Cy4wIoYBZDUWCA1jqe32KiLFIRFL8hpkHW3k+Q2icTUSuzmuh8G 24irTrEULS/CB+qFB5HJaBGHDP0TaISr7GRev9KR5LwZ4ZrgB2/9gu57Hoq2aSgKtqFP NlGa/7TjcyUpdzWubtvAzQeobWJeePGtUSmA5OSXA8YzMzkOcEdn2xSU2NmPF8PYWNw1 IWAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Wlgo+HDD4XVGLL4+0YFLCCYhPxqOV8dpTaeF7KubZV8=; b=DDL8sZN3UPoHfC5mKHA9RkVyBb7fCw6ikiGz3YRpoIjdVTjMRzaAjHW0Q0pi6Mq8Z0 JvCuPcLZAXDyxKggbKf75/YjdtK7ovSRUQ8oWkzTYxsOKWdS+VnPQIG+OI8OjdnFsfh/ hQKYnN1RFQpxBG/XRNuxMZLPh9V9d/GrVPfv2JKyoEmcVBf2slWtQHd7Q1Vfeki3ec1x 4rpBtx4CLPe+OIT0W8v+ZQilFCgYAjjpybCCBbuwS4a7ecCB4GxpAE95GGOOf/nVOQP1 /qEnUa5U64UqHicBmRip/03V4acBogNOCSUwuUHRrQcIYsCf0jGeYtOuJW6hIzD9z9aN lWDA== X-Gm-Message-State: AOAM531Q4SCh5PGza2dtFbJQpN2hCT0tADdvwpkQib/L52vse9Fn9ino xIV/aectppDZsfRLuKSBm4WixdO7yAlXHynEYio= X-Received: by 2002:a19:7512:: with SMTP id y18mr28071154lfe.533.1626926379270; Wed, 21 Jul 2021 20:59:39 -0700 (PDT) MIME-Version: 1.0 References: <20210721072048.3035928-1-daeho43@gmail.com> In-Reply-To: From: Daeho Jeong Date: Wed, 21 Jul 2021 20:59:28 -0700 Message-ID: Subject: Re: [f2fs-dev] [PATCH] f2fs: change fiemap way in printing compression chunk To: Eric Biggers Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 21, 2021 at 6:56 PM Eric Biggers wrote: > > On Wed, Jul 21, 2021 at 06:40:00PM -0700, Daeho Jeong wrote: > > On Wed, Jul 21, 2021 at 6:15 PM Eric Biggers wrote: > > > > > > On Wed, Jul 21, 2021 at 06:04:22PM -0700, Daeho Jeong wrote: > > > > > > > > > > How f2fs stores the mapping information doesn't matter. That's an > > > > > implementation detail that shouldn't be exposed to userspace. The only thing > > > > > that should be exposed is the actual mapping, and for that it seems natural to > > > > > report the physical blocks first. > > > > > > > > > > There is no perfect solution for how to handle the remaining logical blocks, > > > > > given that the fiemap API was not designed for compressed files, but I think we > > > > > should just go with extending the length of the last compressed extent in the > > > > > cluster to cover the remaining logical blocks, i.e.: > > > > > > > > > > [0..31]: 2683128..2683159 flag(0x1009) -> merged, encoded, last_extent > > > > > > > > > > That's what btrfs does on compressed files. > > > > > > > > > > - Eric > > > > > > > > I also agree that that's an implementation detail that shouldn't be > > > > exposed to userspace. > > > > > > > > I want to make it more clear for better appearance. > > > > > > > > Do you think we have to remove "unwritten" information below? I also > > > > think it might be unnecessary information for the user. > > > > [0..31]: 2683128..2683159 flag(0x1009) -> merged, encoded, last_extent > > > > (unwritten?) > > > > > > FIEMAP_EXTENT_UNWRITTEN already has a specific meaning; see > > > Documentation/filesystems/fiemap.rst. It means that the data is all zeroes, and > > > the disk space is preallocated but the data hasn't been written to disk yet. > > > > > > In this case, the data is *not* necessarily all zeroes. So I think > > > FIEMAP_EXTENT_UNWRITTEN shouldn't be used here. > > > > > > > Do you want f2fs to print out the info on a cluster basis, even when > > > > the user asks for one block information? > > > > Like > > > > If the user asks for the info of [8..15], f2fs will return the info of [0..31]? > > > > > > Yes, since that's how FS_IOC_FIEMAP is supposed to work; see > > > Documentation/filesystems/fiemap.rst: > > > > > > All offsets and lengths are in bytes and mirror those on disk. It is > > > valid for an extents logical offset to start before the request or its > > > logical length to extend past the request. > > > > > > (That being said, the f2fs compression+encryption tests I've written don't > > > exercise this case; they only map the whole file at once.) > > > > > > - Eric > > > > My last question is. > > How about a discontinuous cluster like [0..31] maps to discontinuous > > three blocks like physical address 0x4, 0x14 and 0x24. > > I think we have to return three extents for the one logical region > > like the below. What do you think? > > [0..31] -> 0x4 (merged, encoded) > > [0..31] -> 0x14 (merged, encoded) > > [0..31] -> 0x24 (merged, encoded, last_extent) > > No, please don't do that. struct fiemap_extent only has a single length field, > not separate lengths for fe_logical and fe_physical, so with your proposal there > would be no way to know how many physical blocks to take from each extent. It > would be reporting the same part of the file in contradictory ways. > > Like I suggested originally, I think this case should be reported like: > > fe_logical=0 fe_physical=16384 length=4096 > fe_logical=4096 fe_physical=81920 length=4096 > fe_logical=8192 fe_physical=147456 length=8192 > > It's not perfect, but I think it's the least bad option, for the reasons I've > explained previously... > > - Eric Ok, I got your point. Let me try it again. Thank you,