Re: [PATCH 1/2] partitions: use sector size for EFI GPT

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux