Download raw body.
sysutils/usmb: suggestions for (performance) improvements
On Thu, Mar 06, 2025 at 07:01:44PM +0000, Stuart Henderson wrote:
> On 2025/03/06 18:45, Hiltjo Posthuma wrote:
> > In the following commit the sysctl kern.usermount=1 was removed:
> > https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/kern/kern_sysctl.c?rev=1.306&content-type=text/x-cvsweb-markup
> >
> > What is the alternative to run FUSE safely as non-root now? It seems ports
> > like sshfs, curlftps etc cannot run as a user now?
>
> There isn't one. (And fuse is a bit of a dead-end on OpenBSD anyway, we
> have always been a bit incompatible anyway, and the fuse 3 compatible
> code that was written never made it into the tree).
>
> > Feel free to use the above changes into usmb if you want.
>
> a set of "I changed this and this and this" instructions isn't
> particularly helpful for getting something into a port..
Yes, sorry, below is a patch that changes the following:
* Change the block size from the 512 bytes default to 32768 for files (struct
stat.st_blksize).
* Remove max_read FUSE limit option.
* Remove the maximum 32768 bytes per write limitation (the smbclient code
handles this just fine).
Thank you,
diff --git a/sysutils/usmb/Makefile b/sysutils/usmb/Makefile
index f10c062979a..3f7fcc47264 100644
--- a/sysutils/usmb/Makefile
+++ b/sysutils/usmb/Makefile
@@ -1,7 +1,7 @@
COMMENT= mount SMB shares from userland via FUSE
DISTNAME= usmb-20130204
-REVISION= 7
+REVISION= 8
CATEGORIES= sysutils
diff --git a/sysutils/usmb/patches/patch-options_c b/sysutils/usmb/patches/patch-options_c
new file mode 100644
index 00000000000..e293d27457b
--- /dev/null
+++ b/sysutils/usmb/patches/patch-options_c
@@ -0,0 +1,21 @@
+Index: options.c
+--- options.c.orig
++++ options.c
+@@ -149,7 +149,6 @@
+ static char MINUS_D[] = "-d";
+ static char MINUS_F[] = "-f";
+ static char MINUS_O[] = "-o";
+- static char MAX_READ[] = "max_read=32768";
+
+ assert (NULL != mountpoint);
+ static char *argv[MAXARGS];
+@@ -167,9 +166,6 @@
+ if (nofork)
+ #endif
+ argv[argc++] = MINUS_F;
+-
+- argv[argc++] = MINUS_O;
+- argv[argc++] = MAX_READ;
+
+ if ((NULL != options) && ('\0' != options[0]))
+ {
diff --git a/sysutils/usmb/patches/patch-usmb_file_c b/sysutils/usmb/patches/patch-usmb_file_c
index 8e16874813c..714eaf71cbf 100644
--- a/sysutils/usmb/patches/patch-usmb_file_c
+++ b/sysutils/usmb/patches/patch-usmb_file_c
@@ -1,10 +1,75 @@
Index: usmb_file.c
--- usmb_file.c.orig
+++ usmb_file.c
-@@ -202,6 +202,30 @@ int usmb_write (const char *filename UNUSED, const cha
+@@ -60,7 +60,18 @@
+ return (NULL == dirent);
}
++static bool change_blksiz(struct stat *st)
++{
++ if (st == NULL)
++ return false;
+
++ if (S_ISREG(st->st_mode)) {
++ st->st_blksize = 32768;
++ return true;
++ }
++ return false;
++}
++
+ int usmb_getattr (const char *filename, struct stat *st)
+ {
+ char *url = make_url (filename);
+@@ -74,6 +85,8 @@
+ if ((0 > ret) || !fix_nlink (url, st))
+ ret = -errno;
+
++ change_blksiz(st);
++
+ free (url);
+ return ret;
+ }
+@@ -101,6 +114,8 @@
+ return -errno;
+ }
+
++ change_blksiz(st);
++
+ return 0;
+ }
+
+@@ -147,8 +162,6 @@
+ int usmb_read (const char *filename UNUSED, char *buff, size_t len, off_t off,
+ struct fuse_file_info *fi)
+ {
+- assert (32768 >= len);
+-
+ SMBCFILE *file = fd_to_smbcfile (fi->fh);
+ DEBUG (fprintf (stderr, "read (%p, %p, %llu, %lld) ",
+ (void *)file, buff, (unsigned long long)len, (long long)off));
+@@ -178,14 +191,11 @@
+ size_t written = 0;
+ int bytes = 0;
+
+- // No idea whether Windows servers don't like > 32768 byte writes
+- // (cf. usmb_read), but taking no chances...
+-
+ const smbc_write_fn write_fn = smbc_getFunctionWrite (ctx);
+
+ while (written < len)
+ {
+- bytes = write_fn (ctx, file, (char *)buff, (len > 32768) ? 32768 : len);
++ bytes = write_fn (ctx, file, (char *)buff, len);
+ if (0 > bytes)
+ break;
+
+@@ -199,6 +209,30 @@
+ DEBUG (fprintf (stderr, "= %d\n", (0 > bytes) ? -errno : (int)written));
+ return (0 > bytes) ? -errno : (int)written;
++}
++
++
+/* File systems must support mknod on OpenBSD */
+int usmb_mknod (const char *filename, mode_t mode, __attribute__((unused)) dev_t dev)
+{
@@ -26,9 +91,4 @@ Index: usmb_file.c
+ smbc_getFunctionClose (ctx) (ctx, file);
+ free (url);
+ return ret;
-+}
-+
-+
- int usmb_create (const char *filename, mode_t mode, struct fuse_file_info *fi)
- {
- char *url = make_url (filename);
+ }
--
Kind regards,
Hiltjo
sysutils/usmb: suggestions for (performance) improvements