Commit 44445500 authored by Mike Hibler's avatar Mike Hibler

Get rid of old SHD (shadow disk) support.

Another idea whose time never came...
parent 2b6575d3
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2009 University of Utah and the Flux Group.
# Copyright (c) 2000-2010 University of Utah and the Flux Group.
# All rights reserved.
#
......@@ -41,10 +41,6 @@ WITH_LTHREADS = 1
endif
endif
endif
# XXX special checkpoint/shadow device support
WITH_SHD = 0
endif
# Linux specific goop
......@@ -145,14 +141,6 @@ SUBDIRS += fat
ZIPLIBS += fat/libfat.a
endif
# with SHD
ifeq ($(WITH_SHD),1)
CFLAGS += -DWITH_SHD
SUBDIRS += shd
ZIPLIBS += shd/libshd.a
SHDLIBS += shd/libshd.a
endif
# with HASH
ifeq ($(WITH_HASH),1)
CFLAGS += -DWITH_HASH -DHASHSTATS
......@@ -185,8 +173,8 @@ imageunzip: imageunzip.o disksize.o crc.o version.o
imageunzip.o: imageunzip.c
$(CC) -c $(UNZIPCFLAGS) -o imageunzip.o $<
imagedump: imagedump.o version.o $(SHDLIBS)
$(CC) $(CFLAGS) imagedump.o version.o $(LIBS) $(SHDLIBS) -o imagedump
imagedump: imagedump.o version.o
$(CC) $(CFLAGS) imagedump.o version.o $(LIBS) -o imagedump
imagehash: imagehash.o version.o
$(CC) $(CFLAGS) imagehash.o version.o $(HASHLIBS) -o imagehash
......
......@@ -55,12 +55,6 @@ static int dumpchunk(char *name, char *buf, int chunkno, int checkindex);
static void dumpchunkhash(char *name, char *buf, int chunkno, int checkindex);
#endif
#ifdef WITH_SHD
void add_shdrange(u_int32_t start, u_int32_t size);
int write_shd(char *shddev);
int debug = 0;
#endif
#define SECTOBYTES(s) ((unsigned long long)(s) * SECSIZE)
int
......@@ -288,13 +282,6 @@ dumpfile(char *name, int fd)
}
done:
#ifdef WITH_SHD
if (chkpointdev && write_shd(chkpointdev)) {
fprintf(stderr, "Could not record SHD alloc block info\n");
exit(1);
}
#endif
if (filesize == 0)
filesize = (off_t)(chunkno + 1) * CHUNKSIZE;
......@@ -505,14 +492,6 @@ dumpchunk(char *name, char *buf, int chunkno, int checkindex)
franges++;
}
#ifdef WITH_SHD
/*
* Accumulate SHD allocated list info
*/
if (chkpointdev)
add_shdrange(reg->start, reg->size);
#endif
count = reg->size;
sectinuse += count;
if (count < amin)
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2009 University of Utah and the Flux Group.
* Copyright (c) 2000-2010 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -61,10 +61,6 @@ int filemode = 0;
off_t datawritten;
partmap_t ignore, forceraw;
#ifdef WITH_SHD
char *chkpointdev;
#endif
#ifdef WITH_HASH
char *hashfile;
#endif
......@@ -119,11 +115,6 @@ int read_raw(void);
int compress_image(void);
void usage(void);
#ifdef WITH_SHD
int read_shd(char *shddev, char *infile, int infd, u_int32_t ssect,
void (*add)(uint32_t, uint32_t));
#endif
#ifdef WITH_HASH
struct range *hashmap_compute_delta(struct range *, char *, int, u_int32_t);
void report_hash_stats(int pnum);
......@@ -379,7 +370,7 @@ main(int argc, char *argv[])
extern char build_info[];
gettimeofday(&sstamp, 0);
while ((ch = getopt(argc, argv, "vlbnNdihrs:c:z:ofI:1F:DR:S:XC:H:M")) != -1)
while ((ch = getopt(argc, argv, "vlbnNdihrs:c:z:ofI:1F:DR:S:XH:M")) != -1)
switch(ch) {
case 'v':
version++;
......@@ -447,14 +438,6 @@ main(int argc, char *argv[])
case 'X':
forcereads++;
break;
case 'C':
#ifdef WITH_SHD
chkpointdev = optarg;
#else
fprintf(stderr, "'C' option not supported\n");
usage();
#endif
break;
case 'H':
#ifdef WITH_HASH
hashfile = optarg;
......@@ -487,9 +470,6 @@ main(int argc, char *argv[])
fprintf(stderr, "%c %s",
ch > 1 ? ',' : ':',
fsmap[ch].desc);
#ifdef WITH_SHD
fprintf(stderr, ", SHD device");
#endif
#ifdef WITH_HASH
fprintf(stderr, ", hash-signature comparison");
#endif
......@@ -538,73 +518,33 @@ main(int argc, char *argv[])
inputmaxsec = getdisksize(infd);
#endif
#ifdef WITH_SHD
if (chkpointdev) {
rval = 0;
if (dorelocs) {
fprintf(stderr, "WARNING: no relocation info "
"generated for checkpoint images\n");
dorelocs = 0;
}
/*
* Slice indicates the slice shadowed for checkpointing.
* XXX we need this right now to determine the offset of
* the block numbers returned by the shd device.
*/
if (slicemode) {
struct doslabel doslabel;
rval = read_doslabel(infd, DOSBBSECTOR, 0, &doslabel);
if (rval == 0) {
inputminsec = doslabel.parts[slice-1].dp_start;
inputmaxsec = inputminsec +
doslabel.parts[slice-1].dp_size;
}
}
if (rval == 0) {
rval = read_shd(chkpointdev, infilename, infd,
inputminsec, addvalid);
if (rval == 0)
sortrange(&ranges, 1, 0);
}
if (rval) {
fprintf(stderr, "* * * Aborting * * *\n");
exit(1);
}
} else
#endif
{
/*
* Create the skip list by scanning the filesystems on
* the disk or indicated partition.
*/
if (slicetype != 0) {
rval = read_slice(-1, slicetype, 0, 0,
infilename, infd);
if (rval == -1)
fprintf(stderr, ", cannot process\n");
} else if (rawmode)
rval = read_raw();
else
rval = read_image(DOSBBSECTOR, 0, 0);
if (rval) {
fprintf(stderr, "* * * Aborting * * *\n");
exit(1);
}
/*
* Create a valid range list from the skip list
*/
(void) mergeskips(debug > 1);
if (debug)
dumpskips(debug > 1);
makeranges();
/*
* Create the skip list by scanning the filesystems on
* the disk or indicated partition.
*/
if (slicetype != 0) {
rval = read_slice(-1, slicetype, 0, 0,
infilename, infd);
if (rval == -1)
fprintf(stderr, ", cannot process\n");
} else if (rawmode)
rval = read_raw();
else
rval = read_image(DOSBBSECTOR, 0, 0);
if (rval) {
fprintf(stderr, "* * * Aborting * * *\n");
exit(1);
}
/*
* Create a valid range list from the skip list
*/
(void) mergeskips(debug > 1);
if (debug)
dumpskips(debug > 1);
makeranges();
if (debug)
dumpranges(debug > 1);
sortrange(&fixups, 0, cmpfixups);
if (debug > 1)
dumpfixups(debug > 2);
......
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2005 University of Utah and the Flux Group.
# All rights reserved.
#
SRCDIR = @srcdir@
TESTBED_SRCDIR = @top_srcdir@
OBJDIR = ../../..
SUBDIR = os/imagezip/shd
MAINDIR = $(SRCDIR)/..
include $(OBJDIR)/Makeconf
CFLAGS += $(SUBDIRCFLAGS) -I$(MAINDIR) -I$(SRCDIR)
all: libshd.a
include $(TESTBED_SRCDIR)/GNUmakerules
OBJS = shd.o
shd.o: shd.h
shd.o: $(MAINDIR)/global.h $(MAINDIR)/sliceinfo.h $(MAINDIR)/imagehdr.h
libshd.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $?
$(RANLIB) $@
install:
clean:
rm -f libshd.a $(OBJS)
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2005 University of Utah and the Flux Group.
* All rights reserved.
*/
/*
* Support for extracting a changed block list from the shadow/checkpoint
* device driver.
*
* Open the indicated device and make repeated ioctl calls to extract the
* changed block info.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <assert.h>
#include <sys/ioctl.h>
#include "shd.h"
#include "sliceinfo.h"
#include "global.h"
#include "imagehdr.h"
#define ENTRIESPERCALL 1024
#ifdef FAKEIT
#define SHDIOCTL fake_ioctl
int fake_ioctl(int, int, void *);
#else
#define SHDIOCTL ioctl
#endif
int
read_shd(char *shddev, char *infile, int infd, u_int32_t ssect,
void (*addvalid)(u_int32_t, u_int32_t))
{
int shdfd;
struct shd_modinfo sm;
sm.bufsiz = ENTRIESPERCALL;
sm.buf = malloc(sm.bufsiz * sizeof(struct shd_range));
if (sm.buf == 0) {
fprintf(stderr, "No memory for SHD ranges\n");
return 1;
}
/*
* Open the shd device so we can ioctl
*/
shdfd = open(shddev, O_RDONLY, 0);
if (shdfd < 0) {
perror(shddev);
return 1;
}
/*
* Initialize the iterator (and return the first set of entries)
*/
sm.command = 1;
if (SHDIOCTL(shdfd, SHDGETMODIFIEDRANGES, &sm) < 0) {
perror(shddev);
close(shdfd);
return 1;
}
/*
* Loop extracting changed block ranges and creating imagezip
* block ranges.
*/
while (sm.retsiz > 0) {
struct shd_range *sr = sm.buf;
if (debug > 1)
fprintf(stderr, "GETRANGES returns %ld ranges:\n",
sm.retsiz);
for (sr = sm.buf; sm.retsiz > 0; sr++, sm.retsiz--) {
if (debug > 2)
fprintf(stderr, " %12d %9d\n",
sr->start, (sr->end-sr->start));
(*addvalid)(sr->start + ssect, (sr->end-sr->start));
}
sm.command = 2;
if (SHDIOCTL(shdfd, SHDGETMODIFIEDRANGES, &sm) < 0) {
perror(shddev);
close(shdfd);
/* XXX should flush the valid table */
return 1;
}
}
sm.command = 3;
(void) SHDIOCTL(shdfd, SHDGETMODIFIEDRANGES, &sm);
close(shdfd);
return 0;
}
static struct shd_allocinfo alloclist;
int
write_shd(char *shddev)
{
int shdfd;
if (alloclist.buf == 0 || alloclist.bufsiz == 0)
return 0;
/*
* Open the shd device so we can ioctl
*/
shdfd = open(shddev, O_RDWR);
if (shdfd < 0) {
perror(shddev);
return 1;
}
if (SHDIOCTL(shdfd, SHDSETALLOCATEDRANGES, &alloclist) < 0) {
perror(shddev);
close(shdfd);
return 1;
}
close(shdfd);
free(alloclist.buf);
alloclist.buf = 0;
alloclist.bufsiz = 0;
return 0;
}
void
add_shdrange(u_int32_t start, u_int32_t size)
{
size_t nsize = (alloclist.bufsiz + 1) * sizeof(struct shd_range);
alloclist.buf = realloc(alloclist.buf, nsize);
if (alloclist.buf == 0) {
fprintf(stderr, "No memory for SHD alloc ranges\n");
exit(1);
}
alloclist.buf[alloclist.bufsiz].start = start;
alloclist.buf[alloclist.bufsiz].end = start + size;
alloclist.bufsiz++;
}
#ifdef FAKEIT
struct shd_range foo[] = {
{ 110427, 4 },
{ 2410487, 8 },
{ 2564819, 12 },
{ 2862827, 16 },
{ 2774027, 20 },
{ 4277895, 24 },
{ 3853567, 28 },
{ 2372447, 32 },
{ 12352615, 40 },
{ 5428223, 44 },
{ 2436383, 48 },
{ 2602463, 52 },
{ 11039151, 56 },
{ 4774459, 68 },
{ 10265207, 88 },
{ 4409343, 120 },
{ 4387795, 204 },
{ 11033303, 408 },
{ 9786815, 1040 },
{ 2361715, 1056 },
{ 8139631, 1752 },
{ 9795103, 11808 },
{ 4499231, 104368 },
{ 11832015, 112032 },
{ 9076719, 115560 },
{ 9307719, 123600 },
{ 5598591, 130240 },
{ 0, 0 }
};
int
fake_ioctl(int fd, int cmd, void *data)
{
static struct shd_range *fooptr, *out;
int i;
switch (cmd) {
case SHDGETMODIFIEDRANGES:
{
struct shd_modinfo *sm = data;
switch (sm->command) {
case 1:
fooptr = foo;
case 2:
out = sm->buf;
for (i = 0; i < sm->bufsiz; i++) {
if (fooptr->start == 0 && fooptr->end == 0)
break;
out->start = fooptr->start;
out->end = fooptr->start + fooptr->end;
fooptr++, out++;
}
sm->retsiz = i;
break;
case 3:
break;
}
return 0;
}
case SHDSETALLOCATEDRANGES:
{
struct shd_allocinfo *sa = data;
int i;
printf("SETALLOCATEDRANGES: %ld entries:\n", sa->bufsiz);
out = sa->buf;
for (i = 0; i < sa->bufsiz; i++) {
printf(" [%u-%u]\n", out->start, out->end);
out++;
}
return 0;
}
}
return -1;
}
#endif
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2005 University of Utah and the Flux Group.
* All rights reserved.
*/
/*
* XXX all this should come out of a standard include file, this is just
* here to get everything to compile.
*/
#include <sys/ioctl.h>
struct shd_range {
u_int32_t start;
u_int32_t end;
};
struct shd_modinfo {
int command; /* init=1, data=2, deinit=3 */
struct shd_range *buf; /* range buffer */
long bufsiz; /* buffer size (in entries) */
long retsiz; /* size of returned data (in entries) */
};
struct shd_allocinfo {
struct shd_range *buf; /* range buffer */
long bufsiz; /* buffer size (in entries) */
};
#define SHDGETMODIFIEDRANGES _IOWR('S', 29, struct shd_modinfo)
#define SHDSETALLOCATEDRANGES _IOWR('S', 30, struct shd_allocinfo)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment