SCCS-vsn: sys/nfs/nfs_bio.c 7.5
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * @(#)nfs_bio.c 7.4 (Berkeley) %G%
+ * @(#)nfs_bio.c 7.5 (Berkeley) %G%
* Vnode op for read using bio
* Any similarity to readip() is purely coincidental
*/
* Vnode op for read using bio
* Any similarity to readip() is purely coincidental
*/
-nfs_read(vp, uio, offp, ioflag, cred)
+nfs_read(vp, uio, ioflag, cred)
register struct vnode *vp;
struct uio *uio;
register struct vnode *vp;
struct uio *uio;
int ioflag;
struct ucred *cred;
{
int ioflag;
struct ucred *cred;
{
int diff, error = 0;
long n, on;
int diff, error = 0;
long n, on;
- if (!(ioflag & IO_NODELOCKED))
- nfs_lock(vp);
/*
* Avoid caching directories. Once everything is using getdirentries()
* this will never happen anyhow.
*/
/*
* Avoid caching directories. Once everything is using getdirentries()
* this will never happen anyhow.
*/
- if (vp->v_type == VDIR) {
- error = nfs_readrpc(vp, uio, offp, cred);
- if (!(ioflag & IO_NODELOCKED))
- nfs_unlock(vp);
- return (error);
- }
- uio->uio_offset = *offp;
+ if (vp->v_type == VDIR)
+ return (nfs_readrpc(vp, uio, cred));
if (uio->uio_rw != UIO_READ)
panic("nfs_read mode");
if (vp->v_type != VREG)
panic("nfs_read type");
if (uio->uio_resid == 0)
if (uio->uio_rw != UIO_READ)
panic("nfs_read mode");
if (vp->v_type != VREG)
panic("nfs_read type");
if (uio->uio_resid == 0)
- goto out;
- if (uio->uio_offset < 0) {
- error = EINVAL;
- goto out;
- }
+ return (0);
+ if (uio->uio_offset < 0)
+ return (EINVAL);
/*
* If the file's modify time on the server has changed since the
* last read rpc or you have written to the file,
/*
* If the file's modify time on the server has changed since the
* last read rpc or you have written to the file,
if (np->n_flag & NMODIFIED) {
np->n_flag &= ~NMODIFIED;
if (error = nfs_blkflush(vp, (daddr_t)0, np->n_size, TRUE))
if (np->n_flag & NMODIFIED) {
np->n_flag &= ~NMODIFIED;
if (error = nfs_blkflush(vp, (daddr_t)0, np->n_size, TRUE))
if (error = nfs_getattr(vp, &vattr, cred))
if (error = nfs_getattr(vp, &vattr, cred))
np->n_mtime = vattr.va_mtime.tv_sec;
} else {
if (error = nfs_getattr(vp, &vattr, cred))
np->n_mtime = vattr.va_mtime.tv_sec;
} else {
if (error = nfs_getattr(vp, &vattr, cred))
if (np->n_mtime != vattr.va_mtime.tv_sec) {
if (error = nfs_blkflush(vp, (daddr_t)0,
np->n_size, TRUE))
if (np->n_mtime != vattr.va_mtime.tv_sec) {
if (error = nfs_blkflush(vp, (daddr_t)0,
np->n_size, TRUE))
np->n_mtime = vattr.va_mtime.tv_sec;
}
}
np->n_mtime = vattr.va_mtime.tv_sec;
}
}
n = MIN((unsigned)(NFS_BIOSIZE - on), uio->uio_resid);
diff = np->n_size - uio->uio_offset;
if (diff <= 0)
n = MIN((unsigned)(NFS_BIOSIZE - on), uio->uio_resid);
diff = np->n_size - uio->uio_offset;
if (diff <= 0)
if (diff < n)
n = diff;
bn = lbn*(NFS_BIOSIZE/DEV_BSIZE);
if (diff < n)
n = diff;
bn = lbn*(NFS_BIOSIZE/DEV_BSIZE);
}
if (error) {
brelse(bp);
}
if (error) {
brelse(bp);
}
if (n > 0)
error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
}
if (n > 0)
error = uiomove(bp->b_un.b_addr + on, (int)n, uio);
bp->b_flags |= B_AGE;
brelse(bp);
} while (error == 0 && uio->uio_resid > 0 && n != 0);
bp->b_flags |= B_AGE;
brelse(bp);
} while (error == 0 && uio->uio_resid > 0 && n != 0);
-out:
- *offp = uio->uio_offset;
- if (!(ioflag & IO_NODELOCKED))
- nfs_unlock(vp);
return (error);
}
/*
* Vnode op for write using bio
*/
return (error);
}
/*
* Vnode op for write using bio
*/
-nfs_write(vp, uio, offp, ioflag, cred)
+nfs_write(vp, uio, ioflag, cred)
register struct vnode *vp;
register struct uio *uio;
register struct vnode *vp;
register struct uio *uio;
int ioflag;
struct ucred *cred;
{
struct buf *bp;
struct nfsnode *np = VTONFS(vp);
daddr_t lbn, bn;
int ioflag;
struct ucred *cred;
{
struct buf *bp;
struct nfsnode *np = VTONFS(vp);
daddr_t lbn, bn;
- int i, n, on, cnt, count, error = 0;
+ int i, n, on, count, error = 0;
- if ((ioflag & IO_NODELOCKED) == 0)
- nfs_lock(vp);
/* Should we try and do this ?? */
if (vp->v_type == VREG && (ioflag & IO_APPEND))
/* Should we try and do this ?? */
if (vp->v_type == VREG && (ioflag & IO_APPEND))
- *offp = np->n_size;
- uio->uio_offset = *offp;
- cnt = uio->uio_resid;
+ uio->uio_offset = np->n_size;
osize = np->n_size;
#endif
if (uio->uio_rw != UIO_WRITE)
panic("nfs_write mode");
if (vp->v_type != VREG)
panic("nfs_write type");
osize = np->n_size;
#endif
if (uio->uio_rw != UIO_WRITE)
panic("nfs_write mode");
if (vp->v_type != VREG)
panic("nfs_write type");
- if (uio->uio_offset < 0) {
- error = EINVAL;
- goto out;
- }
+ if (uio->uio_offset < 0)
+ return (EINVAL);
/*
* Maybe this should be above the vnode op call, but so long as
* file servers have no limits, i don't think it matters
/*
* Maybe this should be above the vnode op call, but so long as
* file servers have no limits, i don't think it matters
uio->uio_offset + uio->uio_resid >
u.u_rlimit[RLIMIT_FSIZE].rlim_cur) {
psignal(u.u_procp, SIGXFSZ);
uio->uio_offset + uio->uio_resid >
u.u_rlimit[RLIMIT_FSIZE].rlim_cur) {
psignal(u.u_procp, SIGXFSZ);
- error = EFBIG;
- goto out;
}
np->n_flag |= (NMODIFIED|NBUFFERED);
do {
}
np->n_flag |= (NMODIFIED|NBUFFERED);
do {
}
if (bp->b_dirtyend > 0) {
/*
}
if (bp->b_dirtyend > 0) {
/*
- * Iff the new write will leave a contiguous
+ * If the new write will leave a contiguous
* dirty area, just update the b_dirtyoff and
* b_dirtyend
* otherwise force a write rpc of the old dirty
* dirty area, just update the b_dirtyoff and
* b_dirtyend
* otherwise force a write rpc of the old dirty
error = bp->b_error;
else
error = EIO;
error = bp->b_error;
else
error = EIO;
}
bp->b_dirtyoff = on;
bp->b_dirtyend = on+n;
}
bp->b_dirtyoff = on;
bp->b_dirtyend = on+n;
bp->b_dirtyend = on+n;
}
if (error = uiomove(bp->b_un.b_addr + on, n, uio))
bp->b_dirtyend = on+n;
}
if (error = uiomove(bp->b_un.b_addr + on, n, uio))
if ((n+on) == NFS_BIOSIZE) {
bp->b_flags |= B_AGE;
bawrite(bp);
if ((n+on) == NFS_BIOSIZE) {
bp->b_flags |= B_AGE;
bawrite(bp);
} while (error == 0 && uio->uio_resid > 0 && n != 0);
#ifdef notdef
/* Should we try and do this for nfs ?? */
} while (error == 0 && uio->uio_resid > 0 && n != 0);
#ifdef notdef
/* Should we try and do this for nfs ?? */
- if (error && (ioflag & IO_UNIT))
+ if (error && (ioflag & IO_UNIT)) {
+ uio->uio_offset -= cnt - uio->uio_resid;
+ uio->uio_resid = cnt;
+ }
- *offp += cnt - uio->uio_resid;
-out:
- if ((ioflag & IO_NODELOCKED) == 0)
- nfs_unlock(vp);