Windows: Build Demand Attach File Service

This patchset permits the building of demand attach file server
and volume server.

Change-Id: I7ee81c69924cde5e8aec2067d73b51cba7e4423e
Reviewed-on: http://gerrit.openafs.org/2450
Reviewed-by: Derrick Brashear <shadow@dementia.org>
Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
Jeffrey Altman 2010-07-20 00:05:18 -04:00 committed by Derrick Brashear
parent 939382c5c1
commit 901423b1e5
14 changed files with 208 additions and 54 deletions

View File

@ -283,7 +283,7 @@ ptserver: ubik
$(DOCD) $(SRC)\$@
$(CD) $(SRC)\$@
$(NTMAKE)
$(CD) ..\..
$(CD) ..\..
libacl: ptserver
@echo ***** $@
@ -431,7 +431,21 @@ tvolser: tviced
$(NTMAKE)
$(CD) ..\..
tbutc: tvolser
dviced: tvolser
@echo ***** $@
$(DOCD) $(SRC)\$@
$(CD) $(SRC)\$@
$(NTMAKE)
$(CD) ..\..
dvolser: dviced
@echo ***** $@
$(DOCD) $(SRC)\$@
$(CD) $(SRC)\$@
$(NTMAKE)
$(CD) ..\..
tbutc: dvolser
@echo ***** $@
$(DOCD) $(SRC)\$@
$(CD) $(SRC)\$@

View File

@ -165,6 +165,9 @@ idirs: doclink
! IF (!EXIST($(OJT)\ptserver))
$(MKDIR) $(OJT)\ptserver
! ENDIF
! IF (!EXIST($(OJT)\tptserver))
$(MKDIR) $(OJT)\ptserver
! ENDIF
! IF (!EXIST($(OJT)\rx))
$(MKDIR) $(OJT)\rx
! ENDIF
@ -201,9 +204,18 @@ idirs: doclink
! IF (!EXIST($(OJT)\tvolser))
$(MKDIR) $(OJT)\tvolser
! ENDIF
! IF (!EXIST($(OJT)\dviced))
$(MKDIR) $(OJT)\dviced
! ENDIF
! IF (!EXIST($(OJT)\dvolser))
$(MKDIR) $(OJT)\dvolser
! ENDIF
! IF (!EXIST($(OJT)\ubik))
$(MKDIR) $(OJT)\ubik
! ENDIF
! IF (!EXIST($(OJT)\tubik))
$(MKDIR) $(OJT)\tubik
! ENDIF
! IF (!EXIST($(OJT)\update))
$(MKDIR) $(OJT)\update
! ENDIF

View File

@ -202,3 +202,7 @@
#if (_MSC_VER < 1400)
typedef int errno_t;
#endif
/* Windows only supports BSD variants */
#define S_IRUSR _S_IREAD
#define S_IWUSR _S_IWRITE

View File

