From: Dave Chinner <david@fromorbit.com>
To: Jeff Liu <jeff.liu@oracle.com>
Cc: "xfs@oss.sgi.com" <xfs@oss.sgi.com>
Subject: Re: [PATCH] xfs: lseek SEEK_DATA/SEEK_HOLE consolidation
Date: Mon, 24 Jun 2013 09:13:20 +1000 [thread overview]
Message-ID: <20130623231320.GC29376@dastard> (raw)
In-Reply-To: <51C454DE.2010008@oracle.com>
On Fri, Jun 21, 2013 at 09:27:58PM +0800, Jeff Liu wrote:
> From: Jie Liu <jeff.liu@oracle.com>
>
> Consolidate lseek(2) SEEK_DATA/SEEK_HOLE according to the
> implementation of VFS lseek_execute():
> - if end up with a negative offset, return EINVAL if file
> is not huge.
> - if end up with an offset larger than s_maxbytes, return
> EINVAL as well.
> - reset file version to 0 if end up with an offset that is
> not equal to the current file offset.
>
> Signed-off-by: Jie Liu <jeff.liu@oracle.com>
>
> ---
> fs/xfs/xfs_file.c | 26 ++++++++++++++++++++++++--
> 1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
> index a5f2042..dc42751 100644
> --- a/fs/xfs/xfs_file.c
> +++ b/fs/xfs/xfs_file.c
> @@ -1270,8 +1270,19 @@ xfs_seek_data(
> }
>
> out:
> - if (offset != file->f_pos)
> + if (offset < 0 && !(file->f_mode & FMODE_UNSIGNED_OFFSET)) {
> + error = EINVAL;
> + goto out_unlock;
> + }
> + if (offset > inode->i_sb->s_maxbytes) {
> + error = EINVAL;
> + goto out_unlock;
> + }
> +
> + if (offset != file->f_pos) {
> file->f_pos = offset;
> + file->f_version = 0;
> + }
Hi Jeff, why are you copy-n-pasting this code from lseek_execute()
rather than making lseek_execute() an exported function and calling
that directly?
>
> out_unlock:
> xfs_iunlock_map_shared(ip, lock);
> @@ -1372,6 +1383,15 @@ xfs_seek_hole(
> }
>
> out:
> + if (offset < 0 && !(file->f_mode & FMODE_UNSIGNED_OFFSET)) {
> + error = EINVAL;
> + goto out_unlock;
> + }
> + if (offset > inode->i_sb->s_maxbytes) {
> + error = EINVAL;
> + goto out_unlock;
> + }
These checks belong after we truncated offset to isize, don't they?
And that would make both of these functions simply require a call to
lseek_execute(), yes?
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2013-06-23 23:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-21 13:27 [PATCH] xfs: lseek SEEK_DATA/SEEK_HOLE consolidation Jeff Liu
2013-06-23 23:13 ` Dave Chinner [this message]
2013-06-24 3:28 ` Jeff 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=20130623231320.GC29376@dastard \
--to=david@fromorbit.com \
--cc=jeff.liu@oracle.com \
--cc=xfs@oss.sgi.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.