/*
ext2_buffer.c -- ext2 buffer cache
Copyright (C) 1998-2000, 2007, 2009-2010 Free Software Foundation,
Inc.
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#ifndef DISCOVER_ONLY
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ext2.h"
/* pseudo-header */
{
unsigned long x;
}
static void ext2_bh_dealloc (struct ext2_buffer_head *);
static int ext2_bh_do_read (struct ext2_buffer_head *);
static int ext2_bh_do_write(struct ext2_buffer_head *);
static void ext2_bh_hash (struct ext2_buffer_head *);
static void ext2_bh_unhash (struct ext2_buffer_head *);
{
int i;
{
{
return 1;
}
}
{
{
return 1;
}
}
_("Couldn't flush buffer cache!"))
return 0;
return 1;
}
{
int i;
{
break;
}
{
goto tryagain;
}
return bh;
}
{
}
{
struct ext2_buffer_head *a;
struct ext2_buffer_head *b;
int hash;
if (a != NULL)
{
b = a;
do
{
return a;
a = a->next;
} while (a != b);
}
return NULL;
}
{
}
{
"Attempt to write unallocated buffer.");
return 0;
}
return 1;
}
{
int hash;
{
return;
}
}
{
int hash;
{
else
}
}
static int breadimmhits = 0;
static int breadindhits = 0;
static int breadmisses = 0;
{
if (fs->opt_verbose)
"direct hits: %i, indirect hits: %i, misses: %i\n",
}
{
int i;
for (i=0;i<(1<<ext2_hash_bits);i++)
{
struct ext2_buffer_head *a;
struct ext2_buffer_head *b;
do
{
a = a->next;
} while (a != b);
}
}
{
return 1;
"Attempt to flush a buffer that's in use! [%i,%i]",
return 0;
}
if (!ext2_bh_do_write(bh))
return 0;
}
return 1;
}
{
return 0;
}
return 1;
}
{
int i;
int size;
return 0;
if ((bc->heads = (struct ext2_buffer_head *) ped_malloc(size * sizeof(struct ext2_buffer_head))) == NULL)
return 0;
if ((bc->hash = (struct ext2_buffer_head **) ped_malloc(sizeof(struct ext2_buffer_head *) << ext2_hash_bits)) == NULL)
{
return 0;
}
{
return 0;
}
for (i=0;i<size;i++)
{
}
for (i=0;i<(1<<ext2_hash_bits);i++)
return 1;
}
{
int i;
{
if (!ext2_bh_do_write(bh))
return 0;
}
}
return 1;
}
{
{
}
else
{
}
return bh;
}
{
{
breadimmhits++;
return bh;
}
{
breadindhits++;
return bh;
}
breadmisses++;
if (!ext2_bh_do_read(bh)) {
return NULL;
}
return bh;
}
{
{
if (!ext2_bh_do_write(bh))
return 0;
}
}
return 1;
}
#endif /* !DISCOVER_ONLY */