Lines 32-37
Link Here
|
32 |
#include <sys/types.h> |
32 |
#include <sys/types.h> |
33 |
#include <sys/systm.h> |
33 |
#include <sys/systm.h> |
34 |
#include <sys/namei.h> |
34 |
#include <sys/namei.h> |
|
|
35 |
#include <sys/proc.h> |
35 |
#include <sys/kernel.h> |
36 |
#include <sys/kernel.h> |
36 |
#include <sys/vnode.h> |
37 |
#include <sys/vnode.h> |
37 |
#include <sys/mount.h> |
38 |
#include <sys/mount.h> |
Lines 41-46
Link Here
|
41 |
#include <sys/malloc.h> |
42 |
#include <sys/malloc.h> |
42 |
#include <sys/lock.h> |
43 |
#include <sys/lock.h> |
43 |
#include <sys/iconv.h> |
44 |
#include <sys/iconv.h> |
|
|
45 |
#include <sys/condvar.h> |
46 |
#include <sys/sx.h> |
44 |
|
47 |
|
45 |
/* #define NTFS_DEBUG 1 */ |
48 |
/* #define NTFS_DEBUG 1 */ |
46 |
#include <fs/ntfs/ntfs.h> |
49 |
#include <fs/ntfs/ntfs.h> |
Lines 65-71
Link Here
|
65 |
* ntfs mount, freed upon last ntfs umount */ |
68 |
* ntfs mount, freed upon last ntfs umount */ |
66 |
static wchar *ntfs_toupper_tab; |
69 |
static wchar *ntfs_toupper_tab; |
67 |
#define NTFS_TOUPPER(ch) (ntfs_toupper_tab[(ch)]) |
70 |
#define NTFS_TOUPPER(ch) (ntfs_toupper_tab[(ch)]) |
68 |
static struct lock ntfs_toupper_lock; |
71 |
static struct sx ntfs_toupper_lock_sx; |
69 |
static signed int ntfs_toupper_usecount; |
72 |
static signed int ntfs_toupper_usecount; |
70 |
|
73 |
|
71 |
struct iconv_functions *ntfs_iconv = NULL; |
74 |
struct iconv_functions *ntfs_iconv = NULL; |
Lines 358-364
Link Here
|
358 |
|
361 |
|
359 |
mtx_lock(&ip->i_interlock); |
362 |
mtx_lock(&ip->i_interlock); |
360 |
ip->i_usecount++; |
363 |
ip->i_usecount++; |
361 |
lockmgr(&ip->i_lock, LK_EXCLUSIVE | LK_INTERLOCK, &ip->i_interlock); |
364 |
while (ip->i_busy != 0) { |
|
|
365 |
cv_wait(&ip->i_lock, &ip->i_interlock); |
366 |
} |
367 |
ip->i_busy = 1; |
368 |
mtx_unlock(&ip->i_interlock); |
362 |
|
369 |
|
363 |
return 0; |
370 |
return 0; |
364 |
} |
371 |
} |
Lines 380-400
Link Here
|
380 |
|
387 |
|
381 |
dprintf(("ntfs_ntlookup: looking for ntnode %d\n", ino)); |
388 |
dprintf(("ntfs_ntlookup: looking for ntnode %d\n", ino)); |
382 |
|
389 |
|
383 |
do { |
390 |
*ipp = ntfs_nthashlookup(ntmp->ntm_devvp->v_rdev, ino); |
384 |
ip = ntfs_nthashlookup(ntmp->ntm_devvp->v_rdev, ino); |
391 |
if (*ipp != NULL) { |
385 |
if (ip != NULL) { |
392 |
ntfs_ntget(*ipp); |
386 |
ntfs_ntget(ip); |
393 |
dprintf(("ntfs_ntlookup: ntnode %d: %p, usecount: %d\n", |
387 |
dprintf(("ntfs_ntlookup: ntnode %d: %p, usecount: %d\n", |
394 |
ino, ipp, (*ipp)->i_usecount)); |
388 |
ino, ip, ip->i_usecount)); |
395 |
return (0); |
389 |
*ipp = ip; |
396 |
} |
390 |
return (0); |
|
|
391 |
} |
392 |
} while (lockmgr(&ntfs_hashlock, LK_EXCLUSIVE | LK_SLEEPFAIL, NULL)); |
393 |
|
397 |
|
394 |
MALLOC(ip, struct ntnode *, sizeof(struct ntnode), M_NTFSNTNODE, |
398 |
MALLOC(ip, struct ntnode *, sizeof(struct ntnode), M_NTFSNTNODE, |
395 |
M_WAITOK | M_ZERO); |
399 |
M_WAITOK | M_ZERO); |
396 |
ddprintf(("ntfs_ntlookup: allocating ntnode: %d: %p\n", ino, ip)); |
400 |
ddprintf(("ntfs_ntlookup: allocating ntnode: %d: %p\n", ino, ip)); |
397 |
|
401 |
|
|
|
402 |
mtx_lock(&ntfs_hashlock_mtx); |
403 |
*ipp = ntfs_nthashlookup(ntmp->ntm_devvp->v_rdev, ino); |
404 |
if (*ipp != NULL) { |
405 |
mtx_unlock(&ntfs_hashlock_mtx); |
406 |
ntfs_ntget(*ipp); |
407 |
FREE(ip, M_NTFSNTNODE); |
408 |
dprintf(("ntfs_ntlookup: ntnode %d: %p, usecount: %d\n", |
409 |
ino, ipp, (*ipp)->i_usecount)); |
410 |
return (0); |
411 |
} |
412 |
|
398 |
/* Generic initialization */ |
413 |
/* Generic initialization */ |
399 |
ip->i_devvp = ntmp->ntm_devvp; |
414 |
ip->i_devvp = ntmp->ntm_devvp; |
400 |
ip->i_dev = ntmp->ntm_devvp->v_rdev; |
415 |
ip->i_dev = ntmp->ntm_devvp->v_rdev; |
Lines 405-417
Link Here
|
405 |
VREF(ip->i_devvp); |
420 |
VREF(ip->i_devvp); |
406 |
|
421 |
|
407 |
/* init lock and lock the newborn ntnode */ |
422 |
/* init lock and lock the newborn ntnode */ |
408 |
lockinit(&ip->i_lock, PINOD, "ntnode", 0, LK_EXCLUSIVE); |
423 |
cv_init(&ip->i_lock, "ntfslk"); |
409 |
mtx_init(&ip->i_interlock, "ntnode interlock", NULL, MTX_DEF); |
424 |
mtx_init(&ip->i_interlock, "ntnode interlock", NULL, MTX_DEF); |
410 |
ntfs_ntget(ip); |
425 |
ntfs_ntget(ip); |
411 |
|
426 |
|
412 |
ntfs_nthashins(ip); |
427 |
ntfs_nthashins(ip); |
413 |
|
428 |
|
414 |
lockmgr(&ntfs_hashlock, LK_RELEASE, NULL); |
429 |
mtx_unlock(&ntfs_hashlock_mtx); |
415 |
|
430 |
|
416 |
*ipp = ip; |
431 |
*ipp = ip; |
417 |
|
432 |
|
Lines 446-472
Link Here
|
446 |
} |
461 |
} |
447 |
#endif |
462 |
#endif |
448 |
|
463 |
|
449 |
if (ip->i_usecount > 0) { |
464 |
ip->i_busy = 0; |
450 |
lockmgr(&ip->i_lock, LK_RELEASE|LK_INTERLOCK, &ip->i_interlock); |
465 |
cv_signal(&ip->i_lock); |
451 |
return; |
466 |
mtx_unlock(&ip->i_interlock); |
452 |
} |
|
|
453 |
|
454 |
dprintf(("ntfs_ntput: deallocating ntnode: %d\n", ip->i_number)); |
455 |
|
456 |
if (LIST_FIRST(&ip->i_fnlist)) |
457 |
panic("ntfs_ntput: ntnode has fnodes\n"); |
458 |
|
459 |
ntfs_nthashrem(ip); |
460 |
|
467 |
|
461 |
while ((vap = LIST_FIRST(&ip->i_valist)) != NULL) { |
468 |
if (ip->i_usecount == 0) { |
462 |
LIST_REMOVE(vap,va_list); |
469 |
dprintf(("ntfs_ntput: deallocating ntnode: %d\n", |
463 |
ntfs_freentvattr(vap); |
470 |
ip->i_number)); |
|
|
471 |
|
472 |
if (LIST_FIRST(&ip->i_fnlist)) |
473 |
panic("ntfs_ntput: ntnode has fnodes\n"); |
474 |
|
475 |
ntfs_nthashrem(ip); |
476 |
|
477 |
while ((vap = LIST_FIRST(&ip->i_valist)) != NULL) { |
478 |
LIST_REMOVE(vap,va_list); |
479 |
ntfs_freentvattr(vap); |
480 |
} |
481 |
mtx_destroy(&ip->i_interlock); |
482 |
cv_destroy(&ip->i_lock); |
483 |
vrele(ip->i_devvp); |
484 |
FREE(ip, M_NTFSNTNODE); |
464 |
} |
485 |
} |
465 |
mtx_unlock(&ip->i_interlock); |
|
|
466 |
mtx_destroy(&ip->i_interlock); |
467 |
lockdestroy(&ip->i_lock); |
468 |
vrele(ip->i_devvp); |
469 |
FREE(ip, M_NTFSNTNODE); |
470 |
} |
486 |
} |
471 |
|
487 |
|
472 |
/* |
488 |
/* |
Lines 1955-1961
Link Here
|
1955 |
ntfs_toupper_init() |
1971 |
ntfs_toupper_init() |
1956 |
{ |
1972 |
{ |
1957 |
ntfs_toupper_tab = (wchar *) NULL; |
1973 |
ntfs_toupper_tab = (wchar *) NULL; |
1958 |
lockinit(&ntfs_toupper_lock, PVFS, "ntfs_toupper", 0, 0); |
1974 |
sx_init(&ntfs_toupper_lock_sx, "ntfs toupper lock"); |
1959 |
ntfs_toupper_usecount = 0; |
1975 |
ntfs_toupper_usecount = 0; |
1960 |
} |
1976 |
} |
1961 |
|
1977 |
|
Lines 1963-1969
Link Here
|
1963 |
ntfs_toupper_destroy(void) |
1979 |
ntfs_toupper_destroy(void) |
1964 |
{ |
1980 |
{ |
1965 |
|
1981 |
|
1966 |
lockdestroy(&ntfs_toupper_lock); |
1982 |
sx_destroy(&ntfs_toupper_lock_sx); |
1967 |
} |
1983 |
} |
1968 |
|
1984 |
|
1969 |
/* |
1985 |
/* |
Lines 1979-1985
Link Here
|
1979 |
struct vnode *vp; |
1995 |
struct vnode *vp; |
1980 |
|
1996 |
|
1981 |
/* get exclusive access */ |
1997 |
/* get exclusive access */ |
1982 |
lockmgr(&ntfs_toupper_lock, LK_EXCLUSIVE, NULL); |
1998 |
sx_xlock(&ntfs_toupper_lock_sx); |
1983 |
|
1999 |
|
1984 |
/* only read the translation data from a file if it hasn't been |
2000 |
/* only read the translation data from a file if it hasn't been |
1985 |
* read already */ |
2001 |
* read already */ |
Lines 2002-2008
Link Here
|
2002 |
|
2018 |
|
2003 |
out: |
2019 |
out: |
2004 |
ntfs_toupper_usecount++; |
2020 |
ntfs_toupper_usecount++; |
2005 |
lockmgr(&ntfs_toupper_lock, LK_RELEASE, NULL); |
2021 |
sx_xunlock(&ntfs_toupper_lock_sx); |
2006 |
return (error); |
2022 |
return (error); |
2007 |
} |
2023 |
} |
2008 |
|
2024 |
|
Lines 2014-2020
Link Here
|
2014 |
ntfs_toupper_unuse() |
2030 |
ntfs_toupper_unuse() |
2015 |
{ |
2031 |
{ |
2016 |
/* get exclusive access */ |
2032 |
/* get exclusive access */ |
2017 |
lockmgr(&ntfs_toupper_lock, LK_EXCLUSIVE, NULL); |
2033 |
sx_xlock(&ntfs_toupper_lock_sx); |
2018 |
|
2034 |
|
2019 |
ntfs_toupper_usecount--; |
2035 |
ntfs_toupper_usecount--; |
2020 |
if (ntfs_toupper_usecount == 0) { |
2036 |
if (ntfs_toupper_usecount == 0) { |
Lines 2029-2035
Link Here
|
2029 |
#endif |
2045 |
#endif |
2030 |
|
2046 |
|
2031 |
/* release the lock */ |
2047 |
/* release the lock */ |
2032 |
lockmgr(&ntfs_toupper_lock, LK_RELEASE, NULL); |
2048 |
sx_xunlock(&ntfs_toupper_lock_sx); |
2033 |
} |
2049 |
} |
2034 |
|
2050 |
|
2035 |
int |
2051 |
int |