aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Szeredi <miklos@szeredi.hu>2006-01-30 11:05:40 +0000
committerMiklos Szeredi <miklos@szeredi.hu>2006-01-30 11:05:40 +0000
commitcb4239036ada3acfbf7a425ef9e74d7ace7c9d3a (patch)
tree2284bc9cf11d5e8c3f99642155c182cfc2c68242
parent40393a4b0b1a5c8598743e02144d14a26009c2a1 (diff)
downloadsshfs-cb4239036ada3acfbf7a425ef9e74d7ace7c9d3a.tar
sshfs-cb4239036ada3acfbf7a425ef9e74d7ace7c9d3a.tar.gz
sshfs-cb4239036ada3acfbf7a425ef9e74d7ace7c9d3a.tar.bz2
sshfs-cb4239036ada3acfbf7a425ef9e74d7ace7c9d3a.zip
fix
-rw-r--r--ChangeLog7
-rw-r--r--sshfs.c12
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 <miklos@szeredi.hu>
+
+ * 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 <miklos@szeredi.hu>
* 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"