aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/venti/srv/part.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/venti/srv/part.c')
-rw-r--r--src/cmd/venti/srv/part.c33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/cmd/venti/srv/part.c b/src/cmd/venti/srv/part.c
index a726dfde..e33c7b76 100644
--- a/src/cmd/venti/srv/part.c
+++ b/src/cmd/venti/srv/part.c
@@ -16,6 +16,16 @@
#include "dat.h"
#include "fns.h"
+/* TODO for linux:
+don't use O_DIRECT.
+use
+ posix_fadvise(fd, 0, 0, POSIX_FADV_NOREUSE);
+after block is read and also use
+ posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM);
+to disable readahead on the index partition.
+bump block size of bloom filter higher.
+*/
+
u32int maxblocksize;
int readonly;
@@ -157,6 +167,11 @@ initpart(char *name, int mode)
}
void
+flushpart(Part *part)
+{
+}
+
+void
freepart(Part *part)
{
if(part == nil)
@@ -397,11 +412,7 @@ rwpart(Part *part, int isread, u64int offset, u8int *buf, u32int count)
* Try to fix things up and continue.
*/
rerrstr(err, sizeof err);
- if(strstr(err, "i/o timeout") || strstr(err, "i/o error")){
- if(sdreset(part) >= 0)
- reopen(part);
- continue;
- }else if(strstr(err, "partition has changed")){
+ if(strstr(err, "i/o timeout") || strstr(err, "i/o error") || strstr(err, "partition has changed")){
reopen(part);
continue;
}
@@ -583,9 +594,15 @@ reopen(Part *part)
fprint(2, "reopen %s\n", part->filename);
if((fd = open(part->filename, ORDWR)) < 0){
- fprint(2, "reopen %s: %r\n", part->filename);
- return -1;
- }
+ if(access(part->filename, AEXIST) < 0){
+ sdreset(part);
+ fd = open(part->filename, ORDWR);
+ }
+ if(fd < 0){
+ fprint(2, "reopen %s: %r\n", part->filename);
+ return -1;
+ }
+ }
if(fd != part->fd){
dup(fd, part->fd);
close(fd);