|
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/deadlockQueue.c#1 $
|
|
Packit Service |
b3514a |
*/
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
#include "deadlockQueue.h"
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**********************************************************************/
|
|
Packit Service |
b3514a |
void initializeDeadlockQueue(DeadlockQueue *queue)
|
|
Packit Service |
b3514a |
{
|
|
Packit Service |
b3514a |
spin_lock_init(&queue->lock);
|
|
Packit Service |
b3514a |
bio_list_init(&queue->list);
|
|
Packit Service |
b3514a |
}
|
|
Packit Service |
b3514a |
|
|
Packit Service |
b3514a |
/**********************************************************************/
|
|
Packit Service |
b3514a |
void addToDeadlockQueue(DeadlockQueue *queue, BIO *bio, Jiffies arrivalTime)
|
|
Packit Service |
b3514a |
{
|
|
Packit Service |
b3514a |
spin_lock(&queue->lock);
|
|
Packit Service |
b3514a |
if (bio_list_empty(&queue->list)) {
|
|
Packit Service |
b3514a |
/*
|
|
Packit Service |
b3514a |
* If we get more than one pending at once, this will be inaccurate for
|
|
Packit Service |
b3514a |
* some of them. Oh well. If we've gotten here, we're trying to avoid a
|
|
Packit Service |
b3514a |
* deadlock; stats are a secondary concern.
|
|
Packit Service |
b3514a |
*/
|
|
Packit Service |
b3514a |
queue->arrivalTime = arrivalTime;
|
|
Packit Service |
b3514a |
}
|
|
Packit Service |
b3514a |
bio_list_add(&queue->list, bio);
|
|
Packit Service |
b3514a |
spin_unlock(&queue->lock);
|
|
Packit Service |
b3514a |
}
|