82 */
83 typedef struct nfs_srv {
84 kmutex_t async_write_lock;
85 struct rfs_async_write_list *async_write_head;
86
87 /*
88 * enables write clustering if == 1
89 */
90 int write_async;
91 } nfs_srv_t;
92
93 /*
94 * These are the interface routines for the server side of the
95 * Network File System. See the NFS version 2 protocol specification
96 * for a description of this interface.
97 */
98
99 static int sattr_to_vattr(struct nfssattr *, struct vattr *);
100 static void acl_perm(struct vnode *, struct exportinfo *, struct vattr *,
101 cred_t *);
102 static void *rfs_zone_init(zoneid_t zoneid);
103 static void rfs_zone_fini(zoneid_t zoneid, void *data);
104
105
106 /*
107 * Some "over the wire" UNIX file types. These are encoded
108 * into the mode. This needs to be fixed in the next rev.
109 */
110 #define IFMT 0170000 /* type of file */
111 #define IFCHR 0020000 /* character special */
112 #define IFBLK 0060000 /* block special */
113 #define IFSOCK 0140000 /* socket */
114
115 u_longlong_t nfs2_srv_caller_id;
116 static zone_key_t rfs_zone_key;
117
118 /*
119 * Get file attributes.
120 * Returns the current attributes of the file with the given fhandle.
121 */
122 /* ARGSUSED */
123 void
124 rfs_getattr(fhandle_t *fhp, struct nfsattrstat *ns, struct exportinfo *exi,
125 struct svc_req *req, cred_t *cr, bool_t ro)
126 {
127 int error;
128 vnode_t *vp;
129 struct vattr va;
130
131 vp = nfs_fhtovp(fhp, exi);
132 if (vp == NULL) {
133 ns->ns_status = NFSERR_STALE;
134 return;
135 }
136
137 /*
1298 struct rfs_async_write *trp;
1299 struct rfs_async_write *lrp;
1300 int data_written;
1301 int iovcnt;
1302 mblk_t *m;
1303 struct iovec *iovp;
1304 struct iovec *niovp;
1305 struct iovec iov[MAXCLIOVECS];
1306 int count;
1307 int rcount;
1308 uint_t off;
1309 uint_t len;
1310 struct rfs_async_write nrpsp;
1311 struct rfs_async_write_list nlpsp;
1312 ushort_t t_flag;
1313 cred_t *savecred;
1314 int in_crit = 0;
1315 caller_context_t ct;
1316 nfs_srv_t *nsrv;
1317
1318 ASSERT3P(curzone, ==, ((exi == NULL) ? curzone : exi->exi_zone));
1319 nsrv = zone_getspecific(rfs_zone_key, curzone);
1320 if (!nsrv->write_async) {
1321 rfs_write_sync(wa, ns, exi, req, cr, ro);
1322 return;
1323 }
1324
1325 /*
1326 * Initialize status to RFSWRITE_INITVAL instead of 0, since value of 0
1327 * is considered an OK.
1328 */
1329 ns->ns_status = RFSWRITE_INITVAL;
1330
1331 nrp = &nrpsp;
1332 nrp->wa = wa;
1333 nrp->ns = ns;
1334 nrp->req = req;
1335 nrp->cr = cr;
1336 nrp->ro = ro;
1337 nrp->thread = curthread;
1338
1339 ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
3086 break;
3087 default:
3088 break;
3089 }
3090 }
3091 }
3092 /* copy to va */
3093 va->va_mode &= ~077;
3094 va->va_mode |= grp_perm | other_perm;
3095 }
3096 if (vsa.vsa_aclcnt)
3097 kmem_free(vsa.vsa_aclentp,
3098 vsa.vsa_aclcnt * sizeof (aclent_t));
3099 }
3100 }
3101
3102 void
3103 rfs_srvrinit(void)
3104 {
3105 nfs2_srv_caller_id = fs_new_caller_id();
3106 zone_key_create(&rfs_zone_key, rfs_zone_init, NULL, rfs_zone_fini);
3107 }
3108
3109 void
3110 rfs_srvrfini(void)
3111 {
3112 }
3113
3114 /* ARGSUSED */
3115 static void *
3116 rfs_zone_init(zoneid_t zoneid)
3117 {
3118 nfs_srv_t *ns;
3119
3120 ns = kmem_zalloc(sizeof (*ns), KM_SLEEP);
3121
3122 mutex_init(&ns->async_write_lock, NULL, MUTEX_DEFAULT, NULL);
3123 ns->write_async = 1;
3124
3125 return (ns);
3126 }
3127
3128 /* ARGSUSED */
3129 static void
3130 rfs_zone_fini(zoneid_t zoneid, void *data)
3131 {
3132 nfs_srv_t *ns;
3133
3134 ns = (nfs_srv_t *)data;
3135 mutex_destroy(&ns->async_write_lock);
3136 kmem_free(ns, sizeof (*ns));
3137 }
3138
3139 static int
3140 rdma_setup_read_data2(struct nfsreadargs *ra, struct nfsrdresult *rr)
3141 {
3142 struct clist *wcl;
3143 int wlist_len;
3144 uint32_t count = rr->rr_count;
3145
3146 wcl = ra->ra_wlist;
3147
3148 if (rdma_setup_read_chunks(wcl, count, &wlist_len) == FALSE) {
3149 return (FALSE);
3150 }
3151
3152 wcl = ra->ra_wlist;
3153 rr->rr_ok.rrok_wlist_len = wlist_len;
3154 rr->rr_ok.rrok_wlist = wcl;
|
82 */
83 typedef struct nfs_srv {
84 kmutex_t async_write_lock;
85 struct rfs_async_write_list *async_write_head;
86
87 /*
88 * enables write clustering if == 1
89 */
90 int write_async;
91 } nfs_srv_t;
92
93 /*
94 * These are the interface routines for the server side of the
95 * Network File System. See the NFS version 2 protocol specification
96 * for a description of this interface.
97 */
98
99 static int sattr_to_vattr(struct nfssattr *, struct vattr *);
100 static void acl_perm(struct vnode *, struct exportinfo *, struct vattr *,
101 cred_t *);
102
103
104 /*
105 * Some "over the wire" UNIX file types. These are encoded
106 * into the mode. This needs to be fixed in the next rev.
107 */
108 #define IFMT 0170000 /* type of file */
109 #define IFCHR 0020000 /* character special */
110 #define IFBLK 0060000 /* block special */
111 #define IFSOCK 0140000 /* socket */
112
113 u_longlong_t nfs2_srv_caller_id;
114
115 static nfs_srv_t *
116 nfs_get_srv(void)
117 {
118 nfs_globals_t *ng = zone_getspecific(nfssrv_zone_key, curzone);
119 nfs_srv_t *srv = ng->nfs_srv;
120 ASSERT(srv != NULL);
121 return (srv);
122 }
123
124 /*
125 * Get file attributes.
126 * Returns the current attributes of the file with the given fhandle.
127 */
128 /* ARGSUSED */
129 void
130 rfs_getattr(fhandle_t *fhp, struct nfsattrstat *ns, struct exportinfo *exi,
131 struct svc_req *req, cred_t *cr, bool_t ro)
132 {
133 int error;
134 vnode_t *vp;
135 struct vattr va;
136
137 vp = nfs_fhtovp(fhp, exi);
138 if (vp == NULL) {
139 ns->ns_status = NFSERR_STALE;
140 return;
141 }
142
143 /*
1304 struct rfs_async_write *trp;
1305 struct rfs_async_write *lrp;
1306 int data_written;
1307 int iovcnt;
1308 mblk_t *m;
1309 struct iovec *iovp;
1310 struct iovec *niovp;
1311 struct iovec iov[MAXCLIOVECS];
1312 int count;
1313 int rcount;
1314 uint_t off;
1315 uint_t len;
1316 struct rfs_async_write nrpsp;
1317 struct rfs_async_write_list nlpsp;
1318 ushort_t t_flag;
1319 cred_t *savecred;
1320 int in_crit = 0;
1321 caller_context_t ct;
1322 nfs_srv_t *nsrv;
1323
1324 ASSERT(exi == NULL || exi->exi_zoneid == curzone->zone_id);
1325 nsrv = nfs_get_srv();
1326 if (!nsrv->write_async) {
1327 rfs_write_sync(wa, ns, exi, req, cr, ro);
1328 return;
1329 }
1330
1331 /*
1332 * Initialize status to RFSWRITE_INITVAL instead of 0, since value of 0
1333 * is considered an OK.
1334 */
1335 ns->ns_status = RFSWRITE_INITVAL;
1336
1337 nrp = &nrpsp;
1338 nrp->wa = wa;
1339 nrp->ns = ns;
1340 nrp->req = req;
1341 nrp->cr = cr;
1342 nrp->ro = ro;
1343 nrp->thread = curthread;
1344
1345 ASSERT(curthread->t_schedflag & TS_DONT_SWAP);
3092 break;
3093 default:
3094 break;
3095 }
3096 }
3097 }
3098 /* copy to va */
3099 va->va_mode &= ~077;
3100 va->va_mode |= grp_perm | other_perm;
3101 }
3102 if (vsa.vsa_aclcnt)
3103 kmem_free(vsa.vsa_aclentp,
3104 vsa.vsa_aclcnt * sizeof (aclent_t));
3105 }
3106 }
3107
3108 void
3109 rfs_srvrinit(void)
3110 {
3111 nfs2_srv_caller_id = fs_new_caller_id();
3112 }
3113
3114 void
3115 rfs_srvrfini(void)
3116 {
3117 }
3118
3119 /* ARGSUSED */
3120 void
3121 rfs_srv_zone_init(nfs_globals_t *ng)
3122 {
3123 nfs_srv_t *ns;
3124
3125 ns = kmem_zalloc(sizeof (*ns), KM_SLEEP);
3126
3127 mutex_init(&ns->async_write_lock, NULL, MUTEX_DEFAULT, NULL);
3128 ns->write_async = 1;
3129
3130 ng->nfs_srv = ns;
3131 }
3132
3133 /* ARGSUSED */
3134 void
3135 rfs_srv_zone_fini(nfs_globals_t *ng)
3136 {
3137 nfs_srv_t *ns = ng->nfs_srv;
3138
3139 ng->nfs_srv = NULL;
3140
3141 mutex_destroy(&ns->async_write_lock);
3142 kmem_free(ns, sizeof (*ns));
3143 }
3144
3145 static int
3146 rdma_setup_read_data2(struct nfsreadargs *ra, struct nfsrdresult *rr)
3147 {
3148 struct clist *wcl;
3149 int wlist_len;
3150 uint32_t count = rr->rr_count;
3151
3152 wcl = ra->ra_wlist;
3153
3154 if (rdma_setup_read_chunks(wcl, count, &wlist_len) == FALSE) {
3155 return (FALSE);
3156 }
3157
3158 wcl = ra->ra_wlist;
3159 rr->rr_ok.rrok_wlist_len = wlist_len;
3160 rr->rr_ok.rrok_wlist = wcl;
|