Linux-Fsdevel Archive on lore.kernel.org
 help / color / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Brian Foster <bfoster@redhat.com>
Cc: Christoph Hellwig <hch@infradead.org>,
	linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/2] iomap: zero cached pages over unwritten extents on zero range
Date: Tue, 27 Oct 2020 18:15:52 +0000
Message-ID: <20201027181552.GB32577@infradead.org> (raw)
In-Reply-To: <20201020162150.GB1272590@bfoster>

On Tue, Oct 20, 2020 at 12:21:50PM -0400, Brian Foster wrote:
> Ugh, so the above doesn't quite describe historical behavior.
> block_truncate_page() converts an unwritten block if a page exists
> (dirty or not), but bails out if a page doesn't exist. We could still do
> the above, but if we wanted something more intelligent I think we need
> to check for a page before we get the mapping to know whether we can
> safely skip an unwritten block or need to write over it. Otherwise if we
> check for a page within the actor, we have no way of knowing whether
> there was a (possibly dirty) page that had been written back and/or
> reclaimed since ->iomap_begin(). If we check for the page first, I think
> that the iolock/mmaplock in the truncate path ensures that a page can't
> be added before we complete. We might be able to take that further and
> check for a dirty || writeback page, but that might be safer as a
> separate patch. See the (compile tested only) diff below for an idea of
> what I was thinking.

The idea looks reasonable, but a few comment below:

> +struct iomap_trunc_priv {
> +	bool *did_zero;

I don't think there is any point on using a pointer here, when we
can trivially copy out the scalar value.

> +	bool has_page;

The naming of this flag really confuses me.  Maybe has_data or
in_pagecache might be better options?

> +static loff_t
> +iomap_truncate_page_actor(struct inode *inode, loff_t pos, loff_t count,
> +		void *data, struct iomap *iomap, struct iomap *srcmap)
> +{
> +	struct iomap_trunc_priv	*priv = data;
> +	unsigned offset;
> +	int status;
> +
> +	if (srcmap->type == IOMAP_HOLE)
> +		return count;
> +	if (srcmap->type == IOMAP_UNWRITTEN && !priv->has_page)
> +		return count;

Maybe add a comment here to explain why priv->has_page matters?

> +
> +	offset = offset_in_page(pos);

I'd move this on the initialization line.

> +	ret = iomap_apply(inode, pos, blocksize - off, IOMAP_ZERO, ops, &priv,
> +			  iomap_truncate_page_actor);
> +	if (ret <= 0)
> +		return ret;

The check could just be < 0 and would be a little more obvious.

  reply index

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-12 14:03 [PATCH 0/2] iomap: zero dirty pages over unwritten extents Brian Foster
2020-10-12 14:03 ` [PATCH 1/2] iomap: use page dirty state to seek data " Brian Foster
2020-10-13 12:30   ` Brian Foster
2020-10-13 22:53   ` Dave Chinner
2020-10-14 12:59     ` Brian Foster
2020-10-14 22:37       ` Dave Chinner
2020-10-15  9:47   ` Christoph Hellwig
2020-10-19 16:55     ` Brian Foster
2020-10-27 18:07       ` Christoph Hellwig
2020-10-28 11:31         ` Brian Foster
2020-10-12 14:03 ` [PATCH 2/2] iomap: zero cached pages over unwritten extents on zero range Brian Foster
2020-10-15  9:49   ` Christoph Hellwig
2020-10-19 16:55     ` Brian Foster
2020-10-19 18:01       ` Brian Foster
2020-10-20 16:21         ` Brian Foster
2020-10-27 18:15           ` Christoph Hellwig [this message]
2020-10-28 11:31             ` Brian Foster
2020-10-23  1:02   ` [iomap] 11b5156248: xfstests.xfs.310.fail kernel test robot

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=20201027181552.GB32577@infradead.org \
    --to=hch@infradead.org \
    --cc=bfoster@redhat.com \
    --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

Linux-Fsdevel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-fsdevel/0 linux-fsdevel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-fsdevel linux-fsdevel/ https://lore.kernel.org/linux-fsdevel \
		linux-fsdevel@vger.kernel.org
	public-inbox-index linux-fsdevel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-fsdevel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git