Introduction
If you ever used the Windows 7 NFS Client you surely noticed that is notably slow compared to CIFS(SMB). This happens because Microsoft didn't implement read-ahead and write-behind capabilities in the NFS Client. Performing only one operation at the time means that the NFS Client/Server will be idle while waiting for the network traffic to complete resulting in the observable performance loss.

This program aims to fix this performance issue by acting like a proxy between the NFS Client and NFS Server and based on the NFS traffic analysis by taking the following actions:
  • Sending NFS Read requests to the NFS Server so by the time the NFS Client requests the data this is already buffered or requested from the NFS Server
  • Sending NFS Write responses to the NFS Client so the NFS Client sends more data to be written immediately without waiting for the real NFS Server write response

For more information about the inner workings check out the How It Works section.
Installation & Usage
  1. Download and install the application.
    • The executable setup contains binaries for both x86/x64 platforms - it will automatically install the ones suited for your Windows version
    • The NFSEx service will be started right away. It also has the Start Type set to Automatic so it will start when Windows boots
    • ** WARNING ! ** NFSEx needs to listen on port 111 so make sure that you don't have a portmap service running already
  2. Run NFSEx Control and enter your NFS Server IP Address (see the Configuration section below for more information)
  3. Mount NFS shares as follows:
    mount -o rsize=32 -o wsize=32 \\127.0.0.1\path\to\NFS\share x:
Configuration
The following NFSEx parameters can be changed using the NFSEx Control interface:
  • Enable/disable Read-ahead/Write-behind: if one or both features are disabled, NFSEx will act like a simple proxy without any intervention whatsoever
  • Read-ahead/Write-behind requests number: the maximum number of RA/WB requests active at any given time
  • NFS Server Address: IPV4 address of the NFS Server

The configuration is sent to the NFSEx service and it's stored in the registry so you only have to do it once.
How It Works
Read-ahead (RA) implementation:
Remarks:
  • When a NFS Client read request is received, NFSEx searches its internal data structures using the filehandle associated with the read request as key and we have two possibilities:
    1. If a data structure is not found (see Req 1), the request is sent to the NFS server and no additional RA requests are sent. This happens for two reasons:
      1. We don't know the size of the file to be read - so we don't know if or how many RA requests should be sent
      2. NFSEx uses a read response template in order to send file data to the NFS Client. In order to build this template a valid response from the NFS Server is needed. This template is refreshed every time a read response is received
    2. If a data structure is found, NFSEx does the following:
      1. Checks if the requested file data is buffered (already received as result of sent RA requests - see Req 4) and immediately sends the response if file data is available
      2. If the file data is not buffered, it checks if it's pending (RA requests were sent but the responses were not received - see Req 2,3). If the file data is pending there's nothing to do but wait for NFS Server responses
      3. If the file data is not buffered/pending then the data structure is reset, the responses for the already sent RA requests are marked for discarding (and added to the NFS Dropped statistics) and NFSEx handles the request like in the case a) described above
  • Data structures and internal buffers have a short expiration interval (800 ms). If no NFS Client requests are received during this interval, RA buffers are discarded (and added to the NFS Dropped statistics) in order to prevent file data caching
  • RA requests are not sent if the Client's requested file data size is less than the NFS Block Size - this has nothing to do with the protocol or with the NFS Client, it's just an optimization based on observation



Write-behind implementation:
Remarks:
  • Write-behind works just like read-ahead with two differences:
    1. Because the write response template is refreshed using the NFS Server write response after we have sent a "fake" write response to the NFS Client and there was a write error on the server, the error will be sent to the NFS Client as a subsequent write response. If for some reason the NFS Client stops sending write requests (without completely sending the file) the error response may be lost. However, this should be an extremely rare case
    2. For the last write request (the one which completes the sending of the file) NFSEx doesn't send a "fake" write response. Instead, the "real" NFS Server write response is awaited and then forwarded to the NFS Client untouched
Screenshots
NFSExCtrl interface

Write on the NFS share
Read from the NFS share


Write on the NFS share (NFSEx)
Read from the NFS share (NFSEx)

To do
  • Add UDP support
Copyright © 2012 sba9k