@ -11,15 +11,13 @@ RELDIR=dviced
!INCLUDE ..\config\NTMakefile.$(SYS_NAME)
!INCLUDE ..\config\NTMakefile.version
SRC_DIR = ..\viced
############################################################################
# Build the fileserver
# Build the dafs-fileserver
EXEFILE = $(DESTDIR)\root.server\usr\afs\bin\dafileserver.exe
VICED = ..\viced
TVICED = .
TVICED = ..\tviced
LWP = ..\lwp
LIBACL = ..\libacl
DIR = ..\dir
@ -31,10 +29,10 @@ RXOBJS = $(OUT)\xdr_int64.obj \
VICEDOBJS = $(OUT)\viced.obj $(OUT)\afsfileprocs.obj $(OUT)\host.obj $(OUT)\physio.obj $(OUT)\callback.obj
TVICEDRES = $(OUT)\dafileserver.res
TVICEDOBJS = $(OUT)\serialize_state.obj
DAFS_VICEDRES = $(OUT)\dafileserver.res
LWPOBJS = $(OUT)\lock.obj $(OUT)\fasttime.obj $(OUT)\threadname.obj
LIBACLOBJS = $(OUT)\aclprocs.obj $(OUT)\netprocs.obj
@ -43,12 +41,12 @@ DIROBJS = $(OUT)\buffer.obj $(OUT)\dir.obj $(OUT)\salvage.obj
FSINTOBJS = $(OUT)\afsaux.obj $(OUT)\afscbint.cs.obj $(OUT)\afsint.ss.obj $(OUT)\afsint.xdr.obj
EXEOBJS = $(VICEDOBJS) $(TVICEDRES) $(LWPOBJS) $(LIBACLOBJS) \
$(DIROBJS) $(FSINTOBJS) $(RXOBJS) #$(TVICEDOBJS)
EXEOBJS = $(VICEDOBJS) $(TVICEDOBJS) $(DAFS_VICEDRES) $(LWPOBJS) $(LIBACLOBJS) \
$(DIROBJS) $(FSINTOBJS) $(RXOBJS)
noversion: install
all: dafileserver
all: $(EXEFILE)
$(RXOBJS): $(RX)\$$(@B).c
$(C2OBJ) -I$(RX) $**
@ -56,8 +54,8 @@ $(RXOBJS): $(RX)\$$(@B).c
$(VICEDOBJS): $(VICED)\$$(@B).c
$(C2OBJ) -I$(VICED) $**
$(TVICEDRES): $(VICED)\dafileserver.rc AFS_component_version_number.h
$(RC) /fo $(TVICEDRES) $(TVICED)\dafileserver.rc
$(DAFS_VICEDRES): dafileserver.rc AFS_component_version_number.h
$(RC) /fo $(DAFS_VICEDRES) dafileserver.rc
$(TVICEDOBJS): $(TVICED)\$$(@B).c
$(C2OBJ) -I$(TVICED) $**
@ -84,7 +82,7 @@ EXELIBS = \
$(DESTDIR)\lib\afs\afsprocmgmt.lib \
$(DESTDIR)\lib\afs\afseventlog.lib \
$(DESTDIR)\lib\afs\mtafsutil.lib \
$(DESTDIR)\lib\afs\mtafsvol.lib \
$(DESTDIR)\lib\afs\daafsvol.lib \
$(DESTDIR)\lib\afs\mtafsvldb.lib \
$(DESTDIR)\lib\afspthread.lib
@ -100,6 +98,7 @@ install: $(EXEFILE)
mkdir:
clean::
$(DEL) $(TVICEDRES)
-$(DEL) $(EXEFILE)
-$(DEL) $(DAFS_VICEDRES)

View File

@ -3,3 +3,8 @@
# to check that you haven't inadvertently ignored any tracked files.
/davolserver
/volerr.c
/volerr.et
/volint.h
/volser.h
/volser.p.h

View File

@ -11,10 +11,8 @@ RELDIR=dvolser
!INCLUDE ..\config\NTMakefile.$(SYS_NAME)
!INCLUDE ..\config\NTMakefile.version
SRC_DIR = ..\volser
VOLSER = ..\volser
TVOLSER = .
DVOLSER = .
VLSERVER = ..\vlserver
LWP = ..\lwp
LIBACL = ..\libacl
@ -39,23 +37,27 @@ LOCAL_INCFILES = \
volint.h
############################################################################
# Build afstvolser.lib
# Build afsdavolser.lib
LIBFILE = $(DESTDIR)\lib\afs\afstvolser.lib
LIBFILE = $(DESTDIR)\lib\afs\afsdvolser.lib
LIBOBJS = $(OUT)\volint.cs.obj \
$(OUT)\vsprocs.obj \
$(OUT)\vsutils.obj \
$(OUT)\lockprocs.obj \
$(OUT)\volint.xdr.obj \
$(OUT)\volerr.obj \
$(OUT)\volint.ss.obj \
$(OUT)\AFS_component_version_number.obj
$(LIBOBJS): $(VOLSER)\$$(@B).c
$(C2OBJ) -I$(TVOLSER) -I$(UTIL) $**
LIBOBJS2 = $(OUT)\vsprocs.obj \
$(OUT)\vsutils.obj \
$(OUT)\lockprocs.obj
$(LIBFILE): $(LIBOBJS)
# $(LIBOBJS): $(DVOLSER)\$$(@B).c
# $(C2OBJ) -I$(VOLSER) -I$(UTIL) $**
$(LIBOBJS2): $(VOLSER)\$$(@B).c
$(C2OBJ) -I$(VOLSER) -I$(UTIL) $**
$(LIBFILE): $(LIBOBJS) $(LIBOBJS2)
$(LIBARCH)
@ -84,8 +86,8 @@ VOLSERVER_EXEOBJS = $(VOLSEROBJS) \
VOLSERVER_EXELIBS = \
$(DESTDIR)\lib\afsauthent.lib \
$(DESTDIR)\lib\afsrpc.lib \
$(DESTDIR)\lib\afs\afstvolser.lib \
$(DESTDIR)\lib\afs\mtafsvol.lib \
$(LIBFILE) \
$(DESTDIR)\lib\afs\daafsvol.lib \
$(DESTDIR)\lib\afs\afscmd.lib \
$(DESTDIR)\lib\afs\afsaudit.lib \
$(DESTDIR)\lib/afs/afscom_err.lib \
@ -95,7 +97,7 @@ VOLSERVER_EXELIBS = \
$(DESTDIR)\lib\afs\mtafsutil.lib \
$(DESTDIR)\lib\afspthread.lib
$(VOLSERVER_EXEFILE): $(VOLSERVER_EXEOBJS) $(VOLSERVER_EXELIBS)
$(VOLSERVER_EXEFILE): $(VOLSERVER_EXEOBJS) $(VOLSERVER_EXELIBS)
$(EXECONLINK) dnsapi.lib mpr.lib iphlpapi.lib shell32.lib
$(_VC_MANIFEST_EMBED_EXE)
$(EXEPREP)
@ -158,7 +160,9 @@ install: install_lib $(VOLSERVER_EXEFILE) $(CL_VOS_EXEFILE) \
# Local clean target; augments predefined clean target
clean::
$(DEL) volerr.c volser.h volerr.et volser.p.h $(INCFILES)
$(DEL) volint.cs.c volint.h volint.ss.c volint.xdr.c
- -$(DEL) volerr.c volser.h volerr.et volser.p.h $(INCFILES)
-$(DEL) volint.cs.c volint.h volint.ss.c volint.xdr.c
-$(DEL) $(OUT)\davolserver.res
-$(DEL) $(VOLSERVER_EXEFILE)
mkdir:

