After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 747128 - sftp mount unusable when copying
sftp mount unusable when copying
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: sftp backend
1.24.x
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2015-03-31 17:07 UTC by Ross Lagerwall
Modified: 2015-06-07 16:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
sftp: Add support for multiple connections (55.17 KB, patch)
2015-03-31 17:08 UTC, Ross Lagerwall
none Details | Review
sftp: Login to both connections when mounting (9.42 KB, patch)
2015-03-31 17:08 UTC, Ross Lagerwall
none Details | Review
sftp: Use the data connection when pushing data (3.71 KB, patch)
2015-03-31 17:08 UTC, Ross Lagerwall
none Details | Review
sftp: Use the data connection when pulling data (7.52 KB, patch)
2015-03-31 17:08 UTC, Ross Lagerwall
none Details | Review
sftp: Add support for multiple connections (54.44 KB, patch)
2015-05-25 11:13 UTC, Ross Lagerwall
accepted-commit_now Details | Review
sftp: Add a data connection (2.54 KB, patch)
2015-05-25 11:13 UTC, Ross Lagerwall
none Details | Review
sftp: Login to both connections when mounting (11.31 KB, patch)
2015-05-25 11:13 UTC, Ross Lagerwall
accepted-commit_now Details | Review
sftp: Use the data connection when pushing data (4.51 KB, patch)
2015-05-25 11:13 UTC, Ross Lagerwall
none Details | Review
sftp: Allow queuing and waiting for commands on different connections (6.06 KB, patch)
2015-05-25 11:13 UTC, Ross Lagerwall
none Details | Review
sftp: Use the data connection when pulling data (3.44 KB, patch)
2015-05-25 11:13 UTC, Ross Lagerwall
none Details | Review

Description Ross Lagerwall 2015-03-31 17:07:21 UTC
Since push and pull support was added, because 2 MiB of data is in flight, commands such as query_info and enumerate get queued behind the data and makes the mount unusable (e.g. to browse in Nautilus) when copying at the same time. This is especially noticeable over a slow internet connection.

I think the best fix is to use two connections, one for bulk data transfer (i.e. push and pull) and one for the rest.
Comment 1 Ross Lagerwall 2015-03-31 17:08:18 UTC
Created attachment 300688 [details] [review]
sftp: Add support for multiple connections

