lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 5 Apr 2024 13:26:37 -0600
From: Andreas Dilger <adilger@...ger.ca>
To: Sweet Tea Dorminy <sweettea-kernel@...miny.me>
Cc: Jonathan Corbet <corbet@....net>,
 Kent Overstreet <kent.overstreet@...ux.dev>,
 Brian Foster <bfoster@...hat.com>,
 Chris Mason <clm@...com>,
 Josef Bacik <josef@...icpanda.com>,
 David Sterba <dsterba@...e.com>,
 Jaegeuk Kim <jaegeuk@...nel.org>,
 Chao Yu <chao@...nel.org>,
 Alexander Viro <viro@...iv.linux.org.uk>,
 Christian Brauner <brauner@...nel.org>,
 Jan Kara <jack@...e.cz>,
 Mickaël Salaün <mic@...ikod.net>,
 linux-doc@...r.kernel.org,
 Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
 linux-bcachefs@...r.kernel.org,
 linux-btrfs <linux-btrfs@...r.kernel.org>,
 linux-f2fs-devel@...ts.sourceforge.net,
 linux-fsdevel@...r.kernel.org,
 kernel-team@...a.com
Subject: Re: [PATCH v3 06/13] nilfs2: fiemap: return correct extent physical
 length

On Apr 3, 2024, at 1:22 AM, Sweet Tea Dorminy <sweettea-kernel@...miny.me> wrote:
> 
> Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@...miny.me>
> ---
> 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;

IMHO, rather than setting "flags = FIEMAP..." here, it would be better to
initialize "flags |= FIEMAP_HAS_PHYS_LEN" right after fiemap_fill_next_extent()
is called, and use "flags |= FIEMAP_EXTENT_MERGED | FIEMAP_EXTENT_DELALLOC" here.

That makes it more clear that MERGED|DELALLOC are "add-on" flags beyond the
base flags, and if more flags are added in the future (e.g. COMPRESSED) then
the flag management will be simpler (more on this below).

> @@ -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;

Strictly speaking, this new extent should not have FIEMAP_EXTENT_MERGED set,
and start out with only FIEMAP_EXTENT_HAS_PHYS_LEN, since it has not actually
been merged with anything.

> 					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;

Then this should be "flags |= FIEMAP_EXTENT_MERGED" only once a second
block has been merged into the prior one.

Cheers, Andreas






Download attachment "signature.asc" of type "application/pgp-signature" (874 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