linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Jan Kara <jack@suse.cz>
Cc: Josef Bacik <jbacik@fb.com>, linux-fsdevel@vger.kernel.org
Subject: Re: Usefulness of SEEK_HOLE / SEEK_DATA in generic_file_llseek()
Date: Tue, 31 Dec 2013 01:00:51 -0500	[thread overview]
Message-ID: <20131231060051.GA17519@thunk.org> (raw)
In-Reply-To: <20131230211831.GE5457@quack.suse.cz>

On Mon, Dec 30, 2013 at 10:18:31PM +0100, Jan Kara wrote:
> > IIRC with the generic implementation we treat everything <= i_size
> > as data and i_size as the first hole.  The way the spec works is
> > that if we are currently at data and do seek_data then we just
> > return our current offset, same for a hole.  In order to not be a
> > jackass and have -EOPNOTSUPP for anybody who didn't implement
> > seek_hole/seek_data I just did it this way where the only hole is
> > the one that starts at i_size, so seek_data before that is going to
> > return the value.
>
>   Correct. My point is that I actually don't see anything 'jackass' in
> returning -EOPNOTSUPP. 

In fact, one useful reason in returning -EOPNOTSUPP is so the
userspace program can tell whether or not SEEK_HOLE/SEEK_DATA is
really implemented by the low-level file system.  If the userspace
program knows that it's not available, it might want to fall back to
some alternate mechanism, such as scanning the contents of the file
blocks which are all zeros.  (If the program knows that
SEEK_HOLE/SEEK_DATA is really there, it might to avoid the CPU
overhead of scanning the data buffers as it does the copy.)

					- Ted

      reply	other threads:[~2013-12-31  6:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-23 23:12 Usefulness of SEEK_HOLE / SEEK_DATA in generic_file_llseek() Jan Kara
2013-12-24  0:34 ` Josef Bacik
2013-12-25 14:34   ` Jeff Liu
2013-12-30 21:18   ` Jan Kara
2013-12-31  6:00     ` Theodore Ts'o [this message]

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=20131231060051.GA17519@thunk.org \
    --to=tytso@mit.edu \
    --cc=jack@suse.cz \
    --cc=jbacik@fb.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).