LCOV - code coverage report
Current view: top level - dm-pcache - dm_pcache.h (source / functions) Coverage Total Hit
Test: dm_pcache.info Lines: 100.0 % 8 8
Test Date: 2025-08-08 03:56:04 Functions: 100.0 % 1 1
Legend: Lines: hit not hit

            Line data    Source code
       1              : /* SPDX-License-Identifier: GPL-2.0-or-later */
       2              : #ifndef _DM_PCACHE_H
       3              : #define _DM_PCACHE_H
       4              : #include <linux/device-mapper.h>
       5              : 
       6              : #include "../dm-core.h"
       7              : 
       8              : #define CACHE_DEV_TO_PCACHE(cache_dev)          (container_of(cache_dev, struct dm_pcache, cache_dev))
       9              : #define BACKING_DEV_TO_PCACHE(backing_dev)      (container_of(backing_dev, struct dm_pcache, backing_dev))
      10              : #define CACHE_TO_PCACHE(cache)                  (container_of(cache, struct dm_pcache, cache))
      11              : 
      12              : #define PCACHE_STATE_RUNNING                    1
      13              : #define PCACHE_STATE_STOPPING                   2
      14              : 
      15              : struct pcache_cache_dev;
      16              : struct pcache_backing_dev;
      17              : struct pcache_cache;
      18              : struct pcache_cache_options;
      19              : struct dm_pcache {
      20              :         struct dm_target *ti;
      21              :         struct pcache_cache_dev cache_dev;
      22              :         struct pcache_backing_dev backing_dev;
      23              :         struct pcache_cache cache;
      24              :         struct pcache_cache_options opts;
      25              : 
      26              :         spinlock_t                      defered_req_list_lock;
      27              :         struct list_head                defered_req_list;
      28              :         struct workqueue_struct         *task_wq;
      29              : 
      30              :         struct work_struct              defered_req_work;
      31              : 
      32              :         atomic_t                        inflight_reqs;
      33              :         wait_queue_head_t               inflight_wq;
      34              : 
      35              :         spinlock_t                      state_lock;
      36              :         u8                              state;
      37              : };
      38              : 
      39    449351420 : static inline bool __pcache_is_stopping(struct dm_pcache *pcache)
      40              : {
      41    449316977 :         return (pcache->state == PCACHE_STATE_STOPPING);
      42              : }
      43              : 
      44    390937675 : static inline bool pcache_is_stopping(struct dm_pcache *pcache)
      45              : {
      46    390937675 :         bool stopping;
      47              : 
      48    390937675 :         spin_lock(&pcache->state_lock);
      49    391015468 :         stopping = __pcache_is_stopping(pcache);;
      50    391015468 :         spin_unlock(&pcache->state_lock);
      51              : 
      52    390951838 :         return stopping;
      53              : }
      54              : 
      55              : #define pcache_dev_err(pcache, fmt, ...)                                                        \
      56              :         pcache_err("%s " fmt, pcache->ti->table->md->name, ##__VA_ARGS__)
      57              : #define pcache_dev_info(pcache, fmt, ...)                                                       \
      58              :         pcache_info("%s " fmt, pcache->ti->table->md->name, ##__VA_ARGS__)
      59              : #define pcache_dev_debug(pcache, fmt, ...)                                                      \
      60              :         pcache_debug("%s " fmt, pcache->ti->table->md->name, ##__VA_ARGS__)
      61              : 
      62              : struct pcache_request {
      63              :         struct dm_pcache        *pcache;
      64              :         struct bio              *bio;
      65              : 
      66              :         u64                     off;
      67              :         u32                     data_len;
      68              : 
      69              :         struct kref             ref;
      70              :         int                     ret;
      71              : 
      72              :         struct list_head        list_node;
      73              : };
      74              : 
      75              : void pcache_req_get(struct pcache_request *pcache_req);
      76              : void pcache_req_put(struct pcache_request *pcache_req, int ret);
      77              : 
      78              : void pcache_defer_reqs_kick(struct dm_pcache *pcache);
      79              : 
      80              : #endif /* _DM_PCACHE_H */
        

Generated by: LCOV version 2.0-1