View File

@ -9,9 +9,9 @@
/* Define VERSIONINFO resource */
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Volume Server (Threaded)"
#define AFS_VERINFO_NAME "volserver"
#define AFS_VERINFO_FILENAME "volserver.exe"
#define AFS_VERINFO_FILE_DESCRIPTION "AFS Volume Server (Demand Attach)"
#define AFS_VERINFO_NAME "davolserver"
#define AFS_VERINFO_FILENAME "davolserver.exe"
#include "AFS_component_version_number.h"
#include "..\config\NTVersioninfo.rc"

View File

@ -99,14 +99,16 @@ extern off_t afs_lseek(int FD, off_t O, int F);
* have been written so that it will be very simple to go
* back to standard I/O for just those poorly written platforms
*/
#ifndef _WIN32
#define FS_STATE_USE_MMAP
#ifndef AFS_NT40_ENV
#define FS_STATE_USE_MMAP 1
#endif
#ifdef FS_STATE_USE_MMAP
#define FS_STATE_INIT_FILESIZE (8 * 1024 * 1024) /* truncate to 8MB initially */
#ifndef AFS_NT40_ENV
#include <sys/mman.h>
#endif
#endif
static int fs_stateCreateDump(struct fs_dump_state * state);
static int fs_stateLoadDump(struct fs_dump_state * state);
@ -136,6 +138,17 @@ static int fs_stateFree(struct fs_dump_state * state);
extern afsUUID FS_HostUUID;
extern char cml_version_number[];
int
fs_stateFileOpen(struct fs_dump_state *state)
{
#ifdef AFS_NT40_ENV
return(state->fd != -1);
#else
return(state->fd >= 0);
#endif
}
/*
* demand attach fs
* save all fileserver state
@ -235,8 +248,8 @@ fs_stateSave(void)
state.fn));
}
done:
if (state.fd >= 0)
done:
if (fs_stateFileOpen(&state))
fs_stateCloseDump(&state);
fs_stateFree(&state);
H_UNLOCK;
@ -626,11 +639,21 @@ fs_stateWriteV(struct fs_dump_state * state,
fs_stateIncCursor(state, iov[i].iov_len);
}
#else
#ifndef AFS_NT40_ENV
if (writev(state->fd, iov, niov) != len) {
ViceLog(0, ("fs_stateWriteV: write failed\n"));
ret = 1;
goto done;
}
#else /* AFS_NT40_ENV */
for (i=0; i < niov; i++) {
if (write(state->fd, iov[i].iov_base, iov[i].iov_len) != iov[i].iov_len) {
ViceLog(0, ("fs_stateWriteV: write failed\n"));
ret = 1;
goto done;
}
}
#endif /* AFS_NT40_ENV */
#endif
done:
@ -661,11 +684,21 @@ fs_stateReadV(struct fs_dump_state * state,
fs_stateIncCursor(state, iov[i].iov_len);
}
#else
#ifndef AFS_NT40_ENV
if (readv(state->fd, iov, niov) != len) {
ViceLog(0, ("fs_stateReadV: read failed\n"));
ret = 1;
goto done;
}
#else
for (i=0; i < niov; i++) {
if (read(state->fd, iov[i].iov_base, iov[i].iov_len) != iov[i].iov_len) {
ViceLog(0, ("fs_stateReadV: read failed\n"));
ret = 1;
goto done;
}
}
#endif /* AFS_NT40_ENV */
#endif
done:
@ -737,9 +770,7 @@ fs_stateResizeFile(struct fs_dump_state * state, size_t min_add)
int ret = 0;
afs_foff_t inc;
#ifdef FS_STATE_USE_MMAP
fs_stateUnmapFile(state);
#endif
inc = ((min_add / FS_STATE_INIT_FILESIZE)+1) * FS_STATE_INIT_FILESIZE;
state->file_len += inc;
@ -750,13 +781,11 @@ fs_stateResizeFile(struct fs_dump_state * state, size_t min_add)
goto done;
}
#ifdef FS_STATE_USE_MMAP
if (fs_stateMapFile(state)) {
ViceLog(0, ("fs_stateResizeFile: remapping memory mapped file failed\n"));
ret = 1;
goto done;
}
#endif
done:
return ret;
@ -773,9 +802,7 @@ fs_stateTruncateFile(struct fs_dump_state * state)
return ret;
}
#endif
#ifdef FS_STATE_USE_MMAP
static int
fs_stateMapFile(struct fs_dump_state * state)
{
@ -844,9 +871,7 @@ fs_stateUnmapFile(struct fs_dump_state * state)
done:
return ret;
}
#endif /* FS_STATE_USE_MMAP */
#ifdef FS_STATE_USE_MMAP
int
fs_stateSync(struct fs_dump_state * state)
{
@ -865,7 +890,6 @@ fs_stateSync(struct fs_dump_state * state)
if (fsync(state->fd) == -1)
ret = 1;
done:
return ret;
}
#endif /* !FS_STATE_USE_MMAP */

