Incorrect fallocate behaviour in cifs or samba?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David Howells <dhowells@xxxxxxxxxx> wrote:

> If I do the following:
> 
> 	mount //carina/test /xfstest.test -o user=shares,pass=foobar,noperm,vers=3.0,mfsymlinks,actimeo=0
> 	/usr/sbin/xfs_io -f -t \
> 		-c "pwrite -S 0x41 0 4096"
> 		-c "pwrite -S 0x42 4096 4096"
> 		-c "fzero 0 4096" \
> 		-c "pread 0 8192" \
> 		/xfstest.test/008.7067
> ...
>    31 0.321638749  192.168.6.2 -> 192.168.6.1  SMB2 206 Ioctl Request FSCTL_SET_ZERO_DATA File: 008.7067

So what I see is that Samba does:

	fallocate(24, FALLOC_FL_KEEP_SIZE|FALLOC_FL_PUNCH_HOLE, 0, 4096) = 0

for this... but that's not what cifs was asked to do.  Should Samba be using
FALLOC_FL_ZERO_RANGE instead?

Also cifs wasn't given FALLOC_FL_KEEP_SIZE, so the caller expected the file to
be extended - smb3_zero_range(), however, doesn't seem necessarily to get this
right.  It seems to allow for KEEP_SIZE not being set by calling
SMB2_set_eof() - but only if the range ends beyond the *local* i_size (which
the server doesn't know about yet).

However, we did two pwrites first, which moved the local i_size over.  This
means the server's EOF isn't extended - probably correctly, since we haven't
saved the data, but the subsequent reads then fail.

In this case, I wonder if the right thing to do is one of the following
options:

 (1) Flush the pagecache before doing proceeding with the fallocate.

 (2) Modify the local pagecache and don't talk to the server at all unless
     there are gaps in the pagecache.

 (3) Keep separate track of where we think the server's EOF is and skip any
     read that's beyond that.

 (4) Treat a read ending in EOF as a read of blank data if it's below the
     local EOF.  I guess that's what we do now.

David





[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux