From owner-svn-src-projects@freebsd.org Tue Apr 23 22:34:33 2019 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id B01FC15848C7 for ; Tue, 23 Apr 2019 22:34:33 +0000 (UTC) (envelope-from asomers@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 560AC8E2EC; Tue, 23 Apr 2019 22:34:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 2D7723123; Tue, 23 Apr 2019 22:34:33 +0000 (UTC) (envelope-from asomers@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3NMYXJS071185; Tue, 23 Apr 2019 22:34:33 GMT (envelope-from asomers@FreeBSD.org) Received: (from asomers@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3NMYXds071184; Tue, 23 Apr 2019 22:34:33 GMT (envelope-from asomers@FreeBSD.org) Message-Id: <201904232234.x3NMYXds071184@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: asomers set sender to asomers@FreeBSD.org using -f From: Alan Somers Date: Tue, 23 Apr 2019 22:34:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r346609 - projects/fuse2/sys/fs/fuse X-SVN-Group: projects X-SVN-Commit-Author: asomers X-SVN-Commit-Paths: projects/fuse2/sys/fs/fuse X-SVN-Commit-Revision: 346609 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 560AC8E2EC X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.97 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.97)[-0.969,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US] X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 23 Apr 2019 22:34:33 -0000 Author: asomers Date: Tue Apr 23 22:34:32 2019 New Revision: 346609 URL: https://svnweb.freebsd.org/changeset/base/346609 Log: fusefs: diff reduction between fuse_read_biobackend and ext_read The main difference is to replace some custom logic with bread. No functional change at this point, but this is one step towards adding readahead. Sponsored by: The FreeBSD Foundation Modified: projects/fuse2/sys/fs/fuse/fuse_io.c Modified: projects/fuse2/sys/fs/fuse/fuse_io.c ============================================================================== --- projects/fuse2/sys/fs/fuse/fuse_io.c Tue Apr 23 22:26:55 2019 (r346608) +++ projects/fuse2/sys/fs/fuse/fuse_io.c Tue Apr 23 22:34:32 2019 (r346609) @@ -110,7 +110,7 @@ static int fuse_read_directbackend(struct vnode *vp, struct uio *uio, struct ucred *cred, struct fuse_filehandle *fufh); static int -fuse_read_biobackend(struct vnode *vp, struct uio *uio, +fuse_read_biobackend(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred, struct fuse_filehandle *fufh, pid_t pid); static int fuse_write_directbackend(struct vnode *vp, struct uio *uio, @@ -160,7 +160,8 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, in } else { SDT_PROBE2(fusefs, , io, trace, 1, "buffered read of vnode"); - err = fuse_read_biobackend(vp, uio, cred, fufh, pid); + err = fuse_read_biobackend(vp, uio, ioflag, cred, fufh, + pid); } break; case UIO_WRITE: @@ -198,72 +199,52 @@ SDT_PROBE_DEFINE3(fusefs, , io, read_bio_backend_start SDT_PROBE_DEFINE2(fusefs, , io, read_bio_backend_feed, "int", "int"); SDT_PROBE_DEFINE3(fusefs, , io, read_bio_backend_end, "int", "ssize_t", "int"); static int -fuse_read_biobackend(struct vnode *vp, struct uio *uio, +fuse_read_biobackend(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred, struct fuse_filehandle *fufh, pid_t pid) { struct buf *bp; daddr_t lbn; int bcount; - int err = 0, n = 0, on = 0; + int err, n = 0, on = 0; off_t filesize; const int biosize = fuse_iosize(vp); - if (uio->uio_resid == 0) - return (0); if (uio->uio_offset < 0) return (EINVAL); - bcount = biosize; filesize = VTOFUD(vp)->filesize; - do { + for (err = 0, bp = NULL; uio->uio_resid > 0; bp = NULL) { if (fuse_isdeadfs(vp)) { err = ENXIO; break; } + if (filesize - uio->uio_offset <= 0) + break; lbn = uio->uio_offset / biosize; on = uio->uio_offset & (biosize - 1); SDT_PROBE3(fusefs, , io, read_bio_backend_start, biosize, (int)lbn, on); - /* - * Obtain the buffer cache block. Figure out the buffer size - * when we are at EOF. If we are modifying the size of the - * buffer based on an EOF condition we need to hold - * nfs_rslock() through obtaining the buffer to prevent - * a potential writer-appender from messing with n_size. - * Otherwise we may accidentally truncate the buffer and - * lose dirty data. - * - * Note that bcount is *not* DEV_BSIZE aligned. - */ if ((off_t)lbn * biosize >= filesize) { bcount = 0; } else if ((off_t)(lbn + 1) * biosize > filesize) { bcount = filesize - (off_t)lbn *biosize; + } else { + bcount = biosize; } - bp = getblk(vp, lbn, bcount, PCATCH, 0, 0); - if (!bp) - return (EINTR); + /* TODO: readahead. See ext2_read for an example */ + err = bread(vp, lbn, bcount, NOCRED, &bp); + if (err) { + brelse(bp); + bp = NULL; + break; + } /* - * If B_CACHE is not set, we must issue the read. If this - * fails, we return an error. - */ - - if ((bp->b_flags & B_CACHE) == 0) { - bp->b_iocmd = BIO_READ; - vfs_busy_pages(bp, 0); - err = fuse_io_strategy(vp, bp); - if (err) { - brelse(bp); - return (err); - } - } - /* * on is the offset into the current bp. Figure out how many * bytes we can copy out of the bp. Note that bcount is * NOT DEV_BSIZE aligned. @@ -279,10 +260,10 @@ fuse_read_biobackend(struct vnode *vp, struct uio *uio n, n + (int)bp->b_resid); err = uiomove(bp->b_data + on, n, uio); } - brelse(bp); + vfs_bio_brelse(bp, ioflag); SDT_PROBE3(fusefs, , io, read_bio_backend_end, err, uio->uio_resid, n); - } while (err == 0 && uio->uio_resid > 0 && n > 0); + } return (err); }