linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Andreas Gruenbacher <agruenba@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,
	linux-xfs@vger.kernel.org, Jan Kara <jack@suse.cz>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2 4/4] ext4: Switch to iomap for SEEK_HOLE / SEEK_DATA
Date: Thu, 14 Sep 2017 14:02:29 +0200	[thread overview]
Message-ID: <20170914120229.GA22886@quack2.suse.cz> (raw)
In-Reply-To: <20170914095047.23935-5-agruenba@redhat.com>

On Thu 14-09-17 11:50:47, Andreas Gruenbacher wrote:
> @@ -3422,9 +3422,38 @@ static int ext4_iomap_begin(struct inode *inode, loff_t offset, loff_t length,
>  	map.m_lblk = first_block;
>  	map.m_len = last_block - first_block + 1;
>  
> -	if (!(flags & IOMAP_WRITE)) {
> +	if (flags & IOMAP_REPORT) {
>  		ret = ext4_map_blocks(NULL, inode, &map, 0);
> -	} else {
> +		if (ret < 0)
> +			return ret;
> +
> +		if (ret == 0) {
> +			ext4_lblk_t end = map.m_lblk + map.m_len - 1;
> +			struct extent_status es;
> +
> +			ext4_es_find_delayed_extent_range(inode, map.m_lblk, end, &es);
> +
> +			if (!es.es_len || es.es_lblk > end) {
> +				/* entire range is a hole */
> +			} else if (es.es_lblk > map.m_lblk) {
> +				/* range starts with a hole */
> +				map.m_len = es.es_lblk - map.m_lblk;
> +			} else {
> +				ext4_lblk_t offs = 0;
> +
> +				if (es.es_lblk < map.m_lblk)
> +					offs = map.m_lblk - es.es_lblk;
> +				map.m_lblk = es.es_lblk + offs;
> +				map.m_pblk = ext4_es_pblock(&es) + offs;
> +				map.m_len = es.es_len - offs;
> +				if (ext4_es_is_unwritten(&es))
> +					map.m_flags |= EXT4_MAP_UNWRITTEN;

This is not possible. If there is unwritten extent at map->m_lblk, then
ext4_map_blocks() could not have possibly returned 0. So just delete this
condition and set map.m_pblk to 0 since delalloc extent has no physical
possition.

> +				if (ext4_es_is_delayed(&es))
> +					delalloc = true;

Also ext4_es_is_delayed(&es) is guaranteed to be true since you've looked
it up by ext4_es_find_delayed_extent_range(). So just set delalloc = true
unconditionally.

Otherwise the patch looks good so after fixing up these small issues feel
free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2017-09-14 12:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-14  9:50 [PATCH v2 0/4] ext4: SEEK_HOLE / SEEK_DATA via iomap Andreas Gruenbacher
2017-09-14  9:50 ` [PATCH v2 1/4] iomap: Switch from blkno to disk offset Andreas Gruenbacher
2017-09-14  9:50 ` [PATCH v2 2/4] iomap: Add IOMAP_F_DATA_INLINE flag Andreas Gruenbacher
2017-09-14  9:50 ` [PATCH v2 3/4] ext4: Add iomap support for inline data Andreas Gruenbacher
2017-09-28 17:57   ` Theodore Ts'o
2017-10-02 14:39     ` Andreas Gruenbacher
2017-10-02 15:02       ` Theodore Ts'o
2017-09-14  9:50 ` [PATCH v2 4/4] ext4: Switch to iomap for SEEK_HOLE / SEEK_DATA Andreas Gruenbacher
2017-09-14 12:02   ` Jan Kara [this message]
2017-09-14 12:47     ` Andreas Grünbacher
2017-09-14 13:14       ` Jan Kara

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=20170914120229.GA22886@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=agruenba@redhat.com \
    --cc=hch@lst.de \
    --cc=linux-ext4@vger.kernel.org \
    --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).