2006-01-25 02:58:30

by Joshua Hudson

[permalink] [raw]
Subject: Block device API

I am working on a kernel filesystem driver. I have found plenty of
documentation on
how to communicate between the VFS and the filesystem driver, but nothing
on how to communicate between the block device and the filesystem driver.

I found sb_bread() but there is no corrisponding sb_bwrite().
I presume that if ((struct superblock *)s) -> bdev is the block
device handle, but I cannot find the read/write pair of functions.


2006-01-25 03:17:05

by Fawad Lateef

[permalink] [raw]
Subject: Re: Block device API

On 1/25/06, Joshua Hudson <[email protected]> wrote:
> I am working on a kernel filesystem driver. I have found plenty of
> documentation on
> how to communicate between the VFS and the filesystem driver, but nothing
> on how to communicate between the block device and the filesystem driver.
>

AFAIK there isn't any documentation/article for block and filesystem
layer interaction (or till now me also not able to find any) :)

> I found sb_bread() but there is no corrisponding sb_bwrite().
> I presume that if ((struct superblock *)s) -> bdev is the block
> device handle, but I cannot find the read/write pair of functions.
> -

sb_bread is the function used for reading a block (especially
superblock) from the storage. For reading/writing do look at
generic_file_read/write functions found in mm/filemap.c and when going
through the code you will see its ends up in calling
mappings->a_ops->readpage(s)/writepage(s) of filesystem in which
normal filesystems (like ext2) just call function
mpage_readpages/writepages found in fs/mpage.c which performs actual
read/write on the block device.

I hope this helps !

--
Fawad Lateef

2006-01-25 08:37:27

by Qi Yong

[permalink] [raw]
Subject: Re: Block device API

On Wed, Jan 25, 2006 at 08:17:02AM +0500, Fawad Lateef wrote:
> On 1/25/06, Joshua Hudson <[email protected]> wrote:
> > I am working on a kernel filesystem driver. I have found plenty of
> > documentation on
> > how to communicate between the VFS and the filesystem driver, but nothing
> > on how to communicate between the block device and the filesystem driver.
> >
>
> AFAIK there isn't any documentation/article for block and filesystem
> layer interaction (or till now me also not able to find any) :)
>
> > I found sb_bread() but there is no corrisponding sb_bwrite().
> > I presume that if ((struct superblock *)s) -> bdev is the block
> > device handle, but I cannot find the read/write pair of functions.
> > -
>
> sb_bread is the function used for reading a block (especially
> superblock) from the storage. For reading/writing do look at

Does __bread() contribute to page cache? I think not. And we don't
care the work done by __bread().

> generic_file_read/write functions found in mm/filemap.c and when going
> through the code you will see its ends up in calling
> mappings->a_ops->readpage(s)/writepage(s) of filesystem in which
> normal filesystems (like ext2) just call function
> mpage_readpages/writepages found in fs/mpage.c which performs actual
> read/write on the block device.
--
Coywolf Qi Hunt

2006-01-25 09:27:25

by Fawad Lateef

[permalink] [raw]
Subject: Re: Block device API

On 1/25/06, Coywolf Qi Hunt <[email protected]> wrote:
> On Wed, Jan 25, 2006 at 08:17:02AM +0500, Fawad Lateef wrote:
> >
> > AFAIK there isn't any documentation/article for block and filesystem
> > layer interaction (or till now me also not able to find any) :)
> >
> >
> > sb_bread is the function used for reading a block (especially
> > superblock) from the storage. For reading/writing do look at
>
> Does __bread() contribute to page cache? I think not. And we don't
> care the work done by __bread().
>

Ya, __bread() directly sends read request to the block device without
involvement of buffer cache ! Is there any point In my explaination in
which I mentioned __bread related to buffer_cache ? if yes then its a
mistake .... and __bread is direct function which calls submit_bh and
waits for its completion.

--
Fawad Lateef