lkml.org 
[lkml]   [2009]   [Jul]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH] block: slightly optimize blkdev_ioctl BLKRA{SET,GET}
Date
Slightly optimize blkdev_ioctl by using shift instead of multiply
and divide.

Signed-off-by: Xiaotian Feng <dfeng@redhat.com>
---
block/ioctl.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/block/ioctl.c b/block/ioctl.c
index 500e4c7..f8c7362 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -305,7 +305,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
bdi = blk_get_backing_dev_info(bdev);
if (bdi == NULL)
return -ENOTTY;
- return put_long(arg, (bdi->ra_pages * PAGE_CACHE_SIZE) / 512);
+ return put_long(arg, bdi->ra_pages << (PAGE_CACHE_SHIFT - 9));
case BLKROGET:
return put_int(arg, bdev_read_only(bdev) != 0);
case BLKBSZGET: /* get the logical block size (cf. BLKSSZGET) */
@@ -321,7 +321,7 @@ int blkdev_ioctl(struct block_device *bdev, fmode_t mode, unsigned cmd,
bdi = blk_get_backing_dev_info(bdev);
if (bdi == NULL)
return -ENOTTY;
- bdi->ra_pages = (arg * 512) / PAGE_CACHE_SIZE;
+ bdi->ra_pages = arg >> (PAGE_CACHE_SHIFT - 9);
return 0;
case BLKBSZSET:
/* set the logical block size */
--
1.6.2.5


\
 
 \ /
  Last update: 2009-07-14 16:15    [W:0.030 / U:6.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site