Skip to content

Commit

Permalink
Fix incorrect disk usage reported by 'du' for files of size 4GB or above
Browse files Browse the repository at this point in the history
  • Loading branch information
szmi committed Apr 22, 2008
1 parent 4d6e5a0 commit c61e700
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 7 deletions.
16 changes: 16 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
2008-04-22 Miklos Szeredi <miklos@szeredi.hu>

* Add missing ssh options: ControlMaster, ControlPath,
KbdInteractiveAuthentication, KbdInteractiveDevices, LocalCommand,
RekeyLimit (Debian bug #430225).

2008-04-21 Miklos Szeredi <miklos@szeredi.hu>

* Fix incorrect disk usage reported by 'du' for files of size 4GB
or above. Reported by Christian Boltz.

2008-04-16 Miklos Szeredi <miklos@szeredi.hu>

* If debugging is enabled, print some statistics at exit about the
number of bytes transferred, etc..

2008-03-31 Miklos Szeredi <miklos@szeredi.hu>

* Support "posix-rename@openssh.com" extension available in
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT(sshfs-fuse, 1.9)
AC_INIT(sshfs-fuse, 2.0)
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(config.h)

Expand Down
64 changes: 58 additions & 6 deletions sshfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,16 @@ struct sshfs {
int password_stdin;
char *password;
int ext_posix_rename;

/* statistics */
uint64_t bytes_sent;
uint64_t bytes_received;
uint64_t num_sent;
uint64_t num_received;
unsigned int min_rtt;
unsigned int max_rtt;
uint64_t total_rtt;
unsigned int num_connect;
};

static struct sshfs sshfs;
Expand All @@ -218,15 +228,20 @@ static const char *ssh_opts[] = {
"CompressionLevel",
"ConnectionAttempts",
"ConnectTimeout",
"ControlMaster",
"ControlPath",
"GlobalKnownHostsFile",
"GSSAPIAuthentication",
"GSSAPIDelegateCredentials",
"HostbasedAuthentication",
"HostKeyAlgorithms",
"HostKeyAlias",
"HostName",
"IdentityFile",
"IdentitiesOnly",
"IdentityFile",
"KbdInteractiveAuthentication",
"KbdInteractiveDevices",
"LocalCommand",
"LogLevel",
"MACs",
"NoHostAuthenticationForLocalhost",
Expand All @@ -236,10 +251,11 @@ static const char *ssh_opts[] = {
"PreferredAuthentications",
"ProxyCommand",
"PubkeyAuthentication",
"RekeyLimit",
"RhostsRSAAuthentication",
"RSAAuthentication",
"ServerAliveInterval",
"ServerAliveCountMax",
"ServerAliveInterval",
"SmartcardDevice",
"StrictHostKeyChecking",
"TCPKeepAlive",
Expand Down Expand Up @@ -615,7 +631,7 @@ static int buf_get_attrs(struct buffer *buf, struct stat *stbuf, int *flagsp)
if (sshfs.blksize) {
stbuf->st_blksize = sshfs.blksize;
stbuf->st_blocks = ((size + sshfs.blksize - 1) &
~(sshfs.blksize - 1)) >> 9;
~((unsigned long long) sshfs.blksize - 1)) >> 9;
}
stbuf->st_uid = uid;
stbuf->st_gid = gid;
Expand Down Expand Up @@ -1132,12 +1148,21 @@ static int process_one_request(void)
if (sshfs.debug) {
struct timeval now;
unsigned int difftime;
unsigned msgsize = buf.size + 5;

gettimeofday(&now, NULL);
difftime = (now.tv_sec - req->start.tv_sec) * 1000;
difftime += (now.tv_usec - req->start.tv_usec) / 1000;
DEBUG(" [%05i] %14s %8ubytes (%ims)\n", id,
type_name(type),
(unsigned) buf.size + 5, difftime);
type_name(type), msgsize, difftime);

if (difftime < sshfs.min_rtt || !sshfs.num_received)
sshfs.min_rtt = difftime;
if (difftime > sshfs.max_rtt)
sshfs.max_rtt = difftime;
sshfs.total_rtt += difftime;
sshfs.num_received++;
sshfs.bytes_received += msgsize;
}
req->reply = buf;
req->reply_type = type;
Expand Down Expand Up @@ -1439,6 +1464,8 @@ static int connect_remote(void)

if (err)
close_conn();
else
sshfs.num_connect++;

return err;
}
Expand Down Expand Up @@ -1585,8 +1612,11 @@ static int sftp_request_send(uint8_t type, struct iovec *iov, size_t count,
pthread_cond_wait(&sshfs.outstanding_cond, &sshfs.lock);

g_hash_table_insert(sshfs.reqtab, GUINT_TO_POINTER(id), req);
if (sshfs.debug)
if (sshfs.debug) {
gettimeofday(&req->start, NULL);
sshfs.num_sent++;
sshfs.bytes_sent += req->len;
}
DEBUG("[%05i] %s\n", id, type_name(type));
pthread_mutex_unlock(&sshfs.lock);

Expand Down Expand Up @@ -2917,6 +2947,8 @@ int main(int argc, char *argv[])
parse_workarounds() == -1)
exit(1);

DEBUG("SSHFS version %s\n", PACKAGE_VERSION);

if (sshfs.password_stdin) {
res = read_password();
if (res == -1)
Expand Down Expand Up @@ -3008,6 +3040,26 @@ int main(int argc, char *argv[])
g_free(fsname);
check_large_read(&args);
res = sshfs_fuse_main(&args);

if (sshfs.debug) {
unsigned int avg_rtt = 0;

if (sshfs.num_sent)
avg_rtt = sshfs.total_rtt / sshfs.num_sent;

DEBUG("\n"
"sent: %llu messages, %llu bytes\n"
"received: %llu messages, %llu bytes\n"
"rtt min/max/avg: %ums/%ums/%ums\n"
"num connect: %u\n",
(unsigned long long) sshfs.num_sent,
(unsigned long long) sshfs.bytes_sent,
(unsigned long long) sshfs.num_received,
(unsigned long long) sshfs.bytes_received,
sshfs.min_rtt, sshfs.max_rtt, avg_rtt,
sshfs.num_connect);
}

fuse_opt_free_args(&args);
fuse_opt_free_args(&sshfs.ssh_args);
free(sshfs.directport);
Expand Down

0 comments on commit c61e700

Please sign in to comment.