LCOV - code coverage report
Current view: top level - fs/xfs - mrlock.h (source / functions) Hit Total Coverage
Test: fstests of 6.5.0-rc3-acha @ Mon Jul 31 20:08:06 PDT 2023 Lines: 14 17 82.4 %
Date: 2023-07-31 20:08:07 Functions: 0 0 -

          Line data    Source code
       1             : // SPDX-License-Identifier: GPL-2.0
       2             : /*
       3             :  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
       4             :  * All Rights Reserved.
       5             :  */
       6             : #ifndef __XFS_SUPPORT_MRLOCK_H__
       7             : #define __XFS_SUPPORT_MRLOCK_H__
       8             : 
       9             : #include <linux/rwsem.h>
      10             : 
      11             : typedef struct {
      12             :         struct rw_semaphore     mr_lock;
      13             : #if defined(DEBUG) || defined(XFS_WARN)
      14             :         int                     mr_writer;
      15             : #endif
      16             : } mrlock_t;
      17             : 
      18             : #if defined(DEBUG) || defined(XFS_WARN)
      19             : #define mrinit(mrp, name)       \
      20             :         do { (mrp)->mr_writer = 0; init_rwsem(&(mrp)->mr_lock); } while (0)
      21             : #else
      22             : #define mrinit(mrp, name)       \
      23             :         do { init_rwsem(&(mrp)->mr_lock); } while (0)
      24             : #endif
      25             : 
      26             : #define mrlock_init(mrp, t,n,s) mrinit(mrp, n)
      27             : #define mrfree(mrp)             do { } while (0)
      28             : 
      29             : static inline void mraccess_nested(mrlock_t *mrp, int subclass)
      30             : {
      31 65817591094 :         down_read_nested(&mrp->mr_lock, subclass);
      32 65800214141 : }
      33             : 
      34             : static inline void mrupdate_nested(mrlock_t *mrp, int subclass)
      35             : {
      36  2289400324 :         down_write_nested(&mrp->mr_lock, subclass);
      37             : #if defined(DEBUG) || defined(XFS_WARN)
      38  2289595352 :         mrp->mr_writer = 1;
      39             : #endif
      40  2289595352 : }
      41             : 
      42             : static inline int mrtryaccess(mrlock_t *mrp)
      43             : {
      44   798201444 :         return down_read_trylock(&mrp->mr_lock);
      45             : }
      46             : 
      47             : static inline int mrtryupdate(mrlock_t *mrp)
      48             : {
      49  1251435680 :         if (!down_write_trylock(&mrp->mr_lock))
      50             :                 return 0;
      51             : #if defined(DEBUG) || defined(XFS_WARN)
      52  1251463192 :         mrp->mr_writer = 1;
      53             : #endif
      54  1251463192 :         return 1;
      55             : }
      56             : 
      57             : static inline void mrunlock_excl(mrlock_t *mrp)
      58             : {
      59             : #if defined(DEBUG) || defined(XFS_WARN)
      60  3539596253 :         mrp->mr_writer = 0;
      61             : #endif
      62  3539596253 :         up_write(&mrp->mr_lock);
      63  3539294429 : }
      64             : 
      65             : static inline void mrunlock_shared(mrlock_t *mrp)
      66             : {
      67 66520627731 :         up_read(&mrp->mr_lock);
      68 66640039468 : }
      69             : 
      70             : static inline void mrdemote(mrlock_t *mrp)
      71             : {
      72             : #if defined(DEBUG) || defined(XFS_WARN)
      73           0 :         mrp->mr_writer = 0;
      74             : #endif
      75           0 :         downgrade_write(&mrp->mr_lock);
      76           0 : }
      77             : 
      78             : #endif /* __XFS_SUPPORT_MRLOCK_H__ */

Generated by: LCOV version 1.14