|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
310c69 |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
310c69 |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
310c69 |
* of the License, or (at your option) any later version.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
310c69 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
310c69 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
310c69 |
* GNU General Public License for more details.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
310c69 |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
310c69 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
310c69 |
* 02110-1301, USA.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/kernel/kvio.c#7 $
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "kvio.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "logger.h"
|
|
Packit Service |
310c69 |
#include "memoryAlloc.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "numUtils.h"
|
|
Packit Service |
310c69 |
#include "vdo.h"
|
|
Packit Service |
310c69 |
#include "waitQueue.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#include "bio.h"
|
|
Packit Service |
310c69 |
#include "ioSubmitter.h"
|
|
Packit Service |
310c69 |
#include "kvdoFlush.h"
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* A function to tell vdo that we have completed the requested async
|
|
Packit Service |
310c69 |
* operation for a vio
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param item The work item of the VIO to complete
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
static void kvdoHandleVIOCallback(KvdoWorkItem *item)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
KVIO *kvio = workItemAsKVIO(item);
|
|
Packit Service |
310c69 |
runCallback(vioAsCompletion(kvio->vio));
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
void kvdoEnqueueVIOCallback(KVIO *kvio)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
enqueueKVIO(kvio, kvdoHandleVIOCallback,
|
|
Packit Service |
310c69 |
(KvdoWorkFunction) vioAsCompletion(kvio->vio)->callback,
|
|
Packit Service |
310c69 |
REQ_Q_ACTION_VIO_CALLBACK);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
void kvdoContinueKvio(KVIO *kvio, int error)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
if (unlikely(error != VDO_SUCCESS)) {
|
|
Packit Service |
310c69 |
setCompletionResult(vioAsCompletion(kvio->vio), error);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
kvdoEnqueueVIOCallback(kvio);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
// noinline ensures systemtap can hook in here
|
|
Packit Service |
310c69 |
static noinline void maybeLogKvioTrace(KVIO *kvio)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
if (kvio->layer->traceLogging) {
|
|
Packit Service |
310c69 |
logKvioTrace(kvio);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
static void freeKVIO(KVIO **kvioPtr)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
KVIO *kvio = *kvioPtr;
|
|
Packit Service |
310c69 |
if (kvio == NULL) {
|
|
Packit Service |
310c69 |
return;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
if (unlikely(kvio->vio->trace != NULL)) {
|
|
Packit Service |
310c69 |
maybeLogKvioTrace(kvio);
|
|
Packit Service |
310c69 |
FREE(kvio->vio->trace);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
freeBio(kvio->bio, kvio->layer);
|
|
Packit Service |
310c69 |
FREE(kvio);
|
|
Packit Service |
310c69 |
*kvioPtr = NULL;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
void freeMetadataKVIO(MetadataKVIO **metadataKVIOPtr)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
freeKVIO((KVIO **) metadataKVIOPtr);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
void freeCompressedWriteKVIO(CompressedWriteKVIO **compressedWriteKVIOPtr)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
freeKVIO((KVIO **) compressedWriteKVIOPtr);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
void kvdoWriteCompressedBlock(AllocatingVIO *allocatingVIO)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
// This method assumes that compressed writes never set the flush or FUA
|
|
Packit Service |
310c69 |
// bits.
|
|
Packit Service |
310c69 |
CompressedWriteKVIO *compressedWriteKVIO
|
|
Packit Service |
310c69 |
= allocatingVIOAsCompressedWriteKVIO(allocatingVIO);
|
|
Packit Service |
310c69 |
KVIO *kvio = compressedWriteKVIOAsKVIO(compressedWriteKVIO);
|
|
Packit Service |
310c69 |
BIO *bio = kvio->bio;
|
|
Packit Service |
310c69 |
resetBio(bio, kvio->layer);
|
|
Packit Service |
310c69 |
setBioOperationWrite(bio);
|
|
Packit Service |
310c69 |
setBioSector(bio, blockToSector(kvio->layer, kvio->vio->physical));
|
|
Packit Service |
310c69 |
submitBio(bio, BIO_Q_ACTION_COMPRESSED_DATA);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Get the BioQueue action for a metadata VIO based on that VIO's priority.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param vio The VIO
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return The action with which to submit the VIO's BIO.
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
static inline BioQAction getMetadataAction(VIO *vio)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
return ((vio->priority == VIO_PRIORITY_HIGH)
|
|
Packit Service |
310c69 |
? BIO_Q_ACTION_HIGH : BIO_Q_ACTION_METADATA);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
void kvdoSubmitMetadataVIO(VIO *vio)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
KVIO *kvio = metadataKVIOAsKVIO(vioAsMetadataKVIO(vio));
|
|
Packit Service |
310c69 |
BIO *bio = kvio->bio;
|
|
Packit Service |
310c69 |
resetBio(bio, kvio->layer);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
setBioSector(bio, blockToSector(kvio->layer, vio->physical));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
// Metadata I/Os bypass the read cache.
|
|
Packit Service |
310c69 |
if (isReadVIO(vio)) {
|
|
Packit Service |
310c69 |
ASSERT_LOG_ONLY(!vioRequiresFlushBefore(vio),
|
|
Packit Service |
310c69 |
"read VIO does not require flush before");
|
|
Packit Service |
310c69 |
vioAddTraceRecord(vio, THIS_LOCATION("$F;io=readMeta"));
|
|
Packit Service |
310c69 |
setBioOperationRead(bio);
|
|
Packit Service |
310c69 |
} else {
|
|
Packit Service |
310c69 |
KernelLayerState state = getKernelLayerState(kvio->layer);
|
|
Packit Service |
310c69 |
ASSERT_LOG_ONLY(((state == LAYER_RUNNING)
|
|
Packit Service |
310c69 |
|| (state == LAYER_RESUMING)
|
|
Packit Service |
310c69 |
|| (state = LAYER_STARTING)),
|
|
Packit Service |
310c69 |
"write metadata in allowed state %d", state);
|
|
Packit Service |
310c69 |
if (vioRequiresFlushBefore(vio)) {
|
|
Packit Service |
310c69 |
setBioOperationWrite(bio);
|
|
Packit Service |
310c69 |
setBioOperationFlagPreflush(bio);
|
|
Packit Service |
310c69 |
vioAddTraceRecord(vio, THIS_LOCATION("$F;io=flushWriteMeta"));
|
|
Packit Service |
310c69 |
} else {
|
|
Packit Service |
310c69 |
setBioOperationWrite(bio);
|
|
Packit Service |
310c69 |
vioAddTraceRecord(vio, THIS_LOCATION("$F;io=writeMeta"));
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
if (vioRequiresFlushAfter(vio)) {
|
|
Packit Service |
310c69 |
setBioOperationFlagFua(bio);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
submitBio(bio, getMetadataAction(vio));
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Handle the completion of a base-code initiated flush by continuing the flush
|
|
Packit Service |
310c69 |
* VIO.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param bio The bio to complete
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
static void completeFlushBio(BIO *bio)
|
|
Packit Service |
310c69 |
#else
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Handle the completion of a base-code initiated flush by continuing the flush
|
|
Packit Service |
310c69 |
* VIO.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param bio The bio to complete
|
|
Packit Service |
310c69 |
* @param error Possible error from underlying block device
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
static void completeFlushBio(BIO *bio, int error)
|
|
Packit Service |
310c69 |
#endif
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4,4,0)
|
|
Packit Service |
310c69 |
int error = getBioResult(bio);
|
|
Packit Service |
310c69 |
#endif
|
|
Packit Service |
310c69 |
KVIO *kvio = (KVIO *) bio->bi_private;
|
|
Packit Service |
310c69 |
// XXX This assumes a VDO-created bio around a buffer contains exactly 1
|
|
Packit Service |
310c69 |
// page, which we believe is true, but do not assert.
|
|
Packit Service |
310c69 |
bio->bi_vcnt = 1;
|
|
Packit Service |
310c69 |
// Restore the bio's notion of its own data.
|
|
Packit Service |
310c69 |
resetBio(bio, kvio->layer);
|
|
Packit Service |
310c69 |
kvdoContinueKvio(kvio, error);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
void kvdoFlushVIO(VIO *vio)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
KVIO *kvio = metadataKVIOAsKVIO(vioAsMetadataKVIO(vio));
|
|
Packit Service |
310c69 |
BIO *bio = kvio->bio;
|
|
Packit Service |
310c69 |
KernelLayer *layer = kvio->layer;
|
|
Packit Service |
310c69 |
resetBio(bio, layer);
|
|
Packit Service |
310c69 |
prepareFlushBIO(bio, kvio, getKernelLayerBdev(layer), completeFlushBio);
|
|
Packit Service |
310c69 |
submitBio(bio, getMetadataAction(vio));
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/*
|
|
Packit Service |
310c69 |
* Hook for a SystemTap probe to potentially restrict the choices
|
|
Packit Service |
310c69 |
* of which VIOs should have their latencies tracked.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* Normally returns true. Even if true is returned, sampleThisOne may
|
|
Packit Service |
310c69 |
* cut down the monitored VIOs by some fraction so as to reduce the
|
|
Packit Service |
310c69 |
* impact on system performance.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* Must be "noinline" so that SystemTap can find the return
|
|
Packit Service |
310c69 |
* instruction and modify the return value.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param kvio The KVIO being initialized
|
|
Packit Service |
310c69 |
* @param layer The kernel layer
|
|
Packit Service |
310c69 |
* @param bio The incoming I/O request
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return whether it's useful to track latency for VIOs looking like
|
|
Packit Service |
310c69 |
* this one
|
|
Packit Service |
310c69 |
*/
|
|
Packit Service |
310c69 |
static noinline bool
|
|
Packit Service |
310c69 |
sampleThisVIO(KVIO *kvio, KernelLayer *layer, BIO *bio)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
bool result = true;
|
|
Packit Service |
310c69 |
// Ensure the arguments and result exist at the same time, for SystemTap.
|
|
Packit Service |
310c69 |
__asm__ __volatile__(""
|
|
Packit Service |
310c69 |
: "=g" (result)
|
|
Packit Service |
310c69 |
: "0" (result),
|
|
Packit Service |
310c69 |
"g" (kvio),
|
|
Packit Service |
310c69 |
"g" (layer),
|
|
Packit Service |
310c69 |
"g" (bio)
|
|
Packit Service |
310c69 |
: "memory");
|
|
Packit Service |
310c69 |
return result;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
void initializeKVIO(KVIO *kvio,
|
|
Packit Service |
310c69 |
KernelLayer *layer,
|
|
Packit Service |
310c69 |
VIOType vioType,
|
|
Packit Service |
310c69 |
VIOPriority priority,
|
|
Packit Service |
310c69 |
void *parent,
|
|
Packit Service |
310c69 |
BIO *bio)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
if (layer->vioTraceRecording
|
|
Packit Service |
310c69 |
&& sampleThisVIO(kvio, layer, bio)
|
|
Packit Service |
310c69 |
&& sampleThisOne(&layer->traceSampleCounter)) {
|
|
Packit Service |
310c69 |
int result = (isDataVIOType(vioType)
|
|
Packit Service |
310c69 |
? allocTraceFromPool(layer, &kvio->vio->trace)
|
|
Packit Service |
310c69 |
: ALLOCATE(1, Trace, "trace", &kvio->vio->trace));
|
|
Packit Service |
310c69 |
if (result != VDO_SUCCESS) {
|
|
Packit Service |
310c69 |
logError("trace record allocation failure %d", result);
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
kvio->bio = bio;
|
|
Packit Service |
310c69 |
kvio->layer = layer;
|
|
Packit Service |
310c69 |
if (bio != NULL) {
|
|
Packit Service |
310c69 |
bio->bi_private = kvio;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
initializeVIO(kvio->vio, vioType, priority, parent, getVDO(&layer->kvdo),
|
|
Packit Service |
310c69 |
&layer->common);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
// XXX: The "init" label should be replaced depending on the
|
|
Packit Service |
310c69 |
// write/read/flush path followed.
|
|
Packit Service |
310c69 |
kvioAddTraceRecord(kvio, THIS_LOCATION("$F;io=?init;j=normal"));
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
VDOCompletion *completion = vioAsCompletion(kvio->vio);
|
|
Packit Service |
310c69 |
kvio->enqueueable.enqueueable.completion = completion;
|
|
Packit Service |
310c69 |
completion->enqueueable = &kvio->enqueueable.enqueueable;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Construct a metadata KVIO.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param [in] layer The physical layer
|
|
Packit Service |
310c69 |
* @param [in] vioType The type of VIO to create
|
|
Packit Service |
310c69 |
* @param [in] priority The relative priority to assign to the
|
|
Packit Service |
310c69 |
* MetadataKVIO
|
|
Packit Service |
310c69 |
* @param [in] parent The parent of the MetadataKVIO completion
|
|
Packit Service |
310c69 |
* @param [in] bio The bio to associate with this MetadataKVIO
|
|
Packit Service |
310c69 |
* @param [out] metadataKVIOPtr A pointer to hold the new MetadataKVIO
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result))
|
|
Packit Service |
310c69 |
static int makeMetadataKVIO(KernelLayer *layer,
|
|
Packit Service |
310c69 |
VIOType vioType,
|
|
Packit Service |
310c69 |
VIOPriority priority,
|
|
Packit Service |
310c69 |
void *parent,
|
|
Packit Service |
310c69 |
BIO *bio,
|
|
Packit Service |
310c69 |
MetadataKVIO **metadataKVIOPtr)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
// If MetadataKVIO grows past 256 bytes, we'll lose benefits of VDOSTORY-176.
|
|
Packit Service |
310c69 |
STATIC_ASSERT(sizeof(MetadataKVIO) <= 256);
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
// Metadata VIOs should use direct allocation and not use the buffer pool,
|
|
Packit Service |
310c69 |
// which is reserved for submissions from the linux block layer.
|
|
Packit Service |
310c69 |
MetadataKVIO *metadataKVIO;
|
|
Packit Service |
310c69 |
int result = ALLOCATE(1, MetadataKVIO, __func__, &metadataKVIO);
|
|
Packit Service |
310c69 |
if (result != VDO_SUCCESS) {
|
|
Packit Service |
310c69 |
logError("metadata KVIO allocation failure %d", result);
|
|
Packit Service |
310c69 |
return result;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
KVIO *kvio = &metadataKVIO->kvio;
|
|
Packit Service |
310c69 |
kvio->vio = &metadataKVIO->vio;
|
|
Packit Service |
310c69 |
initializeKVIO(kvio, layer, vioType, priority, parent, bio);
|
|
Packit Service |
310c69 |
*metadataKVIOPtr = metadataKVIO;
|
|
Packit Service |
310c69 |
return VDO_SUCCESS;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**
|
|
Packit Service |
310c69 |
* Construct a CompressedWriteKVIO.
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @param [in] layer The physical layer
|
|
Packit Service |
310c69 |
* @param [in] parent The parent of the CompressedWriteKVIO
|
|
Packit Service |
310c69 |
* completion
|
|
Packit Service |
310c69 |
* @param [in] bio The bio to associate with this
|
|
Packit Service |
310c69 |
* CompressedWriteKVIO
|
|
Packit Service |
310c69 |
* @param [out] compressedWriteKVIOPtr A pointer to hold the new
|
|
Packit Service |
310c69 |
* CompressedWriteKVIO
|
|
Packit Service |
310c69 |
*
|
|
Packit Service |
310c69 |
* @return VDO_SUCCESS or an error
|
|
Packit Service |
310c69 |
**/
|
|
Packit Service |
310c69 |
__attribute__((warn_unused_result))
|
|
Packit Service |
310c69 |
static int
|
|
Packit Service |
310c69 |
makeCompressedWriteKVIO(KernelLayer *layer,
|
|
Packit Service |
310c69 |
void *parent,
|
|
Packit Service |
310c69 |
BIO *bio,
|
|
Packit Service |
310c69 |
CompressedWriteKVIO **compressedWriteKVIOPtr)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
// Compressed write VIOs should use direct allocation and not use the buffer
|
|
Packit Service |
310c69 |
// pool, which is reserved for submissions from the linux block layer.
|
|
Packit Service |
310c69 |
CompressedWriteKVIO *compressedWriteKVIO;
|
|
Packit Service |
310c69 |
int result = ALLOCATE(1, CompressedWriteKVIO, __func__,
|
|
Packit Service |
310c69 |
&compressedWriteKVIO);
|
|
Packit Service |
310c69 |
if (result != VDO_SUCCESS) {
|
|
Packit Service |
310c69 |
logError("compressed write KVIO allocation failure %d", result);
|
|
Packit Service |
310c69 |
return result;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
KVIO *kvio = &compressedWriteKVIO->kvio;
|
|
Packit Service |
310c69 |
kvio->vio = allocatingVIOAsVIO(&compressedWriteKVIO->allocatingVIO);
|
|
Packit Service |
310c69 |
initializeKVIO(kvio, layer, VIO_TYPE_COMPRESSED_BLOCK,
|
|
Packit Service |
310c69 |
VIO_PRIORITY_COMPRESSED_DATA, parent, bio);
|
|
Packit Service |
310c69 |
*compressedWriteKVIOPtr = compressedWriteKVIO;
|
|
Packit Service |
310c69 |
return VDO_SUCCESS;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
int kvdoCreateMetadataVIO(PhysicalLayer *layer,
|
|
Packit Service |
310c69 |
VIOType vioType,
|
|
Packit Service |
310c69 |
VIOPriority priority,
|
|
Packit Service |
310c69 |
void *parent,
|
|
Packit Service |
310c69 |
char *data,
|
|
Packit Service |
310c69 |
VIO **vioPtr)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
int result = ASSERT(isMetadataVIOType(vioType),
|
|
Packit Service |
310c69 |
"%d is a metadata type", vioType);
|
|
Packit Service |
310c69 |
if (result != VDO_SUCCESS) {
|
|
Packit Service |
310c69 |
return result;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
BIO *bio;
|
|
Packit Service |
310c69 |
KernelLayer *kernelLayer = asKernelLayer(layer);
|
|
Packit Service |
310c69 |
result = createBio(kernelLayer, data, &bio;;
|
|
Packit Service |
310c69 |
if (result != VDO_SUCCESS) {
|
|
Packit Service |
310c69 |
return result;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
MetadataKVIO *metadataKVIO;
|
|
Packit Service |
310c69 |
result = makeMetadataKVIO(kernelLayer, vioType, priority, parent, bio,
|
|
Packit Service |
310c69 |
&metadataKVIO);
|
|
Packit Service |
310c69 |
if (result != VDO_SUCCESS) {
|
|
Packit Service |
310c69 |
freeBio(bio, kernelLayer);
|
|
Packit Service |
310c69 |
return result;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
*vioPtr = &metadataKVIO->vio;
|
|
Packit Service |
310c69 |
return VDO_SUCCESS;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
/**********************************************************************/
|
|
Packit Service |
310c69 |
int kvdoCreateCompressedWriteVIO(PhysicalLayer *layer,
|
|
Packit Service |
310c69 |
void *parent,
|
|
Packit Service |
310c69 |
char *data,
|
|
Packit Service |
310c69 |
AllocatingVIO **allocatingVIOPtr)
|
|
Packit Service |
310c69 |
{
|
|
Packit Service |
310c69 |
BIO *bio;
|
|
Packit Service |
310c69 |
KernelLayer *kernelLayer = asKernelLayer(layer);
|
|
Packit Service |
310c69 |
int result = createBio(kernelLayer, data, &bio;;
|
|
Packit Service |
310c69 |
if (result != VDO_SUCCESS) {
|
|
Packit Service |
310c69 |
return result;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
CompressedWriteKVIO *compressedWriteKVIO;
|
|
Packit Service |
310c69 |
result = makeCompressedWriteKVIO(kernelLayer, parent, bio,
|
|
Packit Service |
310c69 |
&compressedWriteKVIO);
|
|
Packit Service |
310c69 |
if (result != VDO_SUCCESS) {
|
|
Packit Service |
310c69 |
freeBio(bio, kernelLayer);
|
|
Packit Service |
310c69 |
return result;
|
|
Packit Service |
310c69 |
}
|
|
Packit Service |
310c69 |
|
|
Packit Service |
310c69 |
*allocatingVIOPtr = &compressedWriteKVIO->allocatingVIO;
|
|
Packit Service |
310c69 |
return VDO_SUCCESS;
|
|
Packit Service |
310c69 |
}
|