summaryrefslogtreecommitdiff
path: root/include/linux/annotate.h
diff options
context:
space:
mode:
authorPaulo Alcantara <pc@manguebit.org>2026-03-11 15:00:52 -0300
committerSteve French <stfrench@microsoft.com>2026-03-11 18:46:40 -0500
commit40e75e42f49ca54b4ff41f3edb94f5ef0299140c (patch)
treeb6e12e468920c29bb1914d3b40b1e39485f5c856 /include/linux/annotate.h
parentd4c7210d2f3ea481a6481f03040a64d9077a6172 (diff)
smb: client: fix open handle lookup in cifs_open()
When looking up open handles to be re-used in cifs_open(), calling cifs_get_{writable,readable}_path() is wrong as it will look up for the first matching open handle, and if @file->f_flags doesn't match, it will ignore the remaining open handles in cifsInodeInfo::openFileList that might potentially match @file->f_flags. For writable and readable handles, fix this by calling __cifs_get_writable_file() and __find_readable_file(), respectively, with FIND_OPEN_FLAGS set. With the patch, the following program ends up with two opens instead of three sent over the wire. ``` #define _GNU_SOURCE #include <unistd.h> #include <string.h> #include <fcntl.h> int main(int argc, char *argv[]) { int fd; fd = open("/mnt/1/foo", O_CREAT | O_WRONLY | O_TRUNC, 0664); close(fd); fd = open("/mnt/1/foo", O_DIRECT | O_WRONLY); close(fd); fd = open("/mnt/1/foo", O_WRONLY); close(fd); fd = open("/mnt/1/foo", O_DIRECT | O_WRONLY); close(fd); return 0; } ``` ``` $ mount.cifs //srv/share /mnt/1 -o ... $ gcc test.c && ./a.out ``` Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Reviewed-by: ChenXiaoSong <chenxiaosong@kylinos.cn> Cc: David Howells <dhowells@redhat.com> Cc: linux-cifs@vger.kernel.org Signed-off-by: Steve French <stfrench@microsoft.com>
Diffstat (limited to 'include/linux/annotate.h')
0 files changed, 0 insertions, 0 deletions