Blame source/vdo/kernel/ioSubmitter.h

Packit Service d40955
/*
Packit Service d40955
 * Copyright (c) 2020 Red Hat, Inc.
Packit Service d40955
 *
Packit Service d40955
 * This program is free software; you can redistribute it and/or
Packit Service d40955
 * modify it under the terms of the GNU General Public License
Packit Service d40955
 * as published by the Free Software Foundation; either version 2
Packit Service d40955
 * of the License, or (at your option) any later version.
Packit Service d40955
 * 
Packit Service d40955
 * This program is distributed in the hope that it will be useful,
Packit Service d40955
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service d40955
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service d40955
 * GNU General Public License for more details.
Packit Service d40955
 * 
Packit Service d40955
 * You should have received a copy of the GNU General Public License
Packit Service d40955
 * along with this program; if not, write to the Free Software
Packit Service d40955
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit Service d40955
 * 02110-1301, USA. 
Packit Service d40955
 *
Packit Service d40955
 * $Id: //eng/vdo-releases/aluminum/src/c++/vdo/kernel/ioSubmitter.h#4 $
Packit Service d40955
 */
Packit Service d40955
Packit Service d40955
#ifndef IOSUBMITTER_H
Packit Service d40955
#define IOSUBMITTER_H
Packit Service d40955
Packit Service d40955
#include <linux/version.h>
Packit Service d40955
Packit Service d40955
#include "kernelLayer.h"
Packit Service d40955
#include "kvio.h"
Packit Service d40955
Packit Service d40955
/**
Packit Service d40955
 * Does all the appropriate accounting for bio completions
Packit Service d40955
 *
Packit Service d40955
 * @param bio  the bio to count
Packit Service d40955
 **/
Packit Service d40955
void countCompletedBios(BIO *bio);
Packit Service d40955
Packit Service d40955
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
Packit Service d40955
/**
Packit Service d40955
 * Completes a bio relating to a kvio, causing the completion callback
Packit Service d40955
 * to be invoked.
Packit Service d40955
 *
Packit Service d40955
 * This is used as the bi_end_io function for most of the bios created
Packit Service d40955
 * within VDO and submitted to the storage device. Exceptions are the
Packit Service d40955
 * flush code and the read-block code, both of which need to regain
Packit Service d40955
 * control in the kernel layer after the I/O is completed.
Packit Service d40955
 *
Packit Service d40955
 * @param bio   The bio to complete
Packit Service d40955
 **/
Packit Service d40955
void completeAsyncBio(BIO *bio);
Packit Service d40955
#else
Packit Service d40955
/**
Packit Service d40955
 * Completes a bio relating to a kvio, causing the completion callback
Packit Service d40955
 * to be invoked.
Packit Service d40955
 *
Packit Service d40955
 * This is used as the bi_end_io function for most of the bios created
Packit Service d40955
 * within VDO and submitted to the storage device. Exceptions are the
Packit Service d40955
 * flush code and the read-block code, both of which need to regain
Packit Service d40955
 * control in the kernel layer after the I/O is completed.
Packit Service d40955
 *
Packit Service d40955
 * @param bio   The bio to complete
Packit Service d40955
 * @param error Possible error from underlying block device
Packit Service d40955
 **/
Packit Service d40955
void completeAsyncBio(BIO *bio, int error);
Packit Service d40955
#endif
Packit Service d40955
Packit Service d40955
/**
Packit Service d40955
 * Create a IOSubmitter structure for a new physical layer.
Packit Service d40955
 *
Packit Service d40955
 * @param [in]  threadNamePrefix  The per-device prefix to use in process names
Packit Service d40955
 * @param [in]  threadCount       Number of bio-submission threads to set up
Packit Service d40955
 * @param [in]  rotationInterval  Interval to use when rotating between
Packit Service d40955
 *                                bio-submission threads when enqueuing work
Packit Service d40955
 *                                items
Packit Service d40955
 * @param [in]  maxRequestsActive Number of bios for merge tracking
Packit Service d40955
 * @param [in]  layer             The kernel layer
Packit Service d40955
 * @param [out] ioSubmitter       Pointer to the new data structure
Packit Service d40955
 *
Packit Service d40955
 * @return VDO_SUCCESS or an error
Packit Service d40955
 **/
