lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <SN6PR04MB45274B06F05A56F1E07BF17586210@SN6PR04MB4527.namprd04.prod.outlook.com>
Date:   Sun, 21 Apr 2019 17:39:35 +0000
From:   Chaitanya Kulkarni <Chaitanya.Kulkarni@....com>
To:     Marcos Paulo de Souza <marcos.souza.org@...il.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
CC:     Ming Lei <ming.lei@...hat.com>, Greg Edwards <gedwards@....com>,
        Hannes Reinecke <hare@...e.com>,
        "linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Jens Axboe <axboe@...nel.dk>,
        Bart Van Assche <bvanassche@....org>,
        Omar Sandoval <osandov@...com>,
        Damien Le Moal <Damien.LeMoal@....com>
Subject: Re: [RFC PATCH 1/2] blkdev.h: Introduce size_to_sectors hlper
 function

Looks good, with one small comment.

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

On 04/20/2019 08:53 PM, Marcos Paulo de Souza wrote:
> This function takes an argument to specify the size of a block device,
> in bytes, and return the number of sectors of 512 bytes.
>
> Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@...il.com>
> ---
>   include/linux/blkdev.h | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
>
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 317ab30d2904..7bf7b99161b7 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -871,6 +871,24 @@ static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
>   #define SECTOR_SIZE (1 << SECTOR_SHIFT)
>   #endif
>
> +/**
> + * size_to_sectors - Convert size in bytes to number of sectors of 512 bytes
> + * @size: size in bytes to be converted to sectors
> + *
> + * Description:
> + * Kernel I/O operation are always made in "sectors". In order to set the
> + * correct number of sectors for a given number of bytes, we need to group the
> + * number of bytes in "sectors of 512 bytes" by shifting the size value by 9,
> + * which is the same than dividing the size by 512. For example, for a capacity
> + * of 32M (33554432 bytes), the number of sectors will be 65536.
I am not sure we need an example because description prior to the 
example and the code is self explanatory.
> + *
> + * Returns the number of sectors by the given number of bytes.
> + */
> +static inline sector_t size_to_sectors(long long size)
> +{
> +	return size >> SECTOR_SHIFT;
> +}
> +
>   /*
>    * blk_rq_pos()			: the current sector
>    * blk_rq_bytes()		: bytes left in the entire request
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