diff --git a/SOURCES/smb-Improve-enumeration-performance.patch b/SOURCES/smb-Improve-enumeration-performance.patch new file mode 100644 index 0000000..9019b0a --- /dev/null +++ b/SOURCES/smb-Improve-enumeration-performance.patch @@ -0,0 +1,115 @@ +diff --git a/configure.ac b/configure.ac +index daeee728..689667e5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -551,6 +551,11 @@ if test "x$enable_samba" != "xno"; then + AC_DEFINE(HAVE_SMBC_SETOPTIONPROTOCOLS, 1, [Define to 1 if smbc_setOptionProtocols() is available]), + [] + ) ++ ++ AC_CHECK_LIB(smbclient, smbc_readdirplus2, ++ AC_DEFINE(HAVE_SMBC_READDIRPLUS2, 1, [Define to 1 if smbc_readdirplus2() is available]), ++ [] ++ ) + fi + fi + +diff --git a/daemon/gvfsbackendsmb.c b/daemon/gvfsbackendsmb.c +index 9571fa0d..ce151648 100644 +--- a/daemon/gvfsbackendsmb.c ++++ b/daemon/gvfsbackendsmb.c +@@ -1738,25 +1738,34 @@ do_enumerate (GVfsBackend *backend, + GFileQueryInfoFlags flags) + { + GVfsBackendSmb *op_backend = G_VFS_BACKEND_SMB (backend); +- struct stat st; +- int res; ++ struct stat st = { 0 }; + GError *error; + SMBCFILE *dir; +- char dirents[1024*4]; +- struct smbc_dirent *dirp; + GFileInfo *info; + GString *uri; +- int uri_start_len; + smbc_opendir_fn smbc_opendir; ++ smbc_closedir_fn smbc_closedir; ++#ifndef HAVE_SMBC_READDIRPLUS2 ++ int res; ++ char dirents[1024*4]; ++ struct smbc_dirent *dirp; ++ int uri_start_len; + smbc_getdents_fn smbc_getdents; + smbc_stat_fn smbc_stat; +- smbc_closedir_fn smbc_closedir; ++#else ++ smbc_readdirplus2_fn smbc_readdirplus2; ++ const struct libsmb_file_info *exstat; ++#endif + + uri = create_smb_uri_string (op_backend->server, op_backend->port, op_backend->share, filename); + + smbc_opendir = smbc_getFunctionOpendir (op_backend->smb_context); ++#ifndef HAVE_SMBC_READDIRPLUS2 + smbc_getdents = smbc_getFunctionGetdents (op_backend->smb_context); + smbc_stat = smbc_getFunctionStat (op_backend->smb_context); ++#else ++ smbc_readdirplus2 = smbc_getFunctionReaddirPlus2 (op_backend->smb_context); ++#endif + smbc_closedir = smbc_getFunctionClosedir (op_backend->smb_context); + + dir = smbc_opendir (op_backend->smb_context, uri->str); +@@ -1776,6 +1785,8 @@ do_enumerate (GVfsBackend *backend, + + if (uri->str[uri->len - 1] != '/') + g_string_append_c (uri, '/'); ++ ++#ifndef HAVE_SMBC_READDIRPLUS2 + uri_start_len = uri->len; + + while (TRUE) +@@ -1827,9 +1838,27 @@ do_enumerate (GVfsBackend *backend, + dirp = (struct smbc_dirent *) (((char *)dirp) + dirlen); + res -= dirlen; + } ++ } ++#else ++ while ((exstat = smbc_readdirplus2 (op_backend->smb_context, dir, &st)) != NULL) ++ { ++ if ((S_ISREG (st.st_mode) || ++ S_ISDIR (st.st_mode) || ++ S_ISLNK (st.st_mode)) && ++ g_strcmp0 (exstat->name, ".") != 0 && ++ g_strcmp0 (exstat->name, "..") != 0) ++ { ++ info = g_file_info_new (); ++ set_info_from_stat (op_backend, info, &st, exstat->name, matcher); ++ g_vfs_job_enumerate_add_info (job, info); ++ g_object_unref (info); ++ } ++ ++ memset (&st, 0, sizeof (struct stat)); + } +- +- res = smbc_closedir (op_backend->smb_context, dir); ++#endif ++ ++ smbc_closedir (op_backend->smb_context, dir); + + g_vfs_job_enumerate_done (job); + +diff --git a/meson.build b/meson.build +index 6ae768d9..d3f59457 100644 +--- a/meson.build ++++ b/meson.build +@@ -418,6 +418,7 @@ if enable_samba + smbclient_dep = dependency('smbclient') + + config_h.set('HAVE_SMBC_SETOPTIONPROTOCOLS', cc.has_function('smbc_setOptionProtocols', dependencies: smbclient_dep)) ++ config_h.set('HAVE_SMBC_READDIRPLUS2', cc.has_function('smbc_readdirplus2', dependencies: smbclient_dep)) + endif + + # *** Check for libarchive *** +-- +2.26.2 + diff --git a/SPECS/gvfs.spec b/SPECS/gvfs.spec index 0d4cfa8..415dcd9 100644 --- a/SPECS/gvfs.spec +++ b/SPECS/gvfs.spec @@ -25,7 +25,7 @@ Name: gvfs Version: 1.36.2 -Release: 8%{?dist} +Release: 10%{?dist} Summary: Backends for the gio framework in GLib License: GPLv3 and LGPLv2+ and BSD and MPLv2.0 @@ -60,6 +60,9 @@ Patch8: admin-Ensure-correct-ownership-when-moving-to-file-u.patch # https://bugzilla.redhat.com/show_bug.cgi?id=1759075 Patch9: udisks2-Fix-crashes-caused-by-missing-source-tag.patch +# https://bugzilla.redhat.com/show_bug.cgi?id=1569868 +Patch10: smb-Improve-enumeration-performance.patch + BuildRequires: pkgconfig BuildRequires: pkgconfig(glib-2.0) >= %{glib2_version} BuildRequires: pkgconfig(dbus-glib-1) @@ -161,7 +164,6 @@ Summary: gphoto2 support for gvfs Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}-client%{?_isa} = %{version}-%{release} BuildRequires: pkgconfig(libgphoto2) >= %{libgphoto2_version} -BuildRequires: libusb-devel >= %{libusb_version} BuildRequires: libexif-devel %description gphoto2 @@ -204,6 +206,7 @@ Summary: MTP support for gvfs Requires: %{name}%{?_isa} = %{version}-%{release} Requires: %{name}-client%{?_isa} = %{version}-%{release} BuildRequires: pkgconfig(libmtp) >= %{libmtp_version} +BuildRequires: pkgconfig(libusb-1.0) >= %{libusb_version} %description mtp This package provides support for reading and writing files on @@ -438,6 +441,12 @@ killall -USR1 gvfsd >&/dev/null || : %{_datadir}/installed-tests %changelog +* Wed Aug 05 2020 Ondrej Holy - 1.36.2-10 +- Fix libusb(x) requirements (rhbz#1866332) + +* Wed Jun 17 2020 Ondrej Holy - 1.36.2-9 +- Improve enumeration performance of smb backend (rhbz#1569868) + * Tue Oct 8 2019 Ondrej Holy - 1.36.2-8 - Fix udisks2 volume monitor crashes when stopping drive (rhbz#1759075)