filemon_lock.c revision 293893
10SN/A/*-
2157SN/A * Copyright (c) 2009-2011, Juniper Networks, Inc.
30SN/A * Copyright (c) 2015, EMC Corp.
40SN/A * All rights reserved.
50SN/A *
60SN/A * Redistribution and use in source and binary forms, with or without
7157SN/A * modification, are permitted provided that the following conditions
80SN/A * are met:
9157SN/A * 1. Redistributions of source code must retain the above copyright
100SN/A *    notice, this list of conditions and the following disclaimer.
110SN/A * 2. Redistributions in binary form must reproduce the above copyright
120SN/A *    notice, this list of conditions and the following disclaimer in the
130SN/A *    documentation and/or other materials provided with the distribution.
140SN/A *
150SN/A * THIS SOFTWARE IS PROVIDED BY JUNIPER NETWORKS AND CONTRIBUTORS ``AS IS'' AND
160SN/A * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
170SN/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
180SN/A * ARE DISCLAIMED. IN NO EVENT SHALL JUNIPER NETWORKS OR CONTRIBUTORS BE LIABLE
190SN/A * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
200SN/A * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21157SN/A * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22157SN/A * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23157SN/A * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
240SN/A * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
250SN/A * SUCH DAMAGE.
260SN/A */
270SN/A
280SN/A#include <sys/cdefs.h>
290SN/A__FBSDID("$FreeBSD: releng/10.2/sys/dev/filemon/filemon_lock.c 293893 2016-01-14 09:10:46Z glebius $");
300SN/A
310SN/Astatic __inline void
320SN/Afilemon_filemon_lock(struct filemon *filemon)
330SN/A{
340SN/A
350SN/A	sx_xlock(&filemon->lock);
360SN/A}
370SN/A
380SN/Astatic __inline void
390SN/Afilemon_filemon_unlock(struct filemon *filemon)
400SN/A{
410SN/A
420SN/A	sx_xunlock(&filemon->lock);
430SN/A}
440SN/A
450SN/Astatic __inline void
460SN/Afilemon_lock_read(void)
470SN/A{
480SN/A
490SN/A	sx_slock(&access_lock);
500SN/A}
510SN/A
520SN/Astatic __inline void
530SN/Afilemon_unlock_read(void)
540SN/A{
550SN/A
560SN/A	sx_sunlock(&access_lock);
570SN/A}
580SN/A
590SN/Astatic __inline void
600SN/Afilemon_lock_write(void)
610SN/A{
620SN/A
630SN/A	sx_xlock(&access_lock);
640SN/A}
650SN/A
660SN/Astatic __inline void
670SN/Afilemon_unlock_write(void)
680SN/A{
690SN/A
700SN/A	sx_xunlock(&access_lock);
710SN/A}
720SN/A