All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Lukas Czerner <lczerner@redhat.com>
Cc: "Theodore Y. Ts'o" <tytso@mit.edu>,
	linux-ext4 <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH] libext2fs: revert "try to always use PUNCH_HOLE for unix_discard"
Date: Fri, 15 Feb 2019 08:25:43 -0800	[thread overview]
Message-ID: <20190215162543.GA6471@magnolia> (raw)
In-Reply-To: <20190215095007.jx5ol3ss7uhegz3z@localhost.localdomain>

On Fri, Feb 15, 2019 at 10:50:07AM +0100, Lukas Czerner wrote:
> On Thu, Feb 14, 2019 at 04:04:48PM -0500, Theodore Y. Ts'o wrote:
> > On Mon, Jan 14, 2019 at 03:37:08PM -0800, Darrick J. Wong wrote:
> > > From: Darrick J. Wong <darrick.wong@oracle.com>
> > > 
> > > Revert bcca9876a3428c10417c660b78933e6e70e8a5f5, because
> > > fallocate(PUNCH_HOLE) on block devices was changed to use zeroout
> > > instead of discard shortly after block device fallocate was merged.
> > > zeroout isn't necessarily a "drop storage" operation like discard is,
> > > so we prefer to use that on block devices.
> > > 
> > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Thanks, applied.
> > 
> > 					- Ted
> 
> I just noticed this patch, sorry. I think we can still use fallocate,
> but we need to set the right flags to make sure it uses discard instead
> of zeroout. See fs/block_dev.c
> 
> 	switch (mode) {
> 	case FALLOC_FL_ZERO_RANGE:
> 	case FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE:
> 		error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9,
> 					    GFP_KERNEL, BLKDEV_ZERO_NOUNMAP);
> 		break;
> 	case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE:
> 		error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9,
> 					     GFP_KERNEL, BLKDEV_ZERO_NOFALLBACK);
> 		break;
> 	case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE:
> 		error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
> 					     GFP_KERNEL, 0);
> 		break;
> 	default:
> 		return -EOPNOTSUPP;
> 	}
> 
> So if we want a discard (meaning we want to unallocate the blocks
> without necessarily making sure we can't read stale data from it) we
> have to use FALLOC_FL_NO_HIDE_STALE.
> 
> So the flags would be FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE

Userspace isn't allowed to pass in _NO_HIDE_STALE; see
FALLOC_FL_SUPPORTED_MASK in include/linux/falloc.h.

The behavior of "no hide stale" isn't defined in the manpages; it's
merely a reserved code point.

--D

> Ted, Darrick what do you think ? Can we keep the
> bcca9876a3428c10417c660b78933e6e70e8a5f5 commit and just change the
> flags ?
> 
> -Lukas

      reply	other threads:[~2019-02-15 16:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14 23:37 [PATCH] libext2fs: revert "try to always use PUNCH_HOLE for unix_discard" Darrick J. Wong
2019-02-14 21:04 ` Theodore Y. Ts'o
2019-02-15  9:50   ` Lukas Czerner
2019-02-15 16:25     ` Darrick J. Wong [this message]

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=20190215162543.GA6471@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.