public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shaohua Li <shli@fb.com>
To: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<axboe@fb.com>, <sitsofe@yahoo.com>, <snitzer@redhat.com>,
	<hch@infradead.org>, <Kernel-team@fb.com>
Subject: Re: [PATCH V2] block: correctly fallback for zeroout
Date: Thu, 9 Jun 2016 19:54:36 -0700	[thread overview]
Message-ID: <20160610025435.GA48899@shli-mbp.local> (raw)
In-Reply-To: <yq18tydiyuf.fsf@sermon.lab.mkp.net>

On Thu, Jun 09, 2016 at 10:04:08PM -0400, Martin K. Petersen wrote:
> >>>>> "Shaohua" == Shaohua Li <shli@fb.com> writes:
> 
> Shaohua,
> 
> diff --git a/block/blk-lib.c b/block/blk-lib.c
> index 23d7f30..a3a26c8 100644
> --- a/block/blk-lib.c
> +++ b/block/blk-lib.c
> @@ -84,6 +84,28 @@ int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
>  }
>  EXPORT_SYMBOL(__blkdev_issue_discard);
>  
> +static int do_blkdev_issue_discard(struct block_device *bdev, sector_t sector,
> +		sector_t nr_sects, gfp_t gfp_mask, unsigned long flags,
> +		int *io_err)
> +{
> +	int type = REQ_WRITE | REQ_DISCARD;
> +	struct bio *bio = NULL;
> +	struct blk_plug plug;
> +	int ret;
> +
> +	if (flags & BLKDEV_DISCARD_SECURE)
> +		type |= REQ_SECURE;
> +
> +	blk_start_plug(&plug);
> +	ret = __blkdev_issue_discard(bdev, sector, nr_sects, gfp_mask, type,
> +			&bio);
> +	if (!ret && bio)
> +		*io_err = submit_bio_wait(type, bio);
> +	blk_finish_plug(&plug);
> +
> +	return ret;
> +}
> +
> 
> What does the extra io_err buy us? Just have this function return an
> error. And then in blkdev_issue_discard if you get -EOPNOTSUPP you
> special case it there.

The __blkdev_issue_discard returns -EOPNOTSUPP if disk doesn't support discard.
in that case, blkdev_issue_discard doesn't return 0. blkdev_issue_discard only
returns 0 if IO error is -EOPNOTSUPP. Please see bbd848e0fade51ae51da.

Thanks,
Shaohua

  reply	other threads:[~2016-06-10  2:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-06 22:33 [PATCH V2] block: correctly fallback for zeroout Shaohua Li
2016-06-07  4:50 ` Sitsofe Wheeler
2016-06-07 14:58   ` Shaohua Li
2016-06-15 21:26     ` Sitsofe Wheeler
2016-06-10  2:04 ` Martin K. Petersen
2016-06-10  2:54   ` Shaohua Li [this message]
2016-06-11  1:49     ` Martin K. Petersen
2016-06-13  8:20       ` Christoph Hellwig
2016-06-14 18:36         ` Mike Snitzer
2016-06-15  2:30           ` Martin K. Petersen
2016-06-15  2:40             ` Mike Snitzer
2016-06-15  2:14         ` Martin K. Petersen
2016-06-15 21:24           ` Sitsofe Wheeler

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=20160610025435.GA48899@shli-mbp.local \
    --to=shli@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=axboe@fb.com \
    --cc=hch@infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sitsofe@yahoo.com \
    --cc=snitzer@redhat.com \
    /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