Re: how to write get_block?

Alexander Viro (viro@math.psu.edu)
Fri, 8 Oct 1999 09:53:14 -0400 (EDT)


On Fri, 8 Oct 1999, Mikulas Patocka wrote:

> > > Hi.
> > >
> > > I'm porting my HPFS driver to 2.3.18 and I don't know how to write
> > > get_block properly. When user does lseek(far beyond file end) and
> > > write(), get_block must allocate a lot of sectors and clear them (HPFS
> > > doesn't support holes). The question is: what call should I use to
> > > clear these sectors?
> >
> > Use the (fixed) variant of FAT code. I.e block_write_cont_page() +
> > equivalent of fat_write_partial_page().
>
> The only thing this function needs from fat filesystem is i_realsize. What
> about to replace i_realsize with i_size (I guess they have identical
> values at the beginning) and move it to /fs/buffer.c to let other
> filesystems use it?

Hmm... I'm not sure that allowing i_size to change in the middle of
writepage() is a good idea. I'll look at it. i_realsize is the size of
initialized part of file... Maybe it can be merged with i_size, but I'll
have to look at mm/filemap.c to be sure.

[snip]

> How do you manage freeing buffers on rmdir? I don't see any bforget there.
> If you don't free buffers pointing to deallocated space, it can cause data
> corruption.

On what? ITYM truncate(), right? Metadata doesn't end up in the page
cache, so... ->flushpage() set to block_flushpage() should be OK, but it
will not be enough. All stuff with truncate()/write() is racey right now,
AFAICS. The next thing I'm going to do is a (dumb) implementation of
blocking rwlocks. write() being reader and truncate() - writer.

Oh, crap! Add

--- fs/fat/file.c Fri Oct 8 09:46:35 1999
+++ fs/fat/file.c.new Fri Oct 8 09:47:16 1999
@@ -60,7 +60,7 @@
fat_get_block, /* get_block */
block_read_full_page, /* readpage */
NULL, /* writepage */
- NULL, /* flushpage */
+ block_flushpage, /* flushpage */
fat_truncate, /* truncate */
NULL, /* permission */
NULL, /* smap */

to the previous patch. Sheesh...

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/