|
Lines 1-5
Link Here
|
| 1 |
--- fuse_module/fuse.c.orig Wed Sep 27 15:49:47 2006 |
1 |
--- fuse_module/fuse.c.orig Thu May 3 13:26:34 2007 |
| 2 |
+++ fuse_module/fuse.c Wed Sep 27 15:52:02 2006 |
2 |
+++ fuse_module/fuse.c Thu May 3 13:26:03 2007 |
| 3 |
@@ -75,7 +75,7 @@ |
3 |
@@ -75,7 +75,7 @@ |
| 4 |
}; |
4 |
}; |
| 5 |
|
5 |
|
|
Lines 141-147
Link Here
|
| 141 |
static struct vop_vector fuse_germ_vnops; |
141 |
static struct vop_vector fuse_germ_vnops; |
| 142 |
#endif |
142 |
#endif |
| 143 |
|
143 |
|
| 144 |
@@ -2092,7 +2092,7 @@ |
144 |
@@ -2070,29 +2070,42 @@ |
|
|
145 |
M_WAITOK | M_ZERO); |
| 146 |
|
| 147 |
err = getnewvnode("fuse", mp, &fuse_vnops, &rvp); |
| 148 |
+ if (! err) { |
| 149 |
+ err = vn_lock(rvp, LK_EXCLUSIVE | LK_RETRY, td); |
| 150 |
+#if NEW_VNODES_ADJUSTED_MANUALLY |
| 151 |
+ if (err) |
| 152 |
+ printf("fuse4bsd: leaking vnode %p\n", rvp); |
| 153 |
+#endif |
| 154 |
+ } |
| 155 |
+ |
| 156 |
+ if (! err) { |
| 157 |
+ /* |
| 158 |
+ * FUSE_ROOT_ID as an inode number will be resolved directly. |
| 159 |
+ * without resorting to the vfs hashing mechanism, thus it also |
| 160 |
+ * can be inserted directly to the v_hash slot. |
| 161 |
+ */ |
| 162 |
+ rvp->v_hash = FUSE_ROOT_ID; |
| 163 |
+ fmnt->rvp = rvp; |
| 164 |
+ fuse_vnode_init(rvp, fvdat, FUSE_ROOT_ID, VNON); |
| 165 |
+ rvp->v_vflag |= VV_ROOT; |
| 166 |
+#if NEW_VNODES_ADJUSTED_MANUALLY |
| 167 |
+ err = insmntque(rvp, mp); |
| 168 |
+#endif |
| 169 |
+ } |
| 170 |
|
| 171 |
if (err) { |
| 172 |
fdata_kick_set(data); |
| 173 |
sx_xunlock(slock); |
| 174 |
FREE(fvdat, M_FUSEFS); |
| 175 |
goto out; |
| 176 |
- } |
| 177 |
- |
| 178 |
- /* |
| 179 |
- * FUSE_ROOT_ID as an inode number will be resolved directly. |
| 180 |
- * without resorting to the vfs hashing mechanism, thus it also |
| 181 |
- * can be inserted directly to the v_hash slot. |
| 182 |
- */ |
| 183 |
- rvp->v_hash = FUSE_ROOT_ID; |
| 184 |
- fmnt->rvp = rvp; |
| 185 |
- fuse_vnode_init(rvp, fvdat, FUSE_ROOT_ID, VNON); |
| 186 |
- rvp->v_vflag |= VV_ROOT; |
| 187 |
+ } else |
| 188 |
+ VOP_UNLOCK(rvp, 0, td); |
| 189 |
|
| 190 |
rootdone: |
| 145 |
|
191 |
|
| 146 |
if (! (fmnt->mntopts & FUSEFS_SECONDARY)) { |
192 |
if (! (fmnt->mntopts & FUSEFS_SECONDARY)) { |
| 147 |
data->mp = mp; |
193 |
data->mp = mp; |
|
Lines 150-156
Link Here
|
| 150 |
fmnt->mntopts &= ~FUSEFS_UNPRIVPROCDBG; |
196 |
fmnt->mntopts &= ~FUSEFS_UNPRIVPROCDBG; |
| 151 |
fmnt->mntopts |= get_unprivileged_proc_debug(td) ? FUSEFS_UNPRIVPROCDBG : 0; |
197 |
fmnt->mntopts |= get_unprivileged_proc_debug(td) ? FUSEFS_UNPRIVPROCDBG : 0; |
| 152 |
#endif |
198 |
#endif |
| 153 |
@@ -2380,7 +2380,7 @@ |
199 |
@@ -2380,7 +2393,7 @@ |
| 154 |
return (0); |
200 |
return (0); |
| 155 |
} |
201 |
} |
| 156 |
|
202 |
|
|
Lines 159-165
Link Here
|
| 159 |
/* |
205 |
/* |
| 160 |
* Vnode comparison function with which the given vnode always |
206 |
* Vnode comparison function with which the given vnode always |
| 161 |
* gets inserted, but got marked invalid upon a clash. Caller |
207 |
* gets inserted, but got marked invalid upon a clash. Caller |
| 162 |
@@ -2654,7 +2654,7 @@ |
208 |
@@ -2405,11 +2418,11 @@ |
|
|
209 |
fuse_vget_i(struct mount *mp, struct thread *td, uint64_t nodeid, |
| 210 |
enum vtype vtyp, struct vnode **vpp, int wantnew) |
| 211 |
{ |
| 212 |
+#define myflags LK_EXCLUSIVE | LK_RETRY |
| 213 |
int err = 0; |
| 214 |
struct fuse_mnt_data *fmnt; |
| 215 |
struct fuse_vnode_data *fvdat; |
| 216 |
struct vnode *vp2; |
| 217 |
- int myflags = LK_EXCLUSIVE; |
| 218 |
|
| 219 |
DEBUG2G("mp %p: %s\n", mp, mp->mnt_stat.f_mntfromname); |
| 220 |
DEBUG("been asked for vno #%llu\n", (unsigned long long)nodeid); |
| 221 |
@@ -2470,6 +2483,18 @@ |
| 222 |
return (err); |
| 223 |
} |
| 224 |
|
| 225 |
+#if NEW_VNODES_ADJUSTED_MANUALLY |
| 226 |
+ err = vn_lock(*vpp, myflags, td); |
| 227 |
+ if (err) |
| 228 |
+ printf("fuse4bsd: leaking vnode %p\n", *vpp); |
| 229 |
+ else |
| 230 |
+ err = insmntque(*vpp, mp); |
| 231 |
+ if (err) { |
| 232 |
+ free(fvdat, M_FUSEFS); |
| 233 |
+ return (err); |
| 234 |
+ } |
| 235 |
+#endif |
| 236 |
+ |
| 237 |
/* |
| 238 |
* There is no harm in fully initializing the vnode before trying |
| 239 |
* at insertion, because vnodes are gc-d anyway. For the same reason, |
| 240 |
@@ -2504,6 +2529,7 @@ |
| 241 |
vn_printf(*vpp, " * "); |
| 242 |
#endif |
| 243 |
return (err); |
| 244 |
+#undef myflags |
| 245 |
} |
| 246 |
|
| 247 |
|
| 248 |
@@ -2654,7 +2680,7 @@ |
| 163 |
|
249 |
|
| 164 |
fuse_filehandle_gc(vp, td, NULL); |
250 |
fuse_filehandle_gc(vp, td, NULL); |
| 165 |
|
251 |
|
|
Lines 168-174
Link Here
|
| 168 |
/* |
254 |
/* |
| 169 |
* Dropping vnodes when they are not in use would mean that |
255 |
* Dropping vnodes when they are not in use would mean that |
| 170 |
* the respective inode must be freed on the daemon's side |
256 |
* the respective inode must be freed on the daemon's side |
| 171 |
@@ -2751,7 +2751,7 @@ |
257 |
@@ -2751,7 +2777,7 @@ |
| 172 |
int denied; |
258 |
int denied; |
| 173 |
|
259 |
|
| 174 |
if ((denied = cr_candebug( |
260 |
if ((denied = cr_candebug( |
|
Lines 177-183
Link Here
|
| 177 |
get_unprivileged_proc_debug(td), |
263 |
get_unprivileged_proc_debug(td), |
| 178 |
#else |
264 |
#else |
| 179 |
fmnt->mntopts & FUSEFS_UNPRIVPROCDBG, |
265 |
fmnt->mntopts & FUSEFS_UNPRIVPROCDBG, |
| 180 |
@@ -2948,7 +2948,7 @@ |
266 |
@@ -2948,7 +2974,7 @@ |
| 181 |
|
267 |
|
| 182 |
} else { |
268 |
} else { |
| 183 |
struct sx *devlock = fdi.slock; |
269 |
struct sx *devlock = fdi.slock; |
|
Lines 186-192
Link Here
|
| 186 |
struct fuse_access_in *fai; |
272 |
struct fuse_access_in *fai; |
| 187 |
|
273 |
|
| 188 |
if (! (facp->facc_flags & FACCESS_DO_ACCESS)) |
274 |
if (! (facp->facc_flags & FACCESS_DO_ACCESS)) |
| 189 |
@@ -3056,7 +3056,7 @@ |
275 |
@@ -3056,7 +3082,7 @@ |
| 190 |
|
276 |
|
| 191 |
bzero(&facp, sizeof(facp)); |
277 |
bzero(&facp, sizeof(facp)); |
| 192 |
if ( |
278 |
if ( |
|
Lines 195-201
Link Here
|
| 195 |
1 |
281 |
1 |
| 196 |
#else |
282 |
#else |
| 197 |
dvp->v_vflag & VV_ROOT |
283 |
dvp->v_vflag & VV_ROOT |
| 198 |
@@ -3281,8 +3281,12 @@ |
284 |
@@ -3281,8 +3307,12 @@ |
| 199 |
DEBUG("we peacefully found that file\n"); |
285 |
DEBUG("we peacefully found that file\n"); |
| 200 |
|
286 |
|
| 201 |
if (flags & ISDOTDOT) { |
287 |
if (flags & ISDOTDOT) { |
|
Lines 209-215
Link Here
|
| 209 |
*vpp = pdp; |
295 |
*vpp = pdp; |
| 210 |
} else if (nid == VTOI(dvp)) { |
296 |
} else if (nid == VTOI(dvp)) { |
| 211 |
VREF(dvp); /* We want ourself, ie "." */ |
297 |
VREF(dvp); /* We want ourself, ie "." */ |
| 212 |
@@ -3347,7 +3351,7 @@ |
298 |
@@ -3347,7 +3377,7 @@ |
| 213 |
if (islastcn && flags & ISOPEN) |
299 |
if (islastcn && flags & ISOPEN) |
| 214 |
((struct fuse_vnode_data *)(*vpp)->v_data)->flags |= FVP_ACCESS_NOOP; |
300 |
((struct fuse_vnode_data *)(*vpp)->v_data)->flags |= FVP_ACCESS_NOOP; |
| 215 |
|
301 |
|
|
Lines 218-224
Link Here
|
| 218 |
if (! islastcn) { |
304 |
if (! islastcn) { |
| 219 |
/* We have the attributes of the next item |
305 |
/* We have the attributes of the next item |
| 220 |
* *now*, and it's a fact, and we do not have |
306 |
* *now*, and it's a fact, and we do not have |
| 221 |
@@ -3486,7 +3490,7 @@ |
307 |
@@ -3486,7 +3516,7 @@ |
| 222 |
return (0); |
308 |
return (0); |
| 223 |
} |
309 |
} |
| 224 |
|
310 |
|
|
Lines 227-233
Link Here
|
| 227 |
static __inline int |
313 |
static __inline int |
| 228 |
create_filehandle(struct vnode *vp, struct thread *td, struct ucred *cred, |
314 |
create_filehandle(struct vnode *vp, struct thread *td, struct ucred *cred, |
| 229 |
int mode, struct fuse_dispatcher *fdip) |
315 |
int mode, struct fuse_dispatcher *fdip) |
| 230 |
@@ -3643,7 +3647,7 @@ |
316 |
@@ -3567,7 +3597,20 @@ |
|
|
317 |
bzero(fvdat, sizeof(*fvdat)); |
| 318 |
fuse_vnode_init(vp, fvdat, feo->nodeid, VREG); |
| 319 |
vp->v_op = &fuse_vnops; |
| 320 |
+#if NEW_VNODES_ADJUSTED_MANUALLY |
| 321 |
+ { |
| 322 |
+ struct mount *mp = vp->v_mount; |
| 323 |
+ |
| 324 |
+ vp->v_mount = NULL; |
| 325 |
+ err = insmntque(vp, mp); |
| 326 |
+ if (err) { |
| 327 |
+ free(fvdat, M_FUSEFS); |
| 328 |
+ return (err); |
| 329 |
+ } |
| 330 |
+ } |
| 331 |
+#else |
| 332 |
VOP_UNLOCK(vp, 0, td); |
| 333 |
+#endif |
| 334 |
/* |
| 335 |
* We can't let the vnode being vput() here, the caller wants |
| 336 |
* that do by herself. |
| 337 |
@@ -3643,7 +3686,7 @@ |
| 231 |
* the vnode... if the vnode is a germ, it will be tried to be initialized |
338 |
* the vnode... if the vnode is a germ, it will be tried to be initialized |
| 232 |
* via a dedicated method, but from that on we go on as usual.) |
339 |
* via a dedicated method, but from that on we go on as usual.) |
| 233 |
*/ |
340 |
*/ |
|
Lines 236-242
Link Here
|
| 236 |
if (vp->v_op == &fuse_germ_vnops) { |
343 |
if (vp->v_op == &fuse_germ_vnops) { |
| 237 |
KASSERT(gefhp, ("create_filehandle called without get_filehandle_param")); |
344 |
KASSERT(gefhp, ("create_filehandle called without get_filehandle_param")); |
| 238 |
gone_create = 1; |
345 |
gone_create = 1; |
| 239 |
@@ -3709,7 +3713,7 @@ |
346 |
@@ -3709,7 +3752,7 @@ |
| 240 |
if ((err = fdisp_wait_answ(&fdi))) |
347 |
if ((err = fdisp_wait_answ(&fdi))) |
| 241 |
goto out; |
348 |
goto out; |
| 242 |
|
349 |
|
|
Lines 245-251
Link Here
|
| 245 |
setup_filehandle: |
352 |
setup_filehandle: |
| 246 |
#endif |
353 |
#endif |
| 247 |
foo = fdi.answ; |
354 |
foo = fdi.answ; |
| 248 |
@@ -4184,7 +4188,7 @@ |
355 |
@@ -4184,7 +4227,7 @@ |
| 249 |
#define BSD_FUSE_PAGENO_BOUND MIN(FUSE_MAX_PAGES_PER_REQ, MAXBSIZE / PAGE_SIZE) |
356 |
#define BSD_FUSE_PAGENO_BOUND MIN(FUSE_MAX_PAGES_PER_REQ, MAXBSIZE / PAGE_SIZE) |
| 250 |
|
357 |
|
| 251 |
bcount = MIN(MAXBSIZE, biosize * BSD_FUSE_PAGENO_BOUND); |
358 |
bcount = MIN(MAXBSIZE, biosize * BSD_FUSE_PAGENO_BOUND); |
|
Lines 254-269
Link Here
|
| 254 |
if (vp->v_type != VDIR) { |
361 |
if (vp->v_type != VDIR) { |
| 255 |
/* |
362 |
/* |
| 256 |
* for directories we can't predict the size, in fact |
363 |
* for directories we can't predict the size, in fact |
| 257 |
@@ -4493,7 +4497,7 @@ |
364 |
@@ -4215,11 +4258,9 @@ |
|
|
365 |
#if _DEBUG |
| 366 |
prettyprint(bp->b_data, 48); |
| 367 |
printf("\n"); |
| 368 |
-#if ZERO_PAD_INCOMPLETE_BUFS |
| 369 |
prettyprint(bp->b_data + PAGE_SIZE, 48); |
| 370 |
printf("\n"); |
| 371 |
#endif |
| 372 |
-#endif |
| 373 |
if (err) { |
| 374 |
brelse(bp); |
| 375 |
return (err); |
| 376 |
@@ -4493,13 +4534,6 @@ |
| 258 |
break; |
377 |
break; |
| 259 |
} |
378 |
} |
| 260 |
|
379 |
|
| 261 |
-#if ZERO_PAD_INCOMPLETE_BUFS |
380 |
-#if ZERO_PAD_INCOMPLETE_BUFS |
| 262 |
+#ifdef ZERO_PAD_INCOMPLETE_BUFS |
381 |
- if (isbzero(buf), FUSE_NAME_OFFSET) { |
| 263 |
if (isbzero(buf), FUSE_NAME_OFFSET) { |
382 |
- err = -1; |
| 264 |
err = -1; |
383 |
- break; |
| 265 |
break; |
384 |
- } |
| 266 |
@@ -4658,7 +4662,7 @@ |
385 |
-#endif |
|
|
386 |
- |
| 387 |
/* Sanity checks */ |
| 388 |
|
| 389 |
if (!fudge->namelen || fudge->namelen > MAXNAMLEN) { |
| 390 |
@@ -4658,7 +4692,7 @@ |
| 267 |
struct vnode *dvp = ap->a_dvp; |
391 |
struct vnode *dvp = ap->a_dvp; |
| 268 |
struct vnode **vpp = ap->a_vpp; |
392 |
struct vnode **vpp = ap->a_vpp; |
| 269 |
struct vattr *vap = ap->a_vap; |
393 |
struct vattr *vap = ap->a_vap; |
|
Lines 272-278
Link Here
|
| 272 |
struct fuse_dispatcher fdi; |
396 |
struct fuse_dispatcher fdi; |
| 273 |
struct fuse_vnode_data *fvdat; |
397 |
struct fuse_vnode_data *fvdat; |
| 274 |
int err; |
398 |
int err; |
| 275 |
@@ -4949,7 +4953,7 @@ |
399 |
@@ -4683,8 +4717,12 @@ |
|
|
400 |
if ((err = getnewvnode("fuse", dvp->v_mount, &fuse_vnops, vpp))) |
| 401 |
return (err); |
| 402 |
|
| 403 |
- if ((err = vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curthread))) |
| 404 |
+ if ((err = vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curthread))) { |
| 405 |
+#if NEW_VNODES_ADJUSTED_MANUALLY |
| 406 |
+ printf("fuse4bsd: leaking vnode %p\n", *vpp); |
| 407 |
+#endif |
| 408 |
return (err); |
| 409 |
+ } |
| 410 |
|
| 411 |
MALLOC(fvdat, struct fuse_vnode_data *, sizeof(*fvdat), M_FUSEFS, |
| 412 |
M_WAITOK | M_ZERO); |
| 413 |
@@ -4704,6 +4742,9 @@ |
| 414 |
*/ |
| 415 |
(*vpp)->v_op = &fuse_germ_vnops; |
| 416 |
(*vpp)->v_data = fvdat; |
| 417 |
+#if NEW_VNODES_ADJUSTED_MANUALLY |
| 418 |
+ (*vpp)->v_mount = dvp->v_mount; |
| 419 |
+#endif |
| 420 |
|
| 421 |
return (0); |
| 422 |
|
| 423 |
@@ -4949,7 +4990,7 @@ |
| 276 |
if (err) |
424 |
if (err) |
| 277 |
goto out; |
425 |
goto out; |
| 278 |
|
426 |
|
|
Lines 281-287
Link Here
|
| 281 |
if (doingdirectory && fdvp != tdvp) { |
429 |
if (doingdirectory && fdvp != tdvp) { |
| 282 |
/* |
430 |
/* |
| 283 |
* Check for pathname conflict. |
431 |
* Check for pathname conflict. |
| 284 |
@@ -5396,7 +5400,6 @@ |
432 |
@@ -5396,7 +5437,6 @@ |
| 285 |
struct vnode *vp = fioda->vp; |
433 |
struct vnode *vp = fioda->vp; |
| 286 |
struct uio *uio = fioda->uio; |
434 |
struct uio *uio = fioda->uio; |
| 287 |
struct ucred *cred = fioda->cred; |
435 |
struct ucred *cred = fioda->cred; |
|
Lines 289-295
Link Here
|
| 289 |
|
437 |
|
| 290 |
int biosize; |
438 |
int biosize; |
| 291 |
|
439 |
|
| 292 |
@@ -5506,7 +5509,7 @@ |
440 |
@@ -5506,7 +5546,7 @@ |
| 293 |
if ((bp->b_flags & B_CACHE) == 0) { |
441 |
if ((bp->b_flags & B_CACHE) == 0) { |
| 294 |
bp->b_iocmd = BIO_READ; |
442 |
bp->b_iocmd = BIO_READ; |
| 295 |
vfs_busy_pages(bp, 0); |
443 |
vfs_busy_pages(bp, 0); |
|
Lines 298-313
Link Here
|
| 298 |
if ((err = bp->b_error)) { |
446 |
if ((err = bp->b_error)) { |
| 299 |
brelse(bp); |
447 |
brelse(bp); |
| 300 |
break; |
448 |
break; |
| 301 |
@@ -5741,7 +5744,7 @@ |
449 |
@@ -5741,23 +5781,16 @@ |
| 302 |
chunksize, (long long unsigned)fri->offset, respsize); |
450 |
chunksize, (long long unsigned)fri->offset, respsize); |
| 303 |
|
451 |
|
| 304 |
if (respsize < chunksize) { |
452 |
if (respsize < chunksize) { |
| 305 |
-#if ZERO_PAD_INCOMPLETE_BUFS |
453 |
-#if ZERO_PAD_INCOMPLETE_BUFS |
| 306 |
+#ifdef ZERO_PAD_INCOMPLETE_BUFS |
|
|
| 307 |
/* |
454 |
/* |
| 308 |
* "if we don't get enough data, just fill the |
455 |
- * "if we don't get enough data, just fill the |
| 309 |
* rest with zeros." |
456 |
- * rest with zeros." |
| 310 |
@@ -5888,7 +5891,7 @@ |
457 |
- * in nfs context this means a hole in the |
|
|
458 |
- * file, I don't know what to do with this |
| 459 |
- * here... [we just get a buch of zeroes |
| 460 |
- * instead of EOF, baaad] |
| 461 |
+ * if we don't get enough data, just fill the |
| 462 |
+ * rest with zeros. |
| 463 |
*/ |
| 464 |
DEBUG("zeroing tail of %ld bytes\n", |
| 465 |
bp->b_resid); |
| 466 |
bzero((char *)bp->b_data + bp->b_bcount - bp->b_resid, |
| 467 |
bp->b_resid); |
| 468 |
- bp->b_resid = 0; |
| 469 |
-#else |
| 470 |
+ |
| 471 |
break; |
| 472 |
-#endif |
| 473 |
} |
| 474 |
ticket_refresh(fdi.tick); |
| 475 |
DEBUG("bp->b_data %p\n", bp->b_data); |
| 476 |
@@ -5888,7 +5921,7 @@ |
| 311 |
"vp=%p, rc=%d", bp, vp, rc)); |
477 |
"vp=%p, rc=%d", bp, vp, rc)); |
| 312 |
} |
478 |
} |
| 313 |
|
479 |
|
|
Lines 316-322
Link Here
|
| 316 |
static int |
482 |
static int |
| 317 |
fuse_germ_access(struct vop_access_args *ap) |
483 |
fuse_germ_access(struct vop_access_args *ap) |
| 318 |
{ |
484 |
{ |
| 319 |
@@ -5908,7 +5911,7 @@ |
485 |
@@ -5908,7 +5941,7 @@ |
| 320 |
|
486 |
|
| 321 |
/* Modeled after tunclone() of net/if_tun.c |
487 |
/* Modeled after tunclone() of net/if_tun.c |
| 322 |
*/ |
488 |
*/ |
|
Lines 325-331
Link Here
|
| 325 |
static void |
491 |
static void |
| 326 |
fusedev_clone(void *arg, char *name, int namelen, struct cdev **dev) |
492 |
fusedev_clone(void *arg, char *name, int namelen, struct cdev **dev) |
| 327 |
#else |
493 |
#else |
| 328 |
@@ -6019,7 +6022,7 @@ |
494 |
@@ -6019,7 +6052,7 @@ |
| 329 |
fuse_fileops.fo_close = fuse_close_f; |
495 |
fuse_fileops.fo_close = fuse_close_f; |
| 330 |
fuse_fileops.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE; |
496 |
fuse_fileops.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE; |
| 331 |
|
497 |
|