LCOV - code coverage report
Current view: top level - fs/xfs - mrlock.h (source / functions) Hit Total Coverage
Test: fstests of 6.5.0-rc3-achx @ Mon Jul 31 20:08:12 PDT 2023 Lines: 14 17 82.4 %
Date: 2023-07-31 20:08:12 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 >11500*10^7 :         down_read_nested(&mrp->mr_lock, subclass);
      32 >11550*10^7 : }
      33             : 
      34             : static inline void mrupdate_nested(mrlock_t *mrp, int subclass)
      35             : {
      36  3770658339 :         down_write_nested(&mrp->mr_lock, subclass);
      37             : #if defined(DEBUG) || defined(XFS_WARN)
      38  3772438319 :         mrp->mr_writer = 1;
      39             : #endif
      40  3772438319 : }
      41             : 
      42             : static inline int mrtryaccess(mrlock_t *mrp)
      43             : {
      44   963224053 :         return down_read_trylock(&mrp->mr_lock);
      45             : }
      46             : 
      47             : static inline int mrtryupdate(mrlock_t *mrp)
      48             : {
      49  1425050660 :         if (!down_write_trylock(&mrp->mr_lock))
      50             :                 return 0;
      51             : #if defined(DEBUG) || defined(XFS_WARN)
      52  1426302699 :         mrp->mr_writer = 1;
      53             : #endif
      54  1426302699 :         return 1;
      55             : }
      56             : 
      57             : static inline void mrunlock_excl(mrlock_t *mrp)
      58             : {
      59             : #if defined(DEBUG) || defined(XFS_WARN)
      60  5199631980 :         mrp->mr_writer = 0;
      61             : #endif
      62  5199631980 :         up_write(&mrp->mr_lock);
      63  5203396970 : }
      64             : 
      65             : static inline void mrunlock_shared(mrlock_t *mrp)
      66             : {
      67 >11513*10^7 :         up_read(&mrp->mr_lock);
      68 >11602*10^7 : }
      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