View File

@ -50,7 +50,7 @@ struct disk_version_stamp {
/* 1024 byte header structure */
struct fs_state_header {
struct disk_version_stamp stamp; /* version stamp */
afs_uint32 timestamp; /* timestamp of save */
time_t timestamp; /* timestamp of save */
afs_uint32 sys_name; /* sys name id for this machine */
afsUUID server_uuid; /* server's UUID */
byte valid; /* whether header contents are valid */
@ -267,10 +267,10 @@ struct fs_dump_state {
} cb_map;
};
/* prototypes */
/* serialize_state.c */
extern int fs_stateFileOpen(struct fs_dump_state *state);
extern int fs_stateWrite(struct fs_dump_state * state,
void * buf, size_t len);
extern int fs_stateRead(struct fs_dump_state * state,

View File

@ -242,6 +242,7 @@ static void FlagMsg(void);
#define PTHREAD_RWLOCK_INITIALIZER {0x2DA8B3B4, {0}}
#endif
#ifndef AFS_NT40_ENV
struct fs_state fs_state =
{ FS_MODE_NORMAL,
0,
@ -252,6 +253,26 @@ struct fs_state fs_state =
PTHREAD_COND_INITIALIZER,
PTHREAD_RWLOCK_INITIALIZER
};
#else /* AFS_NT40_ENV */
struct fs_state fs_state;
static int fs_stateInit(void)
{
fs_state.mode = FS_MODE_NORMAL;
fs_state.FiveMinuteLWP_tranquil = 0;
fs_state.HostCheckLWP_tranquil = 0;
fs_state.FsyncCheckLWP_tranquil = 0;
fs_state.salvsync_fatal_error = 0;
fs_state.options.fs_state_save = 1;
fs_state.options.fs_state_restore = 1;
fs_state.options.fs_state_verify_before_save = 1;
fs_state.options.fs_state_verify_after_restore = 1;
assert(pthread_cond_init(&fs_state.worker_done_cv, NULL) == 0);
assert(pthread_rwlock_init(&fs_state.state_lock, NULL) == 0);
}
#endif /* AFS_NT40_ENV */
#endif /* AFS_DEMAND_ATTACH_FS */
/*

View File

@ -245,7 +245,11 @@ struct fs_state {
extern struct fs_state fs_state;
/* this lock is defined to be directly above FS_LOCK in the locking hierarchy */
#ifdef AFS_NT40_ENV
#define FS_STATE_INIT fs_stateInit()
#else
#define FS_STATE_INIT assert(pthread_rwlock_init(&fs_state.state_lock, NULL) == 0)
#endif
#define FS_STATE_RDLOCK assert(pthread_rwlock_rdlock(&fs_state.state_lock) == 0)
#define FS_STATE_WRLOCK assert(pthread_rwlock_wrlock(&fs_state.state_lock) == 0)
#define FS_STATE_UNLOCK assert(pthread_rwlock_unlock(&fs_state.state_lock) == 0)

View File

@ -38,6 +38,8 @@ LIBFILE = $(DESTDIR)\lib\afs\afsvol.lib
MT_LIBFILE = $(DESTDIR)\lib\afs\mtafsvol.lib
DAFS_LIBFILE = $(DESTDIR)\lib\afs\daafsvol.lib
LIBOBJS =\
$(OUT)\common.obj \
$(OUT)\clone.obj \
@ -52,7 +54,7 @@ LIBOBJS =\
$(OUT)\volume.obj \
$(OUT)\vutil.obj \
$(OUT)\ihandle.obj \
$(OUT)\AFS_component_version_number.obj
$(OUT)\AFS_component_version_number.obj
MT_LIBOBJS =\
$(OUT)\common.obj \
@ -68,7 +70,7 @@ MT_LIBOBJS =\
$(OUT)\volume_mt.obj \
$(OUT)\vutil_mt.obj \
$(OUT)\ihandle_mt.obj \
$(OUT)\AFS_component_version_number.obj
$(OUT)\AFS_component_version_number.obj
$(OUT)\clone_mt.obj:clone.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV
@ -106,6 +108,63 @@ $(LIBFILE): $(LIBOBJS)
$(MT_LIBFILE): $(MT_LIBOBJS)
$(LIBARCH)
DAFS_LIBOBJS =\
$(OUT)\common.obj \
$(OUT)\clone_dafs.obj \
$(OUT)\fssync-client_dafs.obj \
$(OUT)\fssync-server_dafs.obj \
$(OUT)\daemon_com_dafs.obj \
$(OUT)\ntops.obj \
$(OUT)\nuke_dafs.obj \
$(OUT)\partition_dafs.obj \
$(OUT)\purge.obj \
$(OUT)\vnode_dafs.obj \
$(OUT)\volume_dafs.obj \
$(OUT)\vutil_dafs.obj \
$(OUT)\ihandle_dafs.obj \
$(OUT)\vg_cache.obj \
$(OUT)\vg_scan.obj \
$(OUT)\AFS_component_version_number.obj
$(OUT)\clone_dafs.obj:clone.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\daemon_com_dafs.obj:daemon_com.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\fssync-client_dafs.obj:fssync-client.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\fssync-server_dafs.obj:fssync-server.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\ihandle_dafs.obj:ihandle.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\nuke_dafs.obj:nuke.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\partition_dafs.obj:partition.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\vnode_dafs.obj:vnode.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\volume_dafs.obj:volume.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\vutil_dafs.obj:vutil.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\vg_cache.obj:vg_cache.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(OUT)\vg_scan.obj:vg_scan.c
$(C2OBJ) $** -DAFS_PTHREAD_ENV -DAFS_DEMAND_ATTACH_FS
$(DAFS_LIBFILE): $(DAFS_LIBOBJS)
$(LIBARCH)
############################################################################
# External libraries
@ -186,7 +245,7 @@ $(OUT)\volinfo.res: AFS_component_version_number.h
############################################################################
# Install targets
install: $(INCFILES) $(LIBFILE) $(MT_LIBFILE) $(SALVAGER) $(VOLINFO)
install: $(INCFILES) $(LIBFILE) $(MT_LIBFILE) $(DAFS_LIBFILE) $(SALVAGER) $(VOLINFO)
mkdir:

View File

@ -25,12 +25,16 @@
#include <dirent.h>
#include <afs/assert.h>
#include <string.h>
#ifdef AFS_NT40_ENV
#include <io.h>
#else
#include <sys/file.h>
#include <sys/param.h>
#include <lock.h>
#if defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
#include <unistd.h>
#endif
#endif /* AFS_NT40_ENV */
#include <lock.h>
#include <afs/afsutil.h>
#include <lwp.h>
#include "nfs.h"

View File

@ -26,12 +26,16 @@
#include <dirent.h>
#include <afs/assert.h>
#include <string.h>
#ifdef AFS_NT40_ENV
#include <io.h>
#else
#include <sys/file.h>
#include <sys/param.h>
#include <lock.h>
#if defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
#include <unistd.h>
#endif
#endif /* AFS_NT40_ENV */
#include <lock.h>
#include <afs/afsutil.h>
#include <lwp.h>
#include "nfs.h"