pastebin - collaborative debugging tool
rovema.kpaste.net RSS


msnfs41client: Patch to flush+purge fs cache data of dest file for FSCTL operations, 2025-12-04
Posted by Anonymous on Tue 9th Dec 2025 19:39
raw | new post

  1. From 7212716b0022f72710072b19d87d5ca7afd2afab Mon Sep 17 00:00:00 2001
  2. From: Roland Mainz <roland.mainz@nrubsig.org>
  3. Date: Thu, 4 Dec 2025 14:19:57 +0100
  4. Subject: [PATCH] sys:
  5.  |FSCTL_SET_ZERO_DATA|,|FSCTL_DUPLICATE_EXTENTS_TO_FILE|,|FSCTL_OFFLOAD_WRITE|
  6.  should purge cache data
  7.  
  8. |FSCTL_SET_ZERO_DATA|,|FSCTL_DUPLICATE_EXTENTS_TO_FILE|,|FSCTL_OFFLOAD_WRITE|
  9. should flush+purge filesystem cache data of the destination file, to
  10. make sure that a read after the FSCTL reads the data from
  11. the server.
  12.  
  13. Signed-off-by: Cedric Blancher <cedric.blancher@gmail.com>
  14. ---
  15. sys/nfs41sys_fsctl.c | 34 +++++++++++++++++-----------------
  16.  1 file changed, 17 insertions(+), 17 deletions(-)
  17.  
  18. diff --git a/sys/nfs41sys_fsctl.c b/sys/nfs41sys_fsctl.c
  19. index 686b139..d39544f 100644
  20. --- a/sys/nfs41sys_fsctl.c
  21. +++ b/sys/nfs41sys_fsctl.c
  22. @@ -500,12 +500,12 @@ NTSTATUS nfs41_SetZeroData(
  23.      /*
  24.       * NFSv4.2 DEALLOCATE is basically a "write" operation, but happens
  25.       * only on the NFS server side. We need to flush our NFS client
  26. -     * cache and wait for the kernel lazy writer before doing the
  27. -     * DEALLOCATE, to avoid that we have outstanding writes in the
  28. -     * kernel cache at the same location where the DEALLOCATE should
  29. -     * do it's work.
  30. +     * cache, wait for the kernel lazy writer and purge the cache map
  31. +     * before doing the DEALLOCATE, to avoid that we have outstanding
  32. +     * writes in the kernel cache at the same location where the
  33. +     * DEALLOCATE should do it's work.
  34.       */
  35. -    (void)RxFlushFcbInSystemCache((PFCB)RxContext->pFcb, TRUE);
  36. +    (void)RxPurgeFcbInSystemCache((PFCB)RxContext->pFcb, NULL, 0L, TRUE, TRUE);
  37.  
  38.      status = nfs41_UpcallCreate(NFS41_SYSOP_FSCTL_SET_ZERO_DATA,
  39.          &nfs41_fobx->sec_ctx,
  40. @@ -804,18 +804,18 @@ NTSTATUS nfs41_DuplicateData(
  41.      /*
  42.       * NFSv4.2 CLONE is basically a "write" operation, but happens
  43.       * only on the NFS server side. We need to flush our NFS client
  44. -     * cache (for both src and dest files!!) and wait in both cases
  45. -     * for the kernel lazy writer before doing the CLONE, to avoid
  46. -     * that we have outstanding writes in the kernel cache at the
  47. -     * same location where the CLONE should do it's work.
  48. +     * cache for the src file, flush+purge the dest file, and wait
  49. +     * in both cases for the kernel lazy writer before doing the CLONE,
  50. +     * to avoid that we have outstanding writes in the kernel cache at
  51. +     * the same location where the CLONE should do it's work.
  52.       */
  53.      DbgP("nfs41_DuplicateData: flushing src file '%wZ'\n",
  54.          srcfox->SrvOpen->pAlreadyPrefixedName);
  55.      (void)RxFlushFcbInSystemCache((PFCB)srcfcb, TRUE);
  56.  
  57. -    DbgP("nfs41_DuplicateData: flushing dest file '%wZ'\n",
  58. +    DbgP("nfs41_DuplicateData: flush+purge dest file '%wZ'\n",
  59.          RxContext->pRelevantSrvOpen->pAlreadyPrefixedName);
  60. -    (void)RxFlushFcbInSystemCache((PFCB)RxContext->pFcb, TRUE);
  61. +    (void)RxPurgeFcbInSystemCache((PFCB)RxContext->pFcb, NULL, 0L, TRUE, TRUE);
  62.  
  63.      status = nfs41_UpcallCreate(NFS41_SYSOP_FSCTL_DUPLICATE_DATA,
  64.          &nfs41_fobx->sec_ctx,
  65. @@ -1338,18 +1338,18 @@ NTSTATUS nfs41_OffloadWrite(
  66.      /*
  67.       * NFSv4.2 COPY is basically a "write" operation, but happens
  68.       * only on the NFS server side. We need to flush our NFS client
  69. -     * cache (for both src and dest files!!) and wait in both cases
  70. -     * for the kernel lazy writer before doing the COPY, to avoid
  71. -     * that we have outstanding writes in the kernel cache at the
  72. -     * same location where the COPY should do it's work.
  73. +     * cache for the src file, flush+purge the dest file, and wait
  74. +     * in both cases for the kernel lazy writer before doing the COPY,
  75. +     * to avoid that we have outstanding writes in the kernel cache at
  76. +     * the same location where the COPY should do it's work.
  77.       */
  78.      DbgP("nfs41_OffloadWrite: flushing src file '%wZ'\n",
  79.          src_oce->src_srvopen->pAlreadyPrefixedName);
  80.      (void)RxFlushFcbInSystemCache((PFCB)src_oce->src_srvopen->pFcb, TRUE);
  81.  
  82. -    DbgP("nfs41_OffloadWrite: flushing dest file '%wZ'\n",
  83. +    DbgP("nfs41_OffloadWrite: flush+purge dest file '%wZ'\n",
  84.          RxContext->pRelevantSrvOpen->pAlreadyPrefixedName);
  85. -    (void)RxFlushFcbInSystemCache((PFCB)RxContext->pFcb, TRUE);
  86. +    (void)RxPurgeFcbInSystemCache((PFCB)RxContext->pFcb, NULL, 0L, TRUE, TRUE);
  87.  
  88.      status = nfs41_UpcallCreate(NFS41_SYSOP_FSCTL_OFFLOAD_DATACOPY,
  89.          &nfs41_fobx->sec_ctx,
  90. --
  91. 2.51.0

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.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at