Date: Wed, 25 Aug 2021 16:04:26 GMT From: Ka Ho Ng <khng@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 9e202d036dd6 - main - fspacectl(2): Changes on rmsr.r_offset's minimum value returned Message-ID: <202108251604.17PG4QpD064334@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by khng: URL: https://cgit.FreeBSD.org/src/commit/?id=9e202d036dd6f38ce0f578aa2086ebc358315bab commit 9e202d036dd6f38ce0f578aa2086ebc358315bab Author: Ka Ho Ng <khng@FreeBSD.org> AuthorDate: 2021-08-25 16:02:27 +0000 Commit: Ka Ho Ng <khng@FreeBSD.org> CommitDate: 2021-08-25 16:03:37 +0000 fspacectl(2): Changes on rmsr.r_offset's minimum value returned rmsr.r_offset now is set to rqsr.r_offset plus the number of bytes zeroed before hitting the end-of-file. After this change rmsr.r_offset no longer contains the EOF when the requested operation range is completely beyond the end-of-file. Instead in such case rmsr.r_offset is equal to rqsr.r_offset. Callers can obtain the number of bytes zeroed by subtracting rqsr.r_offset from rmsr.r_offset. Sponsored by: The FreeBSD Foundation Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D31677 --- lib/libc/sys/fspacectl.2 | 9 ++++----- share/man/man9/VOP_DEALLOCATE.9 | 9 +++------ share/man/man9/vn_deallocate.9 | 7 ++----- sys/kern/uipc_shm.c | 1 - sys/kern/vfs_default.c | 5 ++--- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/lib/libc/sys/fspacectl.2 b/lib/libc/sys/fspacectl.2 index 0e369785b883..430f3de950df 100644 --- a/lib/libc/sys/fspacectl.2 +++ b/lib/libc/sys/fspacectl.2 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 18, 2021 +.Dd August 25, 2021 .Dt FSPACECTL 2 .Os .Sh NAME @@ -73,10 +73,9 @@ operation range, .Fa "rmsr->r_len" is updated to be the value 0, and .Fa "rmsr->r_offset" -is updated to be the smallest of -.Fa "rqsr->r_offset" + -.Fa "rqsr->r_len" ; -and the end-of-file offset. +is updated to be +.Fa "rqsr->r_offset" +plus the number of bytes zeroed before the end-of-file. The file descriptor's file offset is not used or modified by the system call. Both .Fa rqsr diff --git a/share/man/man9/VOP_DEALLOCATE.9 b/share/man/man9/VOP_DEALLOCATE.9 index 2ec915c6fef3..d20fe1590314 100644 --- a/share/man/man9/VOP_DEALLOCATE.9 +++ b/share/man/man9/VOP_DEALLOCATE.9 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 11, 2021 +.Dd August 25, 2021 .Dt VOP_DEALLOCATE 9 .Os .Sh NAME @@ -74,14 +74,11 @@ and are updated to reflect the portion of the range that still needs to be zeroed/deallocated on return. Partial result is considered a successful operation. -For a successful completion without an unprocessed portion of the range, +For a non-partial successful completion, .Fa *len is updated to be the value 0, and .Fa *offset -is updated to be the smallest of -.Fa *offset + -.Fa *len -passed to the call and the end-of-file offset. +is incremented by the number of bytes zeroed before the end-of-file. .Sh LOCKS The vnode should be locked on entry and will still be locked on exit. .Sh RETURN VALUES diff --git a/share/man/man9/vn_deallocate.9 b/share/man/man9/vn_deallocate.9 index 08f4e92ec597..ce1515ddaaa1 100644 --- a/share/man/man9/vn_deallocate.9 +++ b/share/man/man9/vn_deallocate.9 @@ -27,7 +27,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd August 11, 2021 +.Dd August 25, 2021 .Dt VN_DEALLOCATE 9 .Os .Sh NAME @@ -99,10 +99,7 @@ For a successful completion, .Fa *length is updated to be the value 0, and .Fa *offset -is updated to be the smallest of -.Fa *offset + -.Fa *length -passed to the call and the end-of-file offset. +is incremented by the number of bytes zeroed before the end-of-file. .Sh RETURN VALUES Upon successful completion, the value 0 is returned; otherwise the appropriate error is returned. diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index c632c7f150df..c672c0477b95 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -1917,7 +1917,6 @@ shm_deallocate(struct shmfd *shmfd, off_t *offset, off_t *length, int flags) /* Handle the case when offset is on or beyond shm size. */ if ((off_t)len <= 0) { - *offset = shmfd->shm_size; *length = 0; return (0); } diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index d5df9cd8bf7b..9fd43004b8fd 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -1156,6 +1156,7 @@ vop_stddeallocate(struct vop_deallocate_args *ap) /* * No more data region to be filled */ + offset += len; len = 0; error = 0; break; @@ -1185,10 +1186,8 @@ vop_stddeallocate(struct vop_deallocate_args *ap) break; } /* Handle the case when offset is beyond EOF */ - if (len < 0) { - offset += len; + if (len < 0) len = 0; - } out: *ap->a_offset = offset; *ap->a_len = len;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202108251604.17PG4QpD064334>