Closed Kenny0793 closed 2 years ago
I got it. may be ksmbd is not the same as samba in compatibility
Okay, Let's check other project has similar issue. @neheb Could you please check ksmbd of openWRT has issues(file creation and deletion failure) with windows ? @BrainSlayer dd-wrt ?
@mmakassikis Marios, Could you please check that ksmbd of freebox has issues(file creation and deletion failure) with windows ?
may be ksmbd is not the same as samba in compatibility
They should be same in compatibility. Just note that ksmbd is another smb server project.
What version of OpenWrt is this? 19.07 has ksmbd 3.3.4 I think because of kernel 4.14 compatibility.
21.02 (just released) has 3.3.9 because of...reasons. Can't really update it.
I install it in linux host(Debian),kernel version is 4.19.98,ksmbd version is the 3.3.7. the issue is the same.
no issues here. based on kernel 4.9. for me the problem description sounds like a permission problem between ksmbd and the local filesystem. using windows 11 right now for daily use
it is not related to permission. it is related to access path. issue exist with full path \ip\sharename, if only use \ip,no issue
@mmakassikis Marios, Could you please check that ksmbd of freebox has issues(file creation and deletion failure) with windows ?
I have received reports that sometimes a file copy/deletion will remain stuck. Annoyingly, I have not figured out how to reproduce it. It may be the same as the one reported in https://github.com/cifsd-team/ksmbd/issues/497
@Kenny0793
echo smb > /sys/class/ksmbd-control/debug echo vfs > /sys/class/ksmbd-control/debug
And share the messages. It's may be quite verbose, but perhaps that will help in figuring out what's wrong.
On devices where the issue appears, is it 100% reproducible ? If yes, can you try deleting the file using the command line rather than explorer.exe ?
Have you tried creating a networked-mapped drive ? If yes, does the issue still occur ?
What version of debian are you using ? If you're using "buster", you can enable the buster-backports APT repository. This way, you can install a 5.10 kernel and test with the latest ksmbd version.
I also encountered this issue moving from samba4 to ksmbd 3.4.1 on openwrt-snapshots-5.10 kernel.
I believe the root of the problem is caused by old quick access short cuts.
Steps taken to resolve: Remove all Mapped drives. In an elevated CMD prompt: del /F /Q %APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations*
Remap new drive via ip address(maybe doesn't matter). Repin Quick access shortcuts.
After doing this on 2 win10 pro machines, the 99% hang has not happened again in limited testing.
I'm not sure if there is something for the ksmbd guys to fix here.
@mmakassikis Can you reproduce the issue while having ksmbd debug messages enabled ? At the very least, I would do
see attachment.
On devices where the issue appears, is it 100% reproducible ? If yes, can you try deleting the file using the command line rather than explorer.exe ?
Yes, when accessing share file with full path \IP\sharename, it is 100% reproducible. When accessing with path \IP, all are ok. Do you mean using the command line in windows 10 Enterprise? I didn't know how to do it for windows. I can do all in Debian via command line.
Have you tried creating a networked-mapped drive ? If yes, does the issue still occur ?
I map \192.168.0.4\team2 to network driver, it is ok. But we don't do this in normal use. It is not available solution for us.
What version of debian are you using ? If you're using "buster", you can enable the buster-backports APT repository. This way, you can install a 5.10 kernel and test with the latest ksmbd version.
I can't install a 5.10 kernel. As randomgitname said, ksmbd 3.4.1 still has the issue.
uname -a
Linux shz-p5620460vl 4.19.98arg #1 SMP Wed Jul 7 09:07:36 CEST 2021 x86_64 GNU/Linux
could you help check and give your suggestion? Thanks in advance.
Hi All, When accessing share file with SAMBA, I can see messages 'Cancel Request' that PC sends. But for KSMBD, pc doesn't send the messages. Do you know why there is a difference between them? What affects the data packets sent by the PC?Is it related to this? Thanks. BR Kenny
I think that it is not related with this issue. Should I create many files to reproduce it ? or problem happen whenever creating first file in ksmbd share ?
It is not necessary to create many files. Only the first file is ok.
When I see file list in response packet, they are different with your picture you shared. e.g. there is no New Text Document (5).txt file in picture, otherwise there is this file in packet. New Text Document (5).txt is exist ?
When I try to create a new file, it will generate a file with a name that does not exist, for example: New Text Document (5).txt. The PC hangs at this time, but I checked that the file was generated on the linux host.
Okay, If you provide wireshark dump files when trying to reproduce using samba and ksmbd, I will check more. When you create file while capturing patckets, Please use same filename to easily compare samba and ksmbd s dump. Thank you for your help!
okay, i will provide it tommorrow.
Hi namjaejeon,
I uploaded the wireshark and tcpdump dump files for SAMBA and KSMBD. Before testing, I clean the directory Downloads. They will use the same file name(New Text Document.txt) when creating files. For ksmbd, I rename it to ssssss.txt after creating success in PC.
please help check it. . If you need more test, I will do it now. thanks
BR
Kenny
so no any useful info was found?
Sorry for late response, I will check it soon. Thanks for your help:)
Can you try to apply this patch and try to reproduce again ? if problem happen, please provide wireshark dump again. Thanks!
diff --git a/smb2pdu.c b/smb2pdu.c
index 18324e6..2c90fac 100644
--- a/smb2pdu.c
+++ b/smb2pdu.c
@@ -3408,7 +3408,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
smb2_get_reparse_tag_special_file(ksmbd_kstat->kstat->mode);
if (fbdinfo->EaSize)
fbdinfo->ExtFileAttributes = FILE_ATTRIBUTE_REPARSE_POINT_LE;
- fbdinfo->ShortNameLength = 0;
+ fbdinfo->ShortNameLength = ksmbd_extract_shortname(conn,
+ d_info->name,
+ fbdinfo->ShortName);
fbdinfo->Reserved = 0;
if (d_info->hide_dot_file && d_info->name[0] == '.')
fbdinfo->ExtFileAttributes |= FILE_ATTRIBUTE_HIDDEN_LE;
@@ -3467,7 +3469,9 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
if (fibdinfo->EaSize)
fibdinfo->ExtFileAttributes = FILE_ATTRIBUTE_REPARSE_POINT_LE;
fibdinfo->UniqueId = cpu_to_le64(ksmbd_kstat->kstat->ino);
- fibdinfo->ShortNameLength = 0;
+ fibdinfo->ShortNameLength = ksmbd_extract_shortname(conn,
+ d_info->name,
+ fibdinfo->ShortName);
fibdinfo->Reserved = 0;
fibdinfo->Reserved2 = cpu_to_le16(0);
if (d_info->hide_dot_file && d_info->name[0] == '.')
--
2.17.1
Thanks, okay, I will do it on next monday
Ok!
Issue still can be reproduced after applying the patch. please check it, Thanks.
Can you try to apply the below patch and reproduce again ?
diff --git a/smb2pdu.c b/smb2pdu.c
index 18324e6..29dae78 100644
--- a/smb2pdu.c
+++ b/smb2pdu.c
@@ -3347,7 +3347,8 @@ static int dentry_name(struct ksmbd_dir_info *d_info, int info_level)
*/
static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
struct ksmbd_dir_info *d_info,
- struct ksmbd_kstat *ksmbd_kstat)
+ struct ksmbd_kstat *ksmbd_kstat,
+ bool is_last_entry)
{
int next_entry_offset = 0;
char *conv_name;
@@ -3368,7 +3369,11 @@ static int smb2_populate_readdir_entry(struct ksmbd_conn *conn, int info_level,
}
struct_sz = readdir_info_level_struct_sz(info_level);
- next_entry_offset = ALIGN(struct_sz - 1 + conv_len,
+
+ if (is_last_entry)
+ next_entry_offset = struct_sz - 1 + conv_len;
+ else
+ next_entry_offset = ALIGN(struct_sz - 1 + conv_len,
KSMBD_DIR_INFO_ALIGNMENT);
if (next_entry_offset > d_info->out_buf_len) {
@@ -3600,7 +3605,8 @@ static int process_query_dir_entries(struct smb2_query_dir_private *priv)
rc = smb2_populate_readdir_entry(priv->work->conn,
priv->info_level,
priv->d_info,
- &ksmbd_kstat);
+ &ksmbd_kstat,
+ i == (priv->d_info->num_entry - 1));
dput(dent);
if (rc)
return rc;
diff --git a/smb_common.c b/smb_common.c
index 0aea882..2b916cc 100644
--- a/smb_common.c
+++ b/smb_common.c
@@ -338,7 +338,8 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
char *search_pattern,
int (*fn)(struct ksmbd_conn *, int,
struct ksmbd_dir_info *,
- struct ksmbd_kstat *))
+ struct ksmbd_kstat *,
+ bool))
{
int i, rc = 0;
struct ksmbd_conn *conn = work->conn;
@@ -368,7 +369,7 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
user_ns,
dir->filp->f_path.dentry->d_parent,
&ksmbd_kstat);
- rc = fn(conn, info_level, d_info, &ksmbd_kstat);
+ rc = fn(conn, info_level, d_info, &ksmbd_kstat, 0);
if (rc)
break;
if (d_info->out_buf_len <= 0)
diff --git a/smb_common.h b/smb_common.h
index 92e4504..e9788cb 100644
--- a/smb_common.h
+++ b/smb_common.h
@@ -461,7 +461,8 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work,
int (*fn)(struct ksmbd_conn *,
int,
struct ksmbd_dir_info *,
- struct ksmbd_kstat *));
+ struct ksmbd_kstat *,
+ bool));
int ksmbd_extract_shortname(struct ksmbd_conn *conn,
const char *longname,
--
2.25.1
Okay.I will test it tommorrow.Thanks
Ok, I hope that your issue is fixed with this patch...
Please check this patch. https://github.com/namjaejeon/ksmbd/commit/92db162315701b71ffe957a94bd80c05a922def8
I need to apply all patches or only the last patch?
i tested the second patch, it did not work
You can apply this patch (namjaejeon/ksmbd@92db162) What is meaning it did not work ?
problem is still reproduced with this patch ? can you provide wireshark dump ?
there are three patches, i do not test the last patch.
Ah, ignore prior 2 patch. Please check last patch (namjaejeon/ksmbd@92db162))
Or you can test #ksmbd-next branch included this patch. git clone --branch=ksmbd-next https://github.com/namjaejeon/ksmbd
still nok
Since I can't reproduce this problem, I need to keep requesting test. Sorry for bothering you.
Can you apply the below patch and reproduce again ?
diff --git a/smb2pdu.c b/smb2pdu.c
index 5ceb570..bfc30a4 100644
--- a/smb2pdu.c
+++ b/smb2pdu.c
@@ -5259,7 +5259,7 @@ int smb2_close(struct ksmbd_work *work)
rsp->Flags = SMB2_CLOSE_FLAG_POSTQUERY_ATTRIB;
rsp->AllocationSize = S_ISDIR(inode->i_mode) ? 0 :
cpu_to_le64(inode->i_blocks << 9);
- rsp->EndOfFile = cpu_to_le64(inode->i_size);
+ rsp->EndOfFile = S_ISDIR(inode->i_mode) ? 0 : cpu_to_le64(inode->i_size);
rsp->Attributes = fp->f_ci->m_fattr;
rsp->CreationTime = cpu_to_le64(fp->create_time);
time = ksmbd_UnixTimeToNT(inode->i_atime);
you are welcome, ignore previous patch?
Ah, No need to revert previous ones. you can apply it to current your ksmbd source.
still nok
Ah can you remind me what is issue when creating file ? When creating file, file is not showing ? if you try to refresh using F5, can you see file ?
Yes, file is not showing. In the explorer.exe, it will show "not responding". I can't refresh, explorer.exe was blocked. I printed screen in previous attachment.
@Kenny0793 Since explorer.exe is crashing, there should be a log in the Windows Event Viewer. Perhaps that will help figure out what it bothering it.
@mmakassikis I copy the error event in text format. I can't read it. can you figure out what issue is happening?
Log Name: Application Source: Windows Error Reporting Date: 9/16/2021 4:20:10 PM Event ID: 1001 Task Category: None Level: Information Keywords: Classic User: N/A Computer: .ADS.LOCAL Description: Fault bucket , type 0 Event Name: AppHangB1 Response: Not available Cab Id: 0
Problem signature: P1: explorer.exe P2: 10.0.19041.1151 P3: 2885d2b8 P4: e23f P5: 134217728 P6: P7: P8: P9: P10:
Attached files: \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERA32C.tmp.WERInternalMetadata.xml \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERA35C.tmp.xml \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERA36A.tmp.csv \?\C:\ProgramData\Microsoft\Windows\WER\Temp\WERA39A.tmp.txt \?\C:\Users\admin\AppData\Local\Temp\WERA495.tmp.appcompat.txt \?\C:\Users\admin\AppData\Local\Temp\WERA4B6.tmp.xml \?\C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppHang_explorer.exe_22c97aca503b8306caafb7fbfdf8c206f1187_bb0dc81a_cab_f8751f72-0feb-46c0-9610-ec90a7274773\minidump.mdmp \?\C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppHang_explorer.exe_22c97aca503b8306caafb7fbfdf8c206f1187_bb0dc81a_cab_f8751f72-0feb-46c0-9610-ec90a7274773\memory.hdmp
These files may be available here: \?\C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppHang_explorer.exe_22c97aca503b8306caafb7fbfdf8c206f1187_bb0dc81a_cab_f8751f72-0feb-46c0-9610-ec90a7274773
Analysis symbol: Rechecking for solution: 0 Report Id: eaa023f4-ef85-4df0-810a-73adffc0a93c Report Status: 100 Hashed bucket: Cab Guid: 0 Event Xml:
Hi All,
BR Kenny