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 X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 230A0C4338F for ; Mon, 26 Jul 2021 04:18:46 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C6F246069E; Mon, 26 Jul 2021 04:18:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org C6F246069E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.92.3) (envelope-from ) id 1m7s4h-0004Jn-Ok; Mon, 26 Jul 2021 04:18:43 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1m7s4g-0004Jg-IL for linux-f2fs-devel@lists.sourceforge.net; Mon, 26 Jul 2021 04:18:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=2thOxj6ctqmCSeGKTO0PklZgYjLXVrYMprKtsyIwFdQ=; b=bHfd1ZWY9duNajf9BzIq2yilVd Vkl2Fd/ttd6RYw8ppnNRUzA2EgxmkG3oeO32mSj7VymKxtD9tNCMddAibJV6xP1IxDLxTySPuqdpu DGvJLFU8HtIfAN5p91lCZ7VxOyyXWejh5Rg3tfPcWEW4Ed/l46dVZGiNqT3QL0y8LE3c=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=2thOxj6ctqmCSeGKTO0PklZgYjLXVrYMprKtsyIwFdQ=; b=m 0cz4qedRG9FrsCgoDEH263vhJWxmgIRHMUnXorOd0U5HNHtyALaoBfJzgrnATXW8LepYpQOMCA+y8 Edb2oMV4hesQ3Q40FJnBRdOf7hTecX7c/kXIfuvqLQAxoUVxABFDL66Hm5GkSxqoELRIHfiD0zJlk 7BslX/3whEmFwvWk=; Received: from mail-pl1-f176.google.com ([209.85.214.176]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.92.3) id 1m7s4T-002kaU-Bp for linux-f2fs-devel@lists.sourceforge.net; Mon, 26 Jul 2021 04:18:42 +0000 Received: by mail-pl1-f176.google.com with SMTP id t21so9935664plr.13 for ; Sun, 25 Jul 2021 21:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2thOxj6ctqmCSeGKTO0PklZgYjLXVrYMprKtsyIwFdQ=; b=E6YnqwG/l7j6GsLDG5sI85c1f8k6puuOIXFTKw6dDIyNb62iLh9Z33ha1+QyWqGuP/ kKX4DRToWTQLcXCA2vST3jgzUTJe1lfUTYduJzTCKGokXH9RmW0LVG8Weaz4FO3zBE5B 3gxFQ/Zuv0Ig8h4hcKdqNEnZgMIEX6ytdTPEXIZC2ysnIcjzbMn/Jl1X+IZYgNB3ZOMZ LOokuS9jPRZ+8bCGwQhxeeCMpn93OqBherjNZgmwWXuK6MoauqGmVICkZmqSR+4lc1Xd AbF+hglHjbEwEtf5rI8/6KuKK5lCOTifjKVjSM7E3YxOwc92kqzDqEhOPG6igezBArQG IczA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2thOxj6ctqmCSeGKTO0PklZgYjLXVrYMprKtsyIwFdQ=; b=TLtX7JnlivkffBog9p9kXS+6zZklDc/c6GT1xZFcBFfyHJn0OjyTfyJY/vD8WqtPis KG90+kA+m+gW2r/Z2jL1WpZaIFAVs4YOjOst35YaQF4vkzwEFnFKl7C2+FibHZRHTL5b TngiQ9Q6alIlWG+AKH7o5i/PVFsfCLIaeRGUaCazW8X/5BFPy5gJK1gTcyMX7MYn1DA6 ZxBCkfjn+6f26kRy2MEZgv14uiX4gBS4uaqVA1g7ZcZyI87151DXA54QFlYCDYgilzHv SGTWxgB/fbmzjRp6Io0ffD0vBJ74PGGQqoEG8mTUgwPT4281bokFH6oyQXPw+grRLLyD cCHw== X-Gm-Message-State: AOAM530LYfyGhEcvaV/uF+H/kIWdxfNn8Ex8O0T8ZSqcop5bK/0h73E0 ATekCTFtjX0I8eS639txb7AJB6HZsB4= X-Google-Smtp-Source: ABdhPJyVj60F7grBg+B2l5aaIJhEeGR0fJFaQCZV0mjDO8r2qBHGpC67A0/P31g3pOyL6B4ETeAtEA== X-Received: by 2002:a17:90b:1194:: with SMTP id gk20mr24693980pjb.181.1627273103758; Sun, 25 Jul 2021 21:18:23 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2620:15c:211:201:cb45:e631:40f9:6a6]) by smtp.gmail.com with ESMTPSA id d2sm12147861pjd.24.2021.07.25.21.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jul 2021 21:18:23 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Sun, 25 Jul 2021 21:18:19 -0700 Message-Id: <20210726041819.2059593-1-daeho43@gmail.com> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog MIME-Version: 1.0 X-Headers-End: 1m7s4T-002kaU-Bp Subject: [f2fs-dev] [PATCH v4] f2fs: change fiemap way in printing compression chunk X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daeho Jeong , Eric Biggers Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong When we print out a discontinuous compression chunk, it shows like a continuous chunk now. To show it more correctly, I've changed the way of printing fiemap info like below. Plus, eliminated NEW_ADDR(-1) in fiemap info, since it is not in fiemap user api manual. Let's assume 16KB compression cluster. Logical Physical Length Flags 0: 0000000000000000 00000002c091f000 0000000000004000 1008 1: 0000000000004000 00000002c0920000 0000000000004000 1008 ... 9: 0000000000034000 0000000f8c623000 0000000000004000 1008 10: 0000000000038000 000000101a6eb000 0000000000004000 1008 0: 0000000000000000 00000002c091f000 0000000000004000 1008 1: 0000000000004000 00000002c0920000 0000000000004000 1008 ... 9: 0000000000034000 0000000f8c623000 0000000000001000 1008 10: 0000000000035000 000000101a6ea000 0000000000003000 1008 11: 0000000000038000 000000101a6eb000 0000000000002000 1008 12: 000000000003a000 00000002c3544000 0000000000002000 1008 Flags 0x1000 => FIEMAP_EXTENT_MERGED 0x0008 => FIEMAP_EXTENT_ENCODED Signed-off-by: Daeho Jeong Tested-by: Eric Biggers --- v4: initialized count_in_cluster v3: fix the missing last extent flag issue v2: changed the print format --- fs/f2fs/data.c | 75 ++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 33 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 3a01a1b50104..1a716c3b5457 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1843,8 +1843,9 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 logical = 0, phys = 0, size = 0; u32 flags = 0; int ret = 0; - bool compr_cluster = false; + bool compr_cluster = false, compr_appended; unsigned int cluster_size = F2FS_I(inode)->i_cluster_size; + unsigned int count_in_cluster = 0; loff_t maxbytes; if (fieinfo->fi_flags & FIEMAP_FLAG_CACHE) { @@ -1892,15 +1893,17 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, map.m_next_pgofs = &next_pgofs; map.m_seg_type = NO_CHECK_TYPE; - if (compr_cluster) - map.m_len = cluster_size - 1; + if (compr_cluster) { + map.m_lblk += 1; + map.m_len = cluster_size - count_in_cluster; + } ret = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_FIEMAP); if (ret) goto out; /* HOLE */ - if (!(map.m_flags & F2FS_MAP_FLAGS)) { + if (!compr_cluster && !(map.m_flags & F2FS_MAP_FLAGS)) { start_blk = next_pgofs; if (blks_to_bytes(inode, start_blk) < blks_to_bytes(inode, @@ -1910,6 +1913,14 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, flags |= FIEMAP_EXTENT_LAST; } + compr_appended = false; + /* In a case of compressed cluster, append this to the last extent */ + if (compr_cluster && ((map.m_flags & F2FS_MAP_UNWRITTEN) || + !(map.m_flags & F2FS_MAP_FLAGS))) { + compr_appended = true; + goto skip_fill; + } + if (size) { flags |= FIEMAP_EXTENT_MERGED; if (IS_ENCRYPTED(inode)) @@ -1926,38 +1937,36 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, if (start_blk > last_blk) goto out; - if (compr_cluster) { - compr_cluster = false; - - - logical = blks_to_bytes(inode, start_blk - 1); - phys = blks_to_bytes(inode, map.m_pblk); - size = blks_to_bytes(inode, cluster_size); - - flags |= FIEMAP_EXTENT_ENCODED; - - start_blk += cluster_size - 1; - - if (start_blk > last_blk) - goto out; - - goto prep_next; - } - +skip_fill: if (map.m_pblk == COMPRESS_ADDR) { compr_cluster = true; - start_blk++; - goto prep_next; - } - - logical = blks_to_bytes(inode, start_blk); - phys = blks_to_bytes(inode, map.m_pblk); - size = blks_to_bytes(inode, map.m_len); - flags = 0; - if (map.m_flags & F2FS_MAP_UNWRITTEN) - flags = FIEMAP_EXTENT_UNWRITTEN; + count_in_cluster = 1; + } else if (compr_appended) { + unsigned int appended_blks = cluster_size - + count_in_cluster + 1; + size += blks_to_bytes(inode, appended_blks); + start_blk += appended_blks; + compr_cluster = false; + } else { + logical = blks_to_bytes(inode, start_blk); + phys = __is_valid_data_blkaddr(map.m_pblk) ? + blks_to_bytes(inode, map.m_pblk) : 0; + size = blks_to_bytes(inode, map.m_len); + flags = 0; + + if (compr_cluster) { + flags = FIEMAP_EXTENT_ENCODED; + count_in_cluster += map.m_len; + if (count_in_cluster == cluster_size) { + compr_cluster = false; + size += blks_to_bytes(inode, 1); + } + } else if (map.m_flags & F2FS_MAP_UNWRITTEN) { + flags = FIEMAP_EXTENT_UNWRITTEN; + } - start_blk += bytes_to_blks(inode, size); + start_blk += bytes_to_blks(inode, size); + } prep_next: cond_resched(); -- 2.32.0.432.gabb21c7263-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel