Compare commits

...

9 Commits

Author SHA1 Message Date
Miklos Szeredi 1af7516f1e Released 1.8 2007-05-16 11:20:35 +00:00
Miklos Szeredi 15f911853e fixes 2007-05-15 20:09:29 +00:00
Miklos Szeredi eff1631428 Fix spurious cache entries remaining after renaming a directory 2007-04-18 10:24:10 +00:00
Miklos Szeredi 4399cfca84 Fix crash within gdb 2007-04-18 09:44:08 +00:00
Miklos Szeredi dd258a5117 Don't set DISPLAY environment variable to empty string 2007-03-16 13:15:16 +00:00
Miklos Szeredi feeaf76340 fix 2007-02-19 16:04:03 +00:00
Miklos Szeredi b3ffcfe3ac Work around write performace issues due to missing TCP_NODELAY in sshd 2006-12-20 17:48:08 +00:00
Miklos Szeredi d045a9be5e fix 2006-11-11 10:11:55 +00:00
Miklos Szeredi 09d5ee2eee fix segfault 2006-09-29 14:22:54 +00:00
6 changed files with 165 additions and 16 deletions
+51
View File
@@ -1,3 +1,54 @@
2007-05-16 Miklos Szeredi <miklos@szeredi.hu>
* Released 1.8
2007-05-15 Miklos Szeredi <miklos@szeredi.hu>
* Add needed g_thread_init() to fix rare crashes. Reported by
Dimitrios Apostolou
* Fix memory leak in sshfs_open_common()
2007-04-18 Miklos Szeredi <miklos@szeredi.hu>
* Fix crash within gdb, caused by sem_wait() returning with an
error on interrupt. Reported by Dimitrios Apostolou
* Fix spurious cache entries remaining after renaming a directory
2007-02-28 Miklos Szeredi <miklos@szeredi.hu>
* Don't set DISPLAY environment variable to "", because it breaks
ssh-askpass. Make nodelaysrv_workaround default to off, because
with this change it may have security implications.
2007-02-19 Miklos Szeredi <miklos@szeredi.hu>
* OpenSSH sftp-server can read requests faster, than it processes
them, when it's buffer is full it aborts. This can happen on a
large upload to a slow server. Work around this by limiting the
total size of outstanding reqests. Debian bug #365541. Tracked
down by Thue Janus Kristensen
* Add --disable-sshnodelay configure option. The sshnodelay.so
hack shouldnt be needed with OpenSSH client versions >= 4.3
2006-12-20 Miklos Szeredi <miklos@szeredi.hu>
* Work around write performace issues due to missing TCP_NODELAY
in sshd. Reported by Justin Searle
2006-11-10 Miklos Szeredi <miklos@szeredi.hu>
* Fix bug which ommitted directory entries for symlinks with the
-ofollow_symlinks option. Bug reported by Mikael Ståldal
2006-09-29 Miklos Szeredi <miklos@szeredi.hu>
* Fix segfault if there are outstanding writes to the server after
release on the file descriptor. This only happened on FreeBSD.
Reported by Andriy Gapon
2006-08-18 Miklos Szeredi <miklos@szeredi.hu>
* Released 1.7
+2
View File
@@ -14,6 +14,7 @@ sshfs_CPPFLAGS = -D_REENTRANT -DFUSE_USE_VERSION=26 -DLIBDIR=\"$(libdir)\"
EXTRA_DIST = sshnodelay.c FAQ.txt
CLEANFILES = sshnodelay.so
if SSH_NODELAY_SO
all-local: sshnodelay.so
install-exec-local: sshnodelay.so
@@ -25,3 +26,4 @@ uninstall-local:
sshnodelay.so:
$(CC) -Wall -W -s --shared -fPIC $(sshnodelay_libs) sshnodelay.c -o sshnodelay.so
endif
+5
View File
@@ -1,3 +1,8 @@
What is new in 1.8
------------------
* Bug fixes
What is new in 1.7
------------------
+18 -5
View File
@@ -116,9 +116,20 @@ static void cache_invalidate_dir(const char *path)
pthread_mutex_unlock(&cache.lock);
}
static int cache_del_children(const char *key, void *val_, const char *path)
{
(void) val_;
if (strncmp(key, path, strlen(path)) == 0)
return TRUE;
else
return FALSE;
}
static void cache_do_rename(const char *from, const char *to)
{
pthread_mutex_lock(&cache.lock);
g_hash_table_foreach_remove(cache.table, (GHRFunc) cache_del_children,
(char *) from);
cache_purge(from);
cache_purge(to);
cache_purge_parent(from);
@@ -250,12 +261,14 @@ static int cache_dirfill(fuse_cache_dirh_t ch, const char *name,
const struct stat *stbuf)
{
int err = ch->filler(ch->h, name, 0, 0);
if (!err && (stbuf->st_mode & S_IFMT)) {
char *fullpath;
if (!err) {
g_ptr_array_add(ch->dir, g_strdup(name));
fullpath = g_strdup_printf("%s/%s", !ch->path[1] ? "" : ch->path, name);
cache_add_attr(fullpath, stbuf);
g_free(fullpath);
if (stbuf->st_mode & S_IFMT) {
char *fullpath =
g_strdup_printf("%s/%s", !ch->path[1] ? "" : ch->path, name);
cache_add_attr(fullpath, stbuf);
g_free(fullpath);
}
}
return err;
}
+11 -2
View File
@@ -1,4 +1,4 @@
AC_INIT(sshfs-fuse, 1.7)
AC_INIT(sshfs-fuse, 1.8)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)
@@ -10,8 +10,17 @@ sshnodelay_libs=$LIBS
AC_SUBST(sshnodelay_libs)
LIBS=
AC_ARG_ENABLE(sshnodelay,
[ --disable-sshnodelay Don't compile NODELAY workaround for ssh])
if test "$enable_sshnodelay" != "no"; then
AC_DEFINE(SSH_NODELAY_WORKAROUND, 1, [Compile ssh NODELAY workaround])
fi
AM_CONDITIONAL(SSH_NODELAY_SO, test "$enable_sshnodelay" != "no")
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
PKG_CHECK_MODULES(SSHFS, [fuse >= 2.2 glib-2.0])
PKG_CHECK_MODULES(SSHFS, [fuse >= 2.2 glib-2.0 gthread-2.0])
have_fuse_opt_parse=no
AC_CHECK_FUNC([fuse_opt_parse], [have_fuse_opt_parse=yes])
if test "$have_fuse_opt_parse" = no; then
+78 -9
View File
@@ -124,6 +124,7 @@ struct request {
struct timeval start;
void *data;
request_func end_func;
size_t len;
struct list_head list;
};
@@ -147,6 +148,7 @@ struct sshfs_file {
int is_seq;
int connver;
int modifver;
int refs;
};
struct sshfs {
@@ -157,7 +159,9 @@ struct sshfs {
char *workarounds;
int rename_workaround;
int nodelay_workaround;
int nodelaysrv_workaround;
int truncate_workaround;
int buflimit_workaround;
int transform_symlinks;
int follow_symlinks;
int no_check_root;
@@ -184,6 +188,9 @@ struct sshfs {
unsigned blksize;
char *progname;
long modifver;
unsigned outstanding_len;
unsigned max_outstanding_len;
pthread_cond_t outstanding_cond;
};
static struct sshfs sshfs;
@@ -270,16 +277,24 @@ static struct fuse_opt sshfs_opts[] = {
static struct fuse_opt workaround_opts[] = {
SSHFS_OPT("none", rename_workaround, 0),
SSHFS_OPT("none", nodelay_workaround, 0),
SSHFS_OPT("none", nodelaysrv_workaround, 0),
SSHFS_OPT("none", truncate_workaround, 0),
SSHFS_OPT("none", buflimit_workaround, 0),
SSHFS_OPT("all", rename_workaround, 1),
SSHFS_OPT("all", nodelay_workaround, 1),
SSHFS_OPT("all", nodelaysrv_workaround, 1),
SSHFS_OPT("all", truncate_workaround, 1),
SSHFS_OPT("all", buflimit_workaround, 1),
SSHFS_OPT("rename", rename_workaround, 1),
SSHFS_OPT("norename", rename_workaround, 0),
SSHFS_OPT("nodelay", nodelay_workaround, 1),
SSHFS_OPT("nonodelay", nodelay_workaround, 0),
SSHFS_OPT("nodelaysrv", nodelaysrv_workaround, 1),
SSHFS_OPT("nonodelaysrv", nodelaysrv_workaround, 0),
SSHFS_OPT("truncate", truncate_workaround, 1),
SSHFS_OPT("notruncate", truncate_workaround, 0),
SSHFS_OPT("buflimit", buflimit_workaround, 1),
SSHFS_OPT("nobuflimit", buflimit_workaround, 0),
FUSE_OPT_END
};
@@ -627,6 +642,7 @@ static void ssh_add_arg(const char *arg)
_exit(1);
}
#ifdef SSH_NODELAY_WORKAROUND
static int do_ssh_nodelay_workaround(void)
{
char *oldpreload = getenv("LD_PRELOAD");
@@ -668,6 +684,7 @@ static int do_ssh_nodelay_workaround(void)
g_free(newpreload);
return 0;
}
#endif
static int start_ssh(void)
{
@@ -687,8 +704,15 @@ static int start_ssh(void)
} else if (pid == 0) {
int devnull;
#ifdef SSH_NODELAY_WORKAROUND
if (sshfs.nodelay_workaround && do_ssh_nodelay_workaround() == -1)
fprintf(stderr, "warning: ssh nodelay workaround disabled\n");
#endif
if (sshfs.nodelaysrv_workaround) {
/* Hack to work around missing TCP_NODELAY setting in sshd */
sshfs.ssh_args.argv[1] = "-X";
}
devnull = open("/dev/null", O_WRONLY);
@@ -822,7 +846,7 @@ static int sftp_send_iov(uint8_t type, uint32_t id, struct iovec iov[],
unsigned nout = 0;
assert(count <= SFTP_MAX_IOV - 1);
buf_init(&buf, 5);
buf_init(&buf, 9);
buf_add_uint32(&buf, iov_length(iov, count) + 5);
buf_add_uint8(&buf, type);
buf_add_uint32(&buf, id);
@@ -947,8 +971,13 @@ static void *process_requests(void *data_)
GUINT_TO_POINTER(id));
if (req == NULL)
fprintf(stderr, "request %i not found\n", id);
else
else {
int was_over = sshfs.outstanding_len > sshfs.max_outstanding_len;
sshfs.outstanding_len -= req->len;
if (was_over && sshfs.outstanding_len <= sshfs.max_outstanding_len)
pthread_cond_broadcast(&sshfs.outstanding_cond);
g_hash_table_remove(sshfs.reqtab, GUINT_TO_POINTER(id));
}
pthread_mutex_unlock(&sshfs.lock);
if (req != NULL) {
struct timeval now;
@@ -1046,7 +1075,7 @@ static int sftp_find_init_reply(uint32_t *version)
static int sftp_init()
{
int res = -1;
uint32_t version;
uint32_t version = 0;
struct buffer buf;
buf_init(&buf, 0);
if (sftp_send_iov(SSH_FXP_INIT, PROTO_VERSION, NULL, 0) == -1)
@@ -1270,7 +1299,7 @@ static int sftp_request_wait(struct request *req, uint8_t type,
err = req->error;
goto out;
}
sem_wait(&req->ready);
while (sem_wait(&req->ready));
if (req->error) {
err = req->error;
goto out;
@@ -1342,6 +1371,11 @@ static int sftp_request_send(uint8_t type, struct iovec *iov, size_t count,
pthread_mutex_unlock(&sshfs.lock);
goto out;
}
req->len = iov_length(iov, count) + 9;
sshfs.outstanding_len += req->len;
while (sshfs.outstanding_len > sshfs.max_outstanding_len)
pthread_cond_wait(&sshfs.outstanding_cond, &sshfs.lock);
g_hash_table_insert(sshfs.reqtab, GUINT_TO_POINTER(id), req);
gettimeofday(&req->start, NULL);
DEBUG("[%05i] %s\n", id, type_name(type));
@@ -1768,6 +1802,7 @@ static int sshfs_open_common(const char *path, mode_t mode,
pthread_cond_init(&sf->write_finished, NULL);
/* Assume random read after open */
sf->is_seq = 0;
sf->refs = 1;
sf->next_pos = 0;
sf->modifver= sshfs.modifver;
sf->connver = sshfs.connver;
@@ -1782,8 +1817,11 @@ static int sshfs_open_common(const char *path, mode_t mode,
buf_add_path(&buf, path);
err2 = sftp_request(sshfs.follow_symlinks ? SSH_FXP_STAT : SSH_FXP_LSTAT,
&buf, SSH_FXP_ATTRS, &outbuf);
if (!err2 && buf_get_attrs(&outbuf, &stbuf, NULL) == -1)
err2 = -EIO;
if (!err2) {
if (buf_get_attrs(&outbuf, &stbuf, NULL) == -1)
err2 = -EIO;
buf_free(&outbuf);
}
err = sftp_request_wait(open_req, SSH_FXP_OPEN, SSH_FXP_HANDLE,
&sf->handle);
if (!err && err2) {
@@ -1851,6 +1889,19 @@ static int sshfs_fsync(const char *path, int isdatasync,
return sshfs_flush(path, fi);
}
static void sshfs_file_put(struct sshfs_file *sf)
{
sf->refs--;
if (!sf->refs)
g_free(sf);
}
static struct sshfs_file *sshfs_file_get(struct sshfs_file *sf)
{
sf->refs++;
return sf;
}
static int sshfs_release(const char *path, struct fuse_file_info *fi)
{
struct sshfs_file *sf = get_sshfs_file(fi);
@@ -1861,7 +1912,7 @@ static int sshfs_release(const char *path, struct fuse_file_info *fi)
}
buf_free(handle);
chunk_put_locked(sf->readahead);
g_free(sf);
sshfs_file_put(sf);
return 0;
}
@@ -1973,7 +2024,7 @@ static void submit_read(struct sshfs_file *sf, size_t size, off_t offset,
static int wait_chunk(struct read_chunk *chunk, char *buf, size_t size)
{
int res;
sem_wait(&chunk->ready);
while (sem_wait(&chunk->ready));
res = chunk->res;
if (res > 0) {
if ((size_t) res > size)
@@ -2084,6 +2135,7 @@ static void sshfs_write_end(struct request *req)
}
list_del(&req->list);
pthread_cond_broadcast(&sf->write_finished);
sshfs_file_put(sf);
}
static int sshfs_write(const char *path, const char *wbuf, size_t size,
@@ -2110,7 +2162,7 @@ static int sshfs_write(const char *path, const char *wbuf, size_t size,
iov[1].iov_len = size;
if (!sshfs.sync_write && !sf->write_error)
err = sftp_request_send(SSH_FXP_WRITE, iov, 2, sshfs_write_begin,
sshfs_write_end, 0, sf, NULL);
sshfs_write_end, 0, sshfs_file_get(sf), NULL);
else
err = sftp_request_iov(SSH_FXP_WRITE, iov, 2, SSH_FXP_STATUS, NULL);
buf_free(&buf);
@@ -2330,6 +2382,7 @@ static int processing_init(void)
{
pthread_mutex_init(&sshfs.lock, NULL);
pthread_mutex_init(&sshfs.lock_write, NULL);
pthread_cond_init(&sshfs.outstanding_cond, NULL);
sshfs.reqtab = g_hash_table_new(NULL, NULL);
if (!sshfs.reqtab) {
fprintf(stderr, "failed to create hash table\n");
@@ -2396,8 +2449,12 @@ static void usage(const char *progname)
" none no workarounds enabled\n"
" all all workarounds enabled\n"
" [no]rename fix renaming to existing file (default: off)\n"
#ifdef SSH_NODELAY_WORKAROUND
" [no]nodelay set nodelay tcp flag in ssh (default: on)\n"
#endif
" [no]nodelaysrv set nodelay tcp flag in sshd (default: on)\n"
" [no]truncate fix truncate for old servers (default: off)\n"
" [no]buflimit fix buffer fillup bug in server (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"
@@ -2551,11 +2608,15 @@ int main(int argc, char *argv[])
char *base_path;
const char *sftp_server;
g_thread_init(NULL);
sshfs.blksize = 4096;
sshfs.max_read = 65536;
sshfs.nodelay_workaround = 1;
sshfs.nodelaysrv_workaround = 0;
sshfs.rename_workaround = 0;
sshfs.truncate_workaround = 0;
sshfs.buflimit_workaround = 1;
sshfs.ssh_ver = 2;
sshfs.progname = argv[0];
ssh_add_arg("ssh");
@@ -2567,6 +2628,14 @@ int main(int argc, char *argv[])
parse_workarounds() == -1)
exit(1);
if (sshfs.buflimit_workaround)
/* Work around buggy sftp-server in OpenSSH. Without this on
a slow server a 10Mbyte buffer would fill up and the server
would abort */
sshfs.max_outstanding_len = 8388608;
else
sshfs.max_outstanding_len = ~0;
if (!sshfs.host) {
fprintf(stderr, "missing host\n");
fprintf(stderr, "see `%s -h' for usage\n", argv[0]);