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