linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] Introduce size_to_sectors helper in blkdev.h
@ 2019-04-21  3:53 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  3:53 ` [RFC PATCH 2/2] null_blk: Make use of size_to_sectors helper Marcos Paulo de Souza
  0 siblings, 2 replies; 5+ messages in thread
From: Marcos Paulo de Souza @ 2019-04-21  3:53 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ming Lei, Greg Edwards, Hannes Reinecke, linux-block,
	Martin K. Petersen, Jens Axboe, Bart Van Assche,
	Marcos Paulo de Souza, Omar Sandoval, Damien Le Moal

While reading code of drivers/block, I was curious about the set_capacity
argument, always shifting the value by 9, and so I took me a while to realize
this is done on purpose: the capacity is the number of sectors of 512 bytes
related to the storage space.

Rather the shifting by 9, there are other places where the value if shifted by
SECTOR_SHIFT, which is more readable.
This patch aims to reduce these differences by adding a new function called
size_to_sectors, adding a proper comment explaining why this is needed.

null_blk was changed to use this new function.

This is an RFC, please let me know if you have other suggestions.

Thanks,
Marcos

Marcos Paulo de Souza (2):
  blkdev.h: Introduce size_to_sectors hlper function
  null_blk: Make use of size_to_sectors helper

 drivers/block/null_blk_main.c | 18 +++++++++---------
 include/linux/blkdev.h        | 18 ++++++++++++++++++
 2 files changed, 27 insertions(+), 9 deletions(-)

-- 
2.16.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-21 17:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).