diff options
author | kib <kib@FreeBSD.org> | 2010-02-28 17:16:43 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2010-02-28 17:16:43 +0000 |
commit | 9f07095877942c523ecfd82f783bfc9ad9ecebbc (patch) | |
tree | c590d096b0ee22af8d06c56cc58057b73c176c3e | |
parent | 452113665587ed27ad543c49c84d142ef8bd5481 (diff) | |
download | FreeBSD-src-9f07095877942c523ecfd82f783bfc9ad9ecebbc.zip FreeBSD-src-9f07095877942c523ecfd82f783bfc9ad9ecebbc.tar.gz |
Use pm_fatlock to protect per-filesystem rb tree used to allocate fileno
on the large FAT volumes. Previously, a single global mutex was used.
Tested by: pho
MFC after: 3 weeks
-rw-r--r-- | sys/fs/msdosfs/msdosfs_fileno.c | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/sys/fs/msdosfs/msdosfs_fileno.c b/sys/fs/msdosfs/msdosfs_fileno.c index ff1f2b7..b56fb43 100644 --- a/sys/fs/msdosfs/msdosfs_fileno.c +++ b/sys/fs/msdosfs/msdosfs_fileno.c @@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$"); #include <sys/lock.h> #include <sys/malloc.h> #include <sys/mount.h> -#include <sys/mutex.h> #include <fs/msdosfs/bpb.h> #include <fs/msdosfs/direntry.h> @@ -59,9 +58,6 @@ __FBSDID("$FreeBSD$"); static MALLOC_DEFINE(M_MSDOSFSFILENO, "msdosfs_fileno", "MSDOSFS fileno mapping node"); -static struct mtx fileno_mtx; -MTX_SYSINIT(fileno, &fileno_mtx, "MSDOSFS fileno", MTX_DEF); - RB_PROTOTYPE(msdosfs_filenotree, msdosfs_fileno, mf_tree, msdosfs_fileno_compare) @@ -117,30 +113,30 @@ msdosfs_fileno_map(mp, fileno) } if (fileno < FILENO_FIRST_DYN) return ((uint32_t)fileno); - mtx_lock(&fileno_mtx); + MSDOSFS_LOCK_MP(pmp); key.mf_fileno64 = fileno; mf = RB_FIND(msdosfs_filenotree, &pmp->pm_filenos, &key); if (mf != NULL) { mapped = mf->mf_fileno32; - mtx_unlock(&fileno_mtx); + MSDOSFS_UNLOCK_MP(pmp); return (mapped); } if (pmp->pm_nfileno < FILENO_FIRST_DYN) panic("msdosfs_fileno_map: wraparound"); - mtx_unlock(&fileno_mtx); + MSDOSFS_UNLOCK_MP(pmp); mf = malloc(sizeof(*mf), M_MSDOSFSFILENO, M_WAITOK); - mtx_lock(&fileno_mtx); + MSDOSFS_LOCK_MP(pmp); tmf = RB_FIND(msdosfs_filenotree, &pmp->pm_filenos, &key); if (tmf != NULL) { mapped = tmf->mf_fileno32; - mtx_unlock(&fileno_mtx); + MSDOSFS_UNLOCK_MP(pmp); free(mf, M_MSDOSFSFILENO); return (mapped); } mf->mf_fileno64 = fileno; mapped = mf->mf_fileno32 = pmp->pm_nfileno++; RB_INSERT(msdosfs_filenotree, &pmp->pm_filenos, mf); - mtx_unlock(&fileno_mtx); + MSDOSFS_UNLOCK_MP(pmp); return (mapped); } |