linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
To: Marcos Paulo de Souza <marcos.souza.org@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Ming Lei <ming.lei@redhat.com>, Greg Edwards <gedwards@ddn.com>,
	Hannes Reinecke <hare@suse.com>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Jens Axboe <axboe@kernel.dk>,
	Bart Van Assche <bvanassche@acm.org>,
	Omar Sandoval <osandov@fb.com>,
	Damien Le Moal <Damien.LeMoal@wdc.com>
Subject: Re: [RFC PATCH 2/2] null_blk: Make use of size_to_sectors helper
Date: Sun, 21 Apr 2019 17:42:27 +0000	[thread overview]
Message-ID: <SN6PR04MB4527DAFECD39E2C26DDF4CE586210@SN6PR04MB4527.namprd04.prod.outlook.com> (raw)
In-Reply-To: 20190421035328.19322-3-marcos.souza.org@gmail.com

Looks good.

Reviewed-by : Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

On 04/20/2019 08:54 PM, Marcos Paulo de Souza wrote:
> This helper tries to make the code easier to read, and unifies the code
> of returning the number of sectors for a given number of bytes.
>
> Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
> ---
>   drivers/block/null_blk_main.c | 18 +++++++++---------
>   1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/block/null_blk_main.c b/drivers/block/null_blk_main.c
> index d7ac09c092f2..05f0bef54296 100644
> --- a/drivers/block/null_blk_main.c
> +++ b/drivers/block/null_blk_main.c
> @@ -853,7 +853,7 @@ static int null_flush_cache_page(struct nullb *nullb, struct nullb_page *c_page)
>   	dst = kmap_atomic(t_page->page);
>
>   	for (i = 0; i < PAGE_SECTORS;
> -			i += (nullb->dev->blocksize >> SECTOR_SHIFT)) {
> +			i += (size_to_sectors(nullb->dev->blocksize))) {
>   		if (test_bit(i, c_page->bitmap)) {
>   			offset = (i << SECTOR_SHIFT);
>   			memcpy(dst + offset, src + offset,
> @@ -957,7 +957,7 @@ static int copy_to_nullb(struct nullb *nullb, struct page *source,
>   			null_free_sector(nullb, sector, true);
>
>   		count += temp;
> -		sector += temp >> SECTOR_SHIFT;
> +		sector += size_to_sectors(temp);
>   	}
>   	return 0;
>   }
> @@ -989,7 +989,7 @@ static int copy_from_nullb(struct nullb *nullb, struct page *dest,
>   		kunmap_atomic(dst);
>
>   		count += temp;
> -		sector += temp >> SECTOR_SHIFT;
> +		sector += size_to_sectors(temp);
>   	}
>   	return 0;
>   }
> @@ -1004,7 +1004,7 @@ static void null_handle_discard(struct nullb *nullb, sector_t sector, size_t n)
>   		null_free_sector(nullb, sector, false);
>   		if (null_cache_active(nullb))
>   			null_free_sector(nullb, sector, true);
> -		sector += temp >> SECTOR_SHIFT;
> +		sector += size_to_sectors(temp);
>   		n -= temp;
>   	}
>   	spin_unlock_irq(&nullb->lock);
> @@ -1074,7 +1074,7 @@ static int null_handle_rq(struct nullb_cmd *cmd)
>   			spin_unlock_irq(&nullb->lock);
>   			return err;
>   		}
> -		sector += len >> SECTOR_SHIFT;
> +		sector += size_to_sectors(len);
>   	}
>   	spin_unlock_irq(&nullb->lock);
>
> @@ -1109,7 +1109,7 @@ static int null_handle_bio(struct nullb_cmd *cmd)
>   			spin_unlock_irq(&nullb->lock);
>   			return err;
>   		}
> -		sector += len >> SECTOR_SHIFT;
> +		sector += size_to_sectors(len);
>   	}
>   	spin_unlock_irq(&nullb->lock);
>   	return 0;
> @@ -1201,7 +1201,7 @@ static blk_status_t null_handle_cmd(struct nullb_cmd *cmd)
>   		if (dev->queue_mode == NULL_Q_BIO) {
>   			op = bio_op(cmd->bio);
>   			sector = cmd->bio->bi_iter.bi_sector;
> -			nr_sectors = cmd->bio->bi_iter.bi_size >> 9;
> +			nr_sectors = size_to_sectors(cmd->bio->bi_iter.bi_size);
>   		} else {
>   			op = req_op(cmd->rq);
>   			sector = blk_rq_pos(cmd->rq);
> @@ -1406,7 +1406,7 @@ static void null_config_discard(struct nullb *nullb)
>   		return;
>   	nullb->q->limits.discard_granularity = nullb->dev->blocksize;
>   	nullb->q->limits.discard_alignment = nullb->dev->blocksize;
> -	blk_queue_max_discard_sectors(nullb->q, UINT_MAX >> 9);
> +	blk_queue_max_discard_sectors(nullb->q, size_to_sectors(UINT_MAX));
>   	blk_queue_flag_set(QUEUE_FLAG_DISCARD, nullb->q);
>   }
>
> @@ -1520,7 +1520,7 @@ static int null_gendisk_register(struct nullb *nullb)
>   	if (!disk)
>   		return -ENOMEM;
>   	size = (sector_t)nullb->dev->size * 1024 * 1024ULL;
> -	set_capacity(disk, size >> 9);
> +	set_capacity(disk, size_to_sectors(size));
>
>   	disk->flags |= GENHD_FL_EXT_DEVT | GENHD_FL_SUPPRESS_PARTITION_INFO;
>   	disk->major		= null_major;
>


      reply	other threads:[~2019-04-21 17:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-21  3:53 [RFC PATCH 0/2] Introduce size_to_sectors helper in blkdev.h Marcos Paulo de Souza
2019-04-21  3:53 ` [RFC PATCH 1/2] blkdev.h: Introduce size_to_sectors hlper function Marcos Paulo de Souza
2019-04-21 17:39   ` Chaitanya Kulkarni
2019-04-21  3:53 ` [RFC PATCH 2/2] null_blk: Make use of size_to_sectors helper Marcos Paulo de Souza
2019-04-21 17:42   ` Chaitanya Kulkarni [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=SN6PR04MB4527DAFECD39E2C26DDF4CE586210@SN6PR04MB4527.namprd04.prod.outlook.com \
    --to=chaitanya.kulkarni@wdc.com \
    --cc=Damien.LeMoal@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --cc=gedwards@ddn.com \
    --cc=hare@suse.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcos.souza.org@gmail.com \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    --cc=osandov@fb.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).