fusefs: refine the short read fix from r349332

b_fsprivate1 needs to be initialized even for write operations, probably
because a buffer can be used to read, write, and read again with the final
read serviced by cache.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Alan Somers 2019-06-24 20:08:28 +00:00
parent 17575bad85
commit 1734e205f3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/projects/fuse2/; revision=349338

View File

@ -164,6 +164,8 @@ fuse_io_clear_suid_on_write(struct vnode *vp, struct ucred *cred,
SDT_PROBE_DEFINE5(fusefs, , io, io_dispatch, "struct vnode*", "struct uio*",
"int", "struct ucred*", "struct fuse_filehandle*");
SDT_PROBE_DEFINE5(fusefs, , io, io_dispatch_filehandles_closed, "struct vnode*",
"struct uio*", "int", "bool", "struct ucred*");
int
fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag, bool pages,
struct ucred *cred, pid_t pid)
@ -186,6 +188,8 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag, bool pages,
closefufh = true;
}
else if (err) {
SDT_PROBE5(fusefs, , io, io_dispatch_filehandles_closed,
vp, uio, ioflag, pages, cred);
printf("FUSE: io dispatch: filehandles are closed\n");
return err;
}
@ -860,6 +864,7 @@ fuse_io_strategy(struct vnode *vp, struct buf *bp)
fflag = bp->b_iocmd == BIO_READ ? FREAD : FWRITE;
cred = bp->b_iocmd == BIO_READ ? bp->b_rcred : bp->b_wcred;
error = fuse_filehandle_getrw(vp, fflag, &fufh, cred, pid);
bp->b_fsprivate1 = (void*)(intptr_t)0;
if (bp->b_iocmd == BIO_READ && error == EBADF) {
/*
* This may be a read-modify-write operation on a cached file