From cb4239036ada3acfbf7a425ef9e74d7ace7c9d3a Mon Sep 17 00:00:00 2001 From: Miklos Szeredi Date: Mon, 30 Jan 2006 11:05:40 +0000 Subject: fix --- ChangeLog | 7 +++++++ sshfs.c | 12 ++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index a7793fa..e09462e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-01-30 Miklos Szeredi + + * Fix data consitency bug if readahead is enabled and writes are + intermixed with reads. Only fixed for the case when reads and + writes are performed on the same file handle. Bug reported and + test program written by Wolfgang Köbler + 2006-01-29 Miklos Szeredi * Add '-olarge_read' option for Linux-2.4.*. This should diff --git a/sshfs.c b/sshfs.c index af9edf4..9e5efd9 100644 --- a/sshfs.c +++ b/sshfs.c @@ -131,6 +131,7 @@ struct read_chunk { struct buffer data; int refs; int res; + int filever; }; struct sshfs_file { @@ -142,6 +143,7 @@ struct sshfs_file { off_t next_pos; int is_seq; int connver; + int filever; }; struct sshfs { @@ -1751,6 +1753,7 @@ static int submit_read(struct sshfs_file *sf, size_t size, off_t offset, chunk->offset = offset; chunk->size = size; chunk->refs = 1; + chunk->filever = sf->filever; err = sshfs_send_async_read(sf, chunk); if (!err) { pthread_mutex_lock(&sshfs.lock); @@ -1784,7 +1787,7 @@ static int wait_chunk(struct read_chunk *chunk, char *buf, size_t size) static struct read_chunk *search_read_chunk(struct sshfs_file *sf, off_t offset) { struct read_chunk *ch = sf->readahead; - if (ch && ch->offset == offset) { + if (ch && ch->offset == offset && ch->filever == sf->filever) { ch->refs++; return ch; } else @@ -1892,6 +1895,7 @@ static int sshfs_write(const char *path, const char *wbuf, size_t size, if (!sshfs_file_is_conn(sf)) return -EIO; + sf->filever ++; data.p = (uint8_t *) wbuf; data.len = size; buf_init(&buf, 0); @@ -2060,9 +2064,9 @@ static void usage(const char *progname) " -o cache_X_timeout=N sets timeout for {stat,dir,link} cache\n" " -o workaround=LIST colon separated list of workarounds\n" " none no workarounds enabled\n" -" all all workarounds enabled (default)\n" -" [no]rename fix renaming to existing file\n" -" [no]nodelay set nodelay tcp flag in ssh\n" +" all all workarounds enabled\n" +" [no]rename fix renaming to existing file (default: on)\n" +" [no]nodelay set nodelay tcp flag in ssh (default: on)\n" " -o idmap=TYPE user/group ID mapping, possible types are:\n" " none no translation of the ID space (default)\n" " user only translate UID of connecting user\n" -- cgit v1.2.3