All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zheng Liu <gnehzuil.liu@gmail.com>
To: Theodore Ts'o <tytso@mit.edu>
Cc: linux-ext4@vger.kernel.org, Zheng Liu <wenqing.lz@taobao.com>
Subject: Re: [PATCH 1/2 v2] libext2fs: introduce lseek SEEK_DATA/HOLE
Date: Wed, 16 Jan 2013 20:04:56 +0800	[thread overview]
Message-ID: <20130116120455.GA21029@gmail.com> (raw)
In-Reply-To: <20130115185509.GA17719@thunk.org>

On Tue, Jan 15, 2013 at 01:55:09PM -0500, Theodore Ts'o wrote:
> On Mon, Jan 14, 2013 at 10:18:30PM +0800, Zheng Liu wrote:
> > +static errcode_t ext2fs_file_llseek_data(ext2_file_t file, __u64 offset)
> > +{
> > +	int		ret_flags, flag = 1;
> > +	ext2_filsys	fs = file->fs;
> > +	errcode_t	retval;
> > +
> > +	/*
> > +	 * If offset == EXT2_SEEK_OFFSET_INVALID, that means that
> > +	 * the caller wants to find the data from file->pos.
> > +	 */
> > +	offset = offset != EXT2_SEEK_OFFSET_INVALID ? offset : file->pos;
> > +	file->blockno = offset / fs->blocksize;
> > +	while (file->blockno * fs->blocksize < EXT2_I_SIZE(&file->inode)) {
> > +		retval = ext2fs_bmap2(fs, file->ino, &file->inode,
> > +				      BMAP_BUFFER, 0, file->blockno,
> > +				      &ret_flags, &file->physblock);
> 
> Using bmap will certainly work, although as an optimization we can do
> much better for extents if we use the extents interface.  I won't
> insist on this, though.  (We can always optimize this later).

Yeah, it allows us to skip to the next data/hole directly if the extents
interface is used.  But if we do that, we will need to handle
extent-based file and indirect-based file resptively like this.

        if (inode->i_flags & EXT4_EXTENTS_FL) {
                ext2fs_file_ext_llseek_data();
                ...
        } else {
                ext2fs_file_ind_llseek_data();
                ...
        }

I am not sure whether it is too complicated or not for us.  What do you
think?

Thanks,
                                                - Zheng

  reply	other threads:[~2013-01-16 11:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-14 14:18 [PATCH 1/2 v2] libext2fs: introduce lseek SEEK_DATA/HOLE Zheng Liu
2013-01-14 14:18 ` [PATCH 2/2 v2] debugfs: dump a sparse file Zheng Liu
2013-01-15  3:23 ` [PATCH 1/2 v2] libext2fs: introduce lseek SEEK_DATA/HOLE Theodore Ts'o
2013-01-15 13:02   ` Zheng Liu
2013-01-15 18:55 ` Theodore Ts'o
2013-01-16 12:04   ` Zheng Liu [this message]
2013-01-16 14:59     ` Theodore Ts'o
2013-01-18 10:07       ` Zheng Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130116120455.GA21029@gmail.com \
    --to=gnehzuil.liu@gmail.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    --cc=wenqing.lz@taobao.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.