#include <kern/sched_prim.h>
int
-nfs4_access_rpc(nfsnode_t np, u_int32_t *access, vfs_context_t ctx)
+nfs4_access_rpc(nfsnode_t np, u_int32_t *access, int rpcflags, vfs_context_t ctx)
{
int error = 0, lockerror = ENOENT, status, numops, slot;
u_int64_t xid;
nfsm_chain_build_done(error, &nmreq);
nfsm_assert(error, (numops == 0), EPROTO);
nfsmout_if(error);
- error = nfs_request(np, NULL, &nmreq, NFSPROC4_COMPOUND, ctx, &si, &nmrep, &xid, &status);
+ error = nfs_request2(np, NULL, &nmreq, NFSPROC4_COMPOUND,
+ vfs_context_thread(ctx), vfs_context_ucred(ctx),
+ &si, rpcflags, &nmrep, &xid, &status);
if ((lockerror = nfs_node_lock(np)))
error = lockerror;
struct nfsm_chain nmreq, nmrep;
struct nfsreq_secinfo_args si;
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
acls = (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_ACL);
if (flags & NGA_MONITOR) /* vnode monitor requests should be soft */
rpcflags = R_RECOVER;
+ if (flags & NGA_SOFT) /* Return ETIMEDOUT if server not responding */
+ rpcflags |= R_SOFT;
+
NFSREQ_SECINFO_SET(&si, np, NULL, 0, NULL, 0);
nfsm_chain_null(&nmreq);
nfsm_chain_null(&nmrep);
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
return (EINVAL);
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
struct nfsm_chain nmrep;
nmp = NFSTONMP(np);
- if (!nmp) {
+ if (nfs_mount_gone(nmp)) {
nfs_request_async_cancel(req);
return (ENXIO);
}
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
struct nfsm_chain nmrep;
nmp = NFSTONMP(np);
- if (!nmp) {
+ if (nfs_mount_gone(nmp)) {
nfs_request_async_cancel(req);
return (ENXIO);
}
if (error == EINPROGRESS) /* async request restarted */
return (error);
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
error = ENXIO;
if (!error && (lockerror = nfs_node_lock(np)))
error = lockerror;
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(dnp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
if (dnp->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(fdnp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
if (fdnp->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(dnp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
nmreaddirsize = nmp->nm_readdirsize;
} else {
cookie = bp->nb_lblkno;
/* increment with every buffer read */
- OSAddAtomic(1, &nfsstats.readdir_bios);
+ OSAddAtomic64(1, &nfsstats.readdir_bios);
}
lastcookie = cookie;
space_free = nfs_dir_buf_freespace(bp, rdirplus);
dp = NFS_DIR_BUF_FIRST_DIRENTRY(bp);
/* increment with every buffer read */
- OSAddAtomic(1, &nfsstats.readdir_bios);
+ OSAddAtomic64(1, &nfsstats.readdir_bios);
}
nmrepsave = nmrep;
dp->d_fileno = cookie; /* placeholder */
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(dnp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
if (dnp->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
nmp = NFSTONMP(np);
FSDBG(521, np, offset, count, nmp ? nmp->nm_state : 0);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
return (EINVAL);
struct nfs_vattr nvattr;
struct nfsreq_secinfo_args si;
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
struct nfs_vattr nva;
int error, acls, ngaflags;
- if (!(nmp = VTONMP(ap->a_vp)))
+ nmp = VTONMP(ap->a_vp);
+ if (nfs_mount_gone(nmp))
return (ENXIO);
acls = (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_ACL);
nfs_stateid stateid;
struct nfsreq_secinfo_args si;
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
struct timespec ts = { 1, 0 };
int error = 0, slpflag = (NMFLAG(nmp, INTR) && thd) ? PCATCH : 0;
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
lck_mtx_lock(&nmp->nm_lock);
if (nmp->nm_state & (NFSSTA_FORCE|NFSSTA_DEAD)) {
{
int restart = nfs_mount_state_error_should_restart(error);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (restart);
lck_mtx_lock(&nmp->nm_lock);
if (restart && (error != NFSERR_OLD_STATEID) && (error != NFSERR_GRACE)) {
int error = 0, slpflag;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
slpflag = (NMFLAG(nmp, INTR) && thd) ? PCATCH : 0;
int error = 0, slpflag;
nmp = noop->noo_mount;
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
slpflag = (NMFLAG(nmp, INTR) && thd) ? PCATCH : 0;
int error = 0, slpflag;
nmp = nofp->nof_owner->noo_mount;
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
slpflag = (NMFLAG(nmp, INTR) && thd) ? PCATCH : 0;
struct nfs_open_file *nofp = NULL;
nmp = VTONMP(vp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (!vnode_isreg(vp) || !(ap->a_fflags & (PROT_READ|PROT_WRITE)))
}
if (noop)
nfs_open_owner_rele(noop);
+
+ if (!error) {
+ int ismapped = 0;
+ nfs_node_lock_force(np);
+ if ((np->n_flag & NISMAPPED) == 0) {
+ np->n_flag |= NISMAPPED;
+ ismapped = 1;
+ }
+ nfs_node_unlock(np);
+ if (ismapped) {
+ lck_mtx_lock(&nmp->nm_lock);
+ nmp->nm_state &= ~NFSSTA_SQUISHY;
+ nmp->nm_curdeadtimeout = nmp->nm_deadtimeout;
+ if (nmp->nm_curdeadtimeout <= 0)
+ nmp->nm_deadto_start = 0;
+ nmp->nm_mappers++;
+ lck_mtx_unlock(&nmp->nm_lock);
+ }
+ }
+
return (error);
}
struct nfs_open_file *nofp = NULL;
off_t size;
int error;
-
+ int is_mapped_flag = 0;
+
nmp = VTONMP(vp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
+ nfs_node_lock_force(np);
+ if (np->n_flag & NISMAPPED) {
+ is_mapped_flag = 1;
+ np->n_flag &= ~NISMAPPED;
+ }
+ nfs_node_unlock(np);
+ if (is_mapped_flag) {
+ lck_mtx_lock(&nmp->nm_lock);
+ if (nmp->nm_mappers)
+ nmp->nm_mappers--;
+ else
+ NP(np, "nfs_vnop_mnomap: removing mmap reference from mount, but mount has no files mmapped");
+ lck_mtx_unlock(&nmp->nm_lock);
+ }
+
/* flush buffers/ubc before we drop the open (in case it's our last open) */
nfs_flush(np, MNT_WAIT, vfs_context_thread(ctx), V_IGNORE_WRITEERR);
if (UBCINFOEXISTS(vp) && (size = ubc_getsize(vp)))
int error = 0, slpflag;
nmp = nlop->nlo_open_owner->noo_mount;
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
slpflag = (NMFLAG(nmp, INTR) && thd) ? PCATCH : 0;
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
return (EINVAL);
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
return (EINVAL);
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
return (EINVAL);
int error = 0, answered = 0;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
restart:
struct timespec ts = {1, 0};
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
slpflag = NMFLAG(nmp, INTR) ? PCATCH : 0;
wakeup(newnflp);
} else {
/* remove newnflp from lock list and destroy */
- TAILQ_REMOVE(&np->n_locks, newnflp, nfl_link);
+ if (inqueue)
+ TAILQ_REMOVE(&np->n_locks, newnflp, nfl_link);
nfs_file_lock_destroy(newnflp);
}
lck_mtx_unlock(&np->n_openlock);
int error = 0, willsplit = 0, send_unlock_rpcs = 1;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
restart:
#define OFF_MAX QUAD_MAX
nmp = VTONMP(ap->a_vp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
lck_mtx_lock(&nmp->nm_lock);
if ((nmp->nm_vers <= NFS_VER3) && (nmp->nm_lockmode == NFS_LOCK_MODE_DISABLED)) {
return (EINVAL);
nmp = VTONMP(dvp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
namedattrs = (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR);
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
lck_mtx_lock(&nofp->nof_lock);
nofp->nof_flags &= ~NFS_OPEN_FILE_REOPEN;
nofp->nof_flags |= NFS_OPEN_FILE_LOST;
+
lck_mtx_unlock(&nofp->nof_lock);
if (!force && nmp && (nmp->nm_vers >= NFS_VER4))
nfs4_close_rpc(np, nofp, NULL, nofp->nof_owner->noo_cred, R_RECOVER);
struct nfsmount *nmp;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return;
lck_mtx_lock(&np->n_openlock);
int error;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
/* first, make sure the node's marked for delegation return */
int error;
if (vnode_vtype(ap->a_vp) != VREG)
- return (EPERM);
+ return (vnode_vtype(vp) == VDIR) ? EISDIR : EPERM;
np = VTONFS(vp);
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (np->n_flag & NREVOKE)
return (EIO);
struct nfs_open_file *newnofp = NULL, *nofp = NULL;
nmp = VTONMP(dvp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (vap)
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(dnp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
namedattrs = (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR);
int error;
nmp = VTONMP(ap->a_dvp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (!VATTR_IS_ACTIVE(ap->a_vap, va_type))
return (EXDEV);
nmp = VTONMP(vp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
nfsvers = nmp->nm_vers;
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
return (EINVAL);
nmp = NFSTONMP(dnp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
namedattrs = (nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR);
struct nfsreq_secinfo_args si;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (NULL);
if (np->n_vattr.nva_flags & NFS_FFLAG_TRIGGER_REFERRAL)
return (NULL);
slen = sizeof(sbuf);
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
NVATTR_INIT(&nvattr);
negnamecache = !NMFLAG(nmp, NONEGNAMECACHE);
/* FALLTHROUGH */
case -1:
/* cache hit, not really an error */
- OSAddAtomic(1, &nfsstats.lookupcache_hits);
+ OSAddAtomic64(1, &nfsstats.lookupcache_hits);
if (!anp && avp)
*anpp = anp = VTONFS(avp);
/* don't save the data if dirty or potential I/O conflict */
if (!error && bp && !bp->nb_dirtyoff && !(bp->nb_dirty & pagemask) &&
timevalcmp(&anp->n_lastio, &now, <)) {
- OSAddAtomic(1, &nfsstats.read_bios);
+ OSAddAtomic64(1, &nfsstats.read_bios);
CLR(bp->nb_flags, (NB_DONE|NB_ASYNC));
SET(bp->nb_flags, NB_READ);
NFS_BUF_MAP(bp);
int error, putanp = 0;
nmp = NFSTONMP(np);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
bzero(&cn, sizeof(cn));
int error = 0, isrsrcfork;
nmp = VTONMP(ap->a_vp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (!(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR))
struct vnop_write_args vwa;
nmp = VTONMP(ap->a_vp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (!(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR))
struct nfsmount *nmp = VTONMP(ap->a_vp);
int error;
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (!(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR))
return (ENOTSUP);
struct direntry *dp;
nmp = VTONMP(ap->a_vp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (!(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR))
nextcookie = lbn = 0;
while (!error && !done) {
- OSAddAtomic(1, &nfsstats.biocache_readdirs);
+ OSAddAtomic64(1, &nfsstats.biocache_readdirs);
cookie = nextcookie;
getbuffer:
error = nfs_buf_get(adnp, lbn, NFS_DIRBLKSIZ, vfs_context_thread(ctx), NBLK_READ, &bp);
int error = 0;
nmp = VTONMP(ap->a_vp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (!(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR))
int error = 0;
nmp = VTONMP(ap->a_vp);
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
if (!(nmp->nm_fsattr.nfsa_flags & NFS_FSFLAG_NAMED_ATTR))
nfsnode_t np = ap->a_vp ? VTONFS(ap->a_vp) : NULL;
nfsnode_t anp = ap->a_svp ? VTONFS(ap->a_svp) : NULL;
- if (!nmp)
+ if (nfs_mount_gone(nmp))
return (ENXIO);
/*