All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Tom Yan <tom.ty89@gmail.com>, linux-block@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH 2/3] block: make __blkdev_issue_zero_pages() less confusing
Date: Sun, 6 Dec 2020 12:29:23 +0100	[thread overview]
Message-ID: <ed132ef1-b4d0-6e3f-2c7c-a9292bccbfe2@suse.de> (raw)
In-Reply-To: <20201206055332.3144-2-tom.ty89@gmail.com>

On 12/6/20 6:53 AM, Tom Yan wrote:
> Instead of using the same check for the two layers of loops, count
> bio pages in the inner loop instead.
> 
> Signed-off-by: Tom Yan <tom.ty89@gmail.com>
> ---
>   block/blk-lib.c | 11 +++++------
>   1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/block/blk-lib.c b/block/blk-lib.c
> index c1e9388a8fb8..354dcab760c7 100644
> --- a/block/blk-lib.c
> +++ b/block/blk-lib.c
> @@ -318,7 +318,7 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
>   	struct request_queue *q = bdev_get_queue(bdev);
>   	struct bio *bio = *biop;
>   	int bi_size = 0;
> -	unsigned int sz;
> +	unsigned int sz, bio_nr_pages;
>   
>   	if (!q)
>   		return -ENXIO;
> @@ -327,19 +327,18 @@ static int __blkdev_issue_zero_pages(struct block_device *bdev,
>   		return -EPERM;
>   
>   	while (nr_sects != 0) {
> -		bio = blk_next_bio(bio, __blkdev_sectors_to_bio_pages(nr_sects),
> -				   gfp_mask);
> +		bio_nr_pages = __blkdev_sectors_to_bio_pages(nr_sects);
> +		bio = blk_next_bio(bio, bio_nr_pages, gfp_mask);
>   		bio->bi_iter.bi_sector = sector;
>   		bio_set_dev(bio, bdev);
>   		bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
>   
> -		while (nr_sects != 0) {
> +		while (bio_nr_pages != 0) {
>   			sz = min((sector_t) PAGE_SIZE, nr_sects << 9);

nr_sects will need to be modified, too, if we iterate over bio_nr_pages 
instead of nr_sects.

>   			bi_size = bio_add_page(bio, ZERO_PAGE(0), sz, 0);
>   			nr_sects -= bi_size >> 9;
>   			sector += bi_size >> 9;
> -			if (bi_size < sz)
> -				break;
> +			bio_nr_pages--;
>   		}
>   		cond_resched();
>   	}
> 

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@suse.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

  reply	other threads:[~2020-12-06 11:30 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-06  5:53 [PATCH 1/3] block: try one write zeroes request before going further Tom Yan
2020-12-06  5:53 ` [PATCH 2/3] block: make __blkdev_issue_zero_pages() less confusing Tom Yan
2020-12-06 11:29   ` Hannes Reinecke [this message]
2020-12-06 13:28     ` Tom Yan
2020-12-07 13:34   ` Christoph Hellwig
2020-12-08 12:54     ` Tom Yan
2020-12-06  5:53 ` [PATCH 3/3] block: set REQ_PREFLUSH to the final bio from __blkdev_issue_zero_pages() Tom Yan
2020-12-06 11:31   ` Hannes Reinecke
2020-12-06 13:32     ` Tom Yan
2020-12-06 14:05       ` Hannes Reinecke
2020-12-06 14:14         ` Tom Yan
2020-12-06 16:05           ` Hannes Reinecke
2020-12-08 12:51             ` Tom Yan
2020-12-07 13:35   ` Christoph Hellwig
2020-12-06 11:25 ` [PATCH 1/3] block: try one write zeroes request before going further Hannes Reinecke
2020-12-06 13:25   ` Tom Yan
2020-12-06 13:56     ` Hannes Reinecke
2020-12-06 14:07       ` Tom Yan
2020-12-06 14:28         ` Tom Yan
2020-12-07 13:36 ` Christoph Hellwig
2020-12-08 12:48   ` Tom Yan
2020-12-09 17:51     ` Christoph Hellwig
2020-12-08 22:46 ` Ewan D. Milne

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=ed132ef1-b4d0-6e3f-2c7c-a9292bccbfe2@suse.de \
    --to=hare@suse.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=tom.ty89@gmail.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 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.