diff options
author | rodrigc <rodrigc@FreeBSD.org> | 2005-12-12 01:04:32 +0000 |
---|---|---|
committer | rodrigc <rodrigc@FreeBSD.org> | 2005-12-12 01:04:32 +0000 |
commit | 410e08d350a2cfcb50386dc6b5a24a5d82825067 (patch) | |
tree | 8ac52e2fe37d3790aa9ac8fc061d5c395bc1b946 /sys/gnu/fs/xfs/FreeBSD/support/mrlock.c | |
parent | ff6c302a67bb107dfea59fdc76583af9913df36e (diff) | |
download | FreeBSD-src-410e08d350a2cfcb50386dc6b5a24a5d82825067.zip FreeBSD-src-410e08d350a2cfcb50386dc6b5a24a5d82825067.tar.gz |
Initial import of read-only support for SGI's XFS filesystem.
Contributed by: XFS for FreeBSD project
Diffstat (limited to 'sys/gnu/fs/xfs/FreeBSD/support/mrlock.c')
-rw-r--r-- | sys/gnu/fs/xfs/FreeBSD/support/mrlock.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/sys/gnu/fs/xfs/FreeBSD/support/mrlock.c b/sys/gnu/fs/xfs/FreeBSD/support/mrlock.c new file mode 100644 index 0000000..9503039 --- /dev/null +++ b/sys/gnu/fs/xfs/FreeBSD/support/mrlock.c @@ -0,0 +1,49 @@ +#include <sys/param.h> +#include <support/mrlock.h> + +void +_sx_xfs_destroy(struct sx *sx) +{ + if (sx->sx_cnt == -1) + sx_xunlock(sx); + sx_destroy(sx); +} + +void +_sx_xfs_lock(struct sx *sx, int type, const char *file, int line) +{ + if (type == MR_ACCESS) + _sx_slock(sx, file, line); + else if (type == MR_UPDATE) + _sx_sunlock(sx, file, line); + else + panic("Invalid lock type passed"); +} + + +void +_sx_xfs_unlock(struct sx *sx, const char *file, int line) +{ + if (_sx_xfs_xowned(sx)) + _sx_xunlock(sx, file, line); + else if (_sx_xfs_sowned(sx)) + _sx_sunlock(sx, file, line); + else + panic("lock is not locked"); +} + +int +ismrlocked(mrlock_t *mrp, int type) +{ + if (type == MR_ACCESS) + return _sx_xfs_sowned(mrp); /* Read lock */ + else if (type == MR_UPDATE) + return _sx_xfs_xowned(mrp); /* Write lock */ + else if (type == (MR_UPDATE | MR_ACCESS)) + return _sx_xfs_sowned(mrp) || + _sx_xfs_xowned(mrp); /* Any type of lock held */ + return (mrp->sx_shrd_wcnt > 0 || mrp->sx_excl_wcnt > 0); +} + + + |