| c527e13a | 23-Dec-2025 |
David Howells <dhowells@redhat.com> |
cifs: Autogenerate SMB2 error mapping table
Autogenerate the SMB2 status to error code mapping table, from the smb2status.h common header, sorting it by NT status code so that it can be searched by
cifs: Autogenerate SMB2 error mapping table
Autogenerate the SMB2 status to error code mapping table, from the smb2status.h common header, sorting it by NT status code so that it can be searched by binary chopping. This also reduces the number of places this list is duplicated in the source.
Signed-off-by: David Howells <dhowells@redhat.com> cc: Steve French <stfrench@microsoft.com> cc: ChenXiaoSong <chenxiaosong@kylinos.cn> cc: linux-cifs@vger.kernel.org Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Reviewed-by: David Howells <dhowells@redhat.com> Link: https://lore.kernel.org/linux-cifs/20260106071507.1420900-3-chenxiaosong.chenxiaosong@linux.dev/ Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 8e94268b | 22-Jan-2026 |
Stefan Metzmacher <metze@samba.org> |
smb: smbdirect: introduce smbdirect_socket.send_io.bcredits.*
It turns out that our code will corrupt the stream of reassabled data transfer messages when we trigger an immendiate (empty) send.
In
smb: smbdirect: introduce smbdirect_socket.send_io.bcredits.*
It turns out that our code will corrupt the stream of reassabled data transfer messages when we trigger an immendiate (empty) send.
In order to fix this we'll have a single 'batch' credit per connection. And code getting that credit is free to use as much messages until remaining_length reaches 0, then the batch credit it given back and the next logical send can happen.
Cc: <stable@vger.kernel.org> # 6.18.x Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 10dfb073 | 23-Dec-2025 |
David Howells <dhowells@redhat.com> |
cifs: Label SMB2 statuses with errors
Label the SMB2 status entries with error codes as a prelude to autogenerating the mapping table. This was done with the following script:
#!/usr/bin/p
cifs: Label SMB2 statuses with errors
Label the SMB2 status entries with error codes as a prelude to autogenerating the mapping table. This was done with the following script:
#!/usr/bin/perl -w use strict;
my @error_mapping_table = (); my %statuses = ();
# # Read the status list # my $f = "fs/smb/common/smb2status.h"; open FILE, "<$f" || die $f; my @contents = <FILE>; close FILE || die;
my $l = 0; foreach (@contents) { $l++; if (m!^#define\s*([A-Za-z0-9_]+)\s+cpu_to_le32[(]([0-9a-fA-Fx]+)[)]!) { my $status = $1; my $code = $2; my $s;
next if ($status =~ /^STATUS_SEVERITY/);
if (exists($statuses{$status})) { print("$f:$l: Duplicate declaration of ", $s->{status}, "\n"); } else { my %_s = ( status => $status, code => hex($code) ); $statuses{$status} = \%_s; } } }
# # Read the SMB2 status => error mapping table # $f = "fs/smb/client/smb2maperror.c"; open(MFILE, "<$f") || die $f; my @maperror = <MFILE>; close MFILE || die;
my $parse = 0; my $acc = ""; $l = 0; foreach my $line (@maperror) { chomp $line; $l++; if ($parse == 0 && $line =~ /^static const struct status_to_posix_error smb2_error_map_table/) { $parse = 1; next; }
last if ($parse >= 1 && $line =~ /^[}];/);
if ($parse == 1) { if ($line =~ /[\t][{].*[}],/) { $acc = $line; $parse = 3; } elsif ($line =~ /[\t][{].*/) { $acc = $line; $parse = 2; next; } elsif ($line =~ m!^\s*/[*].*[*]/!) { next; } else { die "smb2maperror.c:$l: unparseable mapping element\n"; } } if ($parse == 2) { if ($line =~ /.*[}],/) { $acc .= $line; $parse = 3; } else { $acc .= $line; } }
if ($parse == 3) { $acc =~ s/\s+//g; if ($acc =~ m/[{](.*)[}]/) { $acc = $1; } else { die "'$acc'"; } my ($status, $error, $string) = split(/,/, $acc);
if (exists($statuses{$status})) { my $s = $statuses{$status};
if (exists($s->{error})) { print("$f:$l: Dup mapping entry $status\n"); }
$s->{error} = $error; #print $s->{code}, " => ", $error, "\n"; } else { print STDERR "$f:$l: Unknown status $status\n"; }
$acc = ""; $parse = 1; } }
# # Sort the error table by STATUS_* value # my @order = ();
foreach my $status (keys(%statuses)) { my $s = $statuses{$status}; push @order, $s; unless (exists($s->{code})) { print("Unknown code for ", $s->{status}, "\n") } else { #print("Code for ", $s->{status}, " is ", $s->{code}, "\n"); } }
@order = sort( { $a->{code} <=> $b->{code} } @order);
foreach my $s (@order) { my $status = $s->{status}; my $error = $s->{error}; my $code = $s->{code};
my $pad = " "; if (length($status) < 32) { my $n = 32 - length($status); $pad = "\t" x ((($n-1) / 8) + 1); } #printf("#define %s%scpu_to_le32(0x%08x) // -%s\n", $status, $pad, $code, $error); #printf("\t%s%s= 0x%08x, // -%s\n", $status, $pad, $code, $error); }
# # Decorate the definitions # my @output = (); for (my $i = 0; $i <= $#contents; $i++) { my $line = $contents[$i]; if ($line =~ m!^#define\s*([A-Za-z0-9_]+)\s+cpu_to_le32[(]([0-9a-fA-Fx]+)[)]!) { my $status = $1; my $code = $2;
if ($status =~ /^STATUS_SEVERITY/) { push @output, $line; next; }
my $pad = " "; if (length($status) < 40) { my $n = 40 - length($status); $pad = "\t" x ((($n-1) / 8) + 1); }
my $s = $statuses{$1}; my $error = "EIO"; if (exists($s->{error})) { $error = $s->{error}; } else { if (!$s->{code}) { print "ZERO ", $status, "\n"; $error = "0"; } else { $error = "-EIO"; } }
#my $rev = "#define " . $status . $pad . "_S(" . $2 . ", " . $error . ")\n"; my $rev = "#define " . $status . $pad . "cpu_to_le32(" . $2 . ") // " . $error . "\n";
push @output, $rev; } else { push @output, $line; } }
open FILE, ">fs/smb/common/smb2status.h" || die; print FILE @output; close FILE || die;
Signed-off-by: David Howells <dhowells@redhat.com> cc: Steve French <stfrench@microsoft.com> cc: ChenXiaoSong <chenxiaosong@kylinos.cn> cc: linux-cifs@vger.kernel.org Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Reviewed-by: David Howells <dhowells@redhat.com> Link: https://lore.kernel.org/linux-cifs/20260106071507.1420900-2-chenxiaosong.chenxiaosong@linux.dev/ Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 94d5b8db | 02-Dec-2025 |
ZhangGuoDong <zhangguodong@kylinos.cn> |
smb: move some SMB1 definitions into common/smb1pdu.h
These definitions are only used by SMB1, so move them into the new common/smb1pdu.h.
KSMBD only implements SMB_COM_NEGOTIATE, see MS-SMB2 3.3.5
smb: move some SMB1 definitions into common/smb1pdu.h
These definitions are only used by SMB1, so move them into the new common/smb1pdu.h.
KSMBD only implements SMB_COM_NEGOTIATE, see MS-SMB2 3.3.5.2.
Co-developed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: ZhangGuoDong <zhangguodong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 2b6abb89 | 30-Nov-2025 |
ChenXiaoSong <chenxiaosong@kylinos.cn> |
smb: move File Attributes definitions into common/fscc.h
These definitions are specified in MS-FSCC 2.6, so move them into fscc.h.
Modify the following places:
- FILE_ATTRIBUTE__MASK -> FILE_ATT
smb: move File Attributes definitions into common/fscc.h
These definitions are specified in MS-FSCC 2.6, so move them into fscc.h.
Modify the following places:
- FILE_ATTRIBUTE__MASK -> FILE_ATTRIBUTE_MASK - Update FILE_ATTRIBUTE_MASK value - cpu_to_le32(constant) -> cpu_to_le32(MACRO DEFINITION)
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| c9750332 | 01-Dec-2025 |
ChenXiaoSong <chenxiaosong@kylinos.cn> |
smb: update struct duplicate_extents_to_file_ex
Add the missing field to the structure (see MS-FSCC 2.3.9.2), and correct the section number in the documentation reference.
Signed-off-by: ChenXiaoS
smb: update struct duplicate_extents_to_file_ex
Add the missing field to the structure (see MS-FSCC 2.3.9.2), and correct the section number in the documentation reference.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 08c2a7d2 | 06-Nov-2025 |
ChenXiaoSong <chenxiaosong@kylinos.cn> |
smb: move file_notify_information to common/fscc.h
This struct definition is specified in MS-FSCC, and KSMBD will also use it, so move it into common header file.
Signed-off-by: ChenXiaoSong <chenx
smb: move file_notify_information to common/fscc.h
This struct definition is specified in MS-FSCC, and KSMBD will also use it, so move it into common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 6539e185 | 06-Nov-2025 |
ChenXiaoSong <chenxiaosong@kylinos.cn> |
smb: move SMB2 Notify Action Flags into common/smb2pdu.h
Some of these definitions are already in common/smb2pdu.h. Remove the duplicate client side definitions, and add all SMB2 Notify Action Flags
smb: move SMB2 Notify Action Flags into common/smb2pdu.h
Some of these definitions are already in common/smb2pdu.h. Remove the duplicate client side definitions, and add all SMB2 Notify Action Flags to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 9ec7629b | 06-Nov-2025 |
ChenXiaoSong <chenxiaosong@kylinos.cn> |
smb: move notify completion filter flags into common/smb2pdu.h
Some of these definitions are already in common/smb2pdu.h, remove the duplicate client side definitions, and move FILE_NOTIFY_CHANGE_NA
smb: move notify completion filter flags into common/smb2pdu.h
Some of these definitions are already in common/smb2pdu.h, remove the duplicate client side definitions, and move FILE_NOTIFY_CHANGE_NAME to common header file.
Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 1adb2dab | 25-Nov-2025 |
Stefan Metzmacher <metze@samba.org> |
smb: smbdirect: introduce SMBDIRECT_CHECK_STATUS_{WARN,DISCONNECT}()
These will be used in various places in order to assert the current status mostly during the connect and negotiation phase. It wi
smb: smbdirect: introduce SMBDIRECT_CHECK_STATUS_{WARN,DISCONNECT}()
These will be used in various places in order to assert the current status mostly during the connect and negotiation phase. It will replace the WARN_ON_ONCE(sc->status != ...) calls, which are very useless in order to identify the problem that happened.
As a start client and server will need to define their own __SMBDIRECT_SOCKET_DISCONNECT(__sc) macro in order to use SMBDIRECT_CHECK_STATUS_DISCONNECT().
Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: Paulo Alcantara <pc@manguebit.org> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 1f3fd108 | 25-Nov-2025 |
Stefan Metzmacher <metze@samba.org> |
smb: smbdirect: introduce SMBDIRECT_DEBUG_ERR_PTR() helper
This can be used like this:
int err = somefunc(); pr_warn("err=%1pe\n", SMBDIRECT_DEBUG_ERR_PTR(err));
This will be used in the follo
smb: smbdirect: introduce SMBDIRECT_DEBUG_ERR_PTR() helper
This can be used like this:
int err = somefunc(); pr_warn("err=%1pe\n", SMBDIRECT_DEBUG_ERR_PTR(err));
This will be used in the following fixes in order to be prepared to identify real world problems more easily.
Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: Long Li <longli@microsoft.com> Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: Paulo Alcantara <pc@manguebit.org> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|
| 5003ad71 | 13-Nov-2025 |
ChenXiaoSong <chenxiaosong@kylinos.cn> |
smb: move create_durable_reconn to common/smb2pdu.h
The fields in struct create_durable_reconn_req and struct create_durable are exactly the same, so remove create_durable_reconn_req from server, an
smb: move create_durable_reconn to common/smb2pdu.h
The fields in struct create_durable_reconn_req and struct create_durable are exactly the same, so remove create_durable_reconn_req from server, and use typedef to define both create_durable_req_t and create_durable_reconn_t for a single struct.
Rename the following places:
- struct create_durable -> create_durable_req_t - struct create_durable_reconn_req -> create_durable_reconn_t
The documentation references are:
- SMB2_CREATE_DURABLE_HANDLE_REQUEST in MS-SMB2 2.2.13.2.3 - SMB2_CREATE_DURABLE_HANDLE_RECONNECT in MS-SMB2 2.2.13.2.4 - SMB2_FILEID in MS-SMB2 2.2.14.1
Descriptions of the struct fields:
- __u8 Reserved[16]: DurableRequest field of SMB2_CREATE_DURABLE_HANDLE_REQUEST. A 16-byte field that MUST be reserved. - __u64 PersistentFileId: Persistent field of 2.2.14.1 SMB2_FILEID - __u64 VolatileFileId: Volatile field of 2.2.14.1 SMB2_FILEID - struct Fid: Data field of SMB2_CREATE_DURABLE_HANDLE_RECONNECT. An SMB2_FILEID structure, as specified in section 2.2.14.1.
Suggested-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
show more ...
|