adding writethru mount option

for large writes it is beneficial to turnoff write buffering and allow
large write buffer sizes than 1M (for win 7).
This commit is contained in:
Olga Kornievskaia 2011-12-07 18:10:09 -05:00 committed by unknown
parent 37f3fa0862
commit aed1493e90

View file

@ -318,6 +318,7 @@ typedef struct _NFS41_MOUNT_CONFIG {
DWORD ReadSize; DWORD ReadSize;
DWORD WriteSize; DWORD WriteSize;
BOOLEAN ReadOnly; BOOLEAN ReadOnly;
BOOLEAN write_thru;
WCHAR srv_buffer[SERVER_NAME_BUFFER_SIZE]; WCHAR srv_buffer[SERVER_NAME_BUFFER_SIZE];
UNICODE_STRING SrvName; UNICODE_STRING SrvName;
WCHAR mntpt_buffer[MAX_PATH]; WCHAR mntpt_buffer[MAX_PATH];
@ -350,6 +351,7 @@ typedef struct _NFS41_V_NET_ROOT_EXTENSION {
LONG FsAttrsLen; LONG FsAttrsLen;
DWORD sec_flavor; DWORD sec_flavor;
BOOLEAN read_only; BOOLEAN read_only;
BOOLEAN write_thru;
#define STORE_MOUNT_SEC_CONTEXT #define STORE_MOUNT_SEC_CONTEXT
#ifdef STORE_MOUNT_SEC_CONTEXT #ifdef STORE_MOUNT_SEC_CONTEXT
SECURITY_CLIENT_CONTEXT mount_sec_ctx; SECURITY_CLIENT_CONTEXT mount_sec_ctx;
@ -2409,6 +2411,7 @@ void nfs41_MountConfig_InitDefaults(
Config->ReadSize = MOUNT_CONFIG_RW_SIZE_DEFAULT; Config->ReadSize = MOUNT_CONFIG_RW_SIZE_DEFAULT;
Config->WriteSize = MOUNT_CONFIG_RW_SIZE_DEFAULT; Config->WriteSize = MOUNT_CONFIG_RW_SIZE_DEFAULT;
Config->ReadOnly = FALSE; Config->ReadOnly = FALSE;
Config->write_thru = FALSE;
Config->SrvName.Length = 0; Config->SrvName.Length = 0;
Config->SrvName.MaximumLength = SERVER_NAME_BUFFER_SIZE; Config->SrvName.MaximumLength = SERVER_NAME_BUFFER_SIZE;
Config->SrvName.Buffer = Config->srv_buffer; Config->SrvName.Buffer = Config->srv_buffer;
@ -2500,6 +2503,11 @@ NTSTATUS nfs41_MountConfig_ParseOptions(
status = nfs41_MountConfig_ParseBoolean(Option, &usValue, status = nfs41_MountConfig_ParseBoolean(Option, &usValue,
&Config->ReadOnly); &Config->ReadOnly);
} }
else if (wcsncmp(L"writethru", Name, NameLen) == 0)
{
status = nfs41_MountConfig_ParseBoolean(Option, &usValue,
&Config->write_thru);
}
else if (wcsncmp(L"rsize", Name, NameLen) == 0) else if (wcsncmp(L"rsize", Name, NameLen) == 0)
{ {
status = nfs41_MountConfig_ParseDword(Option, &usValue, status = nfs41_MountConfig_ParseDword(Option, &usValue,
@ -2698,7 +2706,8 @@ NTSTATUS nfs41_CreateVNetRoot(
&Config); &Config);
if (status != STATUS_SUCCESS) if (status != STATUS_SUCCESS)
goto out; goto out;
pVNetRootContext->read_only = Config.ReadOnly; pVNetRootContext->read_only = Config.ReadOnly;
pVNetRootContext->write_thru = Config.write_thru;
} else { } else {
/* use the SRV_CALL name (without leading \) as the hostname */ /* use the SRV_CALL name (without leading \) as the hostname */
Config.SrvName.Buffer = pSrvCall->pSrvCallName->Buffer + 1; Config.SrvName.Buffer = pSrvCall->pSrvCallName->Buffer + 1;
@ -3335,7 +3344,8 @@ NTSTATUS nfs41_Create(
// the file was opened read-only. // the file was opened read-only.
if (/*(params.DesiredAccess & FILE_READ_DATA) && */ if (/*(params.DesiredAccess & FILE_READ_DATA) && */
(params.DesiredAccess & FILE_WRITE_DATA || (params.DesiredAccess & FILE_WRITE_DATA ||
params.DesiredAccess & FILE_APPEND_DATA)) params.DesiredAccess & FILE_APPEND_DATA) &&
!pVNetRootContext->write_thru)
SrvOpen->BufferingFlags |= SrvOpen->BufferingFlags |=
(FCB_STATE_WRITECACHING_ENABLED | FCB_STATE_WRITEBUFFERING_ENABLED); (FCB_STATE_WRITECACHING_ENABLED | FCB_STATE_WRITEBUFFERING_ENABLED);
#endif #endif
@ -5084,6 +5094,7 @@ NTSTATUS nfs41_Write (
LOWIO_READWRITEFLAG_PAGING_IO) && LOWIO_READWRITEFLAG_PAGING_IO) &&
(SrvOpen->DesiredAccess & FILE_WRITE_DATA) && (SrvOpen->DesiredAccess & FILE_WRITE_DATA) &&
(SrvOpen->DesiredAccess & FILE_READ_DATA) && (SrvOpen->DesiredAccess & FILE_READ_DATA) &&
!pVNetRootContext->write_thru &&
!(SrvOpen->BufferingFlags & !(SrvOpen->BufferingFlags &
(FCB_STATE_WRITEBUFFERING_ENABLED | FCB_STATE_WRITECACHING_ENABLED))) (FCB_STATE_WRITEBUFFERING_ENABLED | FCB_STATE_WRITECACHING_ENABLED)))
enable_caching(SrvOpen); enable_caching(SrvOpen);