Packit Service d40955
int makeIOSubmitter(const char    *threadNamePrefix,
Packit Service d40955
                    unsigned int   threadCount,
Packit Service d40955
                    unsigned int   rotationInterval,
Packit Service d40955
                    unsigned int   maxRequestsActive,
Packit Service d40955
                    KernelLayer   *layer,
Packit Service d40955
                    IOSubmitter  **ioSubmitter);
Packit Service d40955
Packit Service d40955
/**
Packit Service d40955
 * Tear down the IOSubmitter fields as needed for a physical layer.
Packit Service d40955
 *
Packit Service d40955
 * @param [in]  ioSubmitter    The I/O submitter data to tear down
Packit Service d40955
 **/
Packit Service d40955
void cleanupIOSubmitter(IOSubmitter *ioSubmitter);
Packit Service d40955
Packit Service d40955
/**
Packit Service d40955
 * Free the IOSubmitter fields and structure as needed for a
Packit Service d40955
 * physical layer. This must be called after
Packit Service d40955
 * cleanupIOSubmitter(). It is used to release resources late in
Packit Service d40955
 * the shutdown process to avoid or reduce the chance of race
Packit Service d40955
 * conditions.
Packit Service d40955
 *
Packit Service d40955
 * @param [in]  ioSubmitter    The I/O submitter data to destroy
Packit Service d40955
 **/
Packit Service d40955
void freeIOSubmitter(IOSubmitter *ioSubmitter);
Packit Service d40955
Packit Service d40955
/**
Packit Service d40955
 * Dump info to the kernel log about the work queue used by the
Packit Service d40955
 * physical layer. For debugging only.
Packit Service d40955
 *
Packit Service d40955
 * @param [in]  ioSubmitter        The I/O submitter data
Packit Service d40955
 **/
Packit Service d40955
void dumpBioWorkQueue(IOSubmitter *ioSubmitter);
Packit Service d40955
Packit Service d40955
Packit Service d40955
/**
Packit Service d40955
 * Enqueue a work item to run in the work queue(s) used for bio
Packit Service d40955
 * submissions from the physical layer.
Packit Service d40955
 *
Packit Service d40955
 * Outside of IOSubmitter, used only for finishing processing of empty
Packit Service d40955
 * flush bios by sending them to the storage device.
Packit Service d40955
 *
Packit Service d40955
 * @param ioSubmitter        The I/O submitter data to update
Packit Service d40955
 * @param workItem           The new work item to run
Packit Service d40955
 **/
Packit Service d40955
void enqueueBioWorkItem(IOSubmitter *ioSubmitter, KvdoWorkItem *workItem);
Packit Service d40955
Packit Service d40955
/**
Packit Service d40955
 * Submit bio but don't block.
Packit Service d40955
 *
Packit Service d40955
 * Submits the bio to a helper work queue which sits in a loop
Packit Service d40955
 * submitting bios. The worker thread may block if the target device
Packit Service d40955
 * is busy, which is why we don't want to do the submission in the
Packit Service d40955
 * original calling thread.
Packit Service d40955
 *
Packit Service d40955
 * The bi_private field of the bio must point to a KVIO associated
Packit Service d40955
 * with the operation. The bi_end_io callback is invoked when the I/O
Packit Service d40955
 * operation completes.
Packit Service d40955
 *
Packit Service d40955
 * @param bio      the block I/O operation descriptor to submit
Packit Service d40955
 * @param action   the action code specifying the priority for the operation
Packit Service d40955
 **/
Packit Service d40955
void submitBio(BIO *bio, BioQAction action);
Packit Service d40955
Packit Service d40955
#endif // IOSUBMITTER_H