From nobody Fri Apr 05 15:16:21 2024 X-Original-To: dev-commits-src-main@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 4VB2BY396Hz5Gf00; Fri, 5 Apr 2024 15:16:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VB2BY1RNTz4Kg4; Fri, 5 Apr 2024 15:16:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712330181; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gCJ/utW2tc4iXH+oVojh2qRmANlZ3NR7u8oKMHnZcJA=; b=QXnlKHP20p9UVXkHgJlE287o39NjOuH3tMvBthpg+6f6LLGVnJ36zCTCxtpzjZTwalgR8B D7Buex/4JqkwXC66MaEIN5Jagxzi7QG0L9z6BFqhfTiz0+Ptr4v588Yva4kB6RsYX0ReKR DuzSVfzBwNboXRnXUq1fUIgaBvQ6eiohIpP9KXyRqSOic4QAorczB4hnXggpsSPsNpkKZo NpzhB7QY5M1yyZ93rr30L3DS5zsmPiBq0i7IzJtMcvAl7+D3qzTBbGd2fadGzKFJjaXV36 NRCtamn0puD2XkOpoXddRltTwz+EEEA7zrs1Rj1zT6YMn0Z9Mrc2OohrLqo+nA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712330181; a=rsa-sha256; cv=none; b=koT9iPjEuAjrkMUaW8422qOwGaimOyzLWgC++n6Dnfpv2Ld3PGth6FlY03bUP9lUndgUej shRRkYsS3vsBe1FRxpUhmhg8g1WJyhqjOslFDHUE670FBHmj1n6WS4UghhlGRit/p4/Rkx B4o4KUC+To8InKXuCPjJPeRhsX3cb+iXE0GPn46OVAcKuq7dRKJ+Q6OqV2dOHbFLumkB2x dqYYaT8NHaLRRmR68LtPGLAzoY19YZ8hAhZ+7h+EINQiA2JzjktVhgLH0c4QkTkybTrlBS ZHrz685pPNJUqPE38Bkvk+G4XO5vlIFwbtEB7uMqF7mm9pZiex7hUQNAt4iI3g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712330181; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=gCJ/utW2tc4iXH+oVojh2qRmANlZ3NR7u8oKMHnZcJA=; b=woKe7ErpqAB2fWVf3/rQHcQW0wphF47D71E+fvGaHPNPjFWKQX5Tvguy9Pi1pMrgSVtf87 UtZJxyrxNzbjp4B+ijsj9NedRbPHfhVohoHp079smN2y1JtQxQ26U6eeXb4HBGTEUMpXKo lcG7roskEKFx3JOZd6pDfzmy96xXOcnpP1kbBd4PPC2oEgwVjFhtscZOhg3uE5xHaYJ7Dh rmYYVdqootnz7NlvNUnK/U4La8Ni2P6/A6JnsGH7gMaUD2W1KEeJXoJbS7B1ZlXGI6i+58 HEUytGnVv2DBi87OrqcCbXPgObzAqNW6v2wvSoKgnH1Zovmn2rYOgP1doI71ZQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VB2BY13rWz14rH; Fri, 5 Apr 2024 15:16:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 435FGLXS077777; Fri, 5 Apr 2024 15:16:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 435FGLSe077775; Fri, 5 Apr 2024 15:16:21 GMT (envelope-from git) Date: Fri, 5 Apr 2024 15:16:21 GMT Message-Id: <202404051516.435FGLSe077775@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: a0895e394d3f - main - tarfs: Implement VOP_BMAP List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a0895e394d3fec374e61a207bdfa0245dae86f53 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=a0895e394d3fec374e61a207bdfa0245dae86f53 commit a0895e394d3fec374e61a207bdfa0245dae86f53 Author: Mark Johnston AuthorDate: 2024-04-05 15:14:36 +0000 Commit: Mark Johnston CommitDate: 2024-04-05 15:14:36 +0000 tarfs: Implement VOP_BMAP This lets tarfs provide readahead/behind hints to the VFS, which helps memory-mapped I/O performance, important when running faulting in executables out of a tarfs mount as one might if tarfs is used to back the root filesystem, for example. The improvement is particularly noticeable when the backing tarball is zstd-compressed. The implementation simply returns the extent of the virtual block containing the target offset, clamped by the maximum I/O size. This is perhaps simplistic; it effectively just chooses values that would correspond to a single VOP_READ call in tarfs_read_file(). Reviewed by: des, kib MFC after: 1 month Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D44626 --- sys/fs/tarfs/tarfs_vnops.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/sys/fs/tarfs/tarfs_vnops.c b/sys/fs/tarfs/tarfs_vnops.c index 7a04f891350e..f2828c60f8a7 100644 --- a/sys/fs/tarfs/tarfs_vnops.c +++ b/sys/fs/tarfs/tarfs_vnops.c @@ -125,6 +125,60 @@ tarfs_access(struct vop_access_args *ap) return (error); } +static int +tarfs_bmap(struct vop_bmap_args *ap) +{ + struct tarfs_node *tnp; + struct vnode *vp; + off_t off; + uint64_t iosize; + int ra, rb, rmax; + + vp = ap->a_vp; + iosize = vp->v_mount->mnt_stat.f_iosize; + + if (ap->a_bop != NULL) + *ap->a_bop = &vp->v_bufobj; + if (ap->a_bnp != NULL) + *ap->a_bnp = ap->a_bn * btodb(iosize); + if (ap->a_runp == NULL) + return (0); + + tnp = VP_TO_TARFS_NODE(vp); + off = ap->a_bn * iosize; + + ra = rb = 0; + for (u_int i = 0; i < tnp->nblk; i++) { + off_t bs, be; + + bs = tnp->blk[i].o; + be = tnp->blk[i].o + tnp->blk[i].l; + if (off > be) + continue; + else if (off < bs) { + /* We're in a hole. */ + ra = bs - off < iosize ? + 0 : howmany(bs - (off + iosize), iosize); + rb = howmany(off - (i == 0 ? + 0 : tnp->blk[i - 1].o + tnp->blk[i - 1].l), + iosize); + break; + } else { + /* We'll be reading from the backing file. */ + ra = be - off < iosize ? + 0 : howmany(be - (off + iosize), iosize); + rb = howmany(off - bs, iosize); + break; + } + } + + rmax = vp->v_mount->mnt_iosize_max / iosize - 1; + *ap->a_runp = imin(ra, rmax); + if (ap->a_runb != NULL) + *ap->a_runb = imin(rb, rmax); + return (0); +} + static int tarfs_getattr(struct vop_getattr_args *ap) { @@ -629,6 +683,7 @@ struct vop_vector tarfs_vnodeops = { .vop_default = &default_vnodeops, .vop_access = tarfs_access, + .vop_bmap = tarfs_bmap, .vop_cachedlookup = tarfs_lookup, .vop_close = tarfs_close, .vop_getattr = tarfs_getattr,