Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp167750pxv; Wed, 21 Jul 2021 19:00:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5vbGfL7VqqXydI/49wPpkqHBkpTl2zpgsP5fzZ8H4Hc1XHBlui9RvVcgXPINL14fm59Fo X-Received: by 2002:a17:906:4e12:: with SMTP id z18mr41229660eju.543.1626919220556; Wed, 21 Jul 2021 19:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626919220; cv=none; d=google.com; s=arc-20160816; b=KB1NobYVXiqUNW8MCgQWJ6mw/UcWrJ5vBV//FJauQ5LsCi8VTUz/LpWm7Egk7a4Z7u 6qMcaAJsWtYMqIOI9U/Y+UDkII7QkUU5CM6YSKjmX3C0nACYyjBjIhF7kLeSBfbhj/DW z7uErnE7jbH0rSGNEeHWKt6sT2IrIJEnvEK15jQzfeN7EjJRZpd0XlTGkmTkytvvvQYQ Jw+N9uu+UURHMJ1szMrK5uHoU8dYkJvT4rrl3PN4iLxabQqv5an/sLMg7klZz8dbsZnf nMTFoMJw2mRlIvOoWxsH4dEwZYPPKevIskw4qvS5nrTiiTxmTfjKk9dPCZoQYTtSd0ny mTGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=l2G1UCFJRW5q/Isdt/gVBdKTaGw2QXIaZax0Ol3tFt0=; b=z/0VFDqDPdPSLGpEQEnF3pzU7p2/lIpgq11VZOa9ZVyFJ0X1mTmtHQMAWz9gdkb49v t/8CapXSRQuv1QI+487SeJsLL+VpD2eEGNJYOdql9kwbxClciKOnEE0Uw4YdNYghjxWL ht4Vi7jYbht1LVuCceiWQ6zosk10dYmLvGipA2PJwlzipV6LMjUXLOqpvKC1x2QPcgCG pTdsLl7Va1X8kUM2i4lmiv5CNl5fRggf11X6q2nFddA9yYSdddgc410pXHTePrNZ3xeS NnNf5WqeLlxQGWWaSoHxXSRevTM+KRUq3O5Hs3T+cprCPmVolD8VGofwDV0B7y4WoWsu FshA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qL16FUTi; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h16si17125383ede.546.2021.07.21.18.59.57; Wed, 21 Jul 2021 19:00:20 -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=@kernel.org header.s=k20201202 header.b=qL16FUTi; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230291AbhGVBPn (ORCPT + 99 others); Wed, 21 Jul 2021 21:15:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:33806 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbhGVBPn (ORCPT ); Wed, 21 Jul 2021 21:15:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1921361260; Thu, 22 Jul 2021 01:56:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626918979; bh=FSLbacg+yZg/KWrRL8YrdLF2CLDJeeioxFUFB3VTb4Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qL16FUTiljQErZIDeG5m6UuVLE/F065GBDgJlDiZwOHPp4hvips3yWZdUgQLoZjvF OlTyB/qp1p5MXs2DRxoEEIY/am0gabqBik7KZDBNp9k6Vs+IyH7+YgDfYl/ivwIfF2 seicmSE8+ewt7GsrctnAmdTg05cMxysjjFICZzBPDGM7N3mrJwGQhUpfwsdUfNlN1M JeH5J7nnGgUV4qmLsNnzllRCcN35roJaKPrYexb1OPcOxWtYA5mWutkx9IntVu6tLk hCP/B7HRlHvM5ebGQABd4Q/CkPATp4vvLmb/bk1WJGZcLKV1eFoddCX1emxF4hFxGn DJPqTSgtt+o6g== Date: Wed, 21 Jul 2021 18:56:17 -0700 From: Eric Biggers To: Daeho Jeong Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com, Daeho Jeong Subject: Re: [f2fs-dev] [PATCH] f2fs: change fiemap way in printing compression chunk Message-ID: References: <20210721072048.3035928-1-daeho43@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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