Patch the experimental NFS client in a manner analogous to
r203072 for the regular NFS client. Also, delete two fields of struct nfsmount that are not used by the FreeBSD port of the client. MFC after: 2 weeks
This commit is contained in:
parent
b007106a58
commit
c20e37e81a
@ -55,6 +55,19 @@
|
|||||||
#define NFS_ISV34(v) \
|
#define NFS_ISV34(v) \
|
||||||
(VFSTONFS((v)->v_mount)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4))
|
(VFSTONFS((v)->v_mount)->nm_flag & (NFSMNT_NFSV3 | NFSMNT_NFSV4))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NFS iod threads can be in one of these three states once spawned.
|
||||||
|
* NFSIOD_NOT_AVAILABLE - Cannot be assigned an I/O operation at this time.
|
||||||
|
* NFSIOD_AVAILABLE - Available to be assigned an I/O operation.
|
||||||
|
* NFSIOD_CREATED_FOR_NFS_ASYNCIO - Newly created for nfs_asyncio() and
|
||||||
|
* will be used by the thread that called nfs_asyncio().
|
||||||
|
*/
|
||||||
|
enum nfsiod_state {
|
||||||
|
NFSIOD_NOT_AVAILABLE = 0,
|
||||||
|
NFSIOD_AVAILABLE = 1,
|
||||||
|
NFSIOD_CREATED_FOR_NFS_ASYNCIO = 2,
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function prototypes.
|
* Function prototypes.
|
||||||
*/
|
*/
|
||||||
@ -87,7 +100,7 @@ int ncl_fsinfo(struct nfsmount *, struct vnode *, struct ucred *,
|
|||||||
int ncl_init(struct vfsconf *);
|
int ncl_init(struct vfsconf *);
|
||||||
int ncl_uninit(struct vfsconf *);
|
int ncl_uninit(struct vfsconf *);
|
||||||
int ncl_mountroot(struct mount *);
|
int ncl_mountroot(struct mount *);
|
||||||
int ncl_nfsiodnew(void);
|
int ncl_nfsiodnew(int);
|
||||||
|
|
||||||
#endif /* _KERNEL */
|
#endif /* _KERNEL */
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ extern int newnfs_directio_allow_mmap;
|
|||||||
extern struct nfsstats newnfsstats;
|
extern struct nfsstats newnfsstats;
|
||||||
extern struct mtx ncl_iod_mutex;
|
extern struct mtx ncl_iod_mutex;
|
||||||
extern int ncl_numasync;
|
extern int ncl_numasync;
|
||||||
extern struct proc *ncl_iodwant[NFS_MAXRAHEAD];
|
extern enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
|
||||||
extern struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
|
extern struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
|
||||||
extern int newnfs_directio_enable;
|
extern int newnfs_directio_enable;
|
||||||
|
|
||||||
@ -1396,7 +1396,7 @@ again:
|
|||||||
* Find a free iod to process this request.
|
* Find a free iod to process this request.
|
||||||
*/
|
*/
|
||||||
for (iod = 0; iod < ncl_numasync; iod++)
|
for (iod = 0; iod < ncl_numasync; iod++)
|
||||||
if (ncl_iodwant[iod]) {
|
if (ncl_iodwant[iod] == NFSIOD_AVAILABLE) {
|
||||||
gotiod = TRUE;
|
gotiod = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1405,7 +1405,7 @@ again:
|
|||||||
* Try to create one if none are free.
|
* Try to create one if none are free.
|
||||||
*/
|
*/
|
||||||
if (!gotiod) {
|
if (!gotiod) {
|
||||||
iod = ncl_nfsiodnew();
|
iod = ncl_nfsiodnew(1);
|
||||||
if (iod != -1)
|
if (iod != -1)
|
||||||
gotiod = TRUE;
|
gotiod = TRUE;
|
||||||
}
|
}
|
||||||
@ -1417,7 +1417,7 @@ again:
|
|||||||
*/
|
*/
|
||||||
NFS_DPF(ASYNCIO, ("ncl_asyncio: waking iod %d for mount %p\n",
|
NFS_DPF(ASYNCIO, ("ncl_asyncio: waking iod %d for mount %p\n",
|
||||||
iod, nmp));
|
iod, nmp));
|
||||||
ncl_iodwant[iod] = NULL;
|
ncl_iodwant[iod] = NFSIOD_NOT_AVAILABLE;
|
||||||
ncl_iodmount[iod] = nmp;
|
ncl_iodmount[iod] = nmp;
|
||||||
nmp->nm_bufqiods++;
|
nmp->nm_bufqiods++;
|
||||||
wakeup(&ncl_iodwant[iod]);
|
wakeup(&ncl_iodwant[iod]);
|
||||||
|
@ -72,7 +72,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
extern struct mtx ncl_iod_mutex;
|
extern struct mtx ncl_iod_mutex;
|
||||||
|
|
||||||
int ncl_numasync;
|
int ncl_numasync;
|
||||||
struct proc *ncl_iodwant[NFS_MAXRAHEAD];
|
enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
|
||||||
struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
|
struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
|
||||||
|
|
||||||
static void nfssvc_iod(void *);
|
static void nfssvc_iod(void *);
|
||||||
@ -114,7 +114,7 @@ sysctl_iodmin(SYSCTL_HANDLER_ARGS)
|
|||||||
* than the new minimum, create some more.
|
* than the new minimum, create some more.
|
||||||
*/
|
*/
|
||||||
for (i = nfs_iodmin - ncl_numasync; i > 0; i--)
|
for (i = nfs_iodmin - ncl_numasync; i > 0; i--)
|
||||||
ncl_nfsiodnew();
|
ncl_nfsiodnew(0);
|
||||||
out:
|
out:
|
||||||
mtx_unlock(&ncl_iod_mutex);
|
mtx_unlock(&ncl_iod_mutex);
|
||||||
return (0);
|
return (0);
|
||||||
@ -147,7 +147,7 @@ sysctl_iodmax(SYSCTL_HANDLER_ARGS)
|
|||||||
*/
|
*/
|
||||||
iod = ncl_numasync - 1;
|
iod = ncl_numasync - 1;
|
||||||
for (i = 0; i < ncl_numasync - ncl_iodmax; i++) {
|
for (i = 0; i < ncl_numasync - ncl_iodmax; i++) {
|
||||||
if (ncl_iodwant[iod])
|
if (ncl_iodwant[iod] == NFSIOD_AVAILABLE)
|
||||||
wakeup(&ncl_iodwant[iod]);
|
wakeup(&ncl_iodwant[iod]);
|
||||||
iod--;
|
iod--;
|
||||||
}
|
}
|
||||||
@ -159,7 +159,7 @@ SYSCTL_PROC(_vfs_newnfs, OID_AUTO, iodmax, CTLTYPE_UINT | CTLFLAG_RW, 0,
|
|||||||
sizeof (ncl_iodmax), sysctl_iodmax, "IU", "");
|
sizeof (ncl_iodmax), sysctl_iodmax, "IU", "");
|
||||||
|
|
||||||
int
|
int
|
||||||
ncl_nfsiodnew(void)
|
ncl_nfsiodnew(int set_iodwant)
|
||||||
{
|
{
|
||||||
int error, i;
|
int error, i;
|
||||||
int newiod;
|
int newiod;
|
||||||
@ -175,12 +175,17 @@ ncl_nfsiodnew(void)
|
|||||||
}
|
}
|
||||||
if (newiod == -1)
|
if (newiod == -1)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
if (set_iodwant > 0)
|
||||||
|
ncl_iodwant[i] = NFSIOD_CREATED_FOR_NFS_ASYNCIO;
|
||||||
mtx_unlock(&ncl_iod_mutex);
|
mtx_unlock(&ncl_iod_mutex);
|
||||||
error = kproc_create(nfssvc_iod, nfs_asyncdaemon + i, NULL, RFHIGHPID,
|
error = kproc_create(nfssvc_iod, nfs_asyncdaemon + i, NULL, RFHIGHPID,
|
||||||
0, "nfsiod %d", newiod);
|
0, "nfsiod %d", newiod);
|
||||||
mtx_lock(&ncl_iod_mutex);
|
mtx_lock(&ncl_iod_mutex);
|
||||||
if (error)
|
if (error) {
|
||||||
|
if (set_iodwant > 0)
|
||||||
|
ncl_iodwant[i] = NFSIOD_NOT_AVAILABLE;
|
||||||
return (-1);
|
return (-1);
|
||||||
|
}
|
||||||
ncl_numasync++;
|
ncl_numasync++;
|
||||||
return (newiod);
|
return (newiod);
|
||||||
}
|
}
|
||||||
@ -199,7 +204,7 @@ nfsiod_setup(void *dummy)
|
|||||||
nfs_iodmin = NFS_MAXRAHEAD;
|
nfs_iodmin = NFS_MAXRAHEAD;
|
||||||
|
|
||||||
for (i = 0; i < nfs_iodmin; i++) {
|
for (i = 0; i < nfs_iodmin; i++) {
|
||||||
error = ncl_nfsiodnew();
|
error = ncl_nfsiodnew(0);
|
||||||
if (error == -1)
|
if (error == -1)
|
||||||
panic("newnfsiod_setup: ncl_nfsiodnew failed");
|
panic("newnfsiod_setup: ncl_nfsiodnew failed");
|
||||||
}
|
}
|
||||||
@ -235,7 +240,8 @@ nfssvc_iod(void *instance)
|
|||||||
goto finish;
|
goto finish;
|
||||||
if (nmp)
|
if (nmp)
|
||||||
nmp->nm_bufqiods--;
|
nmp->nm_bufqiods--;
|
||||||
ncl_iodwant[myiod] = curthread->td_proc;
|
if (ncl_iodwant[myiod] == NFSIOD_NOT_AVAILABLE)
|
||||||
|
ncl_iodwant[myiod] = NFSIOD_AVAILABLE;
|
||||||
ncl_iodmount[myiod] = NULL;
|
ncl_iodmount[myiod] = NULL;
|
||||||
/*
|
/*
|
||||||
* Always keep at least nfs_iodmin kthreads.
|
* Always keep at least nfs_iodmin kthreads.
|
||||||
@ -295,7 +301,7 @@ finish:
|
|||||||
nfs_asyncdaemon[myiod] = 0;
|
nfs_asyncdaemon[myiod] = 0;
|
||||||
if (nmp)
|
if (nmp)
|
||||||
nmp->nm_bufqiods--;
|
nmp->nm_bufqiods--;
|
||||||
ncl_iodwant[myiod] = NULL;
|
ncl_iodwant[myiod] = NFSIOD_NOT_AVAILABLE;
|
||||||
ncl_iodmount[myiod] = NULL;
|
ncl_iodmount[myiod] = NULL;
|
||||||
/* Someone may be waiting for the last nfsiod to terminate. */
|
/* Someone may be waiting for the last nfsiod to terminate. */
|
||||||
if (--ncl_numasync == 0)
|
if (--ncl_numasync == 0)
|
||||||
|
@ -78,7 +78,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/stdarg.h>
|
#include <machine/stdarg.h>
|
||||||
|
|
||||||
extern struct mtx ncl_iod_mutex;
|
extern struct mtx ncl_iod_mutex;
|
||||||
extern struct proc *ncl_iodwant[NFS_MAXRAHEAD];
|
extern enum nfsiod_state ncl_iodwant[NFS_MAXRAHEAD];
|
||||||
extern struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
|
extern struct nfsmount *ncl_iodmount[NFS_MAXRAHEAD];
|
||||||
extern int ncl_numasync;
|
extern int ncl_numasync;
|
||||||
extern unsigned int ncl_iodmax;
|
extern unsigned int ncl_iodmax;
|
||||||
@ -100,7 +100,7 @@ ncl_uninit(struct vfsconf *vfsp)
|
|||||||
mtx_lock(&ncl_iod_mutex);
|
mtx_lock(&ncl_iod_mutex);
|
||||||
ncl_iodmax = 0;
|
ncl_iodmax = 0;
|
||||||
for (i = 0; i < ncl_numasync; i++)
|
for (i = 0; i < ncl_numasync; i++)
|
||||||
if (ncl_iodwant[i])
|
if (ncl_iodwant[i] == NFSIOD_AVAILABLE)
|
||||||
wakeup(&ncl_iodwant[i]);
|
wakeup(&ncl_iodwant[i]);
|
||||||
/* The last nfsiod to exit will wake us up when ncl_numasync hits 0 */
|
/* The last nfsiod to exit will wake us up when ncl_numasync hits 0 */
|
||||||
while (ncl_numasync)
|
while (ncl_numasync)
|
||||||
@ -396,7 +396,7 @@ ncl_init(struct vfsconf *vfsp)
|
|||||||
|
|
||||||
/* Ensure async daemons disabled */
|
/* Ensure async daemons disabled */
|
||||||
for (i = 0; i < NFS_MAXRAHEAD; i++) {
|
for (i = 0; i < NFS_MAXRAHEAD; i++) {
|
||||||
ncl_iodwant[i] = NULL;
|
ncl_iodwant[i] = NFSIOD_NOT_AVAILABLE;
|
||||||
ncl_iodmount[i] = NULL;
|
ncl_iodmount[i] = NULL;
|
||||||
}
|
}
|
||||||
ncl_nhinit(); /* Init the nfsnode table */
|
ncl_nhinit(); /* Init the nfsnode table */
|
||||||
|
@ -71,8 +71,6 @@ struct nfsmount {
|
|||||||
int nm_tprintf_delay; /* interval for messages */
|
int nm_tprintf_delay; /* interval for messages */
|
||||||
|
|
||||||
/* Newnfs additions */
|
/* Newnfs additions */
|
||||||
int nm_iothreadcnt;
|
|
||||||
struct proc *nm_iodwant[NFS_MAXRAHEAD];
|
|
||||||
struct nfsclclient *nm_clp;
|
struct nfsclclient *nm_clp;
|
||||||
uid_t nm_uid; /* Uid for SetClientID etc. */
|
uid_t nm_uid; /* Uid for SetClientID etc. */
|
||||||
u_int64_t nm_clval; /* identifies which clientid */
|
u_int64_t nm_clval; /* identifies which clientid */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user