LCOV - code coverage report
Current view: top level - dm-pcache - segment.c (source / functions) Coverage Total Hit
Test: dm_pcache.info Lines: 97.1 % 35 34
Test Date: 2025-08-04 03:13:17 Functions: 100.0 % 3 3
Legend: Lines: hit not hit

            Line data    Source code
       1              : // SPDX-License-Identifier: GPL-2.0-or-later
       2              : #include <linux/dax.h>
       3              : 
       4              : #include "pcache_internal.h"
       5              : #include "cache_dev.h"
       6              : #include "segment.h"
       7              : 
       8     16242639 : int segment_copy_to_bio(struct pcache_segment *segment,
       9              :                 u32 data_off, u32 data_len, struct bio *bio, u32 bio_off)
      10              : {
      11     16242639 :         struct iov_iter iter;
      12     16242639 :         size_t copied;
      13     16242639 :         void *src;
      14              : 
      15     16237434 :         iov_iter_bvec(&iter, ITER_DEST, &bio->bi_io_vec[bio->bi_iter.bi_idx],
      16     16242639 :                         bio_segments(bio), bio->bi_iter.bi_size);
      17     16238921 :         iter.iov_offset = bio->bi_iter.bi_bvec_done;
      18     16238921 :         if (bio_off)
      19      6375067 :                 iov_iter_advance(&iter, bio_off);
      20              : 
      21     16239280 :         src = segment->data + data_off;
      22     16239280 :         copied = _copy_mc_to_iter(src, data_len, &iter);
      23     16243887 :         if (copied != data_len)
      24            0 :                 return -EIO;
      25              : 
      26              :         return 0;
      27              : }
      28              : 
      29     44383481 : int segment_copy_from_bio(struct pcache_segment *segment,
      30              :                 u32 data_off, u32 data_len, struct bio *bio, u32 bio_off)
      31              : {
      32     44383481 :         struct iov_iter iter;
      33     44383481 :         size_t copied;
      34     44383481 :         void *dst;
      35              : 
      36     44159333 :         iov_iter_bvec(&iter, ITER_SOURCE, &bio->bi_io_vec[bio->bi_iter.bi_idx],
      37     44383481 :                         bio_segments(bio), bio->bi_iter.bi_size);
      38     44161821 :         iter.iov_offset = bio->bi_iter.bi_bvec_done;
      39     44161821 :         if (bio_off)
      40       367033 :                 iov_iter_advance(&iter, bio_off);
      41              : 
      42     44161822 :         dst = segment->data + data_off;
      43     44161822 :         copied = _copy_from_iter_flushcache(dst, data_len, &iter);
      44     44381825 :         if (copied != data_len)
      45              :                 return -EIO;
      46     44381825 :         pmem_wmb();
      47              : 
      48     44381825 :         return 0;
      49              : }
      50              : 
      51        85969 : void pcache_segment_init(struct pcache_cache_dev *cache_dev, struct pcache_segment *segment,
      52              :                       struct pcache_segment_init_options *options)
      53              : {
      54        85969 :         segment->seg_info = options->seg_info;
      55        85969 :         segment_info_set_type(segment->seg_info, options->type);
      56              : 
      57        85969 :         segment->cache_dev = cache_dev;
      58        85969 :         segment->seg_id = options->seg_id;
      59        85969 :         segment->data_size = PCACHE_SEG_SIZE - options->data_off;
      60        85969 :         segment->data = CACHE_DEV_SEGMENT(cache_dev, options->seg_id) + options->data_off;
      61        85969 : }
        

Generated by: LCOV version 2.0-1