Print this page
NEX-15279 support NFS server in zone
NEX-15520 online NFS shares cause zoneadm halt to hang in nfs_export_zone_fini
Portions contributed by: Dan Kruchinin dan.kruchinin@nexenta.com
Portions contributed by: Stepan Zastupov stepan.zastupov@gmail.com
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
@@ -16,14 +16,19 @@
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
*/
+/*
+ * Copyright 2018 Nexenta Systems, Inc.
+ */
+
#include <sys/cred.h>
#include <sys/cmn_err.h>
#include <sys/debug.h>
#include <sys/systm.h>
#include <sys/kmem.h>
@@ -41,12 +46,10 @@
#include <nfs/nfs_log.h>
#define NUM_RECORDS_TO_WRITE 256
#define NUM_BYTES_TO_WRITE 65536
-extern krwlock_t exported_lock;
-
static int nfslog_num_records_to_write = NUM_RECORDS_TO_WRITE;
static int nfslog_num_bytes_to_write = NUM_BYTES_TO_WRITE;
/*
* This struct is used to 'hide' the details of managing the log
@@ -593,14 +596,11 @@
*
* nfslog_record_put() must be used to 'free' this record or allocation.
*/
/* ARGSUSED */
void *
-nfslog_record_alloc(
- struct exportinfo *exi,
- int alloc_indx,
- void **cookie,
+nfslog_record_alloc(struct exportinfo *exi, int alloc_indx, void **cookie,
int flags)
{
struct lr_alloc *lrp;
lrp = (struct lr_alloc *)
@@ -766,12 +766,12 @@
* Take care of writing the provided log record(s) to the log file.
* We group the log records with an iovec and use VOP_WRITE to append
* them to the end of the log file.
*/
static int
-nfslog_write_logrecords(struct log_file *lfp,
- struct lr_alloc *lrp_writers, int num_recs)
+nfslog_write_logrecords(struct log_file *lfp, struct lr_alloc *lrp_writers,
+ int num_recs)
{
struct uio uio;
struct iovec *iovp;
int size_iovecs;
vnode_t *vp;
@@ -1159,12 +1159,12 @@
kmem_free(tparams, sizeof (*tparams));
} else {
/*
* Do the work asynchronously
*/
- (void) thread_create(NULL, 0, nfslog_do_flush,
- tparams, 0, &p0, TS_RUN, minclsyspri);
+ (void) zthread_create(NULL, 0, nfslog_do_flush,
+ tparams, 0, minclsyspri);
}
return (error);
}
@@ -1247,12 +1247,11 @@
* no longer waiting for us.
* Free the thread arguments and exit.
*/
kmem_free(args->buff, args->buff_len);
kmem_free(tparams, sizeof (*tparams));
- thread_exit();
- /* NOTREACHED */
+ zthread_exit();
}
tparams->tp_error = error;
}
@@ -1527,10 +1526,11 @@
* multicomponent lookup and its semantics of crossing file system
* boundaries add to the complexity. See the comments below...
*/
struct exportinfo *
nfslog_get_exi(
+ nfs_export_t *ne,
struct exportinfo *exi,
struct svc_req *req,
caddr_t res,
unsigned int *nfslog_rec_id)
{
@@ -1558,11 +1558,11 @@
*/
exi_hold(exi);
return (exi);
}
- if (exi != exi_public)
+ if (exi != ne->exi_public)
return (NULL);
/*
* Here we have an exi that is not marked for logging.
* It is possible that this request is a multicomponent lookup
@@ -1762,21 +1762,21 @@
}
static char *
get_publicfh_path(int *alloc_length)
{
- extern struct exportinfo *exi_public;
char *pubpath;
+ nfs_export_t *ne = nfs_get_export();
- rw_enter(&exported_lock, RW_READER);
+ rw_enter(&ne->exported_lock, RW_READER);
- *alloc_length = exi_public->exi_export.ex_pathlen + 1;
+ *alloc_length = ne->exi_public->exi_export.ex_pathlen + 1;
pubpath = kmem_alloc(*alloc_length, KM_SLEEP);
- (void) strcpy(pubpath, exi_public->exi_export.ex_path);
+ (void) strcpy(pubpath, ne->exi_public->exi_export.ex_path);
- rw_exit(&exported_lock);
+ rw_exit(&ne->exported_lock);
return (pubpath);
}
static void
@@ -1868,14 +1868,11 @@
(caddr_t)exi, (caddr_t)&res, cr, &nb, 0, NFSLOG_ONE_BUFFER);
}
void
-nfslog_getfh(struct exportinfo *exi,
- fhandle *fh,
- char *fname,
- enum uio_seg seg,
+nfslog_getfh(struct exportinfo *exi, fhandle *fh, char *fname, enum uio_seg seg,
cred_t *cr)
{
struct svc_req req;
int res = 0;
struct netbuf nb = {0, 0, NULL};