ref: 0124e0661a92123df8184b654be6ceabf7482324
parent: fc989d86b03b04ced56a1c489d0a2961c3df39e3
author: 9ferno <gophone2015@gmail.com>
date: Wed Nov 9 20:00:40 EST 2022
cleanup obsolete code
--- a/TODO
+++ b/TODO
@@ -4,22 +4,16 @@
add user and remove user messages
Add readahead?
need rlock() when looking up user id, group id, or user attributes
-more consistent use of tree lock.
-not using the tree lock for reads - replace RWlock with a Qlock sl
- RWlock is better than the Qlock. Just need to enforce it better.
EXCL files - maintain a list of locks in the tree
APPEND files
-ORCLOSE
+ORCLOSE remove on close
correct /adm/ctl operation:
echo df >> /adm/ctl
cat /adm/ctl
make docs/mafs.ms more interesting?
test -A announce
-Split out the Free Blocks - Extents section in the document.
-Add a section on sizing npendingwrites
- ((ups time in seconds )/2) * (diskspeed in bytes/second) / Rawblocksize
-Clean up the Iobuf locking description
+Clean up the Iobuf locking description?
man/mafs.4 man/mafs.8
Add EXAMPLES
Add mafs.pdf as a resource
-Test that removed directories do not show up in the directory listing
+Open device file in EXCL mode?
--- a/all.h
+++ b/all.h
@@ -160,27 +160,14 @@
u8 chkwunlock(RWLock *q);
void cmd_user(void);
char* cname(char*);
-void consproc(void);
-void cprint(char*, ...);
void ctlread(Req *req);
void ctlwrite(Req *req);
-void datestr(char*, long);
-Qid dentryqid(Dentry*);
-void dofilter(Filter*);
int dprint(char *fmt, ...);
-void exit(void);
-/*Float famd(Float, int, int, int);*/
-int fchar(void);
-/*ulong fdf(Float, int);*/
void sublockinit(void);
int fname(char*);
void formatinit(void);
void freeaux(Aux *a);
void freesearchstate(Iobuf **dbuf, Iobuf **buf);
-Dentry* getdir(Iobuf*, int);
-long getraddr(Device);
-Wpath* getwp(Wpath*);
-void hexdump(void*, int);
int iaccess(short uid, Dentry *d, int m);
int ingroup(s16 uid, s16 gid, int locked);
void initconfig(u64 bno);
@@ -201,29 +188,11 @@
u64 power( u64 base, int n);
int prime(long);
void putsuper(int locked);
-void strrand(void*, int);
int strtouid(char*);
int strtouid1(char*);
void sync(void);
-int syncblock(void);
-int Tfmt(Fmt*);
char *username(s16 uid, int locked, char *username);
void usersinit(void);
void writeconfig(u64 bno);
-#pragma varargck argpos cprint 1
#pragma varargck argpos panic 1
-
-#pragma varargck type "A" Filta
-#pragma varargck type "G" int
-#pragma varargck type "T" long
-#pragma varargck type "F" Fcall*
-
-long belong(char *);
-int cmd_exec(char*);
-void consserve(void);
-void confinit(void);
-int fsinit(int, int);
-int nextelem(void);
-long number(int, int);
-int skipbl(int);
--- a/dat.h
+++ b/dat.h
@@ -57,7 +57,7 @@
*/
enum {
Rawblocksize= 512ULL, /* real block size */
- Ndblock = 32, /* number of direct blocks in a Dentry */
+ Ndblock = 32, /* number of direct blocks in a Dentry */
Niblock = 6, /* maximum depth of indirect blocks */
/* global block numbers. The bkp contents locations are calculated by ream() */
@@ -100,14 +100,9 @@
typedef struct Aux Aux;
typedef struct Log Log;
-/* from kfs, might have to be removed */
-typedef struct Filta Filta;
-typedef struct Filter Filter;
typedef struct P9call P9call;
typedef struct Tlock Tlock;
typedef struct Uid Uid;
-typedef struct Wpath Wpath;
-typedef struct AuthRpc AuthRpc;
/*
* DONT TOUCH -- data structures stored on disk
@@ -206,22 +201,6 @@
#pragma pack off
/*
- * for load stats
- */
-struct Filter
-{
- u64 count; /* count and old count kept separate */
- u64 oldcount; /* so interrput can read them */
- /* Float filter[3];*/ /* filters for 1m 10m 100m */
-};
-
-struct Filta
-{
- Filter* f;
- int scale;
-};
-
-/*
* array of qids that are locked
*/
struct Tlock
@@ -342,7 +321,7 @@
Tdentry, /* directory entry */
/* Tdata & indirect blocks are last, to allow for greater depth */
Tdata, /* actual file contents */
- Tind0, /* contains a list of Tdata block numberss for files
+ Tind0, /* contains a list of Tdata block numbers for files
and Tdentry block numbers for directories.*/
Tind1, /* contains a list of Tind0 block numbers */
Tind2, /* contains a list of Tind1 block numbers */
@@ -367,71 +346,11 @@
Bused = 0,/* has contents on the disk */
};
-/*
- * open modes passed into P9 open/create
- */
-enum
-{
- MREAD = 0,
- MWRITE,
- MBOTH,
- MEXEC,
- MTRUNC = (1<<4), /* truncate on open */
- MCEXEC = (1<<5), /* close on exec (host) */
- MRCLOSE = (1<<6), /* remove on close */
-};
-
-/*
- * check flags
- */
-enum
-{
- Crdall = (1<<0), /* read all files */
- Ctag = (1<<1), /* rebuild tags */
- Cpfile = (1<<2), /* print files */
- Cpdir = (1<<3), /* print directories */
- Cfree = (1<<4), /* rebuild free list */
- Cream = (1<<6), /* clear all bad tags */
- Cbad = (1<<7), /* clear all bad blocks */
- Ctouch = (1<<8), /* touch old dir and indir */
- Cquiet = (1<<9), /* report just nasty things */
-};
-
-/*
- * console cons.flag flags
- */
-enum
-{
- Fchat = (1<<0), /* print out filesys rpc traffic */
- Fuid = (1<<2), /* print out uids */
- /* debugging flags for drivers */
-};
-
-struct Cons
-{
- int flags; /* overall flags for all channels */
- int uid; /* botch -- used to get uid on cons_create */
- int gid; /* botch -- used to get gid on cons_create */
- int allow; /* no-protection flag */
- u64 offset; /* used to read files, c.f. fchar */
- char* arg; /* pointer to remaining line */
-
- Filter work; /* thruput in messages */
- Filter rate; /* thruput in bytes */
- Filter bhit; /* getbufs that hit */
- Filter bread; /* getbufs that miss and read */
- Filter binit; /* getbufs that miss and dont read */
- Filter tags[MAXTAG]; /* reads of each type of block */
-};
-
#define SECOND(n) (n)
#define MINUTE(n) (n*SECOND(60))
#define HOUR(n) (n*MINUTE(60))
#define DAY(n) (n*HOUR(24))
#define TLOCK MINUTE(5)
-
-#define CHAT(cp) (chat)
-#define QID9P1(a,b) (Qid9p1){a,b}
extern char* errstring[MAXERR];
extern Tlock *tlocks;
--- a/docs/mafs.ms
+++ b/docs/mafs.ms
@@ -187,7 +187,7 @@
Tdentry, /* directory entry */
/* Tind\fIn\fR are last, to allow for future increases */
Tdata, /* actual file contents */
- Tind0, /* contains a list of Tdata block numberss for files
+ Tind0, /* contains a list of Tdata block numbers for files
and Tdentry block numbers for directories.*/
Tind1, /* contains a list of Tind0 block numbers */
Tind2, /* contains a list of Tind1 block numbers */
@@ -200,9 +200,9 @@
A directory entry is defined as:
.nf
enum {
- Rawblocksize= 512, /* real block size */
- Ndblock = 32,/* number of direct blocks in a Dentry */
- Niblock = 6, /* maximum depth of indirect blocks */
+ Rawblocksize = 512ULL, /* real block size */
+ Ndblock = 32, /* number of direct blocks in a Dentry */
+ Niblock = 6, /* maximum depth of indirect blocks */
};
struct Qid9p1
{
@@ -216,7 +216,7 @@
u64 size; /* 0 for directories. For files, size in bytes of the content */
u64 pdblkno; /* parent dentry absolute block number. 0 for root. */
u64 pqpath; /* parent qid.path */
- u64 mtime; /* modified time nano seconds from epoch */
+ u64 mtime; /* modified time in nano seconds from epoch */
u32 mode; /* same bits as defined in lib.h Dir.mode */
s16 uid;
s16 gid;
@@ -247,38 +247,38 @@
};
.fi
.sp
-A directory entry once assigned is not given up until the parent directory is removed. It is zero'ed if the directory entry is removed. It is reused by the next directory entry created under that parent directory. This removes the need for garbage collection of directory entries on removals and also avoids zero block numbers in the middle of a directory. A zero block number while traversing a directory entry's dblocks or iblocks represents the end of directory or file contents. When a directory is removed, the parent will have a directory entry with a tag of Tdentry and Qpnone and the rest of the contents set to zero.
+A directory entry once assigned is not given up until the parent directory is removed. It is zero'ed if the directory entry is removed. It is reused by the next directory entry created under that parent directory. This removes the need for garbage collection of directory entries on removals and also avoids zero block numbers in the middle of a directory entry's list of blocks. A zero block number while traversing a directory entry's dblocks or iblocks represents the end of directory or file contents. When a directory is removed, the parent will have a directory entry with a tag of Tdentry and Qpnone and the rest of the contents set to zero.
.sp
A directory's size is always zero.
.sp
.nf
-tests/6.sizes # shows the values of the above derived variables.
-Namelen 144 Ndblock 32 Niblock 6
-Blocksize 502 Nindperblock 62
-A Tind0 unit points to 1 data blocks (502 bytes)
- block points to 62 data blocks
- reli start 32 max 93
- max size 94*Blocksize = 47188 bytes
-A Tind1 unit points to 62 data blocks (31124 bytes)
- block points to 3844 data blocks
- reli start 94 max 3937
- max size 3938*Blocksize = 1976876 bytes = 1 MiB
-A Tind2 unit points to 3844 data blocks (1929688 bytes)
- block points to 238328 data blocks
- reli start 3938 max 242265
- max size 242266*Blocksize = 121617532 bytes = 115 MiB
-A Tind3 unit points to 238328 data blocks (119640656 bytes)
- block points to 14776336 data blocks
- reli start 242266 max 15018601
- max size 15018602*Blocksize = 7539338204 bytes = 7 GiB
-A Tind4 unit points to 14776336 data blocks (7417720672 bytes)
- block points to 916132832 data blocks
- reli start 15018602 max 931151433
- max size 931151434*Blocksize = 467438019868 bytes = 435 GiB
-A Tind5 unit points to 916132832 data blocks (459898681664 bytes)
- block points to 56800235584 data blocks
- reli start 931151434 max 57731387017
- max size 57731387018*Blocksize = 28981156283036 bytes = 26 TiB
+ tests/6.sizes # shows the values of the above derived variables.
+ Namelen 145 Ndblock 32 Niblock 6
+ Blocksize 503 Nindperblock 62
+ A Tind0 unit points to 1 data blocks (503 bytes)
+ block points to 62 data blocks
+ reli start 32 max 93
+ max size 94*Blocksize = 47282 bytes
+ A Tind1 unit points to 62 data blocks (31186 bytes)
+ block points to 3844 data blocks
+ reli start 94 max 3937
+ max size 3938*Blocksize = 1980814 bytes = 1 MiB
+ A Tind2 unit points to 3844 data blocks (1933532 bytes)
+ block points to 238328 data blocks
+ reli start 3938 max 242265
+ max size 242266*Blocksize = 121859798 bytes = 116 MiB
+ A Tind3 unit points to 238328 data blocks (119878984 bytes)
+ block points to 14776336 data blocks
+ reli start 242266 max 15018601
+ max size 15018602*Blocksize = 7554356806 bytes = 7 GiB
+ A Tind4 unit points to 14776336 data blocks (7432497008 bytes)
+ block points to 916132832 data blocks
+ reli start 15018602 max 931151433
+ max size 931151434*Blocksize = 468369171302 bytes = 436 GiB
+ A Tind5 unit points to 916132832 data blocks (460814814496 bytes)
+ block points to 56800235584 data blocks
+ reli start 931151434 max 57731387017
+ max size 57731387018*Blocksize = 29038887670054 bytes = 26 TiB
.fi
.ne 30
.sp
@@ -365,9 +365,9 @@
.sp
Contents of block 20 are:
.nf
-disk/block tests/test.1/disk 20
-Tdata 65
-test
+ disk/block tests/test.1/disk 20
+ Tdata 65
+ test
.fi
.PS
right
@@ -464,7 +464,7 @@
}
.PE
.sp
-iblocks[0] has the block number of a Tind0 block. A Tind0 block contains a list of Tdata block numbers for files or a list of Tdentry block numbers for directories.
+iblocks[0] holds the block number of a Tind0 block. A Tind0 block contains a list of Tdata block numbers for files or a list of Tdentry block numbers for directories.
.sp
iblocks[1] has the block number of a Tind1 block. A Tind1 block contains a list of Tind0 block numbers.
.sp
@@ -486,34 +486,34 @@
.sp
To find the actual block number where the second block of a file is stored:
.nf
-tests/6.reli 1
-reli 1
-dblock[1]
+ tests/6.reli 1
+ reli 1
+ dblock[1]
.fi
.sp
And so on, for the 32nd and 33rd blocks of a file:
.nf
-tests/6.reli 31
-reli 31
-dblock[31]
+ tests/6.reli 31
+ reli 31
+ dblock[31]
-tests/6.reli 32
-reli 32
-iblock[0]
-Tind0 reli 0 is at [0]
+ tests/6.reli 32
+ reli 32
+ iblock[0]
+ Tind0 reli 0 is at [0]
.fi
.sp
This is how the last block of a 26 TiB file would be stored:
.nf
-tests/6.reli 57731387017
-reli 57731387017
-iblock[5]
-Tind5 reli 56800235583 is at [61]
-Tind4 reli 916132831 is at [61]
-Tind3 reli 14776335 is at [61]
-Tind2 reli 238327 is at [61]
-Tind1 reli 3843 is at [61]
-Tind0 reli 61 is at [61]
+ tests/6.reli 57731387017
+ reli 57731387017
+ iblock[5]
+ Tind5 reli 56800235583 is at [61]
+ Tind4 reli 916132831 is at [61]
+ Tind3 reli 14776335 is at [61]
+ Tind2 reli 238327 is at [61]
+ Tind1 reli 3843 is at [61]
+ Tind0 reli 61 is at [61]
.fi
.sp
.PS
@@ -667,7 +667,7 @@
.sp
The /adm/ctl file is used to halt or sync the file system. /adm/users is a r/w file that will reload users when written to it. The owner of the /adm/ctl file or any user belonging to the sys group can ream the disk.
.sp
-There is no /adm/magic as the block number of the magic block is zero and zero block in a directory entry signifies the end of the directory contents.
+There is no /adm/magic directory entry as the block number of the magic block is zero and zero block in a directory entry signifies the end of the directory contents.
.sp
.sp
.ne 4
@@ -842,6 +842,8 @@
The writer throttles input when there are more than Npendingwrites waiting to be written. This can be adjusted with the -w parameter.
.sp
The alternative to having a single writer process is to have each worker write to the disk, as mfs does. Synchronous writes throttles writes to disk write speed. With asynchronous writes, memory is used to hold the data until written to the disk. This shows increased write throughput until we fill up memory. After filling up memory, writes happen at disk speed. Asynchronous writes have the side effect of a single disk write queue.
+.sp
+The ideal npendingwrites = ((ups time in seconds )/2) * (diskspeed in bytes/second) / Rawblocksize.
.sp
.sp
.ne 4
--- a/mafs.c
+++ b/mafs.c
@@ -150,40 +150,6 @@
exits(nil);
}
-static
-struct
-{
- int nfilter;
- Filter* filters[100];
-}f;
-
-int alarmed;
-
-void
-catchalarm(void *regs, char *msg)
-{
- USED(regs, msg);
- if(strcmp(msg, "alarm") == 0){
- alarmed = 1;
- noted(NCONT);
- } else
- noted(NDFLT);
-}
-
-void
-dofilter(Filter *ft)
-{
- int i;
-
- i = f.nfilter;
- if(i >= sizeof f.filters / sizeof f.filters[0]) {
- dprint("dofilter: too many filters\n");
- return;
- }
- f.filters[i] = ft;
- f.nfilter = i+1;
-}
-
static u64
memsize(void)
{
--- a/mfs.c
+++ b/mfs.c
@@ -146,40 +146,6 @@
exits(nil);
}
-static
-struct
-{
- int nfilter;
- Filter* filters[100];
-}f;
-
-int alarmed;
-
-void
-catchalarm(void *regs, char *msg)
-{
- USED(regs, msg);
- if(strcmp(msg, "alarm") == 0){
- alarmed = 1;
- noted(NCONT);
- } else
- noted(NDFLT);
-}
-
-void
-dofilter(Filter *ft)
-{
- int i;
-
- i = f.nfilter;
- if(i >= sizeof f.filters / sizeof f.filters[0]) {
- dprint("dofilter: too many filters\n");
- return;
- }
- f.filters[i] = ft;
- f.nfilter = i+1;
-}
-
static u64
memsize(void)
{