summaryrefslogtreecommitdiff
path: root/sys/nfs/nfs_vfsops.c
diff options
context:
space:
mode:
authorThordur I. Bjornsson <thib@cvs.openbsd.org>2009-07-13 15:39:56 +0000
committerThordur I. Bjornsson <thib@cvs.openbsd.org>2009-07-13 15:39:56 +0000
commit603ae68b6293be0dfa5d22f9759bed2f3b2d47ff (patch)
tree880bb28c1e0d4a66d21a8c75b67137a2f326fb18 /sys/nfs/nfs_vfsops.c
parent9bc2e3272110f0fc03393c1cfded8084bc816f7b (diff)
Make the callers of nfs_request() responsible for freeing the reply mbuf,
if the reply is an error and retire the NFS_RETERR hack. For NFSv3 mounts the flag was set and reply mbuf not freed to allow the callers to handle the post-op attributes, or just free the mbuf for NFSv2. Tested by myself and jasper@ on various arch's. OK blambert@.
Diffstat (limited to 'sys/nfs/nfs_vfsops.c')
-rw-r--r--sys/nfs/nfs_vfsops.c95
1 files changed, 46 insertions, 49 deletions
diff --git a/sys/nfs/nfs_vfsops.c b/sys/nfs/nfs_vfsops.c
index 9524d2c8568..3e798842449 100644
--- a/sys/nfs/nfs_vfsops.c
+++ b/sys/nfs/nfs_vfsops.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs_vfsops.c,v 1.83 2009/06/04 00:31:42 blambert Exp $ */
+/* $OpenBSD: nfs_vfsops.c,v 1.84 2009/07/13 15:39:55 thib Exp $ */
/* $NetBSD: nfs_vfsops.c,v 1.46.4.1 1996/05/25 22:40:35 fvdl Exp $ */
/*
@@ -126,20 +126,16 @@ nfs_statfs(mp, sbp, p)
nfsstats.rpccnt[NFSPROC_FSSTAT]++;
mb = mreq = nfsm_reqhead(NFSX_FH(v3));
nfsm_fhtom(&mb, vp, v3);
- if ((error = nfs_request(vp, mreq, NFSPROC_FSSTAT, p, cred, &mrep,
- &md, &dpos)) != 0) {
- if (error & NFSERR_RETERR)
- error &= ~NFSERR_RETERR;
- else
- goto nfsmout;
- }
+
+ error = nfs_request(vp, mreq, NFSPROC_FSSTAT, p, cred, &mrep,
+ &md, &dpos);
if (v3)
nfsm_postop_attr(vp, retattr);
if (error) {
- if (mrep != NULL)
- m_freem(mrep);
+ m_freem(mrep);
goto nfsmout;
}
+
nfsm_dissect(sfp, struct nfs_statfs *, NFSX_STATFS(v3));
sbp->f_iosize = min(nmp->nm_rsize, nmp->nm_wsize);
if (v3) {
@@ -193,47 +189,48 @@ nfs_fsinfo(nmp, vp, cred, p)
nfsstats.rpccnt[NFSPROC_FSINFO]++;
mb = mreq = nfsm_reqhead(NFSX_FH(1));
nfsm_fhtom(&mb, vp, 1);
- if ((error = nfs_request(vp, mreq, NFSPROC_FSINFO, p, cred, &mrep,
- &md, &dpos)) != 0) {
- if (error & NFSERR_RETERR)
- error &= ~NFSERR_RETERR;
- else
- goto nfsmout;
- }
+
+ error = nfs_request(vp, mreq, NFSPROC_FSINFO, p, cred, &mrep,
+ &md, &dpos);
+
nfsm_postop_attr(vp, retattr);
- if (!error) {
- nfsm_dissect(fsp, struct nfsv3_fsinfo *, NFSX_V3FSINFO);
- pref = fxdr_unsigned(u_int32_t, fsp->fs_wtpref);
- if (pref < nmp->nm_wsize)
- nmp->nm_wsize = (pref + NFS_FABLKSIZE - 1) &
- ~(NFS_FABLKSIZE - 1);
- max = fxdr_unsigned(u_int32_t, fsp->fs_wtmax);
- if (max < nmp->nm_wsize) {
- nmp->nm_wsize = max & ~(NFS_FABLKSIZE - 1);
- if (nmp->nm_wsize == 0)
- nmp->nm_wsize = max;
- }
- pref = fxdr_unsigned(u_int32_t, fsp->fs_rtpref);
- if (pref < nmp->nm_rsize)
- nmp->nm_rsize = (pref + NFS_FABLKSIZE - 1) &
- ~(NFS_FABLKSIZE - 1);
- max = fxdr_unsigned(u_int32_t, fsp->fs_rtmax);
- if (max < nmp->nm_rsize) {
- nmp->nm_rsize = max & ~(NFS_FABLKSIZE - 1);
- if (nmp->nm_rsize == 0)
- nmp->nm_rsize = max;
- }
- pref = fxdr_unsigned(u_int32_t, fsp->fs_dtpref);
- if (pref < nmp->nm_readdirsize)
- nmp->nm_readdirsize = (pref + NFS_DIRBLKSIZ - 1) &
- ~(NFS_DIRBLKSIZ - 1);
- if (max < nmp->nm_readdirsize) {
- nmp->nm_readdirsize = max & ~(NFS_DIRBLKSIZ - 1);
- if (nmp->nm_readdirsize == 0)
- nmp->nm_readdirsize = max;
- }
- nmp->nm_flag |= NFSMNT_GOTFSINFO;
+ if (error) {
+ m_freem(mrep);
+ goto nfsmout;
}
+
+ nfsm_dissect(fsp, struct nfsv3_fsinfo *, NFSX_V3FSINFO);
+ pref = fxdr_unsigned(u_int32_t, fsp->fs_wtpref);
+ if (pref < nmp->nm_wsize)
+ nmp->nm_wsize = (pref + NFS_FABLKSIZE - 1) &
+ ~(NFS_FABLKSIZE - 1);
+ max = fxdr_unsigned(u_int32_t, fsp->fs_wtmax);
+ if (max < nmp->nm_wsize) {
+ nmp->nm_wsize = max & ~(NFS_FABLKSIZE - 1);
+ if (nmp->nm_wsize == 0)
+ nmp->nm_wsize = max;
+ }
+ pref = fxdr_unsigned(u_int32_t, fsp->fs_rtpref);
+ if (pref < nmp->nm_rsize)
+ nmp->nm_rsize = (pref + NFS_FABLKSIZE - 1) &
+ ~(NFS_FABLKSIZE - 1);
+ max = fxdr_unsigned(u_int32_t, fsp->fs_rtmax);
+ if (max < nmp->nm_rsize) {
+ nmp->nm_rsize = max & ~(NFS_FABLKSIZE - 1);
+ if (nmp->nm_rsize == 0)
+ nmp->nm_rsize = max;
+ }
+ pref = fxdr_unsigned(u_int32_t, fsp->fs_dtpref);
+ if (pref < nmp->nm_readdirsize)
+ nmp->nm_readdirsize = (pref + NFS_DIRBLKSIZ - 1) &
+ ~(NFS_DIRBLKSIZ - 1);
+ if (max < nmp->nm_readdirsize) {
+ nmp->nm_readdirsize = max & ~(NFS_DIRBLKSIZ - 1);
+ if (nmp->nm_readdirsize == 0)
+ nmp->nm_readdirsize = max;
+ }
+ nmp->nm_flag |= NFSMNT_GOTFSINFO;
+
m_freem(mrep);
nfsmout:
return (error);