diff options
author | kib <kib@FreeBSD.org> | 2010-02-28 17:13:07 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2010-02-28 17:13:07 +0000 |
commit | e272e9af759028f027e0002f8b0b49ad56c96827 (patch) | |
tree | b370ea28c6230a965f50f2973317d61572aba9d6 /sys/fs | |
parent | 8b37b1e408d52056bd5d87de76fe55ee4078cb03 (diff) | |
download | FreeBSD-src-e272e9af759028f027e0002f8b0b49ad56c96827.zip FreeBSD-src-e272e9af759028f027e0002f8b0b49ad56c96827.tar.gz |
Add per-mountpoint lockmgr lock for msdosfs. It is intended to be used
as fat bitmap lock and to replace global mutex protecting fileno rbtree.
Tested by: pho
MFC after: 3 weeks
Diffstat (limited to 'sys/fs')
-rw-r--r-- | sys/fs/msdosfs/msdosfs_vfsops.c | 6 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfsmount.h | 14 |
2 files changed, 19 insertions, 1 deletions
diff --git a/sys/fs/msdosfs/msdosfs_vfsops.c b/sys/fs/msdosfs/msdosfs_vfsops.c index 8186763..be8d1db 100644 --- a/sys/fs/msdosfs/msdosfs_vfsops.c +++ b/sys/fs/msdosfs/msdosfs_vfsops.c @@ -75,6 +75,8 @@ #include <fs/msdosfs/fat.h> #include <fs/msdosfs/msdosfsmount.h> +static const char msdosfs_lock_msg[] = "fatlk"; + /* Mount options that we support. */ static const char *msdosfs_opts[] = { "async", "noatime", "noclusterr", "noclusterw", @@ -466,6 +468,8 @@ mountmsdosfs(struct vnode *devvp, struct mount *mp) pmp->pm_cp = cp; pmp->pm_bo = bo; + lockinit(&pmp->pm_fatlock, 0, msdosfs_lock_msg, 0, 0); + /* * Initialize ownerships and permissions, since nothing else will * initialize them iff we are mounting root. @@ -762,6 +766,7 @@ error_exit: g_topology_unlock(); PICKUP_GIANT(); } + lockdestroy(&pmp->pm_fatlock); if (pmp) { if (pmp->pm_inusemap) free(pmp->pm_inusemap, M_MSDOSFSFAT); @@ -837,6 +842,7 @@ msdosfs_unmount(struct mount *mp, int mntflags) free(pmp->pm_inusemap, M_MSDOSFSFAT); if (pmp->pm_flags & MSDOSFS_LARGEFS) msdosfs_fileno_free(mp); + lockdestroy(&pmp->pm_fatlock); free(pmp, M_MSDOSFSMNT); mp->mnt_data = NULL; MNT_ILOCK(mp); diff --git a/sys/fs/msdosfs/msdosfsmount.h b/sys/fs/msdosfs/msdosfsmount.h index bfe3ec3..2951b2c 100644 --- a/sys/fs/msdosfs/msdosfsmount.h +++ b/sys/fs/msdosfs/msdosfsmount.h @@ -53,6 +53,9 @@ #ifdef _KERNEL +#include <sys/types.h> +#include <sys/lock.h> +#include <sys/lockmgr.h> #include <sys/tree.h> #ifdef MALLOC_DECLARE @@ -106,7 +109,9 @@ struct msdosfsmount { void *pm_u2d; /* Unicode->DOS iconv handle */ void *pm_d2u; /* DOS->Local iconv handle */ u_int32_t pm_nfileno; /* next 32-bit fileno */ - RB_HEAD(msdosfs_filenotree, msdosfs_fileno) pm_filenos; /* 64<->32-bit fileno mapping */ + RB_HEAD(msdosfs_filenotree, msdosfs_fileno) + pm_filenos; /* 64<->32-bit fileno mapping */ + struct lock pm_fatlock; /* lockmgr protecting allocations and rb tree */ }; /* @@ -215,6 +220,13 @@ void msdosfs_fileno_init(struct mount *); void msdosfs_fileno_free(struct mount *); uint32_t msdosfs_fileno_map(struct mount *, uint64_t); +#define MSDOSFS_LOCK_MP(pmp) \ + lockmgr(&(pmp)->pm_fatlock, LK_EXCLUSIVE, NULL) +#define MSDOSFS_UNLOCK_MP(pmp) \ + lockmgr(&(pmp)->pm_fatlock, LK_RELEASE, NULL) +#define MSDOSFS_ASSERT_MP_LOCKED(pmp) \ + lockmgr_assert(&(pmp)->pm_fatlock, KA_XLOCKED) + #endif /* _KERNEL */ /* |