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] [day] [month] [year] [list]
Date:	Mon, 9 Nov 2009 22:33:38 +0100
From:	Karel Zak <kzak@...hat.com>
To:	"Andries E. Brouwer" <Andries.Brouwer@....nl>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Jens Axboe <axboe@...nel.dk>, linux-kernel@...r.kernel.org,
	linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 1/2] partitions: use sector size for EFI GPT

On Mon, Nov 09, 2009 at 08:58:32PM +0100, Andries E. Brouwer wrote:
> static size_t
> read_lba(struct block_device *bdev, u64 lba, u8 * buffer, size_t count)
> {
>         size_t totalreadcount = 0;
> 	sector_t n = lba * (bdev_logical_block_size(bdev) / 512);
> 
>         if (!bdev || !buffer || lba > last_lba(bdev))
>                 return 0;
> 
>         while (count) {
>                 int copied = 512;
>                 Sector sect;
>                 unsigned char *data = read_dev_sector(bdev, n++, &sect);
>                 if (!data)
>                         break;
>                 if (copied > count)
>                         copied = count;
>                 memcpy(buffer, data, copied);
>                 put_dev_sector(sect);
>                 buffer += copied;
>                 totalreadcount +=copied;
>                 count -= copied;
>         }
>         return totalreadcount;
> }
> 
> Ugly - it looks as if you call read_dev_sector 8 times and each time

 Yes, the function is really not elegant, but it follows the way how
 all fs/partitions code reads sectors from disks.

> do a put_dev_sector afterwards to forget it again. Doesnt that mean
> that in order to read a 4096-byte sector the kernel goes to the hardware
> 8 times?

 read_dev_sector() works with 512-byte sectors and it's interface to
 read_mapping_page() which works with pages from cache.

    Karel

-- 
 Karel Zak  <kzak@...hat.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