From: Jeremy Allison <jra@samba.org>
To: David Howells <dhowells@redhat.com>
Cc: smfrench@gmail.com, Shyam Prasad N <nspmangalore@gmail.com>,
jlayton@kernel.org, linux-cifs@vger.kernel.org
Subject: Re: Incorrect fallocate behaviour in cifs or samba?
Date: Thu, 13 Jan 2022 09:43:32 -0800 [thread overview]
Message-ID: <YeBkxLnh8+sUv968@jeremy-acer> (raw)
In-Reply-To: <1856457.1642087232@warthog.procyon.org.uk>
On Thu, Jan 13, 2022 at 03:20:32PM +0000, David Howells wrote:
>David Howells <dhowells@redhat.com> 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?
This is from fsctl_zero_data() in Samba. We have:
/*
* MS-FSCC <58> Section 2.3.67
* This FSCTL sets the range of bytes to zero (0) without extending the
* file size.
*
* The VFS_FALLOCATE_FL_KEEP_SIZE flag is used to satisfy this
* constraint.
*/
mode = VFS_FALLOCATE_FL_PUNCH_HOLE | VFS_FALLOCATE_FL_KEEP_SIZE;
ret = SMB_VFS_FALLOCATE(fsp, mode, zdata_info.file_off, len);
if (ret == -1) {
status = map_nt_error_from_unix_common(errno);
DEBUG(2, ("zero-data fallocate(0x%x) failed: %s\n", mode,
strerror(errno)));
return status;
}
if (!fsp->fsp_flags.is_sparse && lp_strict_allocate(SNUM(fsp->conn))) {
/*
* File marked non-sparse and "strict allocate" is enabled -
* allocate the range that we just punched out.
* In future FALLOC_FL_ZERO_RANGE could be used exclusively for
* this, but it's currently only supported on XFS and ext4.
*
* The newly allocated range still won't be found by SEEK_DATA
* for QAR, but stat.st_blocks will reflect it.
*/
ret = SMB_VFS_FALLOCATE(fsp, VFS_FALLOCATE_FL_KEEP_SIZE,
zdata_info.file_off, len);
Note the "currently only supported on XFS and ext4" problem
with FALLOC_FL_ZERO_RANGE.
next prev parent reply other threads:[~2022-01-13 17:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-13 13:18 cifs fallocate doesn't flush writes? David Howells
2022-01-13 15:20 ` Incorrect fallocate behaviour in cifs or samba? David Howells
2022-01-13 17:43 ` Jeremy Allison [this message]
2022-01-13 18:16 ` David Disseldorp
2022-01-13 18:22 ` Jeremy Allison
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YeBkxLnh8+sUv968@jeremy-acer \
--to=jra@samba.org \
--cc=dhowells@redhat.com \
--cc=jlayton@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=nspmangalore@gmail.com \
--cc=smfrench@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.