mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Dmitry Monakhov <dmonakhov@openvz.org>
Cc: linux-kernel@vger.kernel.org, darrick.wong@oracle.com,
	axboe@kernel.dk, tytso@mit.edu, jack@suse.cz, hch@infradead.org
Subject: Re: [PATCH 5/5] block: truncate page cache only when necessary on fallocate
Date: Thu, 6 Apr 2017 08:43:02 -0700	[thread overview]
Message-ID: <20170406154302.GB16767@infradead.org> (raw)
In-Reply-To: <1491480169-1889-6-git-send-email-dmonakhov@openvz.org>

why?

On Thu, Apr 06, 2017 at 04:02:49PM +0400, Dmitry Monakhov wrote:
> Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
> ---
>  fs/block_dev.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/block_dev.c b/fs/block_dev.c
> index 2eca00e..f4b13e1 100644
> --- a/fs/block_dev.c
> +++ b/fs/block_dev.c
> @@ -2075,7 +2075,7 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
>  {
>  	struct block_device *bdev = I_BDEV(bdev_file_inode(file));
>  	struct request_queue *q = bdev_get_queue(bdev);
> -	struct address_space *mapping;
> +	struct address_space *mapping = bdev->bd_inode->i_mapping;
>  	loff_t end = start + len - 1;
>  	loff_t isize;
>  	int error;
> @@ -2102,13 +2102,10 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
>  	if ((start | len) & (bdev_logical_block_size(bdev) - 1))
>  		return -EINVAL;
>  
> -	/* Invalidate the page cache, including dirty pages. */
> -	mapping = bdev->bd_inode->i_mapping;
> -	truncate_inode_pages_range(mapping, start, end);
> -
>  	switch (mode) {
>  	case FALLOC_FL_ZERO_RANGE:
>  	case FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE:
> +		truncate_inode_pages_range(mapping, start, end);
>  		error = blkdev_issue_zeroout(bdev, start >> 9, len >> 9,
>  					    GFP_KERNEL, false);
>  		break;
> @@ -2116,12 +2113,14 @@ static long blkdev_fallocate(struct file *file, int mode, loff_t start,
>  		/* Only punch if the device can do zeroing discard. */
>  		if (!blk_queue_discard(q) || !q->limits.discard_zeroes_data)
>  			return -EOPNOTSUPP;
> +		truncate_inode_pages_range(mapping, start, end);
>  		error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
>  					     GFP_KERNEL, 0);
>  		break;
>  	case FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE | FALLOC_FL_NO_HIDE_STALE:
>  		if (!blk_queue_discard(q))
>  			return -EOPNOTSUPP;
> +		truncate_inode_pages_range(mapping, start, end);
>  		error = blkdev_issue_discard(bdev, start >> 9, len >> 9,
>  					     GFP_KERNEL, 0);
>  		break;
> -- 
> 2.9.3
> 
---end quoted text---

  reply	other threads:[~2017-04-06 15:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-06 12:02 [PATCH 0/5] falloc on blockdevice: what possibly can go whong? Dmitry Monakhov
2017-04-06 12:02 ` [PATCH 1/5] bh: Prevent panic on invalid BHs Dmitry Monakhov
2017-04-06 15:42   ` Christoph Hellwig
2017-04-06 16:01     ` Dmitry Monakhov
2017-04-06 12:02 ` [PATCH 2/5] block: protect bdevname from null pointer bdev Dmitry Monakhov
2017-04-06 12:02 ` [PATCH 3/5] bio: Protect submit_bio from bdevless bio-s Dmitry Monakhov
2017-04-06 12:02 ` [PATCH 4/5] jbd2: use stable bdev pointer Dmitry Monakhov
2017-04-06 12:02 ` [PATCH 5/5] block: truncate page cache only when necessary on fallocate Dmitry Monakhov
2017-04-06 15:43   ` Christoph Hellwig [this message]
2017-04-06 15:51     ` Dmitry Monakhov

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=20170406154302.GB16767@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=darrick.wong@oracle.com \
    --cc=dmonakhov@openvz.org \
    --cc=jack@suse.cz \
    --cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®