]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_streams: Add "streams_xattr:max xattrs per stream" parameter
authorVolker Lendecke <vl@samba.org>
Thu, 4 Sep 2025 11:48:40 +0000 (13:48 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 21 Oct 2025 17:33:29 +0000 (17:33 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
docs-xml/manpages/vfs_streams_xattr.8.xml
source3/modules/vfs_streams_xattr.c

index 6645928c016bca46866d724b1b2100fe782ba493..e8680c2b4a0e68e304587a2e8245e3db4111326e 100644 (file)
            </listitem>
          </varlistentry>
 
+         <varlistentry>
+           <term>streams_xattr:max xattrs per stream = NUM</term>
+           <listitem>
+             <para>On file systems where the size of a single xattr
+             is more limited than the overall size of xattrs per
+             inode, setting this parameter to a number between 2 and
+             16 will allow smbd to store larger streams than what
+             fits into a single xattr. For example Linux has a limit
+             of 64kB per xattr, but XFS can store more than that per
+             inode.</para>
+             <para>The size of a single xattr is limited by the
+             smb.conf parameter <command>smbd max xattr
+             size</command></para>
+             <para>This is limited to 16 xattrs per alternate data
+             stream.</para>
+             <para>The default value is <command>1</command>,
+             compatible to the default behaviour before this feature
+             was introduced.</para>
+           </listitem>
+         </varlistentry>
+
        </variablelist>
 
 </refsect1>
index c8e14c8a766acd4828efc7d19388cc68dff3e7de..dd5e6b8164d0bb4841cf2e7a910caae3be1556c0 100644 (file)
@@ -34,6 +34,7 @@
 struct streams_xattr_config {
        const char *prefix;
        size_t prefix_len;
+       size_t max_extents;
        bool store_stream_type;
 };
 
@@ -1080,7 +1081,7 @@ static int streams_xattr_connect(vfs_handle_struct *handle,
        struct streams_xattr_config *config;
        const char *default_prefix = SAMBA_XATTR_DOSSTREAM_PREFIX;
        const char *prefix;
-       int rc;
+       int rc, max_xattrs;
 
        rc = SMB_VFS_NEXT_CONNECT(handle, service, user);
        if (rc != 0) {
@@ -1111,6 +1112,19 @@ static int streams_xattr_connect(vfs_handle_struct *handle,
                                                 "store_stream_type",
                                                 true);
 
+       max_xattrs = lp_parm_int(SNUM(handle->conn),
+                                "streams_xattr",
+                                "max xattrs per stream",
+                                1);
+       if ((max_xattrs < 1) || (max_xattrs > 16)) {
+               DBG_WARNING("\"max xattrs per stream\"=%d invalid: "
+                           "Between 1 and 16 possible\n",
+                           max_xattrs);
+               errno = EINVAL;
+               return -1;
+       }
+       config->max_extents = max_xattrs - 1;
+
        SMB_VFS_HANDLE_SET_DATA(handle, config,
                                NULL, struct stream_xattr_config,
                                return -1);