Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Aug 2021 18:39:27 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Ka Ho Ng <khng@freebsd.org>
Cc:        freebsd-fs@freebsd.org
Subject:   Re: fspacectl(2): result of rmsr.r_offset for a success and non-partial operation
Message-ID:  <YSEeL6ivTeQBdEB%2B@kib.kiev.ua>
In-Reply-To: <29087ddc-9b46-15fa-4041-c3a50dcf99db@FreeBSD.org>
References:  <87d4a87d-2ee3-74dd-3689-94dc0daf3983@FreeBSD.org> <29087ddc-9b46-15fa-4041-c3a50dcf99db@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

On Fri, Aug 20, 2021 at 11:33:24PM +0800, Ka Ho Ng wrote:
> On 2021/8/20 11:23 PM, Ka Ho Ng wrote:
> > There were some recent discussion in https://reviews.freebsd.org/D31604
> > around the returned value of rmsr.r_offset. For a complete and
> > successful operation, rmsr.r_len is set to 0. Regarding rmsr.r_offset,
> > the bottom line is to have rmsr.r_offset being no greater than current
> > file size in case rmsr.r_offset is greater than file size, while leaving
> > rmsr.r_offset to be within EOF in case rqsr.r_offset is not beyond EOF.
> > 
> > With the current approach, rmsr.r_offset is loosely defined as file
> > system is free to set it to some value as long as it is neither smaller
> > than rqsr.r_offset (in case rqsr.r_offset is within EOF), or beyond EOF
> > (in case rqsr.r_offset is beyond EOF). Do you think it is a good idea to
> > make it stricter in case the call succeeds and rmsr.r_len == 0 (i.e. a
> > complete operation)? If that is the case, what if we set rmsr.r_offset
> > to be rqsr.r_offset + rqsr.r_len?
> > 
> > Ka Ho
> > 
> 
> My another approach is to explicitly document that for a complete and
> successful operation (i.e. rmsr.r_len == 0) callers need not to consider
> the exact value of rmsr.r_offset, except if the operation range is not
> complete outside of EOF, rmsr.r_offset is not going to be outside of EOF
> either.

I believe that for normal operation, rmsr.r_offset should be set to
to rqsr.r_offset + rqsr.r_len, and for EOF case rqsr.r_offset + rqsr.r_len
should be clipped at EOF.  In both cases, rmsr.r_len should be set to zero.

If rqsr.r_offset is beyond EOF, the statement above naturally implies
that rmsr.r_offset is set to EOF, and rmsr.r_len is set to zero.  This
should interact well with a possibility that file is grown after the
fspacectl(2) syscall is issued, and normal coding of the application
using fspacectl().


help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YSEeL6ivTeQBdEB%2B>