[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <566E0688-E3D4-416A-B496-6B2F0FA3C85C@dilger.ca>
Date: Wed, 12 Jul 2017 23:08:51 -0700
From: Andreas Dilger <adilger@...ger.ca>
To: "Darrick J. Wong" <darrick.wong@...cle.com>
Cc: linux-fsdevel <linux-fsdevel@...r.kernel.org>,
xfs <linux-xfs@...r.kernel.org>,
linux-ext4 <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH] vfs: in iomap seek_{hole,data}, return -ENXIO for
negative offsets
On Jul 12, 2017, at 10:36 AM, Darrick J. Wong <darrick.wong@...cle.com> wrote:
>
> In the iomap implementations of SEEK_HOLE and SEEK_DATA, make sure we
> return -ENXIO for negative offsets instead of badgering the iomap
> provider with garbage requests.
Hmm, wouldn't it be useful to be able to seek N bytes before the hole or data?
It would make more sense to verify the result after finding the hole or data
and adding the relative offset. It should only be an error if the resulting
offset is before the start or after the actual file end. Of course, if
the passed offset > size from the start then there is no way it can get better
and that would be grounds for returning early.
Cheers, Andreas
> Inspired-by: Mateusz S <muttdini@...il.com>
> Signed-off-by: Darrick J. Wong <darrick.wong@...cle.com>
> ---
> fs/iomap.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/iomap.c b/fs/iomap.c
> index 432eed8..16f5c074 100644
> --- a/fs/iomap.c
> +++ b/fs/iomap.c
> @@ -610,8 +610,8 @@ iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
> loff_t length = size - offset;
> loff_t ret;
>
> - /* Nothing to be found beyond the end of the file. */
> - if (offset >= size)
> + /* Nothing to be found before or beyond the end of the file. */
> + if (offset < 0 || offset >= size)
> return -ENXIO;
>
> while (length > 0) {
> @@ -656,8 +656,8 @@ iomap_seek_data(struct inode *inode, loff_t offset, const struct iomap_ops *ops)
> loff_t length = size - offset;
> loff_t ret;
>
> - /* Nothing to be found beyond the end of the file. */
> - if (offset >= size)
> + /* Nothing to be found before or beyond the end of the file. */
> + if (offset < 0 || offset >= size)
> return -ENXIO;
>
> while (length > 0) {
Cheers, Andreas
Download attachment "signature.asc" of type "application/pgp-signature" (196 bytes)
Powered by blists - more mailing lists