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

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

 



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 <e.codemonkey@xxxxxxxxx>

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

-
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux