2006-10-17 01:30:35

by Eric L

[permalink] [raw]
Subject: [PATCH 1/1] lseek - SEEK_HOLE/SEEK_DATA support

Hi All,

This small patch set implements the SEEK_HOLE/SEEK_DATA options to the
lseek system call described in Jeff Bonwick's weblog -
http://blogs.sun.com/bonwick/entry/seek_hole_and_seek_data The first
patch is a small change to the core VFS layer to pass through the
options. The second implements the actual functionality in ext3.

Signed-off-by: Eric Lorimer <[email protected]>


Attachments:
(No filename) (391.00 B)
lseek.patch (4.25 kB)
vfs_lseek.patch (605.00 B)
Download all attachments

2006-10-17 13:36:59

by Dave Kleikamp

[permalink] [raw]
Subject: Re: [PATCH 1/1] lseek - SEEK_HOLE/SEEK_DATA support

On Mon, 2006-10-16 at 20:30 -0500, Eric L wrote:
> Hi All,
>
> This small patch set implements the SEEK_HOLE/SEEK_DATA options to the
> lseek system call described in Jeff Bonwick's weblog -
> http://blogs.sun.com/bonwick/entry/seek_hole_and_seek_data The first
> patch is a small change to the core VFS layer to pass through the
> options. The second implements the actual functionality in ext3.

It's easier to reply to the patch set if the patches are sent inline in
separate emails.

> Signed-off-by: Eric Lorimer <[email protected]>

vfs_lseek.patch:

Can you add definititions of SEEK_HOLE and SEEK_DATA to fs.h? I really
don't like that the code doesn't use the symbolic constants.

+ /* this condition is the same as: NOT (hole XOR physblock) and allows
+ * us to search for holes and data with the same code */
+ while ( (!(hole || physblock) || (hole && physblock))
+ && block < maxblock )

The comment helps, but it's still a bit confusing. How about this?

while ((hole ? physblock : !physblock) && (block < maxblock))

I think this is easier to conceptualize.

+ /* we need to carry... */
+ int lvl = 1;
+ while ( (n-lvl > 0) && offsets[n-lvl] > ptrblock[n-lvl] ) {

How about adding parens to the second half to be more consistent?

+ switch (origin) {
+ case 4: /* SEEK_HOLE */
+ case 3: /* SEEK_DATA */

case SEEK_HOLE:
case SEEK_DATA:

+ index = ext3_seek_holedata(inode, index, (origin-3), maxblock+1);

index = ext3_seek_holedata(inode, index, (origin == SEEK_HOLE), maxblock + 1);

+ if ( (index << blkshift) > inode->i_size )
+ offset = inode->i_size;
+ else if ( index > (offset >> blkshift) )
+ offset = index << blkshift;
+ break;
+ case 2:

case SEEK_END:

+ offset += inode->i_size;
+ break;
+ case 1:

case SEEK_CUR:

+ offset += filp->f_pos;
+ }


--
David Kleikamp
IBM Linux Technology Center