From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-f195.google.com ([209.85.215.195]:36930 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387441AbeKFHko (ORCPT ); Tue, 6 Nov 2018 02:40:44 -0500 Received: by mail-pg1-f195.google.com with SMTP id c10-v6so4861515pgq.4 for ; Mon, 05 Nov 2018 14:18:51 -0800 (PST) From: Andreas Dilger Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_255DB1ED-7F99-4237-9E3E-2C1F2DBA7EC6"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: [PATCH 17/20] fiemap: Get rid of fiemap_extent_info Date: Mon, 5 Nov 2018 15:14:38 -0700 In-Reply-To: <20181030131823.29040-18-cmaiolino@redhat.com> Cc: Linux FS-devel Mailing List , Eric Sandeen , Christoph Hellwig , david@fromorbit.com, darrick.wong@oracle.com To: Carlos Maiolino References: <20181030131823.29040-1-cmaiolino@redhat.com> <20181030131823.29040-18-cmaiolino@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: --Apple-Mail=_255DB1ED-7F99-4237-9E3E-2C1F2DBA7EC6 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii On Oct 30, 2018, at 7:18 AM, Carlos Maiolino = wrote: >=20 > With the goal of using FIEMAP infra-structure for FIBMAP ioctl, and = with > the updates being done previously into the FIEMAP interface, the > fiemap_extent_info structure is no longer necessary, so, move > fi_extents_mapped and fi_extents_max up to fiemap_ctx. and use > fiemap_ctx.fc_data to hold a pointer to struct fiemap_extent. Having the "void *fc_data" pointer point to fiemap_extent is not necessarily intuitive. Why not just make it directly point to it: struct fiemap_extent *fc_extent; Cheers, Andreas > Signed-off-by: Carlos Maiolino > --- > fs/btrfs/extent_io.c | 3 +-- > fs/ioctl.c | 29 +++++++++++++---------------- > include/linux/fs.h | 9 ++------- > include/linux/iomap.h | 1 - > 4 files changed, 16 insertions(+), 26 deletions(-) >=20 > diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c > index 6a8bc502bc04..88b8a4416dfc 100644 > --- a/fs/btrfs/extent_io.c > +++ b/fs/btrfs/extent_io.c > @@ -4436,7 +4436,6 @@ int extent_fiemap(struct inode *inode, struct = fiemap_ctx *f_ctx) > struct btrfs_path *path; > struct btrfs_root *root =3D BTRFS_I(inode)->root; > struct fiemap_cache cache =3D { 0 }; > - struct fiemap_extent_info *fieinfo =3D f_ctx->fc_data; > int end =3D 0; > u64 em_start =3D 0; > u64 em_len =3D 0; > @@ -4561,7 +4560,7 @@ int extent_fiemap(struct inode *inode, struct = fiemap_ctx *f_ctx) > } else if (em->block_start =3D=3D EXTENT_MAP_DELALLOC) { > flags |=3D (FIEMAP_EXTENT_DELALLOC | > FIEMAP_EXTENT_UNKNOWN); > - } else if (fieinfo->fi_extents_max) { > + } else if (f_ctx->fc_extents_max) { > u64 bytenr =3D em->block_start - > (em->start - em->orig_start); >=20 > diff --git a/fs/ioctl.c b/fs/ioctl.c > index cbc1b21c4f7c..71d11201a06b 100644 > --- a/fs/ioctl.c > +++ b/fs/ioctl.c > @@ -78,17 +78,16 @@ static int ioctl_fibmap(struct file *filp, int = __user *p) > int fiemap_fill_usr_extent(struct fiemap_ctx *f_ctx, u64 logical, > u64 phys, u64 len, u32 flags) > { > - struct fiemap_extent_info *fieinfo =3D f_ctx->fc_data; > struct fiemap_extent extent; > - struct fiemap_extent __user *dest =3D fieinfo->fi_extents_start; > + struct fiemap_extent __user *dest =3D f_ctx->fc_data; >=20 > /* only count the extents */ > - if (fieinfo->fi_extents_max =3D=3D 0) { > - fieinfo->fi_extents_mapped++; > + if (f_ctx->fc_extents_max =3D=3D 0) { > + f_ctx->fc_extents_mapped++; > return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0; > } >=20 > - if (fieinfo->fi_extents_mapped >=3D fieinfo->fi_extents_max) > + if (f_ctx->fc_extents_mapped >=3D f_ctx->fc_extents_max) > return 1; >=20 > if (flags & SET_UNKNOWN_FLAGS) > @@ -104,12 +103,12 @@ int fiemap_fill_usr_extent(struct fiemap_ctx = *f_ctx, u64 logical, > extent.fe_length =3D len; > extent.fe_flags =3D flags; >=20 > - dest +=3D fieinfo->fi_extents_mapped; > + dest +=3D f_ctx->fc_extents_mapped; > if (copy_to_user(dest, &extent, sizeof(extent))) > return -EFAULT; >=20 > - fieinfo->fi_extents_mapped++; > - if (fieinfo->fi_extents_mapped =3D=3D fieinfo->fi_extents_max) > + f_ctx->fc_extents_mapped++; > + if (f_ctx->fc_extents_mapped =3D=3D f_ctx->fc_extents_max) > return 1; > return (flags & FIEMAP_EXTENT_LAST) ? 1 : 0; > } > @@ -189,7 +188,6 @@ static int ioctl_fiemap(struct file *filp, = unsigned long arg) > { > struct fiemap fiemap; > struct fiemap __user *ufiemap =3D (struct fiemap __user *) arg; > - struct fiemap_extent_info fieinfo =3D { 0, }; > struct inode *inode =3D file_inode(filp); > struct super_block *sb =3D inode->i_sb; > struct fiemap_ctx f_ctx; > @@ -210,19 +208,18 @@ static int ioctl_fiemap(struct file *filp, = unsigned long arg) > if (error) > return error; >=20 > - fieinfo.fi_extents_max =3D fiemap.fm_extent_count; > - fieinfo.fi_extents_start =3D ufiemap->fm_extents; > - > + f_ctx.fc_extents_max =3D fiemap.fm_extent_count; > + f_ctx.fc_data =3D ufiemap->fm_extents; > + f_ctx.fc_extents_mapped =3D 0; > f_ctx.fc_flags =3D fiemap.fm_flags; > - f_ctx.fc_data =3D &fieinfo; > f_ctx.fc_start =3D fiemap.fm_start; > f_ctx.fc_len =3D len; >=20 > f_ctx.fc_cb =3D fiemap_fill_usr_extent; >=20 > if (fiemap.fm_extent_count !=3D 0 && > - !access_ok(VERIFY_WRITE, fieinfo.fi_extents_start, > - fieinfo.fi_extents_max * sizeof(struct = fiemap_extent))) > + !access_ok(VERIFY_WRITE, f_ctx.fc_data, > + f_ctx.fc_extents_max * sizeof(struct = fiemap_extent))) > return -EFAULT; >=20 > if (f_ctx.fc_flags & FIEMAP_FLAG_SYNC) > @@ -230,7 +227,7 @@ static int ioctl_fiemap(struct file *filp, = unsigned long arg) >=20 > error =3D inode->i_op->fiemap(inode, &f_ctx); > fiemap.fm_flags =3D f_ctx.fc_flags; > - fiemap.fm_mapped_extents =3D fieinfo.fi_extents_mapped; > + fiemap.fm_mapped_extents =3D f_ctx.fc_extents_mapped; > if (copy_to_user(ufiemap, &fiemap, sizeof(fiemap))) > error =3D -EFAULT; >=20 > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 9a538bc0dac2..4c6dee908a38 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -1691,18 +1691,13 @@ extern bool may_open_dev(const struct path = *path); >=20 > struct fiemap_ctx; >=20 > -struct fiemap_extent_info { > - unsigned int fi_extents_mapped; /* Number of mapped extents */ > - unsigned int fi_extents_max; /* Size of fiemap_extent array = */ > - struct fiemap_extent __user *fi_extents_start; /* Start of > - fiemap_extent = array */ > -}; > - > typedef int (*fiemap_fill_cb)(struct fiemap_ctx *f_ctx, u64 logical, > u64 phys, u64 len, u32 flags); >=20 > struct fiemap_ctx { > unsigned int fc_flags; /* Flags as passed from user */ > + unsigned int fc_extents_mapped; /* Number of mapped extents */ > + unsigned int fc_extents_max; /* Size of fiemap_extent array = */ > void *fc_data; > fiemap_fill_cb fc_cb; > u64 fc_start; > diff --git a/include/linux/iomap.h b/include/linux/iomap.h > index 7ce84be499d6..21643bcf6104 100644 > --- a/include/linux/iomap.h > +++ b/include/linux/iomap.h > @@ -9,7 +9,6 @@ > #include >=20 > struct address_space; > -struct fiemap_extent_info; > struct inode; > struct iov_iter; > struct kiocb; > -- > 2.17.1 >=20 Cheers, Andreas --Apple-Mail=_255DB1ED-7F99-4237-9E3E-2C1F2DBA7EC6 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Comment: GPGTools - http://gpgtools.org iQIzBAEBCAAdFiEEDb73u6ZejP5ZMprvcqXauRfMH+AFAlvgwM4ACgkQcqXauRfM H+BSRQ/+JhQinCHT08pIf7ngGQvavilxTfTnz+pvUGOqP1lBHDLuTr+bI89WYLTE RB//+oMweWOLI3R7KK33Em5K4uvRhtD2HihpoP4ozIZ3UNuJS7NYBHomTnh3OiwG fJ+h3s7he8UfYsI/+q5vmK/JATEuwPE0WudLwc2rCyZTVSrtuubrZJ2R+T6X01SL qNe2m3lKMED+AprKCYqQJGdOKp2k6feGGL6+sCqbQAM+SsqFCZOjDUPnh5uL2YBo EVdoDG0uRyq4iuUu3rbj3BBVZf7aamv6i8Ly6rv0teuOm1jK+tbmuAyPJ5OxsbRP NpUEycIfF0QhgV34rZBTQS+bU6h9dh2iTY/KrJpkRjfzdPR8QCPo83Ar2Ch8KuEo Y+IOKQnVo4dY5UeGBfBeEjDnR6Biz0I0MJuqM3FCxn+lSEvW3bdqX48qNp56K3U1 DFSgF+TmkjbVUQlOU/guMMdoOEZThbx3qOGYHKGSEwpmu50+k4Tfc0MikcYOCb1X 3i/OuQ8YHLbq6mrgwB6LslzhfVqnZIvbRjR4PitbEd/xajPFphRD36WGIB8H+eB5 20dGq1QZvMZQIh3fcbS3eXD7fy3Qmv7QRu1C1JYbUZH7KZpFqheMsGw2uMCiWKRn bXqA4UNiHxLz+Vc6RPPI/e6N3/JpR+lr6paBZyKqpYhIHMAuGkI= =SAXV -----END PGP SIGNATURE----- --Apple-Mail=_255DB1ED-7F99-4237-9E3E-2C1F2DBA7EC6--