LCOV - code coverage report
Current view: top level - spdk/lib/ftl - ftl_writer.h (source / functions) Hit Total Coverage
Test: Combined Lines: 9 9 100.0 %
Date: 2024-07-11 20:05:01 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*   SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *   Copyright (C) 2022 Intel Corporation.
       3                 :            :  *   All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef FTL_WRITER_H
       7                 :            : #define FTL_WRITER_H
       8                 :            : 
       9                 :            : #include "spdk/stdinc.h"
      10                 :            : #include "spdk/queue.h"
      11                 :            : 
      12                 :            : #include "ftl_io.h"
      13                 :            : 
      14                 :            : struct ftl_writer {
      15                 :            :         struct spdk_ftl_dev *dev;
      16                 :            : 
      17                 :            :         TAILQ_HEAD(, ftl_rq) rq_queue;
      18                 :            : 
      19                 :            :         /* Band currently being written to */
      20                 :            :         struct ftl_band *band;
      21                 :            : 
      22                 :            :         /* Number of bands associated with writer */
      23                 :            :         uint64_t num_bands;
      24                 :            : 
      25                 :            :         /* Band next being written to */
      26                 :            :         struct ftl_band *next_band;
      27                 :            : 
      28                 :            :         /* List of full bands */
      29                 :            :         TAILQ_HEAD(, ftl_band) full_bands;
      30                 :            : 
      31                 :            :         /* FTL band limit which blocks writes */
      32                 :            :         int limit;
      33                 :            : 
      34                 :            :         /* Flag indicating halt has been requested */
      35                 :            :         bool halt;
      36                 :            : 
      37                 :            :         /* Which type of band the writer uses */
      38                 :            :         enum ftl_band_type writer_type;
      39                 :            : 
      40                 :            :         uint64_t last_seq_id;
      41                 :            : 
      42                 :            :         /* FTL request to pad the current band */
      43                 :            :         struct ftl_rq *pad;
      44                 :            : };
      45                 :            : 
      46                 :            : bool ftl_writer_is_halted(struct ftl_writer *writer);
      47                 :            : 
      48                 :            : void ftl_writer_init(struct spdk_ftl_dev *dev, struct ftl_writer *writer,
      49                 :            :                      uint64_t limit, enum ftl_band_type type);
      50                 :            : 
      51                 :            : void ftl_writer_run(struct ftl_writer *writer);
      52                 :            : 
      53                 :            : void ftl_writer_band_state_change(struct ftl_band *band);
      54                 :            : 
      55                 :            : static inline void
      56                 :     143121 : ftl_writer_halt(struct ftl_writer *writer)
      57                 :            : {
      58                 :     143121 :         writer->halt = true;
      59                 :     143121 : }
      60                 :            : 
      61                 :            : static inline void
      62                 :         54 : ftl_writer_resume(struct ftl_writer *writer)
      63                 :            : {
      64                 :         54 :         writer->halt = false;
      65                 :         54 : }
      66                 :            : 
      67                 :            : bool ftl_writer_is_halted(struct ftl_writer *writer);
      68                 :            : 
      69                 :            : void ftl_writer_run(struct ftl_writer *writer);
      70                 :            : 
      71                 :            : static inline void
      72                 :       4127 : ftl_writer_queue_rq(struct ftl_writer *writer, struct ftl_rq *rq)
      73                 :            : {
      74                 :       4127 :         TAILQ_INSERT_TAIL(&writer->rq_queue, rq, qentry);
      75                 :       4127 : }
      76                 :            : 
      77                 :            : /**
      78                 :            :  * @brief Returns free space in currently processing band
      79                 :            :  */
      80                 :            : uint64_t ftl_writer_get_free_blocks(struct ftl_writer *writer);
      81                 :            : 
      82                 :            : #endif  /* FTL_WRITER_H */

Generated by: LCOV version 1.14