-/* $Id: bfile.c,v 1.35.2.1 2006-08-14 10:38:50 adam Exp $
+/* $Id: bfile.c,v 1.35.2.2 2006-10-04 09:07:19 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
{
if (!bfs)
return;
- mf_reset (bfs->commit_area);
- mf_reset (bfs->register_area);
+ mf_reset(bfs->commit_area, 1);
+ mf_reset(bfs->register_area, 1);
}
void bf_commitExec (BFiles bfs)
mustDisable = 1;
}
- if (!(inf = open_cache (bfs, "rb")))
- return ;
- while (fscanf (inf, "%s %d", path, &block_size) == 2)
- {
- mf = mf_open (bfs->register_area, path, block_size, 0);
- cf = cf_open (mf, bfs->commit_area, path, block_size, 1, &firstTime);
- cf_unlink (cf);
- cf_close (cf);
- mf_close (mf);
- }
- fclose (inf);
+ mf_reset(bfs->commit_area, 1);
+
unlink_cache (bfs);
if (mustDisable)
bf_cache (bfs, 0);
-/* $Id: commit.c,v 1.16.2.1 2006-08-14 10:38:50 adam Exp $
+/* $Id: commit.c,v 1.16.2.2 2006-10-04 09:07:19 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002
Index Data Aps
#define CF_OPTIMIZE_COMMIT 0
-void cf_unlink (CFile cf)
-{
- if (cf->bucket_in_memory)
- {
- logf (LOG_FATAL, "Cannot unlink potential dirty cache");
- exit (1);
- }
- cf->head.state = 0;
- cf->dirty = 1;
- mf_unlink (cf->block_mf);
- mf_unlink (cf->hash_mf);
-}
-
-
#if CF_OPTIMIZE_COMMIT
struct map_cache_entity {
int from;
-/* $Id: mfile.c,v 1.52.2.1 2006-08-14 10:38:50 adam Exp $
+/* $Id: mfile.c,v 1.52.2.2 2006-10-04 09:07:19 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
meta_f->next = ma->mfiles;
meta_f->open = 0;
meta_f->cur_file = -1;
- meta_f->unlink_flag = 0;
ma->mfiles = meta_f;
strcpy(meta_f->name, metaname);
part_f = &meta_f->files[0];
dp = dp->next;
xfree (d);
}
- meta_f = ma->mfiles;
- while (meta_f)
- {
- int i;
- meta_file *m = meta_f;
-
- for (i = 0; i<m->no_files; i++)
- {
- xfree (m->files[i].path);
- }
- zebra_mutex_destroy (&meta_f->mutex);
- meta_f = meta_f->next;
- xfree (m);
- }
+ mf_reset(ma, 0);
xfree (ma);
}
-void mf_reset(MFile_area ma)
+void mf_reset(MFile_area ma, int unlink_flag)
{
meta_file *meta_f;
int i;
meta_file *m = meta_f;
+ meta_f = meta_f->next;
+
assert (!m->open);
for (i = 0; i<m->no_files; i++)
{
- unlink (m->files[i].path);
+ if (unlink_flag)
+ unlink (m->files[i].path);
xfree (m->files[i].path);
}
- meta_f = meta_f->next;
+ zebra_mutex_destroy (&m->mutex);
xfree (m);
}
ma->mfiles = 0;
/*
* Open a metafile.
- * If !ma, Use MF_DEFAULT_AREA.
*/
MFile mf_open(MFile_area ma, const char *name, int block_size, int wflag)
{
mnew->files[0].top = -1;
mnew->files[0].number = 0;
mnew->files[0].fd = -1;
- mnew->unlink_flag = 0;
mnew->min_bytes_creat = MF_MIN_BLOCKS_CREAT * block_size;
for (dp = ma->dirs; dp && dp->max_bytes >= 0 && dp->avail_bytes <
mnew->min_bytes_creat; dp = dp->next);
close(mf->files[i].fd);
mf->files[i].fd = -1;
}
- if (mf->unlink_flag)
- unlink(mf->files[i].path);
}
mf->open = 0;
return 0;
return 0;
}
-/*
- * Destroy a metafile, unlinking component files. File must be open.
- */
-int mf_unlink(MFile mf)
-{
- if (mf->open)
- mf->unlink_flag = 1;
- else
- {
- int i;
- for (i = 0; i<mf->no_files; i++)
- unlink(mf->files[i].path);
- }
- return 0;
-}
-
-/*
- * Unlink the file by name, rather than MFile-handle. File should be closed.
- */
-int mf_unlink_name(MFile_area ma, const char *name)
-{
- abort();
- return 0;
-}
-/* $Id: mfile.h,v 1.21.2.1 2006-08-14 10:38:56 adam Exp $
+/* $Id: mfile.h,v 1.21.2.2 2006-10-04 09:07:19 adam Exp $
Copyright (C) 1995,1996,1997,1998,1999,2000,2001,2002,2003
Index Data Aps
int no_files;
int cur_file;
int open; /* is this file open? */
- int unlink_flag;
int blocksize;
mfile_off_t min_bytes_creat; /* minimum bytes required to enter directory */
MFile_area ma;
int mf_write(MFile mf, int no, int offset, int nbytes, const void *buf);
/*
- * Destroy a metafile, unlinking component files. File must be open.
- */
-int mf_unlink(MFile mf);
-
-
-/*
* Destroy all metafiles. No files may be opened.
*/
-void mf_reset(MFile_area ma);
+void mf_reset(MFile_area ma, int unlink_flag);
/*
* Unlink the file by name, rather than MFile-handle.