readx and CAP_LARGE_READX

James Peach jpeach at samba.org
Thu Dec 7 17:26:47 GMT 2006


On Dec 6, 2006, at 8:08 PM, tridge at samba.org wrote:

> James,
>
> You asked me about smb_raw_read() and reads close to 64k with
> CAP_LARGE_READX on irc the other day.
>
> I've added a test to smbtorture RAW-READ that looks at this, and it
> seems that the behaviour you saw, even though its quite strange, is
> correct. Both w2k3 and Samba4 return zero bytes for readx beyond
> 0xFFFF for the SMB1 protocol. In SMB2 larger reads work.
>
> In Samba4 the code looks like this (in pvfs_read.c):
>
> 	if (maxcnt > UINT16_MAX && req->ctx->protocol < PROTOCOL_SMB2) {
> 		maxcnt = 0;
> 	}
>
> I know this seems strange as SMB1 could in fact handle reads of up to
> nearly 128k, but that's just how it is :-)

I haven't tested the windows or Samba4 behaviour in this regard, so  
I'll defer to your experiments here.

Samba3, on the other hand, implements the readX semantics describes in  
the SNIA spec. For a 64K read, we get the following:
	Read AndX Response:
		Word Count: 12
		...
		Data Length Low: 0
		Data Offset: 59
		Data Length High: 1
		Reserved: 0
		Data Byte Count: 0

Samba3 blindly stuffs the total read amount into the 16-bit Data Byte  
count field, so a read of 65537 bytes gives the following:
	Read AndX Response:
		Word Count: 12
		...
		Data Length Low: 1
		Data Offset: 59
		Data Length High: 1
		Reserved: 0
		Data Byte Count: 1

When the client libraries observe the Data Byte Count field in this  
case, they pass 1 byte of data up to the caller even though the server  
gave us a lot more data.

With the attached patch, I/O sizes of up to 127K work correctly  
against Samba3. This patch is not the best or most correct way to  
implement this in Samba4, but it works for this case :)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: libcli-support-large-readx
Type: application/octet-stream
Size: 3410 bytes
Desc: not available
Url : http://lists.samba.org/archive/samba-technical/attachments/20061207/f09e1527/libcli-support-large-readx.obj
-------------- next part --------------

> If you want cifsdd to work correctly with all servers then you'll need
> to break up the reads into chunks of less than 64k each.

The goal of cifsdd is to tie the I/O specification given on the  
command line as closely as possible to to what goes onto the wire. If  
the wire won't do >64K I/O sizes, then it is OK for cifsdd to fail.

--
James Peach | jpeach at samba.org



More information about the samba-technical mailing list