|
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/dedupeIndex.c#1 $
|
|
Packit Service |
d40955 |
*/
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#include "dedupeIndex.h"
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#include "numeric.h"
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
#include "udsIndex.h"
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
// These times are in milliseconds
|
|
Packit Service |
d40955 |
unsigned int albireoTimeoutInterval = 5000;
|
|
Packit Service |
d40955 |
unsigned int minAlbireoTimerInterval = 100;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
// These times are in jiffies
|
|
Packit Service |
d40955 |
Jiffies albireoTimeoutJiffies = 0;
|
|
Packit Service |
d40955 |
static Jiffies minAlbireoTimerJiffies = 0;
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**********************************************************************/
|
|
Packit Service |
d40955 |
Jiffies getAlbireoTimeout(Jiffies startJiffies)
|
|
Packit Service |
d40955 |
{
|
|
Packit Service |
d40955 |
return maxULong(startJiffies + albireoTimeoutJiffies,
|
|
Packit Service |
d40955 |
jiffies + minAlbireoTimerJiffies);
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**********************************************************************/
|
|
Packit Service |
d40955 |
void setAlbireoTimeoutInterval(unsigned int value)
|
|
Packit Service |
d40955 |
{
|
|
Packit Service |
d40955 |
// Arbitrary maximum value is two minutes
|
|
Packit Service |
d40955 |
if (value > 120000) {
|
|
Packit Service |
d40955 |
value = 120000;
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
// Arbitrary minimum value is 2 jiffies
|
|
Packit Service |
d40955 |
Jiffies albJiffies = msecs_to_jiffies(value);
|
|
Packit Service |
d40955 |
if (albJiffies < 2) {
|
|
Packit Service |
d40955 |
albJiffies = 2;
|
|
Packit Service |
d40955 |
value = jiffies_to_msecs(albJiffies);
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
albireoTimeoutInterval = value;
|
|
Packit Service |
d40955 |
albireoTimeoutJiffies = albJiffies;
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**********************************************************************/
|
|
Packit Service |
d40955 |
void setMinAlbireoTimerInterval(unsigned int value)
|
|
Packit Service |
d40955 |
{
|
|
Packit Service |
d40955 |
// Arbitrary maximum value is one second
|
|
Packit Service |
d40955 |
if (value > 1000) {
|
|
Packit Service |
d40955 |
value = 1000;
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
// Arbitrary minimum value is 2 jiffies
|
|
Packit Service |
d40955 |
Jiffies minJiffies = msecs_to_jiffies(value);
|
|
Packit Service |
d40955 |
if (minJiffies < 2) {
|
|
Packit Service |
d40955 |
minJiffies = 2;
|
|
Packit Service |
d40955 |
value = jiffies_to_msecs(minJiffies);
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
minAlbireoTimerInterval = value;
|
|
Packit Service |
d40955 |
minAlbireoTimerJiffies = minJiffies;
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
/**********************************************************************/
|
|
Packit Service |
d40955 |
int makeDedupeIndex(DedupeIndex **indexPtr, KernelLayer *layer)
|
|
Packit Service |
d40955 |
{
|
|
Packit Service |
d40955 |
if (albireoTimeoutJiffies == 0) {
|
|
Packit Service |
d40955 |
setAlbireoTimeoutInterval(albireoTimeoutInterval);
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
if (minAlbireoTimerJiffies == 0) {
|
|
Packit Service |
d40955 |
setMinAlbireoTimerInterval(minAlbireoTimerInterval);
|
|
Packit Service |
d40955 |
}
|
|
Packit Service |
d40955 |
|
|
Packit Service |
d40955 |
return makeUDSIndex(layer, indexPtr);
|
|
Packit Service |
d40955 |
}
|