From patchwork Wed Apr 3 07:22:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615125 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 304405B68F; Wed, 3 Apr 2024 07:33:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129587; cv=none; b=BnMd9NpwMx4sJWpOw5C9UHodNEKFKX3SK7cwmim+E8hcVYRlBv/IS9ItN33oDgfbGvuLKk79az1O3Gw+hQj7VXnOJIcRclfx3TREaAB4WoxMcjO0deoXYiDa/jz+ZL7Ls9TiN723SeuMcWwrvPp1D+Lzc+9b8Wmj+KUdCgaWRwI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129587; c=relaxed/simple; bh=8hdRucriYr7TDeIc1Z7lCtD9oMQ64x6lsX9+VmwRajs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hu4amzfH5J4b6+u0f00WKMpQlapFy+DDAvg4mCqnEdIahv3gxb3P83wZV8+XLFHVXgnupNulMynR2MTNKiVAITjz6X0AmgkB57TCf4hIOmXy3UARmhdZV2OWqRNiU7X0sL5Oz5hc80csBdAIsBpAS+2l4Hta4gLrdB5Iobpydb4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=duAbvHkd; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="duAbvHkd" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 47146807A5; Wed, 3 Apr 2024 03:33:05 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129585; bh=8hdRucriYr7TDeIc1Z7lCtD9oMQ64x6lsX9+VmwRajs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=duAbvHkdgGafhhkA8hd0r625830aALZZQ8oxeANR/Kl8V2xZug5kmcP4vI1YapxFN A9LIDRTvjeSQOhcIpRDoLRTbG3NMyvM/72K1ifkS/Z9WVfqJVjWSBQ7y9OWOKItEFi P+IExaIGlJDtZ5Rx/+twB5qnULd5b1xw9JJmHoTUZK1CNmor9ry/3WJ5MlliuOXzge eoaW6DepcInBi/zwZ/15PRH144T5KOWel/2PH8M2LXhMM/YZG6q5hG/wxWX1eFQHXr y0rEkGXPrjhNC8NJHfsw4ypdhHDVDROcDUUlNXmuBJ6WY9PkwLnPjt68hBA1lQ7Eyb PKcWh0anOhPtA== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 01/13] fs: fiemap: add physical_length field to extents Date: Wed, 3 Apr 2024 03:22:42 -0400 Message-ID: <1ba5bfccccbf4ff792f178268badde056797d0c4.1712126039.git.sweettea-kernel@dorminy.me> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Some filesystems support compressed extents which have a larger logical size than physical, and for those filesystems, it can be useful for userspace to know how much space those extents actually use. For instance, the compsize [1] tool for btrfs currently uses btrfs-internal, root-only ioctl to find the actual disk space used by a file; it would be better and more useful for this information to require fewer privileges and to be usable on more filesystems. Therefore, use one of the padding u64s in the fiemap extent structure to return the actual physical length; and, for now, return this as equal to the logical length. [1] https://github.com/kilobyte/compsize Signed-off-by: Sweet Tea Dorminy --- Documentation/filesystems/fiemap.rst | 28 +++++++++++++++++------- fs/ioctl.c | 3 ++- include/uapi/linux/fiemap.h | 32 ++++++++++++++++++++++------ 3 files changed, 47 insertions(+), 16 deletions(-) diff --git a/Documentation/filesystems/fiemap.rst b/Documentation/filesystems/fiemap.rst index 93fc96f760aa..c2bfa107c8d7 100644 --- a/Documentation/filesystems/fiemap.rst +++ b/Documentation/filesystems/fiemap.rst @@ -80,14 +80,24 @@ Each extent is described by a single fiemap_extent structure as returned in fm_extents:: struct fiemap_extent { - __u64 fe_logical; /* logical offset in bytes for the start of - * the extent */ - __u64 fe_physical; /* physical offset in bytes for the start - * of the extent */ - __u64 fe_length; /* length in bytes for the extent */ - __u64 fe_reserved64[2]; - __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ - __u32 fe_reserved[3]; + /* + * logical offset in bytes for the start of + * the extent from the beginning of the file + */ + __u64 fe_logical; + /* + * physical offset in bytes for the start + * of the extent from the beginning of the disk + */ + __u64 fe_physical; + /* logical length in bytes for this extent */ + __u64 fe_logical_length; + /* physical length in bytes for this extent */ + __u64 fe_physical_length; + __u64 fe_reserved64[1]; + /* FIEMAP_EXTENT_* flags for this extent */ + __u32 fe_flags; + __u32 fe_reserved[3]; }; All offsets and lengths are in bytes and mirror those on disk. It is valid @@ -175,6 +185,8 @@ FIEMAP_EXTENT_MERGED userspace would be highly inefficient, the kernel will try to merge most adjacent blocks into 'extents'. +FIEMAP_EXTENT_HAS_PHYS_LEN + This will be set if the file system populated the physical length field. VFS -> File System Implementation --------------------------------- diff --git a/fs/ioctl.c b/fs/ioctl.c index 661b46125669..8afd32e1a27a 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -138,7 +138,8 @@ int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical, memset(&extent, 0, sizeof(extent)); extent.fe_logical = logical; extent.fe_physical = phys; - extent.fe_length = len; + extent.fe_logical_length = len; + extent.fe_physical_length = len; extent.fe_flags = flags; dest += fieinfo->fi_extents_mapped; diff --git a/include/uapi/linux/fiemap.h b/include/uapi/linux/fiemap.h index 24ca0c00cae3..3079159b8e94 100644 --- a/include/uapi/linux/fiemap.h +++ b/include/uapi/linux/fiemap.h @@ -14,14 +14,30 @@ #include +/* + * For backward compatibility, where the member of the struct was called + * fe_length instead of fe_logical_length. + */ +#define fe_length fe_logical_length + struct fiemap_extent { - __u64 fe_logical; /* logical offset in bytes for the start of - * the extent from the beginning of the file */ - __u64 fe_physical; /* physical offset in bytes for the start - * of the extent from the beginning of the disk */ - __u64 fe_length; /* length in bytes for this extent */ - __u64 fe_reserved64[2]; - __u32 fe_flags; /* FIEMAP_EXTENT_* flags for this extent */ + /* + * logical offset in bytes for the start of + * the extent from the beginning of the file + */ + __u64 fe_logical; + /* + * physical offset in bytes for the start + * of the extent from the beginning of the disk + */ + __u64 fe_physical; + /* logical length in bytes for this extent */ + __u64 fe_logical_length; + /* physical length in bytes for this extent */ + __u64 fe_physical_length; + __u64 fe_reserved64[1]; + /* FIEMAP_EXTENT_* flags for this extent */ + __u32 fe_flags; __u32 fe_reserved[3]; }; @@ -66,5 +82,7 @@ struct fiemap { * merged for efficiency. */ #define FIEMAP_EXTENT_SHARED 0x00002000 /* Space shared with other * files. */ +#define FIEMAP_EXTENT_HAS_PHYS_LEN 0x00004000 /* Physical length is valid + * and set by FS. */ #endif /* _UAPI_LINUX_FIEMAP_H */ From patchwork Wed Apr 3 07:22:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615126 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC41565BAA; Wed, 3 Apr 2024 07:33:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129590; cv=none; b=q2y1VU0QpOMA7VErhKKowlscDwqjTnYkuRNb5mfptZlpFy1oNK52lwjt79qaTFOCLawCuBRERyQU5veiH+MCa2+hHld0f+z+pOndYGTp6o0Sb2flFWGxggFVGASpL/OOVts6EkXOmq5ijiW05TcGivClSvvpK+aDKC6+e9tMn2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129590; c=relaxed/simple; bh=HfFh43eOQ7BBP8UDPoelIqPTjR0UFDaCRfKQjLQWiQk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HtZF9uigcat8OcvXyTfi67753LPtzgUDPdvo+YVUm5oZ2QPWd6hVJq7T6xjL6iDILlMuySsaNDJPmFaVSI+WsoeZCMBnQ8gT4PtJTiDqCuI+9QWxhmRd6Ck1b60urS1uGC/scPycCrA16EBvcpShOaqCMMJyXHOPCoRHTKagpII= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=lKp/CokE; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="lKp/CokE" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 7C9F8807A7; Wed, 3 Apr 2024 03:33:07 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129588; bh=HfFh43eOQ7BBP8UDPoelIqPTjR0UFDaCRfKQjLQWiQk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=lKp/CokELlh7R28OoZ/U/MxOHn/kYmAEz9J++4sLbkHmqUE0V65SHaRMgOOESHyLi jM5dIweXn3I95igLAcMl6++BFRqGzdPFaSwHuvw2pcEA2vd7BpQQ3rb0yT4S/2japf GpNDRn54Z6e46HhYTzT8YGOxKymBHnQb7fk7IL9QKA7r+FFIUrgbkWIbVLb9Cdm14D KePODvET23VnxVWN3zEbmA9AZZnqQiKkjoR33qDDRl1hNAA0YRcTw/iRPtHBrB0NXQ 4mYBx7+MIQzRuOyBh0f4nieTlWgzGOSvtDqhxRJd8NxYp8ofzngPCRaLFK/cwvXUo3 vD/zgtXiQreeA== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 02/13] fs: fiemap: update fiemap_fill_next_extent() signature Date: Wed, 3 Apr 2024 03:22:43 -0400 Message-ID: <58f9c9eef8b0e33a8d46a3ad8a8db46890e1fbe8.1712126039.git.sweettea-kernel@dorminy.me> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Update the signature of fiemap_fill_next_extent() to allow passing a physical length. Update all callers to pass a 0 physical length -- since none set the EXTENT_HAS_PHYS_LEN flag, this value doesn't matter. Signed-off-by: Sweet Tea Dorminy --- Documentation/filesystems/fiemap.rst | 3 ++- fs/bcachefs/fs.c | 7 ++++--- fs/btrfs/extent_io.c | 4 ++-- fs/ext4/extents.c | 1 + fs/f2fs/data.c | 8 +++++--- fs/f2fs/inline.c | 3 ++- fs/ioctl.c | 9 +++++---- fs/iomap/fiemap.c | 2 +- fs/nilfs2/inode.c | 6 +++--- fs/ntfs3/frecord.c | 7 ++++--- fs/ocfs2/extent_map.c | 4 ++-- fs/smb/client/smb2ops.c | 1 + include/linux/fiemap.h | 2 +- 13 files changed, 33 insertions(+), 24 deletions(-) diff --git a/Documentation/filesystems/fiemap.rst b/Documentation/filesystems/fiemap.rst index c2bfa107c8d7..c060bb83f5d8 100644 --- a/Documentation/filesystems/fiemap.rst +++ b/Documentation/filesystems/fiemap.rst @@ -236,7 +236,8 @@ For each extent in the request range, the file system should call the helper function, fiemap_fill_next_extent():: int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, - u64 phys, u64 len, u32 flags, u32 dev); + u64 phys, u64 log_len, u64 phys_len, u32 flags, + u32 dev); fiemap_fill_next_extent() will use the passed values to populate the next free extent in the fm_extents array. 'General' extent flags will diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 71013256fc39..f830578a9cd1 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -931,7 +931,8 @@ static int bch2_fill_extent(struct bch_fs *c, ret = fiemap_fill_next_extent(info, bkey_start_offset(k.k) << 9, offset << 9, - k.k->size << 9, flags|flags2); + k.k->size << 9, 0, + flags|flags2); if (ret) return ret; } @@ -940,13 +941,13 @@ static int bch2_fill_extent(struct bch_fs *c, } else if (bkey_extent_is_inline_data(k.k)) { return fiemap_fill_next_extent(info, bkey_start_offset(k.k) << 9, - 0, k.k->size << 9, + 0, k.k->size << 9, 0, flags| FIEMAP_EXTENT_DATA_INLINE); } else if (k.k->type == KEY_TYPE_reservation) { return fiemap_fill_next_extent(info, bkey_start_offset(k.k) << 9, - 0, k.k->size << 9, + 0, k.k->size << 9, 0, flags| FIEMAP_EXTENT_DELALLOC| FIEMAP_EXTENT_UNWRITTEN); diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index eceef5ff780b..9e421d99fd5c 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2577,7 +2577,7 @@ static int flush_fiemap_cache(struct fiemap_extent_info *fieinfo, int ret; ret = fiemap_fill_next_extent(fieinfo, entry->offset, - entry->phys, entry->len, + entry->phys, entry->len, 0, entry->flags); /* * Ignore 1 (reached max entries) because we keep track of that @@ -2793,7 +2793,7 @@ static int emit_last_fiemap_cache(struct fiemap_extent_info *fieinfo, return 0; ret = fiemap_fill_next_extent(fieinfo, cache->offset, cache->phys, - cache->len, cache->flags); + cache->len, 0, cache->flags); cache->cached = false; if (ret > 0) ret = 0; diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index e57054bdc5fd..2adade3c202a 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2215,6 +2215,7 @@ static int ext4_fill_es_cache_info(struct inode *inode, (__u64)es.es_lblk << blksize_bits, (__u64)es.es_pblk << blksize_bits, (__u64)es.es_len << blksize_bits, + 0, flags); if (next == 0) break; diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index d9494b5fc7c1..87f8d828e038 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1834,7 +1834,8 @@ static int f2fs_xattr_fiemap(struct inode *inode, if (!xnid) flags |= FIEMAP_EXTENT_LAST; - err = fiemap_fill_next_extent(fieinfo, 0, phys, len, flags); + err = fiemap_fill_next_extent( + fieinfo, 0, phys, len, 0, flags); trace_f2fs_fiemap(inode, 0, phys, len, flags, err); if (err) return err; @@ -1860,7 +1861,8 @@ static int f2fs_xattr_fiemap(struct inode *inode, } if (phys) { - err = fiemap_fill_next_extent(fieinfo, 0, phys, len, flags); + err = fiemap_fill_next_extent( + fieinfo, 0, phys, len, 0, flags); trace_f2fs_fiemap(inode, 0, phys, len, flags, err); } @@ -1979,7 +1981,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; ret = fiemap_fill_next_extent(fieinfo, logical, - phys, size, flags); + phys, size, 0, flags); trace_f2fs_fiemap(inode, logical, phys, size, flags, ret); if (ret) goto out; diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index ac00423f117b..49d2f87fe048 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -806,7 +806,8 @@ int f2fs_inline_data_fiemap(struct inode *inode, byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits; byteaddr += (char *)inline_data_addr(inode, ipage) - (char *)F2FS_INODE(ipage); - err = fiemap_fill_next_extent(fieinfo, start, byteaddr, ilen, flags); + err = fiemap_fill_next_extent( + fieinfo, start, byteaddr, ilen, 0, flags); trace_f2fs_fiemap(inode, start, byteaddr, ilen, flags, err); out: f2fs_put_page(ipage, 1); diff --git a/fs/ioctl.c b/fs/ioctl.c index 8afd32e1a27a..1830baca532b 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -99,7 +99,8 @@ static int ioctl_fibmap(struct file *filp, int __user *p) * @fieinfo: Fiemap context passed into ->fiemap * @logical: Extent logical start offset, in bytes * @phys: Extent physical start offset, in bytes - * @len: Extent length, in bytes + * @log_len: Extent logical length, in bytes + * @phys_len: Extent physical length, in bytes (optional) * @flags: FIEMAP_EXTENT flags that describe this extent * * Called from file system ->fiemap callback. Will populate extent @@ -110,7 +111,7 @@ static int ioctl_fibmap(struct file *filp, int __user *p) * extent that will fit in user array. */ int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical, - u64 phys, u64 len, u32 flags) + u64 phys, u64 log_len, u64 phys_len, u32 flags) { struct fiemap_extent extent; struct fiemap_extent __user *dest = fieinfo->fi_extents_start; @@ -138,8 +139,8 @@ int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical, memset(&extent, 0, sizeof(extent)); extent.fe_logical = logical; extent.fe_physical = phys; - extent.fe_logical_length = len; - extent.fe_physical_length = len; + extent.fe_logical_length = log_len; + extent.fe_physical_length = phys_len; extent.fe_flags = flags; dest += fieinfo->fi_extents_mapped; diff --git a/fs/iomap/fiemap.c b/fs/iomap/fiemap.c index 610ca6f1ec9b..013e843c8d10 100644 --- a/fs/iomap/fiemap.c +++ b/fs/iomap/fiemap.c @@ -36,7 +36,7 @@ static int iomap_to_fiemap(struct fiemap_extent_info *fi, return fiemap_fill_next_extent(fi, iomap->offset, iomap->addr != IOMAP_NULL_ADDR ? iomap->addr : 0, - iomap->length, flags); + iomap->length, 0, flags); } static loff_t iomap_fiemap_iter(const struct iomap_iter *iter, diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 7340a01d80e1..4d3c347c982b 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -1190,7 +1190,7 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, if (size) { /* End of the current extent */ ret = fiemap_fill_next_extent( - fieinfo, logical, phys, size, flags); + fieinfo, logical, phys, size, 0, flags); if (ret) break; } @@ -1240,7 +1240,7 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, flags |= FIEMAP_EXTENT_LAST; ret = fiemap_fill_next_extent( - fieinfo, logical, phys, size, flags); + fieinfo, logical, phys, size, 0, flags); if (ret) break; size = 0; @@ -1256,7 +1256,7 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, /* Terminate the current extent */ ret = fiemap_fill_next_extent( fieinfo, logical, phys, size, - flags); + 0, flags); if (ret || blkoff > end_blkoff) break; diff --git a/fs/ntfs3/frecord.c b/fs/ntfs3/frecord.c index 7f27382e0ce2..ef0ed913428b 100644 --- a/fs/ntfs3/frecord.c +++ b/fs/ntfs3/frecord.c @@ -1947,7 +1947,7 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, if (!attr || !attr->non_res) { err = fiemap_fill_next_extent( fieinfo, 0, 0, - attr ? le32_to_cpu(attr->res.data_size) : 0, + attr ? le32_to_cpu(attr->res.data_size) : 0, 0, FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_LAST | FIEMAP_EXTENT_MERGED); goto out; @@ -2042,7 +2042,7 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, flags |= FIEMAP_EXTENT_LAST; err = fiemap_fill_next_extent(fieinfo, vbo, lbo, dlen, - flags); + 0, flags); if (err < 0) break; if (err == 1) { @@ -2062,7 +2062,8 @@ int ni_fiemap(struct ntfs_inode *ni, struct fiemap_extent_info *fieinfo, if (vbo + bytes >= end) flags |= FIEMAP_EXTENT_LAST; - err = fiemap_fill_next_extent(fieinfo, vbo, lbo, bytes, flags); + err = fiemap_fill_next_extent(fieinfo, vbo, lbo, bytes, 0, + flags); if (err < 0) break; if (err == 1) { diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index 70a768b623cf..eabdf97cd685 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c @@ -723,7 +723,7 @@ static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh, id2.i_data.id_data); ret = fiemap_fill_next_extent(fieinfo, 0, phys, id_count, - flags); + 0, flags); if (ret < 0) return ret; } @@ -794,7 +794,7 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, virt_bytes = (u64)le32_to_cpu(rec.e_cpos) << osb->s_clustersize_bits; ret = fiemap_fill_next_extent(fieinfo, virt_bytes, phys_bytes, - len_bytes, fe_flags); + len_bytes, 0, fe_flags); if (ret) break; diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index 87b63f6ad2e2..23a193512f96 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -3779,6 +3779,7 @@ static int smb3_fiemap(struct cifs_tcon *tcon, le64_to_cpu(out_data[i].file_offset), le64_to_cpu(out_data[i].file_offset), le64_to_cpu(out_data[i].length), + 0, flags); if (rc < 0) goto out; diff --git a/include/linux/fiemap.h b/include/linux/fiemap.h index c50882f19235..17a6c32cdf3f 100644 --- a/include/linux/fiemap.h +++ b/include/linux/fiemap.h @@ -16,6 +16,6 @@ struct fiemap_extent_info { int fiemap_prep(struct inode *inode, struct fiemap_extent_info *fieinfo, u64 start, u64 *len, u32 supported_flags); int fiemap_fill_next_extent(struct fiemap_extent_info *info, u64 logical, - u64 phys, u64 len, u32 flags); + u64 phys, u64 log_len, u64 phys_len, u32 flags); #endif /* _LINUX_FIEMAP_H 1 */ From patchwork Wed Apr 3 07:22:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615127 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C06E46CDB4; Wed, 3 Apr 2024 07:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129592; cv=none; b=H5oSFhah6DgCHLlAypDGky7mbpAEQi2ydgmyW8mNgMtmXqy9+x8ch4csN4UhCSY8NgXeU7WzK4hjAfX9ndlJHyR7WkmHh95nxBvruPFeNNaZxw6Hv9CL8qHxUe7VC83l+Ox2ozYVsRcPY5vDWzeliGDzWa2fxAEa2k4sDx8L3gs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129592; c=relaxed/simple; bh=5jSs8nU917GCzbrVP0KXLbUutJOMwr3M87eATF8xiYE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LP4KM6czLJQlTLY9G1ufy+ezGD4RwsvAWv8VpiLzUzEDHa9LBAvl1tFapDbedqmpYBTZMpJEVYWIQWtlZ0AFpo4JbvUorH4NK2cCW+NWb+IaLexoSaTlowTFe9nXUnUpCIbbTsNRwqSTZiCrr5IzTBwk7FSd/xpOY+HXaa051Kw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=I+GHyyn2; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="I+GHyyn2" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 41FCF807B2; Wed, 3 Apr 2024 03:33:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129590; bh=5jSs8nU917GCzbrVP0KXLbUutJOMwr3M87eATF8xiYE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=I+GHyyn2AqhIMgJR35EkQswgG3miJcGyEJxwzXEC6xVoLDp2OlwyCosaNuuCkBCB9 e3mF+1V+JntbUuBhT+zndD8j1+FQqYM+m18PAE0UkxIGavLc/UHnvJgLZlPhY3HvRU dAB1kd2oBY1IVAYOFyco0jcQzCh32wCqvmI1yUvKFEjAsgvRdtJEggWdai9Jldcnqz ZrXXRiSB4ad5DztioJsAP3FkLablHBamn3DBFU9p+4wWhQQJptJQTzZ4KPwbj+Bogf R+1oWcA8RUDRvVc2MjugMnBE1zMK/gXCQTxbPRZqZkrJjkesi+ktRnElXyFYmnL7+R VHl1Slf2emloA== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 03/13] fs: fiemap: add new COMPRESSED extent state Date: Wed, 3 Apr 2024 03:22:44 -0400 Message-ID: <2befe2c13065bdf3ca74cb8b701727940310fd2a.1712126039.git.sweettea-kernel@dorminy.me> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This goes closely with the new physical length field in struct fiemap_extent, as when physical length is not equal to logical length the reason is frequently compression. Signed-off-by: Sweet Tea Dorminy Reviewed-by: Andreas Dilger --- Documentation/filesystems/fiemap.rst | 4 ++++ fs/ioctl.c | 3 ++- include/uapi/linux/fiemap.h | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/filesystems/fiemap.rst b/Documentation/filesystems/fiemap.rst index c060bb83f5d8..16bd7faba5e0 100644 --- a/Documentation/filesystems/fiemap.rst +++ b/Documentation/filesystems/fiemap.rst @@ -162,6 +162,10 @@ FIEMAP_EXTENT_DATA_ENCRYPTED This will also set FIEMAP_EXTENT_ENCODED The data in this extent has been encrypted by the file system. +FIEMAP_EXTENT_DATA_COMPRESSED + This will also set FIEMAP_EXTENT_ENCODED + The data in this extent is compressed by the file system. + FIEMAP_EXTENT_NOT_ALIGNED Extent offsets and length are not guaranteed to be block aligned. diff --git a/fs/ioctl.c b/fs/ioctl.c index 1830baca532b..b47e2da7ec17 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -126,7 +126,8 @@ int fiemap_fill_next_extent(struct fiemap_extent_info *fieinfo, u64 logical, return 1; #define SET_UNKNOWN_FLAGS (FIEMAP_EXTENT_DELALLOC) -#define SET_NO_UNMOUNTED_IO_FLAGS (FIEMAP_EXTENT_DATA_ENCRYPTED) +#define SET_NO_UNMOUNTED_IO_FLAGS (FIEMAP_EXTENT_DATA_ENCRYPTED|\ + FIEMAP_EXTENT_DATA_COMPRESSED) #define SET_NOT_ALIGNED_FLAGS (FIEMAP_EXTENT_DATA_TAIL|FIEMAP_EXTENT_DATA_INLINE) if (flags & SET_UNKNOWN_FLAGS) diff --git a/include/uapi/linux/fiemap.h b/include/uapi/linux/fiemap.h index 3079159b8e94..ea97e33ddbb3 100644 --- a/include/uapi/linux/fiemap.h +++ b/include/uapi/linux/fiemap.h @@ -67,6 +67,8 @@ struct fiemap { * Sets EXTENT_UNKNOWN. */ #define FIEMAP_EXTENT_ENCODED 0x00000008 /* Data can not be read * while fs is unmounted */ +#define FIEMAP_EXTENT_DATA_COMPRESSED 0x00000040 /* Data is compressed by fs. + * Sets EXTENT_ENCODED. */ #define FIEMAP_EXTENT_DATA_ENCRYPTED 0x00000080 /* Data is encrypted by fs. * Sets EXTENT_NO_BYPASS. */ #define FIEMAP_EXTENT_NOT_ALIGNED 0x00000100 /* Extent offsets may not be From patchwork Wed Apr 3 07:22:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615128 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 336F96EB41; Wed, 3 Apr 2024 07:33:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129594; cv=none; b=BIQLx6Hs5tINHjcRs2yxSkx8mguJ2mC9Zo4pL3rGfGjBjej6WMhxlnBOQqOkrdSvXFiDOBGgPZWnAP+FFOMDcQXQMhXqFir5VmpXGRwN9IE+cmnhCfCV1z5mZCLOiuFCtbGIcm3u4uRaUOhRdxpulGJZhxkXQt/tvt/99uVdSpg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129594; c=relaxed/simple; bh=GM61hCA7kvAHqNWRBNMS7+3u4Ivx/tDJO9J885fhLWo=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NolqJK+z/6n00HXR0U+NTI7sRJFxgjR0EZ4OSbPmC0Cvf2i/daxwG/LG0UZ535W1tEQE0X34+2G33p5GxyuDEQSk8AC5htRi5K2zkOAwj+mKkvkt43HRlsuRhIt1ppgf+4P3T67O6YlmsRk6tKB9VDLZYdmABsj5PBTh1M3YjT8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=QEytHR5M; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="QEytHR5M" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id EFBB2807E8; Wed, 3 Apr 2024 03:33:11 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129592; bh=GM61hCA7kvAHqNWRBNMS7+3u4Ivx/tDJO9J885fhLWo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QEytHR5MrDl3eno9gSXLyQB780SiYAwX/SZdkiJabaBXvfAUR2a/I55tLnkfL+CpI LnJTjdaz247j/qKvYwDUu7CxYvVbE8cVGMf0WclMBiAvAT10XgKz3HSg1Ml/SaYXQa rg2PstwGLpZAeUn5EpHRZFRcrevxmhyfmtSUhkJtQUFuxI0LSJpShGx9d+xVczDG3M x8y3lzEBsciaVn1VquDjmkqOHeXLmOzuRycxl5c2xZombu1LEM3DPEHr6zhFU2SLrO ClzRjg6qvWGUqMZ4Ods46LlfFVGV113DU5DLef8bULDeQuG84gvVvSjV6FppbEL/WO qyopps01ElZSg== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 04/13] btrfs: fiemap: emit new COMPRESSED state. Date: Wed, 3 Apr 2024 03:22:45 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Sweet Tea Dorminy --- fs/btrfs/extent_io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 9e421d99fd5c..e9df670ef7d2 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2706,7 +2706,7 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, if (range_end <= cache_end) return 0; - if (!(flags & (FIEMAP_EXTENT_ENCODED | FIEMAP_EXTENT_DELALLOC))) + if (!(flags & (FIEMAP_EXTENT_DATA_COMPRESSED | FIEMAP_EXTENT_DELALLOC))) phys += cache_end - offset; offset = cache_end; @@ -3236,7 +3236,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, } if (compression != BTRFS_COMPRESS_NONE) - flags |= FIEMAP_EXTENT_ENCODED; + flags |= FIEMAP_EXTENT_DATA_COMPRESSED; if (extent_type == BTRFS_FILE_EXTENT_INLINE) { flags |= FIEMAP_EXTENT_DATA_INLINE; From patchwork Wed Apr 3 07:22:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615129 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8E296FE38; Wed, 3 Apr 2024 07:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129598; cv=none; b=tlGglh3BPfrkKLIjosbSb68gdjqiGojVdcSDCCnNL8V4lParZQ6mXMT+86R5zUZ2a40lG0xTy1jcH/nrCCVq68TaBuTAXJzsb/Yj9ByxKa2UJmFxk8uwarVHzG0Apxj+C+lwMs9hPE7/xawb5lEVgmWOYB1Z4+73IbdoXfdMs/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129598; c=relaxed/simple; bh=k2cIvdzLg3sljiZ/6znD/m3Ichqz9W7DWE80AeNEY2E=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OxKKHiAhFUuQRGq4iUaRbR/jNjeFnfIvH20j2wbRcodTpaMcCehzQsT9n8dypztZVXY6xDiNKIDH6D2g43OlZp7Pl19i/x8RuvgLb7E/x/tvSRE/NSSFWbZYvtH328sbSlsdKcotw2q7Ubqgh+wag9u8yG2L3WKYC0invTthwwE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=QewS3YWB; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="QewS3YWB" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 85BD2807F9; Wed, 3 Apr 2024 03:33:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129596; bh=k2cIvdzLg3sljiZ/6znD/m3Ichqz9W7DWE80AeNEY2E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QewS3YWB1Udfrmc/U+d3uuM7Whmk18AUwovF8JVhddL2HNuIMXaUpIm41h3L4CYTs 5KScePZY2mnNQLA2JWbk7uAmVjO/Q0ocd2pjHbwWhNJ9WeQQ6ErauUPhc3TSpxHsZz IzCe9DHOenanCyWyEZ7PBdaPAQOwz0o5/dwXJq9jHPTyz64Cm4WLLoL8mXGR5VAvFt ieU26UGsxvoUwgp6smA3DzC2kFa+OUkmSZV2Dtt5LZ15W88v7JyshorRDs/anyn52b qaT/UPkoL8UVb6bDkx5xa2Eliks4n2naoWdnSMU7ngNNU+5h23bqxiIVqnuLPee3y9 ighpvtsu8WGLA== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 05/13] btrfs: fiemap: return extent physical size Date: Wed, 3 Apr 2024 03:22:46 -0400 Message-ID: <62391207f8d60060fddc18404af600c4b4f9b170.1712126039.git.sweettea-kernel@dorminy.me> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that fiemap allows returning extent physical size, make btrfs return the appropriate extent's actual disk size. Signed-off-by: Sweet Tea Dorminy --- fs/btrfs/extent_io.c | 70 ++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 25 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index e9df670ef7d2..b631f387cc3c 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -2506,7 +2506,8 @@ int try_release_extent_mapping(struct page *page, gfp_t mask) struct btrfs_fiemap_entry { u64 offset; u64 phys; - u64 len; + u64 log_len; + u64 phys_len; u32 flags; }; @@ -2564,7 +2565,8 @@ struct fiemap_cache { /* Fields for the cached extent (unsubmitted, not ready, extent). */ u64 offset; u64 phys; - u64 len; + u64 log_len; + u64 phys_len; u32 flags; bool cached; }; @@ -2577,8 +2579,8 @@ static int flush_fiemap_cache(struct fiemap_extent_info *fieinfo, int ret; ret = fiemap_fill_next_extent(fieinfo, entry->offset, - entry->phys, entry->len, 0, - entry->flags); + entry->phys, entry->log_len, + entry->phys_len, entry->flags); /* * Ignore 1 (reached max entries) because we keep track of that * ourselves in emit_fiemap_extent(). @@ -2603,7 +2605,8 @@ static int flush_fiemap_cache(struct fiemap_extent_info *fieinfo, */ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, struct fiemap_cache *cache, - u64 offset, u64 phys, u64 len, u32 flags) + u64 offset, u64 phys, u64 log_len, + u64 phys_len, u32 flags) { struct btrfs_fiemap_entry *entry; u64 cache_end; @@ -2611,6 +2614,9 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, /* Set at the end of extent_fiemap(). */ ASSERT((flags & FIEMAP_EXTENT_LAST) == 0); + /* We always set the correct physical length. */ + flags |= FIEMAP_EXTENT_HAS_PHYS_LEN; + if (!cache->cached) goto assign; @@ -2646,7 +2652,7 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, * or equals to what we have in cache->offset. We deal with this as * described below. */ - cache_end = cache->offset + cache->len; + cache_end = cache->offset + cache->log_len; if (cache_end > offset) { if (offset == cache->offset) { /* @@ -2670,10 +2676,10 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, * where a previously found file extent item was split * due to an ordered extent completing. */ - cache->len = offset - cache->offset; + cache->log_len = offset - cache->offset; goto emit; } else { - const u64 range_end = offset + len; + const u64 range_end = offset + log_len; /* * The offset of the file extent item we have just found @@ -2706,11 +2712,13 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, if (range_end <= cache_end) return 0; - if (!(flags & (FIEMAP_EXTENT_DATA_COMPRESSED | FIEMAP_EXTENT_DELALLOC))) + if (!(flags & (FIEMAP_EXTENT_DATA_COMPRESSED | FIEMAP_EXTENT_DELALLOC))) { phys += cache_end - offset; + phys_len -= cache_end - offset; + } offset = cache_end; - len = range_end - cache_end; + log_len = range_end - cache_end; goto emit; } } @@ -2720,15 +2728,17 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, * 1) Their logical addresses are continuous * * 2) Their physical addresses are continuous - * So truly compressed (physical size smaller than logical size) - * extents won't get merged with each other * * 3) Share same flags + * + * 4) Not compressed */ - if (cache->offset + cache->len == offset && - cache->phys + cache->len == phys && - cache->flags == flags) { - cache->len += len; + if (cache->offset + cache->log_len == offset && + cache->phys + cache->log_len == phys && + cache->flags == flags && + !(flags & FIEMAP_EXTENT_DATA_COMPRESSED)) { + cache->log_len += log_len; + cache->phys_len += phys_len; return 0; } @@ -2745,7 +2755,7 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, * to miss it. */ entry = &cache->entries[cache->entries_size - 1]; - cache->next_search_offset = entry->offset + entry->len; + cache->next_search_offset = entry->offset + entry->log_len; cache->cached = false; return BTRFS_FIEMAP_FLUSH_CACHE; @@ -2754,7 +2764,8 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, entry = &cache->entries[cache->entries_pos]; entry->offset = cache->offset; entry->phys = cache->phys; - entry->len = cache->len; + entry->log_len = cache->log_len; + entry->phys_len = cache->phys_len; entry->flags = cache->flags; cache->entries_pos++; cache->extents_mapped++; @@ -2767,7 +2778,8 @@ static int emit_fiemap_extent(struct fiemap_extent_info *fieinfo, cache->cached = true; cache->offset = offset; cache->phys = phys; - cache->len = len; + cache->log_len = log_len; + cache->phys_len = phys_len; cache->flags = flags; return 0; @@ -2793,7 +2805,8 @@ static int emit_last_fiemap_cache(struct fiemap_extent_info *fieinfo, return 0; ret = fiemap_fill_next_extent(fieinfo, cache->offset, cache->phys, - cache->len, 0, cache->flags); + cache->log_len, cache->phys_len, + cache->flags); cache->cached = false; if (ret > 0) ret = 0; @@ -2987,13 +3000,15 @@ static int fiemap_process_hole(struct btrfs_inode *inode, } ret = emit_fiemap_extent(fieinfo, cache, prealloc_start, disk_bytenr + extent_offset, - prealloc_len, prealloc_flags); + prealloc_len, prealloc_len, + prealloc_flags); if (ret) return ret; extent_offset += prealloc_len; } ret = emit_fiemap_extent(fieinfo, cache, delalloc_start, 0, + delalloc_end + 1 - delalloc_start, delalloc_end + 1 - delalloc_start, FIEMAP_EXTENT_DELALLOC | FIEMAP_EXTENT_UNKNOWN); @@ -3034,7 +3049,8 @@ static int fiemap_process_hole(struct btrfs_inode *inode, } ret = emit_fiemap_extent(fieinfo, cache, prealloc_start, disk_bytenr + extent_offset, - prealloc_len, prealloc_flags); + prealloc_len, prealloc_len, + prealloc_flags); if (ret) return ret; } @@ -3180,6 +3196,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, u64 extent_offset = 0; u64 extent_gen; u64 disk_bytenr = 0; + u64 disk_size = 0; u64 flags = 0; int extent_type; u8 compression; @@ -3242,7 +3259,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, flags |= FIEMAP_EXTENT_DATA_INLINE; flags |= FIEMAP_EXTENT_NOT_ALIGNED; ret = emit_fiemap_extent(fieinfo, &cache, key.offset, 0, - extent_len, flags); + extent_len, extent_len, flags); } else if (extent_type == BTRFS_FILE_EXTENT_PREALLOC) { ret = fiemap_process_hole(inode, fieinfo, &cache, &delalloc_cached_state, @@ -3257,6 +3274,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, backref_ctx, 0, 0, 0, key.offset, extent_end - 1); } else { + disk_size = btrfs_file_extent_disk_num_bytes(leaf, ei); /* We have a regular extent. */ if (fieinfo->fi_extents_max) { ret = btrfs_is_data_extent_shared(inode, @@ -3271,7 +3289,9 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, ret = emit_fiemap_extent(fieinfo, &cache, key.offset, disk_bytenr + extent_offset, - extent_len, flags); + extent_len, + disk_size - extent_offset, + flags); } if (ret < 0) { @@ -3309,7 +3329,7 @@ int extent_fiemap(struct btrfs_inode *inode, struct fiemap_extent_info *fieinfo, prev_extent_end = range_end; } - if (cache.cached && cache.offset + cache.len >= last_extent_end) { + if (cache.cached && cache.offset + cache.log_len >= last_extent_end) { const u64 i_size = i_size_read(&inode->vfs_inode); if (prev_extent_end < i_size) { From patchwork Wed Apr 3 07:22:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615130 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40E4571748; Wed, 3 Apr 2024 07:33:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129600; cv=none; b=cLF75bVW+XS8s8fwsifcWqrqDziqbVVhhWsOtnMVVkohEiKNEV+4fkSHq8rn+yYIS8tVBeHtBLHA+IC/oShtQs5ZCNTjoJ3Vri7qdjA2J/r+3wgxz1XVViZ6ffIX76gFylGe0Tf7twuWWPbr5xw1M5bi6rPxqaWbDrv6iE/+sWo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129600; c=relaxed/simple; bh=RN4ChmgSR3ZQz489TYOpQl2oinZST+jD9bAbWRVw3kw=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BIHqjkUaHipni2eoPil+3a8r3b2Bxgi9p3KoZRqVcTIr/TXBTZ1fDlg1LYKyExqPgaDtVTr70N2dmVpJVDaWaPbkmYdDB4Syshfe0hYAVlcf5LTIrSrUlrV4AZkDsSszvPGQyVSLlOrV0eoTZZP8KHT0+tiL5GSA0sQIiX9iu6Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=g4korhKJ; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="g4korhKJ" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 5353F807DB; Wed, 3 Apr 2024 03:33:18 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129598; bh=RN4ChmgSR3ZQz489TYOpQl2oinZST+jD9bAbWRVw3kw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=g4korhKJcSnDsrv9N7vH1U2FU2y1IQ+1cCMgS5/5PrxSN4HMDcoGduvy3dBmz1Nc2 yesnN+yjkh4f2vIszcOepeVVHQ3K67FvmEIxGpiTFYHKpuMe2R6HagoPaJ/l1N7h5B kSFM1+CNyOU88P5figMN31ZJaqkeiNoaljXN4YmqKD9V2WaqCHnY88jix5aqPn43Kf yGgF7UvGPp8P8KQGEm5qGPB01jtmts3h8MXOdQNZoA8tbZ857MqJXRClm9wfhrTLk2 A4L0DcuexATY8/UevIM4mTqaPkV3v1Ac2XqU6Gr25kMylrueJwoopHZo/lPNObd6bQ 02UNpUd0OrtTw== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 06/13] nilfs2: fiemap: return correct extent physical length Date: Wed, 3 Apr 2024 03:22:47 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Sweet Tea Dorminy --- fs/nilfs2/inode.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c index 4d3c347c982b..e3108f2cead7 100644 --- a/fs/nilfs2/inode.c +++ b/fs/nilfs2/inode.c @@ -1160,7 +1160,7 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, { struct the_nilfs *nilfs = inode->i_sb->s_fs_info; __u64 logical = 0, phys = 0, size = 0; - __u32 flags = 0; + __u32 flags = FIEMAP_EXTENT_HAS_PHYS_LEN; loff_t isize; sector_t blkoff, end_blkoff; sector_t delalloc_blkoff; @@ -1197,7 +1197,9 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, if (blkoff > end_blkoff) break; - flags = FIEMAP_EXTENT_MERGED | FIEMAP_EXTENT_DELALLOC; + flags = FIEMAP_EXTENT_MERGED | + FIEMAP_EXTENT_DELALLOC | + FIEMAP_EXTENT_HAS_PHYS_LEN; logical = blkoff << blkbits; phys = 0; size = delalloc_blklen << blkbits; @@ -1261,14 +1263,16 @@ int nilfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, break; /* Start another extent */ - flags = FIEMAP_EXTENT_MERGED; + flags = FIEMAP_EXTENT_MERGED | + FIEMAP_EXTENT_HAS_PHYS_LEN; logical = blkoff << blkbits; phys = blkphy << blkbits; size = n << blkbits; } } else { /* Start a new extent */ - flags = FIEMAP_EXTENT_MERGED; + flags = FIEMAP_EXTENT_MERGED | + FIEMAP_EXTENT_HAS_PHYS_LEN; logical = blkoff << blkbits; phys = blkphy << blkbits; size = n << blkbits; From patchwork Wed Apr 3 07:22:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615131 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BAEF73196; Wed, 3 Apr 2024 07:33:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129602; cv=none; b=GrB/GBvko3XkOnvjIaeSBdQDvKzwWqyQHUkkygkAs24shNuleAJw8KwNGkybZ4ctLclX4YbEmWsvLFoJJNiYhT6fxgi0k69azLRT2mBQdh5paNU/fJoM+t/dr8CslRiN26bxMfkkFaiEEYrP4C1FNPWhmtHCT4bARqK6Zv5uIuk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129602; c=relaxed/simple; bh=HBGmAcZ8dQDWLxuQ2gZciGzNPLnws2Iv6wSJvdOp678=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P/A3NA+m2X9domVtMoKqiyyrOECQ0d5KcrZrT5WJ85K8OLZC7uAnMbaFegtS1r1sZe/oCEBjozLbP4Rc/3OHRPaFmkoe3ZITvSkrdnSGUia0x4wHVNNtJBQUXtk9+6aAmiw3TqRGRigLN3zm0k4ul3OG3ZL4a/ReyG0+TIm8j58= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=k9adrlje; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="k9adrlje" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 80DCC8083D; Wed, 3 Apr 2024 03:33:20 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129601; bh=HBGmAcZ8dQDWLxuQ2gZciGzNPLnws2Iv6wSJvdOp678=; h=From:To:Subject:Date:In-Reply-To:References:From; b=k9adrljeAgmXUEVqR9T38q7UBFhQ7lETYpMXjsStM0XMGS4eG1T8+pjHdefOZtd+9 b9sbXDAHqGTeEotki3koqBZ7FT1290d4WlsagN6Z1Jb5RTuog38L7ZzYucpSa1d0f4 HrhO5RZg8NIYkyjWEsqcLAnOgMmn4utEi4pAOKEYrQOYjdJh36IxT86WJh3JG4pp1O xCkF4oXlZ89mQ1Ia6EZPk/hwSHK3lgiNW/6Wm5o0rgE/z8dTkDN+l20XOjvG16oIUL bA6z8ZMduHhDyDTpqq0FP2+pz2Eq0VSIBWGUHJdJGV+Y0h8M0aDKiiMOSTHKAOpxIl RTUMic1gQE7cQ== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 07/13] ext4: fiemap: return correct extent physical length Date: Wed, 3 Apr 2024 03:22:48 -0400 Message-ID: <20935230b7513031ac497e3afe8446650d20fb1e.1712126039.git.sweettea-kernel@dorminy.me> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Sweet Tea Dorminy --- fs/ext4/extents.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 2adade3c202a..4874f757e1bd 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -2194,7 +2194,7 @@ static int ext4_fill_es_cache_info(struct inode *inode, while (block <= end) { next = 0; - flags = 0; + flags = FIEMAP_EXTENT_HAS_PHYS_LEN; if (!ext4_es_lookup_extent(inode, block, &next, &es)) break; if (ext4_es_is_unwritten(&es)) From patchwork Wed Apr 3 07:22:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615132 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7808C757E8; Wed, 3 Apr 2024 07:33:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129605; cv=none; b=mBxl27Ytuozr8B1CoFh/QI57X2ZsIOWIf2d9swhLiM8brrFds0nF3VpvxLTrBqEK780yDaWRfvsb7rPzjrB4mPyx2tQVNcxVXTMwRyg4fMb7bKgQQIXAH25F4/UtkzfuMjbSt0w2to1ZuINH1xxH47Do8WklTxrOCprJwbdAQDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129605; c=relaxed/simple; bh=OPpE9eN8CD5ANdNxUZDWvEkQM4rXnf4BVN57cpWu324=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KALmm92mqRrf8D4omxg+IEfzbxNHNkPxDvmgUIUcSuV6hQFFodBkIYI7Tj4ZH6VFz2/NI2cMw1igh3Nykb0XCyX0gVVJVqGzC0Flp71cjiLy+cFJYNIUFHkmuQxM2227SS1Vqdt2xvKVFEjpjq3A6E3ImoYHyuJYXprQrsl3u8M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=U9x8ao/Y; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="U9x8ao/Y" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id A63518083E; Wed, 3 Apr 2024 03:33:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129603; bh=OPpE9eN8CD5ANdNxUZDWvEkQM4rXnf4BVN57cpWu324=; h=From:To:Subject:Date:In-Reply-To:References:From; b=U9x8ao/YtXeIP6vqNHdNGYgKj+yXOk1vCiXgPT1yActpXGHe++Cr6YI8vvggHRBq6 yQEPr3sMnm2kFzTH1ieN/TMe77oodEDsf67NWszgd9UtORzWsZJSpA8/rHVAR+Vp/k kSy507v6yuJWP9ELUOt8WkY/1ccbX2arnapapc48dOzST9mkwFMNkApXmXBsrlTJpU r8clqmo9BKvDy4PEY//3I3P1NQc9gF8QtGRC3alOIUoJOicylNVMZ/7KIPNo5srPrx 6ht8RdqQE+ef8OZayxffgmoiCnjb1fa4WZpT69KzEyzHxEgLWebS5z8bReBLyq1zg9 1YgF3ZuwkD2Eg== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 08/13] f2fs: fiemap: add physical length to trace_f2fs_fiemap Date: Wed, 3 Apr 2024 03:22:49 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Sweet Tea Dorminy --- fs/f2fs/data.c | 6 +++--- fs/f2fs/inline.c | 2 +- include/trace/events/f2fs.h | 10 +++++++--- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 87f8d828e038..34af1673461b 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1836,7 +1836,7 @@ static int f2fs_xattr_fiemap(struct inode *inode, err = fiemap_fill_next_extent( fieinfo, 0, phys, len, 0, flags); - trace_f2fs_fiemap(inode, 0, phys, len, flags, err); + trace_f2fs_fiemap(inode, 0, phys, len, 0, flags, err); if (err) return err; } @@ -1863,7 +1863,7 @@ static int f2fs_xattr_fiemap(struct inode *inode, if (phys) { err = fiemap_fill_next_extent( fieinfo, 0, phys, len, 0, flags); - trace_f2fs_fiemap(inode, 0, phys, len, flags, err); + trace_f2fs_fiemap(inode, 0, phys, len, 0, flags, err); } return (err < 0 ? err : 0); @@ -1982,7 +1982,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, ret = fiemap_fill_next_extent(fieinfo, logical, phys, size, 0, flags); - trace_f2fs_fiemap(inode, logical, phys, size, flags, ret); + trace_f2fs_fiemap(inode, logical, phys, size, 0, flags, ret); if (ret) goto out; size = 0; diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index 49d2f87fe048..235b0d72f6fc 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -808,7 +808,7 @@ int f2fs_inline_data_fiemap(struct inode *inode, (char *)F2FS_INODE(ipage); err = fiemap_fill_next_extent( fieinfo, start, byteaddr, ilen, 0, flags); - trace_f2fs_fiemap(inode, start, byteaddr, ilen, flags, err); + trace_f2fs_fiemap(inode, start, byteaddr, ilen, 0, flags, err); out: f2fs_put_page(ipage, 1); return err; diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h index 7ed0fc430dc6..63706eb3a5db 100644 --- a/include/trace/events/f2fs.h +++ b/include/trace/events/f2fs.h @@ -2276,9 +2276,10 @@ TRACE_EVENT(f2fs_bmap, TRACE_EVENT(f2fs_fiemap, TP_PROTO(struct inode *inode, sector_t lblock, sector_t pblock, - unsigned long long len, unsigned int flags, int ret), + unsigned long long len, unsigned long long phys_len, + unsigned int flags, int ret), - TP_ARGS(inode, lblock, pblock, len, flags, ret), + TP_ARGS(inode, lblock, pblock, len, phys_len, flags, ret), TP_STRUCT__entry( __field(dev_t, dev) @@ -2286,6 +2287,7 @@ TRACE_EVENT(f2fs_fiemap, __field(sector_t, lblock) __field(sector_t, pblock) __field(unsigned long long, len) + __field(unsigned long long, phys_len) __field(unsigned int, flags) __field(int, ret) ), @@ -2296,16 +2298,18 @@ TRACE_EVENT(f2fs_fiemap, __entry->lblock = lblock; __entry->pblock = pblock; __entry->len = len; + __entry->phys_len = phys_len; __entry->flags = flags; __entry->ret = ret; ), TP_printk("dev = (%d,%d), ino = %lu, lblock:%lld, pblock:%lld, " - "len:%llu, flags:%u, ret:%d", + "len:%llu, plen:%llu, flags:%u, ret:%d", show_dev_ino(__entry), (unsigned long long)__entry->lblock, (unsigned long long)__entry->pblock, __entry->len, + __entry->phys_len, __entry->flags, __entry->ret) ); From patchwork Wed Apr 3 07:22:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615133 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7899678286; Wed, 3 Apr 2024 07:33:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129606; cv=none; b=W+W88JhHe8we9jseDpI/+OEPmFoIxPuA9/8H3GQZcY2pENOL6ktPmR+JCv2SHvTcUP80JRNzGWL0lH2Fogoxxgh47y7hXmK2fySJ5/Mzlf6/rJxeyPNTrY6zmBWO4lU4JIF8mopDvOUTe99Tdw5y0IRwKWpPDXzrzIEOFe2ve3E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129606; c=relaxed/simple; bh=LnQUExMEi4K5Eq4tutxz2pOoBuBB93Ng5m6J9LLHIv8=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZQzEmkHnkk/ZiAYYe6ndI9DcLA9WQ4MjyN2cAc4+Ptc1AzrsqYyRLLTeHYmR11oNg67LHzTZRtIBWsj906YCk4QQHDRNbRUGKmtbtyuymVWG/CWbT07MrpOzWya5G1nylBbAf+V9junk8uY5XUFsYskZN1sTW/Bui+3YukurzG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=ShLq06yR; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="ShLq06yR" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id BDBF98089D; Wed, 3 Apr 2024 03:33:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129605; bh=LnQUExMEi4K5Eq4tutxz2pOoBuBB93Ng5m6J9LLHIv8=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ShLq06yRFTESpZJwiWHcJo16tBtJUgnqA9agoyQSzZAWKNutSxyYios9BpbTInyZk ScSiv6shQNZnemhUNUlVK2nqEIApjUSOluBjpuf2tmZJn8tx2zsV7xYlxyDuSUDP+5 JR4dJlnpOG6rCx+Bgqk/kHpkK61yY3GXzTQ1RAljAGTG8f8bA+dNbrf7psorjEw+SH HHsns8Qgyx50zcnfxXrLvu27AaOv9tnb4ZHCDSYtifvkkKPYCogkQa6FrqvBR59QAP T/O7VI6Y41ZUJaargTyw3VjXUaZoNxhNjUUOri0m9QA0XtsCxey/Q/c+brGFL7QGe7 BhSc4Llv+6ngQ== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 09/13] f2fs: fiemap: return correct extent physical length Date: Wed, 3 Apr 2024 03:22:50 -0400 Message-ID: <3bcdf126c1db6b4119d4bbdd4dc621c3ca3e2ae1.1712126039.git.sweettea-kernel@dorminy.me> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Sweet Tea Dorminy --- fs/f2fs/data.c | 25 ++++++++++++++++--------- fs/f2fs/inline.c | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 34af1673461b..2a3625c10125 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -1829,7 +1829,9 @@ static int f2fs_xattr_fiemap(struct inode *inode, f2fs_put_page(page, 1); - flags = FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_NOT_ALIGNED; + flags = FIEMAP_EXTENT_DATA_INLINE | + FIEMAP_EXTENT_NOT_ALIGNED | + FIEMAP_EXTENT_HAS_PHYS_LEN; if (!xnid) flags |= FIEMAP_EXTENT_LAST; @@ -1857,7 +1859,7 @@ static int f2fs_xattr_fiemap(struct inode *inode, f2fs_put_page(page, 1); - flags = FIEMAP_EXTENT_LAST; + flags = FIEMAP_EXTENT_LAST | FIEMAP_EXTENT_HAS_PHYS_LEN; } if (phys) { @@ -1894,8 +1896,8 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, struct f2fs_map_blocks map; sector_t start_blk, last_blk; pgoff_t next_pgofs; - u64 logical = 0, phys = 0, size = 0; - u32 flags = 0; + u64 logical = 0, phys = 0, size = 0, phys_size = 0; + u32 flags = FIEMAP_EXTENT_HAS_PHYS_LEN; int ret = 0; bool compr_cluster = false, compr_appended; unsigned int cluster_size = F2FS_I(inode)->i_cluster_size; @@ -1981,11 +1983,12 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, flags |= FIEMAP_EXTENT_DATA_ENCRYPTED; ret = fiemap_fill_next_extent(fieinfo, logical, - phys, size, 0, flags); - trace_f2fs_fiemap(inode, logical, phys, size, 0, flags, ret); + phys, size, phys_size, flags); + trace_f2fs_fiemap(inode, logical, phys, size, phys_size, flags, ret); if (ret) goto out; size = 0; + phys_size = 0; } if (start_blk > last_blk) @@ -2006,17 +2009,21 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, 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; + phys_size = blks_to_bytes(inode, map.m_len); + flags = FIEMAP_EXTENT_HAS_PHYS_LEN; if (compr_cluster) { - flags = FIEMAP_EXTENT_ENCODED; + flags = FIEMAP_EXTENT_ENCODED | + FIEMAP_EXTENT_HAS_PHYS_LEN; count_in_cluster += map.m_len; if (count_in_cluster == cluster_size) { compr_cluster = false; size += blks_to_bytes(inode, 1); + phys_size += blks_to_bytes(inode, 1); } } else if (map.m_flags & F2FS_MAP_DELALLOC) { - flags = FIEMAP_EXTENT_UNWRITTEN; + flags = FIEMAP_EXTENT_UNWRITTEN | + FIEMAP_EXTENT_HAS_PHYS_LEN; } start_blk += bytes_to_blks(inode, size); diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c index 235b0d72f6fc..c1c804a754de 100644 --- a/fs/f2fs/inline.c +++ b/fs/f2fs/inline.c @@ -772,7 +772,7 @@ int f2fs_inline_data_fiemap(struct inode *inode, { __u64 byteaddr, ilen; __u32 flags = FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_NOT_ALIGNED | - FIEMAP_EXTENT_LAST; + FIEMAP_EXTENT_HAS_PHYS_LEN | FIEMAP_EXTENT_LAST; struct node_info ni; struct page *ipage; int err = 0; From patchwork Wed Apr 3 07:22:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615134 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 369B680C1C; Wed, 3 Apr 2024 07:33:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129609; cv=none; b=N0go0bLR5uEGvcwSdob1+jDMHOwXTdqRBMVxWwF9cho8irsiobN+OhBg3Tq2yRMp1fEphvc1q5CIAuiel1WV+dfyhX0f3ymTYld7N5i2N2vqQWkG3ca9tRfSKu7fDYeaJrmxvggXscNCTxR7+XdeqCNneO/K8tAStaF6CCf3LNs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129609; c=relaxed/simple; bh=F4ceUdWui/mdlAkWe1dY+ZhhuS2I1dZLc64k4/7Uo2Y=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RtVzZC3iW2pTHVanA0bYOZMWy08C+Oz7qfp7H1Cb8cvERk4oBywWrAtkkM1+2uWnYFI9IEtP0ie0a097/JIVisinAx62mAk0LIS5TS7moDZVOJAPKWFb7g1amA3iswPWetfSA064hSnsDREODoV/g52PuPYS4o1E/GzZ2SgvZpA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=hcaS2gkR; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="hcaS2gkR" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 2C7F680892; Wed, 3 Apr 2024 03:33:26 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129607; bh=F4ceUdWui/mdlAkWe1dY+ZhhuS2I1dZLc64k4/7Uo2Y=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hcaS2gkRusKnpHkC/vbijCe7K6kF9RnpgEZv+Yk/8S8mIdGMFNwTXjeMXk6Lzd5UC Hi6eke4x6kTY5FTxTcqF9nhsH8Hr3kFTQUa72oYAdA2naZe/2JZk8LMUs8EZmhcKSY k/lGHBMstPOaB75DA6K8YXP0rh0o1c3RFZhWnNym3ibZiv3ynGaWsJBeOu7qdzY3TA kYfAZI95Huok41dLHVC+Ns1ZqhWUMwMY3vTUK+9A3S3+JnYeD8Y4AY5Ve0v1vt+t1v /GbaAWudyNoOzpYQuXbt5o9acwJnV+NKZdaow2b6f9Pu+wdl7RXj4U/v8OpFOXiJXJ MGXyDIMLsHiBQ== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 10/13] ocfs2: fiemap: return correct extent physical length Date: Wed, 3 Apr 2024 03:22:51 -0400 Message-ID: <0b492e10a9034c8fb08ca654c06471575e8bb96d.1712126039.git.sweettea-kernel@dorminy.me> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Sweet Tea Dorminy --- fs/ocfs2/extent_map.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/extent_map.c b/fs/ocfs2/extent_map.c index eabdf97cd685..229ea45df37b 100644 --- a/fs/ocfs2/extent_map.c +++ b/fs/ocfs2/extent_map.c @@ -705,7 +705,9 @@ static int ocfs2_fiemap_inline(struct inode *inode, struct buffer_head *di_bh, unsigned int id_count; struct ocfs2_dinode *di; u64 phys; - u32 flags = FIEMAP_EXTENT_DATA_INLINE|FIEMAP_EXTENT_LAST; + u32 flags = (FIEMAP_EXTENT_DATA_INLINE| + FIEMAP_EXTENT_HAS_PHYS_LEN| + FIEMAP_EXTENT_LAST); struct ocfs2_inode_info *oi = OCFS2_I(inode); di = (struct ocfs2_dinode *)di_bh->b_data; @@ -782,7 +784,7 @@ int ocfs2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, continue; } - fe_flags = 0; + fe_flags = FIEMAP_EXTENT_HAS_PHYS_LEN; if (rec.e_flags & OCFS2_EXT_UNWRITTEN) fe_flags |= FIEMAP_EXTENT_UNWRITTEN; if (rec.e_flags & OCFS2_EXT_REFCOUNTED) From patchwork Wed Apr 3 07:22:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615135 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1D24839E1; Wed, 3 Apr 2024 07:33:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129622; cv=none; b=tJycywj2ewbGgualgewBQoz8qcJwQNA6JM7QyGQH/ih0dWrFeSj4WlrphZvN7uoPJBVvT4lytlBCiiW9/vEj3ACQcGUkTZxAXtpANxSoZnANMsirkXp2DG0CmsbiSnIERuJAkyMK8tIS2p+qD6gKwc4mBTTK7catlvmOAUorVxk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129622; c=relaxed/simple; bh=SgpqdEQktNmIE/si/SsUXivp3OLO9RykBmr/owEiMwk=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hw9tBf6Kc3CCsShXEAa/jfToCXroZTFCJ1rASlmsGY3nMeRsKugIzbdCSS5BaG9O+oVS17ZY4SmOzHphZcRZZWZCPObqIhl/qFBKYmnHDV0qvwtWHRFvVV5m2Qvo1qShm/znzWqQQZAckHiUnjvacyIBnzaOb3V2G2PKkIA0wLY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=XAboOI1g; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="XAboOI1g" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id CBFF38083F; Wed, 3 Apr 2024 03:33:39 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129620; bh=SgpqdEQktNmIE/si/SsUXivp3OLO9RykBmr/owEiMwk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=XAboOI1gOEYEeFHrK1IrQoakMcUXsIMd5sSfqTDBehMhEAI8iLj2M4cvGuZWOnlea sptYc4MV8Ozdb9aTADpJGN+8wTnZ7a4nquwTvUU7Fg8MmCD8svm0CoyTyh7cz/SBD+ ZMFxSNY4lqBJ9+dz+mPFPmrNmB+z57J2Ezal//nHLbJPn2kpBB/DeRdnynt73/ONre w1nx6Q9inAxG9UN8ga9ww6DJNwFqfSLAGdGXdXScTmCspAGRxQd722JIdIuqf41v1U vpPKduXjNxy+o5h6VMKoOcFf5LJdNmM7bXsHLaUDtdElsmkXjDqye/eAoNu2dZVkZX f6UzUKP6VJHVQ== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 11/13] bcachefs: fiemap: return correct extent physical length Date: Wed, 3 Apr 2024 03:22:52 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Sweet Tea Dorminy --- fs/bcachefs/fs.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index f830578a9cd1..d2793bae842d 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -913,15 +913,17 @@ static int bch2_fill_extent(struct bch_fs *c, flags |= FIEMAP_EXTENT_SHARED; bkey_for_each_ptr_decode(k.k, ptrs, p, entry) { - int flags2 = 0; + int flags2 = FIEMAP_EXTENT_HAS_PHYS_LEN; + u64 phys_len = k.k->size << 9; u64 offset = p.ptr.offset; if (p.ptr.unwritten) flags2 |= FIEMAP_EXTENT_UNWRITTEN; - if (p.crc.compression_type) + if (p.crc.compression_type) { flags2 |= FIEMAP_EXTENT_ENCODED; - else + phys_len = p.crc.compressed_size << 9; + } else offset += p.crc.offset; if ((offset & (block_sectors(c) - 1)) || @@ -931,7 +933,7 @@ static int bch2_fill_extent(struct bch_fs *c, ret = fiemap_fill_next_extent(info, bkey_start_offset(k.k) << 9, offset << 9, - k.k->size << 9, 0, + k.k->size << 9, phys_len, flags|flags2); if (ret) return ret; @@ -941,14 +943,18 @@ static int bch2_fill_extent(struct bch_fs *c, } else if (bkey_extent_is_inline_data(k.k)) { return fiemap_fill_next_extent(info, bkey_start_offset(k.k) << 9, - 0, k.k->size << 9, 0, + 0, k.k->size << 9, + bkey_inline_data_bytes(k.k), flags| + FIEMAP_EXTENT_HAS_PHYS_LEN| FIEMAP_EXTENT_DATA_INLINE); } else if (k.k->type == KEY_TYPE_reservation) { return fiemap_fill_next_extent(info, bkey_start_offset(k.k) << 9, - 0, k.k->size << 9, 0, + 0, k.k->size << 9, + k.k->size << 9, flags| + FIEMAP_EXTENT_HAS_PHYS_LEN| FIEMAP_EXTENT_DELALLOC| FIEMAP_EXTENT_UNWRITTEN); } else { From patchwork Wed Apr 3 07:22:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615136 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6424E83A15; Wed, 3 Apr 2024 07:33:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129623; cv=none; b=oxKqOEMy4fakUfiFp0mX+jwRDuGaQtvTMGkg7m+Cq/Gw6MM7PW4ZwogGi7Rq5Ggn1/vLlGI4dwC21zMvhQxB5aCtaX6jjWkOy+zTzss35BMtAJLQjPJW9NZtDuGnpv4G4PihCnkBvp61L+9GAK3smfEOZvN4WwlwOb7DxzslxN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129623; c=relaxed/simple; bh=94RmlMFWXGTXstz1CwkJFfXxsHVZs+VkfOwiVdyhsCI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZJj8LNEnlNxPiQ/TLGwwZGzBIK2SLg5lbWBH/eN273U4VvZ+iEJThedJPXW8su145k7uU6R8XFIXZ9zl3ZAn4IG2BGrSDFVwVR5bAy2aBsUfv3xUa/FPrgMEZpk9sKWEBIgdKzQls4wu8/1f3+5Pp87nSs7E6j4gan9xlyqpn0A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=IbWMGL//; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="IbWMGL//" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 8F82180924; Wed, 3 Apr 2024 03:33:41 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129621; bh=94RmlMFWXGTXstz1CwkJFfXxsHVZs+VkfOwiVdyhsCI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IbWMGL//ndu+2eM5w3j/YnRT3w418ByjraEMNZYb0TTbSS7WXFhnXQENWrVb6R3RT XMvJ7x98BSJoTIoS8dr5PsO4Q3LElCZuY78m99E9Yp1NGJB1wOQKKHDALrrTFFszkb cnahyGw/o5jSZ7OQvg9EkTVmKsJwqBtS8i21HzuewEZSc5qzEGZewbLAdc/pLE499q uoIvMReqQmd3Yp0ZzO3c82sWs2/d2DI/x1RrTza5ZzPWVj7wD7oZSxgtDD8T+bpuEE UlUzkevR3IuBxO03l5JyQ3zoKQv2YmlR7hVVtpSwtDxSbaPwVFFvKaiRejBSpexlW1 eK1THOkEXxD0w== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 12/13] f2fs: fiemap: emit new COMPRESSED state Date: Wed, 3 Apr 2024 03:22:53 -0400 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Sweet Tea Dorminy --- fs/f2fs/data.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 2a3625c10125..e999cb1bb02f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2014,6 +2014,7 @@ int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, if (compr_cluster) { flags = FIEMAP_EXTENT_ENCODED | + flags = FIEMAP_EXTENT_DATA_COMPRESSED | FIEMAP_EXTENT_HAS_PHYS_LEN; count_in_cluster += map.m_len; if (count_in_cluster == cluster_size) { From patchwork Wed Apr 3 07:22:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sweet Tea Dorminy X-Patchwork-Id: 13615137 Received: from box.fidei.email (box.fidei.email [71.19.144.250]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B91BC84A4E; Wed, 3 Apr 2024 07:33:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=71.19.144.250 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129625; cv=none; b=fnpUwUAZjLh2f4qcysFQtAsTl+rrxnVxsLe2+S+qocAQM100ITJnoznOt1RkpoShp8ZvA7nSRMr5o5p2ujXF0lpBhOPi9TyoE81EjjaJOS2l8dEmkrydeYzrhcdGHlu7jUJVFkkdC+Ku+0d72cP7hRjJ073cy5wsfrj4vUSs6u8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712129625; c=relaxed/simple; bh=Yn1zFOsTbXIkMwMfnGhDkiIuwvzgn3xDfiaec4KzrE4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AFnN5moD2X2KJ6KWgK9GKLIUQtocFnzScLjJoY+QVO9s/IkEUQnPVYt2dChKMvKHtaIUJbju0MRHygN/Z1iGcNVW4SIni4Vhpve/mMEN2y+uciyvHTwlp8tdHHPvsazQvh6dgiBClx2FK6PxCUySUvPaUgkoG6PI6who/Mt7fro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me; spf=pass smtp.mailfrom=dorminy.me; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b=sDsi6DwW; arc=none smtp.client-ip=71.19.144.250 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=dorminy.me Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=dorminy.me Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=dorminy.me header.i=@dorminy.me header.b="sDsi6DwW" Received: from authenticated-user (box.fidei.email [71.19.144.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by box.fidei.email (Postfix) with ESMTPSA id 2C4BD809CF; Wed, 3 Apr 2024 03:33:43 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=dorminy.me; s=mail; t=1712129623; bh=Yn1zFOsTbXIkMwMfnGhDkiIuwvzgn3xDfiaec4KzrE4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=sDsi6DwW7MGDTQ5P/PQD0Ea0WGP4MIUzVgMSpVt6+MLu6GooeRA15R0TNohgh6qiL gbBK43U0gy8PnlGmzx5AVqVZKXPV2FapzHQ+oZPLgDBg8vwg4O10OxkgIWX5xngwfS PH2OvUg5EIy5Q30YenZnXA3NlcNTx0gX57l5+aw+qpCar+CfK/i0FS+xCo+A9QqgN4 6P+NdsGSBq4lgIOk6OA7brNJULtIuyL3MvLZhdqTZi4EiuscId9aGny9zekTgpcN+q HHBbpXQKtnX9bDxNcRm1osXmflca6Y1t/MYnIvBMaK6dyDUapKLFgLTXR2osI5KMTX neuFRfY2pFLuQ== From: Sweet Tea Dorminy To: Jonathan Corbet , Kent Overstreet , Brian Foster , Chris Mason , Josef Bacik , David Sterba , Jaegeuk Kim , Chao Yu , Alexander Viro , Christian Brauner , Jan Kara , =?utf-8?q?Micka=C3=ABl_Sala=C3=BCn?= , Sweet Tea Dorminy , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, kernel-team@meta.com Subject: [PATCH v3 13/13] bcachefs: fiemap: emit new COMPRESSED state Date: Wed, 3 Apr 2024 03:22:54 -0400 Message-ID: <943938ff75580b210eebf6c885659dd95f029486.1712126039.git.sweettea-kernel@dorminy.me> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Signed-off-by: Sweet Tea Dorminy --- fs/bcachefs/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index d2793bae842d..54f613f977b4 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -921,7 +921,7 @@ static int bch2_fill_extent(struct bch_fs *c, flags2 |= FIEMAP_EXTENT_UNWRITTEN; if (p.crc.compression_type) { - flags2 |= FIEMAP_EXTENT_ENCODED; + flags2 |= FIEMAP_EXTENT_DATA_COMPRESSED; phys_len = p.crc.compressed_size << 9; } else offset += p.crc.offset;