Multiple connections are needed since 7890d2801a7f ("sftp: Implement
push support") and ed826fdf386c ("sftp: Implement pull support"). This
is because up to 2 MiB of data may be in flight, so any "command" sent
(e.g. refreshing the view in Nautilus) gets queued up which makes the
mount unusable on a slow connection when copying at the same time.

This changes the code to support multiple connections but doesn't
actually make use of them.
Comment 2 Ross Lagerwall 2015-03-31 17:08:31 UTC
Created attachment 300689 [details] [review]
sftp: Login to both connections when mounting

Login to a command connection and a data connection when mounting. Any
password entered during the first connection is reused for the second
connection.
Comment 3 Ross Lagerwall 2015-03-31 17:08:44 UTC
Created attachment 300690 [details] [review]
sftp: Use the data connection when pushing data
Comment 4 Ross Lagerwall 2015-03-31 17:08:59 UTC
Created attachment 300691 [details] [review]
sftp: Use the data connection when pulling data
Comment 5 Ross Lagerwall 2015-03-31 17:10:07 UTC
With these patches, an sftp mount is a lot more usable when copying data at the same time.
Comment 6 Ondrej Holy 2015-04-22 13:43:15 UTC
Review of attachment 300688 [details] [review]:

It would be better only refactor the code in this patch and add the data_connection with another patch, otherwise looks good...

::: daemon/gvfsbackendsftp.c
@@ +281,3 @@
+
+  if (conn->command_stream)
+    g_object_unref (conn->command_stream);

Good time to change it to g_clear_object?
Comment 7 Ondrej Holy 2015-04-22 13:43:21 UTC
Review of attachment 300689 [details] [review]:

::: daemon/gvfsbackendsftp.c
@@ +959,1 @@
       DEBUG ("handle_login #%d - prompt: \"%s\"\n", i, buffer);

Would be good to print if it is initial connection in the debugs...

@@ +1205,2 @@
       /* Login succeed, save password in keyring */
       g_vfs_keyring_save_password (op_backend->user,

I think you shouldn't save the credentials for non-initial connections (again)...

@@ +1852,3 @@
+      g_clear_pointer (&op_backend->tmp_password, g_free);
+      g_cancellable_cancel (op_backend->command_connection.reply_stream_cancellable);
+      return;

What if ssdh_config contains "MaxSessions=1"? Shouldn't this be non-fatal since we are able to work only with one connection (add fallback to use command_connection instead)?
Comment 8 Ondrej Holy 2015-04-22 13:43:30 UTC
Review of attachment 300690 [details] [review]:

Looks good!
Comment 9 Ondrej Holy 2015-04-22 13:44:16 UTC
Review of attachment 300691 [details] [review]:

It needs commit description...

::: daemon/gvfsbackendsftp.c
@@ +1560,3 @@
+  Connection *connection;
+  GDataOutputStream *cmd;
+} Command;

Wouldn't be better to split the patch - introduce this struct in a one patch and use the data_connection in another one?
Comment 10 Ondrej Holy 2015-04-22 13:44:54 UTC
(In reply to Ross Lagerwall from comment #5)
> With these patches, an sftp mount is a lot more usable when copying data at
> the same time.

Good idea! Don't see difference on localhost, but it could be useful on slow connections...
Comment 11 Ross Lagerwall 2015-05-25 11:13:18 UTC
Created attachment 303906 [details] [review]
sftp: Add support for multiple connections

Multiple connections are needed since 7890d2801a7f ("sftp: Implement
push support") and ed826fdf386c ("sftp: Implement pull support"). This
is because up to 2 MiB of data may be in flight, so any "command" sent
(e.g. refreshing the view in Nautilus) gets queued up which makes the
mount unusable on a slow connection when copying at the same time.

This changes the code to support multiple connections but still uses
a single connection.
Comment 12 Ross Lagerwall 2015-05-25 11:13:23 UTC
Created attachment 303907 [details] [review]
sftp: Add a data connection

Add a data connection in addition to the command connection currently
used.
Comment 13 Ross Lagerwall 2015-05-25 11:13:27 UTC
Created attachment 303908 [details] [review]
sftp: Login to both connections when mounting

Login to the command connection and the data connection when mounting.
Any password entered during the first connection is reused for the
second connection.

Because the data connection is not essential, do not fail if the
connection attempt fails, and introduce a function to determine if a
connection is usable.
Comment 14 Ross Lagerwall 2015-05-25 11:13:32 UTC
Created attachment 303909 [details] [review]
sftp: Use the data connection when pushing data

Use the newly-introduced data connection when pushing data from a sftp
mount. This prevents blocking other operations behind a few MBs of
in-flight data and improves interactivity.

If the data connection is not usable, fall back to the default copy
implementation.
Comment 15 Ross Lagerwall 2015-05-25 11:13:36 UTC
Created attachment 303910 [details] [review]
sftp: Allow queuing and waiting for commands on different connections

Update the infrastructure to allow submitting multiple commands to be
sent on different connections and then waiting for the all to complete.
Comment 16 Ross Lagerwall 2015-05-25 11:13:40 UTC
Created attachment 303911 [details] [review]
sftp: Use the data connection when pulling data

Use the newly-introduced data connection when pulling data from a sftp
mount. This prevents blocking other operations behind a few MBs of
in-flight data and improves interactivity.

If the data connection is not usable, fall back to the default copy
implementation.
Comment 17 Ondrej Holy 2015-05-26 12:36:44 UTC
Review of attachment 303908 [details] [review]:

::: daemon/gvfsbackendsftp.c
@@ +908,3 @@
 #endif
 
+  DEBUG ("handle_login #%d, %sinitial_connection - user: %s, host: %s, port: %d\n",

Might be better to print initial_connection = %d as other booleans, but it is just detail...

@@ +1830,3 @@
+                         &error))
+    {
+      if (error)

Would be good to add a note that error isn't returned in case of do_mount recursion when new user is specified, because it looks like we can return here without finishing the job...
Comment 18 Ondrej Holy 2015-05-26 12:37:00 UTC
Review of attachment 303906 [details] [review]:

::: daemon/gvfsbackendsftp.c
@@ +1281,3 @@
     {
       if (expected_reply->callback != NULL)
+        {

There is no reason for adding those curly brackets, is it?
Comment 19 Ondrej Holy 2015-05-26 12:38:25 UTC
Rest of the patches looks good to me (I'm lazy to mark all of them as accepted), thanks for them. It seems sftp is working correctly. Just they are not applicable on master, so be careful...
Comment 20 Ross Lagerwall 2015-06-07 16:12:22 UTC
Pushed all to master as 6809b68..ffe8bdf. Thanks for the reviews!