找到你要的答案

Q:FileCreate without OPLOCK / Opportunistic Locking

Q:没有机会锁定操作锁定/创建文件

I am looking for a way to open / create a file on a SMB2 Windows share without requesting an oplock (SMB2_OPLOCK_LEVEL_LEASE). FileCreate() with the flag FILE_FLAG_NO_BUFFERING doesn't affect the behaviour.

Disabling Opportunistic Locking in the redirector is no option.

Is there a way to affect the fileopen / filecreate to not request an oplock?

我在寻找一种方式打开/创建一个Windows共享文件没有要求SMB2 oplock(smb2_oplock_level_lease)。与旗file_flag_no_buffering并不影响行为filecreate()。

禁用重定向机会锁定没有选择。

有没有办法影响文件打开/创建文件不要求oplock?

answer1: 回答1:

You can't do this. Windows atomaticaly managing opcloks on file system level.

你不能这样做。Windows atomaticaly管理文件系统级别的opcloks。

answer2: 回答2:

There is a tricky way to achieve this. Open the same file for reading from another application. If you do this before your main filecreate, it should not request oplock . If you do the same after your main filecreate, its oplock should become broken by the server.

Honestly, I am not absolutely sure about Win behavior but it wise trying imho.

Good luck

有一个棘手的方式来实现这一点。打开从另一应用程序读取的同一文件。如果你这样做之前,你的主要创建文件,不应要求操作锁定。如果你这样做,你的主要创建文件后,其oplock应当成为服务器坏了。

老实说,我不完全确定但聪明赢得了行为在我。

祝你好运

c++  caching  networking  file-io  smb