49eb1f4806
Primary purpose of change: to support the mmap implementation, VM must know both (a) about some block metadata for FS cache blocks, i.e. inode numbers and inode offsets where applicable; and (b) know about *all* cache blocks, i.e. also of the FS primary caches and not just the blocks that spill into the secondary one. This changes the interface and VM data structures. This change is only for the interface (libminixfs) and VM data structures; the filesystem code is unmodified, so although the secondary cache will be used as normal, blocks will not be annotated with inode information until the FS is modified to provide this information. Until it is modified, mmap of files will fail gracefully on such filesystems. This is indicated to VFS/VM by returning ENOSYS for REQ_PEEK. Change-Id: I1d2df6c485e6c5e89eb28d9055076cc02629594e
68 lines
1.6 KiB
C
68 lines
1.6 KiB
C
#ifndef _SANITYCHECK_H
|
|
#define _SANITYCHECK_H 1
|
|
|
|
#include <assert.h>
|
|
|
|
#include "vm.h"
|
|
|
|
#if SANITYCHECKS
|
|
|
|
#define PT_SANE(p) { pt_sanitycheck((p), __FILE__, __LINE__); }
|
|
|
|
/* This macro is used in the sanity check functions, where file and
|
|
* line are function arguments.
|
|
*/
|
|
#define MYASSERT(c) do { if(!(c)) { \
|
|
printf("VM:%s:%d: %s failed (last sanity check %s:%d)\n", file, line, #c, sc_lastfile, sc_lastline); \
|
|
panic("sanity check failed"); } } while(0)
|
|
|
|
#define SLABSANITYCHECK(l) if(_minix_kerninfo && 0) { \
|
|
slab_sanitycheck(__FILE__, __LINE__); }
|
|
|
|
#define SANITYCHECK(l) if(!nocheck && _minix_kerninfo && 0) { \
|
|
struct vmproc *vmpr; \
|
|
assert(incheck == 0); \
|
|
incheck = 1; \
|
|
usedpages_reset(); \
|
|
slab_sanitycheck(__FILE__, __LINE__); \
|
|
for(vmpr = vmproc; vmpr < &vmproc[VMP_NR]; vmpr++) { \
|
|
if((vmpr->vm_flags & (VMF_INUSE))) { \
|
|
PT_SANE(&vmpr->vm_pt); \
|
|
} \
|
|
} \
|
|
map_sanitycheck(__FILE__, __LINE__); \
|
|
mem_sanitycheck(__FILE__, __LINE__); \
|
|
assert(incheck == 1); \
|
|
incheck = 0; \
|
|
/* printf("(%s:%d OK) ", __FILE__, __LINE__); */ \
|
|
sc_lastfile = __FILE__; sc_lastline = __LINE__; \
|
|
}
|
|
|
|
#define SLABSANE(ptr) { \
|
|
if(!slabsane_f(__FILE__, __LINE__, ptr, sizeof(*(ptr)))) { \
|
|
printf("VM:%s:%d: SLABSANE(%s)\n", __FILE__, __LINE__, #ptr); \
|
|
panic("SLABSANE failed"); \
|
|
} \
|
|
}
|
|
|
|
#else
|
|
#define SANITYCHECK(l)
|
|
#define SLABSANITYCHECK(l)
|
|
#define SLABSANE(ptr)
|
|
#define MYASSERT(c)
|
|
#define PT_SANE(p)
|
|
#endif
|
|
|
|
#if MEMPROTECT
|
|
#define USE(obj, code) do { \
|
|
slabunlock(obj, sizeof(*obj)); \
|
|
do { \
|
|
code \
|
|
} while(0); \
|
|
slablock(obj, sizeof(*obj)); \
|
|
} while(0)
|
|
#else
|
|
#define USE(obj, code) do { code } while(0)
|
|
#endif
|
|
|
|
#endif
|