- From 1597a14238533358ba9fed4679e452dcc9eac93d Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 1 Oct 2025 18:18:50 +0200
- Subject: [PATCH 01/10] cygwin: Fix lockincfile1-related build failure
- Fix lockincfile1-related build failure - Makefile entries were
- missing.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- cygwin/Makefile | 2 ++
- 1 file changed, 2 insertions(+)
- diff --git a/cygwin/Makefile b/cygwin/Makefile
- index 3e55f1c..06d808a 100644
- --- a/cygwin/Makefile
- +++ b/cygwin/Makefile
- @@ -80,6 +80,7 @@ build_testutils:
- (cd "$(PROJECT_BASEDIR_DIR)/tests/lssparse" && make all)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1" && make all)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/filemmaptests" && make all)
- + (cd "$(PROJECT_BASEDIR_DIR)/tests/lockincfile1" && make all)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winclonefile" && make all)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile" && make all)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem" && make all)
- @@ -120,6 +121,7 @@ clean:
- (cd "$(PROJECT_BASEDIR_DIR)/tests/lssparse" && make clean)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winfsinfo1" && make clean)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/filemmaptests" && make clean)
- + (cd "$(PROJECT_BASEDIR_DIR)/tests/lockincfile1" && make clean)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winclonefile" && make clean)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winoffloadcopyfile" && make clean)
- (cd "$(PROJECT_BASEDIR_DIR)/tests/winrunassystem" && make clean)
- --
- 2.51.0
- From 149bef668ec3b54578603ef2b077e68dc03d41ac Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 1 Oct 2025 18:20:15 +0200
- Subject: [PATCH 02/10] tests: lockincfile1 should use
- |FILE_FLAG_WRITE_THROUGH|
- lockincfile1 should use |FILE_FLAG_WRITE_THROUGH|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- tests/lockincfile1/lockincfile1.c | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
- diff --git a/tests/lockincfile1/lockincfile1.c b/tests/lockincfile1/lockincfile1.c
- index cde5822..cae0339 100644
- --- a/tests/lockincfile1/lockincfile1.c
- +++ b/tests/lockincfile1/lockincfile1.c
- @@ -67,7 +67,7 @@ int main(int argc, char *av[])
- FILE_SHARE_READ | FILE_SHARE_WRITE,
- NULL,
- OPEN_EXISTING,
- - /*FILE_ATTRIBUTE_NORMAL*/FILE_FLAG_NO_BUFFERING,
- + /*FILE_ATTRIBUTE_NORMAL*/FILE_FLAG_NO_BUFFERING|FILE_FLAG_WRITE_THROUGH,
- NULL);
- if (h == INVALID_HANDLE_VALUE) {
- (void)fprintf(stderr, "%s: Cannot open file '%s', lasterr=%ld\n",
- --
- 2.51.0
- From 5ebe0d70c7a3854e43bf081e2c9acae1baf77dee Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 1 Oct 2025 19:39:53 +0200
- Subject: [PATCH 03/10] daemon,sys: Move retry loop for blocking locks to the
- userland daemon
- Move retry loop for blocking locks to the userland daemon.
- This makes the kernel module simpler, and allows us to implement
- support for |CB_NOTIFY_LOCK| later.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/lock.c | 50 +++++++++++++++++++++++++++++++++++++++++++--
- sys/nfs41sys_lock.c | 32 -----------------------------
- 2 files changed, 48 insertions(+), 34 deletions(-)
- diff --git a/daemon/lock.c b/daemon/lock.c
- index d41ef2c..e5d9b4e 100644
- --- a/daemon/lock.c
- +++ b/daemon/lock.c
- @@ -1,5 +1,6 @@
- /* NFSv4.1 client for Windows
- - * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2012 The Regents of the University of Michigan
- + * Copyright (C) 2023-2025 Roland Mainz <roland.mainz@nrubsig.org>
- *
- * Olga Kornievskaia <aglo@umich.edu>
- * Casey Bodley <cbodley@umich.edu>
- @@ -197,7 +198,7 @@ static __inline uint32_t get_lock_type(BOOLEAN exclusive, BOOLEAN blocking)
- : ( exclusive == 0 ? READW_LT : WRITEW_LT );
- }
- -static int handle_lock(void *deamon_context, nfs41_upcall *upcall)
- +static int handle_lock_retry(void *deamon_context, nfs41_upcall *upcall)
- {
- stateid_arg stateid;
- lock_upcall_args *args = &upcall->args.lock;
- @@ -266,6 +267,51 @@ out_free:
- goto out;
- }
- +#define LOCK_POLL_MIN_WAIT_MS (100UL) /* 100ms */
- +#define LOCK_POLL_MAX_WAIT_MS (15000UL) /* 15s */
- +
- +static int handle_lock(void *deamon_context, nfs41_upcall *upcall)
- +{
- + int status;
- + lock_upcall_args *args = &upcall->args.lock;
- + nfs41_open_state *state = upcall->state_ref;
- + DWORD poll_delay = 0UL;
- +
- +retry_lock:
- + status = handle_lock_retry(deamon_context, upcall);
- + if ((status == ERROR_LOCK_FAILED) && (args->blocking)) {
- + /*
- + * Use exponential backoff between polls for blocking locks, but
- + * limit it to |LOCK_POLL_MAX_WAIT_MS| milliseconds
- + */
- + if (poll_delay == 0L)
- + poll_delay = LOCK_POLL_MIN_WAIT_MS;
- + else
- + poll_delay *= 2L;
- + if (poll_delay > LOCK_POLL_MAX_WAIT_MS)
- + poll_delay = LOCK_POLL_MAX_WAIT_MS;
- +
- + /*
- + * Make sure the kernel waits for us, and then go to sleep
- + *
- + * ToDO:
- + * - Turn this into an Win32 event, wait via
- + * |WaitForSingleObject(..., poll_delay)|, and signal the event if
- + * a matching |CB_NOTIFY_LOCK| is received
- + */
- + DPRINTF(1,
- + ("handle_lock(state->path.path='%s'): retry in %ldms\n",
- + state->path.path, (long)poll_delay));
- + (void)delayxid(upcall->xid, 30+(poll_delay/1000));
- + Sleep(poll_delay);
- +
- + goto retry_lock;
- + }
- +
- + return status;
- +}
- +
- +
- static void cancel_lock(IN nfs41_upcall *upcall)
- {
- stateid_arg stateid;
- diff --git a/sys/nfs41sys_lock.c b/sys/nfs41sys_lock.c
- index a729ada..b73821d 100644
- --- a/sys/nfs41sys_lock.c
- +++ b/sys/nfs41sys_lock.c
- @@ -218,24 +218,6 @@ static void print_lock_args(
- !BooleanFlagOn(flags, SL_FAIL_IMMEDIATELY));
- }
- -
- -/* use exponential backoff between polls for blocking locks */
- -#define MSEC_TO_RELATIVE_WAIT (-10000LL)
- -#define MIN_LOCK_POLL_WAIT (100 * MSEC_TO_RELATIVE_WAIT) /* 100ms */
- -#define MAX_LOCK_POLL_WAIT (15000 * MSEC_TO_RELATIVE_WAIT) /* 15s */
- -
- -static void denied_lock_backoff(
- - IN OUT PLARGE_INTEGER delay)
- -{
- - if (delay->QuadPart == 0LL)
- - delay->QuadPart = MIN_LOCK_POLL_WAIT;
- - else
- - delay->QuadPart *= 2LL;
- -
- - if (delay->QuadPart > MAX_LOCK_POLL_WAIT)
- - delay->QuadPart = MAX_LOCK_POLL_WAIT;
- -}
- -
- #ifdef NFS41_DRIVER_HACK_LOCKING_STORAGE32_RANGELOCK_PROBING
- static
- bool rangelock_hack_skiplock(
- @@ -276,14 +258,11 @@ NTSTATUS nfs41_Lock(
- __notnull PNFS41_FCB nfs41_fcb = NFS41GetFcbExtension(Fcb);
- #endif /* NFS41_DRIVER_HACK_LOCKING_STORAGE32_RANGELOCK_PROBING */
- const ULONG flags = LowIoContext->ParamsFor.Locks.Flags;
- - LARGE_INTEGER poll_delay = {0};
- #ifdef ENABLE_TIMINGS
- LARGE_INTEGER t1, t2;
- t1 = KeQueryPerformanceCounter(NULL);
- #endif
- - poll_delay.QuadPart = 0;
- -
- #ifdef DEBUG_LOCK
- DbgEn();
- print_lock_args(RxContext);
- @@ -312,7 +291,6 @@ NTSTATUS nfs41_Lock(
- entry->u.Lock.exclusive = BooleanFlagOn(flags, SL_EXCLUSIVE_LOCK);
- entry->u.Lock.blocking = !BooleanFlagOn(flags, SL_FAIL_IMMEDIATELY);
- -retry_upcall:
- status = nfs41_UpcallWaitForReply(entry, pVNetRootContext->timeout);
- if (status) {
- /* Timeout - |nfs41_downcall()| will free |entry|+contents */
- @@ -320,16 +298,6 @@ retry_upcall:
- goto out;
- }
- - /* blocking locks keep trying until it succeeds */
- - if (entry->status == ERROR_LOCK_FAILED && entry->u.Lock.blocking) {
- - denied_lock_backoff(&poll_delay);
- - DbgP("returned ERROR_LOCK_FAILED; retrying in %llums\n",
- - poll_delay.QuadPart / MSEC_TO_RELATIVE_WAIT);
- - KeDelayExecutionThread(KernelMode, FALSE, &poll_delay);
- - entry->state = NFS41_WAITING_FOR_UPCALL;
- - goto retry_upcall;
- - }
- -
- status = map_lock_errors(entry->status);
- RxContext->CurrentIrp->IoStatus.Status = status;
- --
- 2.51.0
- From 82c1ed0b02d51a4941f93285301e4bfbaf309e43 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 1 Oct 2025 19:45:08 +0200
- Subject: [PATCH 04/10] README.md,docs: Cygwin 3.3 (32bit) does not have a
- "bmake" package
- Cygwin 3.3 (32bit) does not have a "bmake" package, we therefore
- remove it from the Cygwin 3.3 package list.
- Reported-by: Cedric Blancher <cedric.blancher@gmail.com>
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- README.md | 2 +-
- docs/README.xml | 2 +-
- 2 files changed, 2 insertions(+), 2 deletions(-)
- diff --git a/README.md b/README.md
- index bc07283..8c28eec 100644
- --- a/README.md
- +++ b/README.md
- @@ -346,7 +346,7 @@ Cygwin 32bit can be installed like this:
- 3. Run installer with these arguments:
- - setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,bmake,git,dos2unix,unzip
- + setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,git,dos2unix,unzip
- ## Download and install MSYS2/64bit \[OPTIONAL\]
- diff --git a/docs/README.xml b/docs/README.xml
- index 7666be1..f994545 100644
- --- a/docs/README.xml
- +++ b/docs/README.xml
- @@ -475,7 +475,7 @@ cd download</programlisting>
- </listitem>
- <listitem>
- <para>Run installer with these arguments:</para>
- - <programlisting>setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,bmake,git,dos2unix,unzip</programlisting>
- + <programlisting>setup-x86.exe --allow-unsupported-windows -q --no-verify --site "http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/2022/11/23/063457" -P cygwin,cygwin-devel,cygrunsrv,cygutils,cygutils-extra,bash,bzip2,coreutils,getent,gdb,grep,hostname,less,libiconv,libiconv2,pax,pbzip2,procps-ng,sed,tar,time,util-linux,wget,libnfs-utils,make,git,dos2unix,unzip</programlisting>
- </listitem>
- </orderedlist>
- </section>
- --
- 2.51.0
- From c7520e90e74f302fa1e7d25049f7c573550ef911 Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Wed, 1 Oct 2025 19:49:56 +0200
- Subject: [PATCH 05/10] daemon: CriticalSections |state->locks.lock| should not
- use a spin count
- CriticalSections |state->locks.lock| should not use a spin count,
- as they are locked for longer time spans, and spinning is then just
- wasted CPU time.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/open.c | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
- diff --git a/daemon/open.c b/daemon/open.c
- index 953fa49..3972a81 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -81,7 +81,11 @@ static int create_open_state(
- state->ref_count = 1; /* will be released in |cleanup_close()| */
- list_init(&state->locks.list);
- list_init(&state->client_entry);
- - InitializeCriticalSection(&state->locks.lock);
- + /*
- + * Disable spin count as |state->locks.lock| is typically used to
- + * protect list searches, which takes a long time
- + */
- + (void)InitializeCriticalSectionAndSpinCount(&state->locks.lock, 0);
- state->ea.list = INVALID_HANDLE_VALUE;
- InitializeCriticalSection(&state->ea.lock);
- --
- 2.51.0
- From c8e705e95d898bbcb9f143e6781b0569fac2407a Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 2 Oct 2025 13:28:20 +0200
- Subject: [PATCH 06/10] tests: manual tests: Add "DISKSPD" for async I/O
- testing
- manual tests: Add "DISKSPD" (storage load generator / performance test tool)
- for async read/write testing.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- tests/manual_testing.txt | 32 +++++++++++++++++++++++++++++++-
- 1 file changed, 31 insertions(+), 1 deletion(-)
- diff --git a/tests/manual_testing.txt b/tests/manual_testing.txt
- index 98ee849..ee1cb7f 100644
- --- a/tests/manual_testing.txt
- +++ b/tests/manual_testing.txt
- @@ -1,5 +1,5 @@
- #
- -# ms-nfs41-client manual testing sequence, 2025-09-19
- +# ms-nfs41-client manual testing sequence, 2025-10-02
- #
- # Draft version, needs to be turned into automated tests
- # if possible
- @@ -1089,5 +1089,35 @@ $ /usr/lib/csih/getVolInfo.exe . | fgrep FILE_CASE_SENSITIVE_SEARCH # must be "F
- 1. https://learn.microsoft.com/en-us/windows/compatibility/ntvdm-and-16-bit-app-support
- +#
- +# DISKSPD storage load generator / performance test tool
- +# (https://github.com/microsoft/diskspd/)
- +# Mainly used to test Win32 async read/write
- +#
- +
- +#
- +# Download&&unpack
- +#
- +wget 'https://github.com/microsoft/diskspd/releases/download/v2.2/DiskSpd.ZIP'
- +mkdir DiskSpd && cd DiskSpd
- +unzip ../DiskSpd.ZIP
- +
- +#
- +# run tests
- +#
- +
- +# prep
- +mkdir testruns && cd testruns
- +
- +# async IO tests
- +../DiskSpd/amd64/diskspd.exe -c512M -b4K -t32 -r -o64 -d120 -Sh -w50 testfile1.dat testfile2.dat
- +../DiskSpd/amd64/diskspd.exe -c512M -b8K -t32 -r -o64 -d120 -Sh -w50 testfile1.dat testfile2.dat
- +../DiskSpd/amd64/diskspd.exe -c512M -b32K -t32 -r -o64 -d120 -Sh -w50 testfile1.dat testfile2.dat
- +../DiskSpd/amd64/diskspd.exe -c512M -b32K -t32 -r -o64 -d120 -Sb -w50 testfile1.dat testfile2.dat
- +../DiskSpd/amd64/diskspd.exe -c512M -b1M -t32 -r -o64 -d120 -Sh -w50 testfile1.dat testfile2.dat
- +# memory-mapped IO (not async)
- +../DiskSpd/amd64/diskspd.exe -c512M -b1M -t32 -r -o64 -d120 -Sm -Nv -w50 testfile1.dat
- +
- +
- #
- # EOF.
- --
- 2.51.0
- From ae191fe5dc724822f565c9e5bf1280a9be9e8c94 Mon Sep 17 00:00:00 2001
- From: Dan Shelton <dan.f.shelton@gmail.com>
- Date: Thu, 2 Oct 2025 15:17:23 +0200
- Subject: [PATCH 07/10] daemon: Fix clang/ReactOS pointer mismatch warnings
- Fix clang/ReactOS pointer mismatch warnings.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/acl.c | 2 +-
- daemon/ea.c | 6 ++++--
- daemon/lock.c | 3 ++-
- daemon/open.c | 2 +-
- daemon/setattr.c | 3 ++-
- daemon/symlink.c | 2 +-
- 6 files changed, 11 insertions(+), 7 deletions(-)
- diff --git a/daemon/acl.c b/daemon/acl.c
- index 24f225f..c37a7c8 100644
- --- a/daemon/acl.c
- +++ b/daemon/acl.c
- @@ -1267,7 +1267,7 @@ static int map_dacl_2_nfs4acl(PACL acl, PSID sid, PSID gsid, nfsacl41 *nfs4_acl,
- nfsace4 *curr_nfsace = &nfs4_acl->aces[nfs_i];
- PSID ace_sid;
- - status = GetAce(acl, win_i, &ace);
- + status = GetAce(acl, win_i, (LPVOID *)&ace);
- if (!status) {
- status = GetLastError();
- eprintf("map_dacl_2_nfs4acl: GetAce failed with %d\n", status);
- diff --git a/daemon/ea.c b/daemon/ea.c
- index e5b012a..b6f1613 100644
- --- a/daemon/ea.c
- +++ b/daemon/ea.c
- @@ -198,7 +198,8 @@ static int parse_setexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- if (status) goto out;
- - status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
- + status = get_safe_read_bufferpos(&buffer, &length,
- + args->buf_len, (void **)&args->buf);
- if (status) goto out;
- EASSERT(length == 0);
- @@ -280,7 +281,8 @@ static int parse_getexattr(unsigned char *buffer, uint32_t length, nfs41_upcall
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->ealist_len, sizeof(args->ealist_len));
- if (status) goto out;
- - status = get_safe_read_bufferpos(&buffer, &length, args->ealist_len, &args->ealist);
- + status = get_safe_read_bufferpos(&buffer, &length,
- + args->ealist_len, (void **)&args->ealist);
- if (status) goto out;
- EASSERT(length == 0);
- diff --git a/daemon/lock.c b/daemon/lock.c
- index e5d9b4e..b5e1f29 100644
- --- a/daemon/lock.c
- +++ b/daemon/lock.c
- @@ -359,7 +359,8 @@ static int parse_unlock(unsigned char *buffer, uint32_t length, nfs41_upcall *up
- status = safe_read(&buffer, &length, &args->count, sizeof(ULONG));
- if (status) goto out;
- args->buf_len = args->count*2L*sizeof(LONGLONG);
- - status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
- + status = get_safe_read_bufferpos(&buffer, &length,
- + args->buf_len, (void **)&args->buf);
- if (status) goto out;
- EASSERT(length == 0);
- diff --git a/daemon/open.c b/daemon/open.c
- index 3972a81..d86b836 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -1265,7 +1265,7 @@ static int marshall_open(unsigned char *buffer, uint32_t *length, nfs41_upcall *
- */
- unsigned short *wc_len_out;
- status = get_safe_write_bufferpos(&buffer, length,
- - sizeof(unsigned short), &wc_len_out);
- + sizeof(unsigned short), (void **)&wc_len_out);
- if (status) goto out;
- EASSERT(wc_len_out != NULL);
- diff --git a/daemon/setattr.c b/daemon/setattr.c
- index 6a877ac..fe920a2 100644
- --- a/daemon/setattr.c
- +++ b/daemon/setattr.c
- @@ -53,7 +53,8 @@ static int parse_setattr(unsigned char *buffer, uint32_t length, nfs41_upcall *u
- if (status) goto out;
- status = safe_read(&buffer, &length, &args->buf_len, sizeof(args->buf_len));
- if (status) goto out;
- - status = get_safe_read_bufferpos(&buffer, &length, args->buf_len, &args->buf);
- + status = get_safe_read_bufferpos(&buffer, &length,
- + args->buf_len, (void **)&args->buf);
- if (status) goto out;
- args->root = upcall->root_ref;
- diff --git a/daemon/symlink.c b/daemon/symlink.c
- index 5722b72..2eb947b 100644
- --- a/daemon/symlink.c
- +++ b/daemon/symlink.c
- @@ -295,7 +295,7 @@ static int marshall_symlink_get(unsigned char *buffer, uint32_t *length,
- unsigned short *wc_len_out;
- status = get_safe_write_bufferpos(&buffer, length,
- - sizeof(unsigned short), &wc_len_out);
- + sizeof(unsigned short), (void **)&wc_len_out);
- if (status) goto out;
- EASSERT(wc_len_out != NULL);
- --
- 2.51.0
- From 7f658e69e8c2dc1a763802de2abee03b37fd7c10 Mon Sep 17 00:00:00 2001
- From: Dan Shelton <dan.f.shelton@gmail.com>
- Date: Thu, 2 Oct 2025 15:24:13 +0200
- Subject: [PATCH 08/10] daemon: Fix clang warning "comparison of integers of
- different signs: 'int' and 'unsigned long long'" in handle_readdir()
- Fix clang warning "comparison of integers of different signs: 'int'
- and 'unsigned long long'" in handle_readdir()
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/readdir.c | 4 ++--
- 1 file changed, 2 insertions(+), 2 deletions(-)
- diff --git a/daemon/readdir.c b/daemon/readdir.c
- index 5496e23..407bcfb 100644
- --- a/daemon/readdir.c
- +++ b/daemon/readdir.c
- @@ -759,8 +759,8 @@ static int handle_readdir(void *deamon_context, nfs41_upcall *upcall)
- bitmap4 attr_request;
- bool_t eof;
- /* make sure we allocate enough space for one nfs41_readdir_entry */
- - const uint32_t max_buf_len = max(args->buf_len,
- - sizeof(nfs41_readdir_entry) + NFS41_MAX_COMPONENT_LEN+1);
- + const uint32_t max_buf_len = max((uint32_t)args->buf_len,
- + (uint32_t)(sizeof(nfs41_readdir_entry) + NFS41_MAX_COMPONENT_LEN+1));
- DPRINTF(1, ("--> handle_nfs41_dirquery(filter='%s',initial=%d,restart=%d,single=%d)\n",
- args->filter, (int)args->initial, (int)args->restart, (int)args->single));
- --
- 2.51.0
- From 81b9155a79416443740be5c664535d66d4c1d1db Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 2 Oct 2025 18:00:44 +0200
- Subject: [PATCH 09/10] daemon: Fix uninitialised variable in
- |nfs41_open_stateid_arg()|
- Fix uninitialised variable in |nfs41_open_stateid_arg()|.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- daemon/nfs41_ops.h | 1 +
- daemon/open.c | 3 +++
- 2 files changed, 4 insertions(+)
- diff --git a/daemon/nfs41_ops.h b/daemon/nfs41_ops.h
- index b3b70fb..f1bf145 100644
- --- a/daemon/nfs41_ops.h
- +++ b/daemon/nfs41_ops.h
- @@ -305,6 +305,7 @@ typedef struct __nfs41_reclaim_complete_res {
- /* recoverable stateid argument */
- enum stateid_type {
- + STATEID_UNINITIALISED = 0,
- STATEID_OPEN,
- STATEID_LOCK,
- STATEID_DELEG_FILE,
- diff --git a/daemon/open.c b/daemon/open.c
- index d86b836..d93ec60 100644
- --- a/daemon/open.c
- +++ b/daemon/open.c
- @@ -165,6 +165,7 @@ void nfs41_open_stateid_arg(
- IN nfs41_open_state *state,
- OUT stateid_arg *arg)
- {
- + arg->type = STATEID_UNINITIALISED;
- arg->open = state;
- arg->delegation = NULL;
- @@ -202,6 +203,8 @@ void nfs41_open_stateid_arg(
- }
- out:
- ReleaseSRWLockShared(&state->lock);
- +
- + EASSERT(arg->type != STATEID_UNINITIALISED);
- }
- /* client list of associated open state */
- --
- 2.51.0
- From 4de73098e54abf4c8d85285aaf533c06e39ddc0b Mon Sep 17 00:00:00 2001
- From: Roland Mainz <roland.mainz@nrubsig.org>
- Date: Thu, 2 Oct 2025 18:56:06 +0200
- Subject: [PATCH 10/10] sys: Fix race conditions with
- |updowncall_entry.timeout_secs| usage
- Fix race conditions with |updowncall_entry.timeout_secs| usage.
- Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
- ---
- sys/nfs41sys_driver.h | 2 +-
- sys/nfs41sys_updowncall.c | 21 ++++++++++-----------
- 2 files changed, 11 insertions(+), 12 deletions(-)
- diff --git a/sys/nfs41sys_driver.h b/sys/nfs41sys_driver.h
- index 913288f..fa019f4 100644
- --- a/sys/nfs41sys_driver.h
- +++ b/sys/nfs41sys_driver.h
- @@ -169,7 +169,7 @@ typedef struct _updowncall_entry {
- LONGLONG xid;
- nfs41_opcodes opcode;
- NTSTATUS status;
- - volatile LONGLONG timeout_secs;
- + volatile LONG timeout_secs;
- nfs41_updowncall_state state;
- FAST_MUTEX lock;
- LIST_ENTRY next;
- diff --git a/sys/nfs41sys_updowncall.c b/sys/nfs41sys_updowncall.c
- index 08d9165..7afc19f 100644
- --- a/sys/nfs41sys_updowncall.c
- +++ b/sys/nfs41sys_updowncall.c
- @@ -468,6 +468,12 @@ NTSTATUS nfs41_UpcallWaitForReply(
- FsRtlEnterFileSystem();
- + /*
- + * |entry->timeout_secs| can be increased by |nfs41_delayxid()| from
- + * another userland thread!
- + */
- + entry->timeout_secs = (LONG)secs;
- +
- nfs41_AddEntry(upcalllist.lock, upcalllist, entry);
- (void)KeSetEvent(&upcallEvent, IO_NFS41FS_INCREMENT, FALSE);
- @@ -476,17 +482,12 @@ NTSTATUS nfs41_UpcallWaitForReply(
- const ULONG tickIncrement = KeQueryTimeIncrement();
- - /*
- - * |entry->timeout_secs| can be increased by |nfs41_delayxid()| from
- - * another userland thread!
- - */
- - entry->timeout_secs = secs;
- -
- LARGE_INTEGER startTicks, currTicks;
- KeQueryTickCount(&startTicks);
- LARGE_INTEGER timeout;
- - timeout.QuadPart = RELATIVE(SECONDS(entry->timeout_secs));
- + timeout.QuadPart =
- + RELATIVE(SECONDS(InterlockedAdd(&entry->timeout_secs, 0)));
- retry_wait:
- status = KeWaitForSingleObject(&entry->cond, Executive,
- @@ -512,7 +513,7 @@ retry_wait:
- */
- KeQueryTickCount(&currTicks);
- if (((currTicks.QuadPart - startTicks.QuadPart) * tickIncrement) <=
- - SECONDS(entry->timeout_secs)) {
- + SECONDS(InterlockedAdd(&entry->timeout_secs, 0))) {
- DbgP("nfs41_UpcallWaitForReply: KeWaitForSingleObject() "
- "returned status(=0x%lx), "
- "retry waiting for '%s' entry=0x%p xid=%lld\n",
- @@ -859,9 +860,7 @@ NTSTATUS nfs41_delayxid(
- DbgP("nfs41_delayxid: Adding moredelay=%llu xid=%lld entry\n",
- moredelay, delayxid);
- - ExAcquireFastMutexUnsafe(&cur->lock);
- - cur->timeout_secs += moredelay;
- - ExReleaseFastMutexUnsafe(&cur->lock);
- + (void)InterlockedAdd(&cur->timeout_secs, (LONG)moredelay);
- out:
- FsRtlExitFileSystem();
- --
- 2.51.0
msnfs41client: Patches for Win32 locking, clang warnings, tests+misc, 2025-10-02
Posted by Anonymous on Thu 2nd Oct 2025 18:08
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.