From: Christoph Hellwig <hch@infradead.org>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
cluster-devel@redhat.com, Jan Kara <jack@suse.cz>
Subject: Re: [PATCH v2 1/6] vfs: Add iomap_seek_hole_data helper
Date: Mon, 26 Jun 2017 03:47:16 -0700 [thread overview]
Message-ID: <20170626104716.GB23149@infradead.org> (raw)
In-Reply-To: <1498224884-346-2-git-send-email-agruenba@redhat.com>
On Fri, Jun 23, 2017 at 03:34:39PM +0200, Andreas Gruenbacher wrote:
> Filesystems can use this for implementing lseek SEEK_HOLE / SEEK_DATA
> support via iomap.
>
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
> fs/iomap.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/iomap.h | 3 ++
> 2 files changed, 92 insertions(+)
>
> diff --git a/fs/iomap.c b/fs/iomap.c
> index 4b10892..781f0a0 100644
> --- a/fs/iomap.c
> +++ b/fs/iomap.c
> @@ -584,6 +584,95 @@ int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fi,
> }
> EXPORT_SYMBOL_GPL(iomap_fiemap);
>
> +static loff_t
> +iomap_seek_hole_actor(struct inode *inode, loff_t offset, loff_t length,
> + void *data, struct iomap *iomap)
> +{
> + if (iomap->type == IOMAP_HOLE)
> + goto found;
> + length = iomap->offset + iomap->length - offset;
What is the problem with the passed in length value?
> + if (iomap->type != IOMAP_UNWRITTEN)
> + return length;
> + offset = page_cache_seek_hole_data(inode, offset, length, SEEK_HOLE);
> + if (offset < 0)
> + return length;
> +found:
> + *(loff_t *)data = offset;
> + return 0;
What about using a switch statement?
switch (iomap->type) {
case IOMAP_UNWRITTEN:
offset = page_cache_seek_hole_data(inode, offset, length,
SEEK_HOLE);
if (offset < 0)
return length;
/*FALLTHRU*/
case IOMAP_HOLE:
*(loff_t *)data = offset;
return 0;
default:
return length;
}
> +static loff_t
> +iomap_seek_data_actor(struct inode *inode, loff_t offset, loff_t length,
> + void *data, struct iomap *iomap)
> +{
> + if (iomap->type != IOMAP_HOLE && iomap->type != IOMAP_UNWRITTEN)
> + goto found;
> + length = iomap->offset + iomap->length - offset;
> + if (iomap->type != IOMAP_UNWRITTEN)
> + return length;
> + offset = page_cache_seek_hole_data(inode, offset, length, SEEK_DATA);
> + if (offset < 0)
> + return length;
> +found:
> + *(loff_t *)data = offset;
> + return 0;
> +loff_t
> +iomap_seek_hole_data(struct inode *inode, loff_t offset,
> + int whence, const struct iomap_ops *ops)
> +{
> + static loff_t (*actor)(struct inode *, loff_t, loff_t, void *,
> + struct iomap *);
I wonder (but I'm not sure) if it would be simpler and easier to
understand to just have to different functions for SEEK_HOLE
vs SEEK_DATA here.
next prev parent reply other threads:[~2017-06-26 10:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-23 13:34 [PATCH v2 0/6] SEEK_HOLE / SEEK_DATA via iomap Andreas Gruenbacher
2017-06-23 13:34 ` [PATCH v2 1/6] vfs: Add iomap_seek_hole_data helper Andreas Gruenbacher
2017-06-25 5:00 ` kbuild test robot
2017-06-26 10:47 ` Christoph Hellwig [this message]
2017-06-26 14:11 ` Andreas Gruenbacher
2017-06-23 13:34 ` [PATCH v2 2/6] xfs: Switch to iomap for SEEK_HOLE / SEEK_DATA Andreas Gruenbacher
2017-06-23 13:34 ` [PATCH v2 3/6] GFS2: Make height info part of metapath Andreas Gruenbacher
2017-06-23 13:34 ` [PATCH v2 4/6] GFS2: Implement iomap for block_map Andreas Gruenbacher
2017-06-23 13:34 ` [PATCH v2 5/6] GFS2: Switch fiemap implementation to use iomap Andreas Gruenbacher
2017-06-23 13:34 ` [PATCH v2 6/6] gfs2: Implement SEEK_HOLE / SEEK_DATA via iomap Andreas Gruenbacher
2017-06-26 9:50 ` [PATCH v2 0/6] " Christoph Hellwig
2017-06-26 14:21 ` Andreas Gruenbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170626104716.GB23149@infradead.org \
--to=hch@infradead.org \
--cc=agruenba@redhat.com \
--cc=cluster-devel@redhat.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).