From 2a587917585f47c6fbad30b109fa6b80b745df4b Mon Sep 17 00:00:00 2001 From: asomers Date: Thu, 20 Jun 2019 13:59:46 +0000 Subject: [PATCH] Add a VOP_BMAP(9) man page Reviewed by: mckusick MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D20704 --- share/man/man9/Makefile | 1 + share/man/man9/VOP_BMAP.9 | 86 +++++++++++++++++++++++++++++++++++++++ sys/kern/vfs_default.c | 8 +++- 3 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 share/man/man9/VOP_BMAP.9 diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile index 8931249df62..682eb2a3950 100644 --- a/share/man/man9/Makefile +++ b/share/man/man9/Makefile @@ -399,6 +399,7 @@ MAN= accept_filter.9 \ VOP_ADVLOCK.9 \ VOP_ALLOCATE.9 \ VOP_ATTRIB.9 \ + VOP_BMAP.9 \ VOP_BWRITE.9 \ VOP_CREATE.9 \ VOP_FSYNC.9 \ diff --git a/share/man/man9/VOP_BMAP.9 b/share/man/man9/VOP_BMAP.9 new file mode 100644 index 00000000000..568f2ab6485 --- /dev/null +++ b/share/man/man9/VOP_BMAP.9 @@ -0,0 +1,86 @@ +.\"- +.\" SPDX-License-Identifier: BSD-2-Clause-FreeBSD +.\" +.\" Copyright (c) 2019 The FreeBSD Foundation +.\" +.\" This software was developed by BFF Storage Systems, LLC under sponsorship +.\" from the FreeBSD Foundation. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\".\"2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd June 19, 2019 +.Dt VOP_BMAP 9 +.Os +.Sh NAME +.Nm VOP_BMAP +.Nd Logical to physical block number conversion +.Sh SYNOPSIS +.In sys/param.h +.In sys/vnode.h +.Ft int +.Fn VOP_BMAP "struct vnode *vp" "daddr_t bn" "struct bufobj **bop" "daddr_t *bnp" "int *runp" "int *runb" +.Sh DESCRIPTION +This vnode call is used to lookup the physical block number of the file system's +underlying device where a given logical block of a file is stored. +Its arguments are: +.Bl -tag -width type +.It Fa vp +The vnode of the file. +.It Fa bn +Logical block number within the file identified by +.Fa vp . +.It Fa bop +Return storage for the buffer object associated with the file system's +underlying device. +.It Fa bnp +Return storage for the physical block number. +.It Fa runp +Return storage for the number of succeeding logical blocks that may be +efficiently read at the same time as the requested block. +This will usually be the number of logical blocks whose physical blocks are +contiguously allocated. +However a file system is free to define "efficient" as it see fit. +.It Fa runb +Like +.Fa runp +but for preceding rather than succeeding blocks. +.El +.Pp +Any of the return arguments may be +.Dv NULL +to indicate that the caller does not care about that information. +.Sh LOCKS +The vnode will be locked on entry and should remain locked on return. +.Sh RETURN VALUES +Zero is returned on success, otherwise an error code is returned. +.Sh SEE ALSO +.Xr vnode 9 , +.Sh HISTORY +A +.Fn bmap +function first appeared in +.Bx 4.2 . +.Sh AUTHORS +This manual page was written by +.An Alan Somers . diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index 22ee43547a9..3c30d2e6c9f 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -603,7 +603,13 @@ vop_stdgetwritemount(ap) return (0); } -/* XXX Needs good comment and VOP_BMAP(9) manpage */ +/* + * If the file system doesn't implement VOP_BMAP, then return sensible defaults: + * - Return the vnode's bufobj instead of any underlying device's bufobj + * - Calculate the physical block number as if there were equal size + * consecutive blocks, but + * - Report no contiguous runs of blocks. + */ int vop_stdbmap(ap) struct vop_bmap_args /* { -- 2.45.0