|
Packit Service |
7e342f |
/*
|
|
Packit Service |
7e342f |
* Copyright (c) 2020 Red Hat, Inc.
|
|
Packit Service |
7e342f |
*
|
|
Packit Service |
7e342f |
* This program is free software; you can redistribute it and/or
|
|
Packit Service |
7e342f |
* modify it under the terms of the GNU General Public License
|
|
Packit Service |
7e342f |
* as published by the Free Software Foundation; either version 2
|
|
Packit Service |
7e342f |
* of the License, or (at your option) any later version.
|
|
Packit Service |
7e342f |
*
|
|
Packit Service |
7e342f |
* This program is distributed in the hope that it will be useful,
|
|
Packit Service |
7e342f |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
7e342f |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit Service |
7e342f |
* GNU General Public License for more details.
|
|
Packit Service |
7e342f |
*
|
|
Packit Service |
7e342f |
* You should have received a copy of the GNU General Public License
|
|
Packit Service |
7e342f |
* along with this program; if not, write to the Free Software
|
|
Packit Service |
7e342f |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
Packit Service |
7e342f |
* 02110-1301, USA.
|
|
Packit Service |
7e342f |
*
|
|
Packit Service |
7e342f |
* $Id: //eng/vdo-releases/aluminum/src/c++/vdo/kernel/deadlockQueue.c#1 $
|
|
Packit Service |
7e342f |
*/
|
|
Packit Service |
7e342f |
|
|
Packit Service |
7e342f |
#include "deadlockQueue.h"
|
|
Packit Service |
7e342f |
|
|
Packit Service |
7e342f |
/**********************************************************************/
|
|
Packit Service |
7e342f |
void initializeDeadlockQueue(DeadlockQueue *queue)
|
|
Packit Service |
7e342f |
{
|
|
Packit Service |
7e342f |
spin_lock_init(&queue->lock);
|
|
Packit Service |
7e342f |
bio_list_init(&queue->list);
|
|
Packit Service |
7e342f |
}
|
|
Packit Service |
7e342f |
|
|
Packit Service |
7e342f |
/**********************************************************************/
|
|
Packit Service |
7e342f |
void addToDeadlockQueue(DeadlockQueue *queue, BIO *bio, Jiffies arrivalTime)
|
|
Packit Service |
7e342f |
{
|
|
Packit Service |
7e342f |
spin_lock(&queue->lock);
|
|
Packit Service |
7e342f |
if (bio_list_empty(&queue->list)) {
|
|
Packit Service |
7e342f |
/*
|
|
Packit Service |
7e342f |
* If we get more than one pending at once, this will be inaccurate for
|
|
Packit Service |
7e342f |
* some of them. Oh well. If we've gotten here, we're trying to avoid a
|
|
Packit Service |
7e342f |
* deadlock; stats are a secondary concern.
|
|
Packit Service |
7e342f |
*/
|
|
Packit Service |
7e342f |
queue->arrivalTime = arrivalTime;
|
|
Packit Service |
7e342f |
}
|
|
Packit Service |
7e342f |
bio_list_add(&queue->list, bio);
|
|
Packit Service |
7e342f |
spin_unlock(&queue->lock);
|
|
Packit Service |
7e342f |
}
|