Re: Block Device arrays Relation?

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

 



On 11/4/05, Xiangfei Jia <xjianz@xxxxxxxxx> wrote:
> 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.
>

I think blkdevs is used to keep the things simple, as one might just
register a block device and might be doing some work internally, but
no one is going to open the device or claiming the device (calling
bdget) then bdev_hashtable won't contain any entry related to that
device hence different memory allocations (for filling the struct
block_device and addition of it in bdev_hashtable) won't be done. (Its
my thinking and understanding from the code block_dev.c, not 100% sure
about this)

>  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?
>

Ya, I want to say that struct block_device is maintaining the device
related information about its count, inode etc but blkdevs have only
name and struct block_device_operations !!

> > 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.
>

And I think that keeping the same thing in two different arrays might
be one of the many reasons to remove those from 2.6.xx kenel


--
Fawad Lateef

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



[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