From nobody Sat Aug 21 15:39:27 2021 X-Original-To: freebsd-fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 79B921784099 for ; Sat, 21 Aug 2021 15:39:36 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4GsN3W1KjDz4nXf; Sat, 21 Aug 2021 15:39:35 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 17LFdRqs027344 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Sat, 21 Aug 2021 18:39:30 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 17LFdRqs027344 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 17LFdRVc027343; Sat, 21 Aug 2021 18:39:27 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 21 Aug 2021 18:39:27 +0300 From: Konstantin Belousov To: Ka Ho Ng Cc: freebsd-fs@freebsd.org Subject: Re: fspacectl(2): result of rmsr.r_offset for a success and non-partial operation Message-ID: References: <87d4a87d-2ee3-74dd-3689-94dc0daf3983@FreeBSD.org> <29087ddc-9b46-15fa-4041-c3a50dcf99db@FreeBSD.org> List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <29087ddc-9b46-15fa-4041-c3a50dcf99db@FreeBSD.org> X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4GsN3W1KjDz4nXf X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=fail reason="No valid SPF, No valid DKIM" header.from=gmail.com (policy=none); spf=softfail (mx1.freebsd.org: 2001:470:d5e7:1::1 is neither permitted nor denied by domain of kostikbel@gmail.com) smtp.mailfrom=kostikbel@gmail.com X-Spamd-Result: default: False [-0.64 / 15.00]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; HAS_XAW(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_SPF_SOFTFAIL(0.00)[~all:c]; NEURAL_SPAM_MEDIUM(0.51)[0.513]; NEURAL_HAM_SHORT(-0.16)[-0.157]; RCPT_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:6939, ipnet:2001:470::/32, country:US]; FREEMAIL_ENVFROM(0.00)[gmail.com]; DMARC_POLICY_SOFTFAIL(0.10)[gmail.com : No valid SPF, No valid DKIM,none] X-ThisMailContainsUnwantedMimeParts: N 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().