linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: Mikulas Patocka <mpatocka@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	Zdenek Kabelac <zkabelac@redhat.com>,
	linux-block@vger.kernel.org, dm-devel@redhat.com
Subject: Re: [PATCH 3/4] brd: enable discard
Date: Tue, 20 Sep 2022 00:39:22 -0700	[thread overview]
Message-ID: <YyluKtwOaLSPvNmI@infradead.org> (raw)
In-Reply-To: <alpine.LRH.2.02.2209160459470.543@file01.intranet.prod.int.rdu2.redhat.com>

> @@ -289,6 +308,23 @@ static void brd_submit_bio(struct bio *b
>  	struct bio_vec bvec;
>  	struct bvec_iter iter;
>  
> +	if (bio_op(bio) == REQ_OP_DISCARD) {
> +		sector_t len = bio_sectors(bio);
> +		sector_t front_pad = -sector & (PAGE_SECTORS - 1);
> +		sector += front_pad;
> +		if (unlikely(len <= front_pad))
> +			goto endio;
> +		len -= front_pad;
> +		len = round_down(len, PAGE_SECTORS);
> +		while (len) {
> +			brd_free_page(brd, sector);
> +			sector += PAGE_SECTORS;
> +			len -= PAGE_SECTORS;
> +			cond_resched();
> +		}
> +		goto endio;
> +	}
> +
>  	bio_for_each_segment(bvec, bio, iter) {

Please add separate helpers to each type of IO and just make the
main submit_bio method a dispatch on the types instead of this
spaghetti code.

> +	disk->queue->limits.discard_granularity = PAGE_SIZE;
> +	blk_queue_max_discard_sectors(disk->queue, UINT_MAX);

We'll probably want an opt in for this new feature.

  reply	other threads:[~2022-09-20  7:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-16  8:58 [PATCH 0/4] brd: implement discard Mikulas Patocka
2022-09-16  8:59 ` [PATCH 1/4] brd: make brd_insert_page return bool Mikulas Patocka
2022-09-20  7:28   ` Christoph Hellwig
2022-09-16  8:59 ` [PATCH 2/4] brd: extend the rcu regions to cover read and write Mikulas Patocka
2022-09-20  7:38   ` Christoph Hellwig
2022-09-16  9:00 ` [PATCH 3/4] brd: enable discard Mikulas Patocka
2022-09-20  7:39   ` Christoph Hellwig [this message]
2022-09-20 17:47     ` Mikulas Patocka
2022-09-16  9:00 ` [PATCH 4/4] brd: implement secure erase and write zeroes Mikulas Patocka
2022-09-20  7:29   ` Christoph Hellwig
2022-09-20 17:46     ` [dm-devel] " Mikulas Patocka

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=YyluKtwOaLSPvNmI@infradead.org \
    --to=hch@infradead.org \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=mpatocka@redhat.com \
    --cc=zkabelac@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;
as well as URLs for NNTP newsgroup(s).