Re: Block Device arrays Relation?

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

 





On 11/4/05, Fawad Lateef <fawadlateef@xxxxxxxxx> wrote:
On 11/4/05, Xiangfei Jia <xjianz@xxxxxxxxx> wrote:
>
>  For block devices, the "blkdevs" array is used to hold all the registered
> block device drivers, and the maximum number of allowed block drivers is
> 255. There is another hash table array called "bdev_hashtable", which is
> array of struct "block_device".
>
>  I'm quite confused with these two arrays. (1) what is the relationship
> between the "blkdevs" and the "bdev_hashtable"??

blkdevs is an array used internally by block_dev.c (block-device
layer) to keep track of registered block devices whereas
bdev_hashtable array of type list-head is used to keep information
related to block_device in a hash formed which actually hold the
struct block_device type pointers/nodes (field bd_hash)
Why is "blkdevs" only used in block-device layer? Why not just use "bdev_hashtable" everywhere? I just can't understand why use two different arrays to represent the same thing twice.

And it seems that "bdev_hashtable" is also a local variable in "block_dev.c" file. Here is the code:
static struct list_head bdev_hashtable[
HASH_SIZE];


 

>  (2) Why a extra sruct, called "block_device" is necessary to be used?
>

struct block_device is actually there for keeping information about
the block_devices like bd_count (how-many times block_device is
claimed through bdget function), bd_inode is the inode having
data/fields filled with the block_device information see bdget
function (http://lxr.linux.no/source/fs/block_dev.c?v=2.4.28#L331),
bd_openers is used to keep track of how many times block_device is
opened and so other fields too used to keep information related to
block_device usage. Just look for struct block_device fields used in
block_dev.c file ...

I hope my explaination might clear some doubts for you !
Are you saying that "struct block_device" acutally keeps the really info about each block device driver, Not the "blkdevs" array?
 

By the way these blkdevs and bdev_hashtable (due to their limitations)
are removed in 2.6.xx series kernels

Sorry, I forgot to mention that I'm using kernel 2.4.28.

Thanks for your help!

Fei






[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux