question about allocation roundup size and smb_roundup()
jra at samba.org
Tue Mar 6 22:25:27 UTC 2018
On Tue, Mar 06, 2018 at 01:47:12PM +0800, ssdl.566 via samba-technical wrote:
> Hi all:
> I noticed in sources/smbd/open.c, after file was created, vfs_allocate_file_space()
> function was called to allocate space for new file. The size passed to
> vfs_allocate_file_space() is returned by smb_roundup(conn, allocation_size).
> When the file copied is small, .e.g 25KB ， the size returned by smb_roundup ()
>is still 1048576 (same as allocation roundup size), i want to know why?
Allocation size is returned to the client, and (at least in SMB1)
used to affect the read sizes used by the client, in that it uses
larger (more efficient) IO sizes for larget files. So we lie :-).
> if the file is smaller than 1048576, why cannot
> call vfs_allocate_file_space () funtion to just allocate the real file size instead of 1048576?
You could, but disk is cheap and small files tend not to
stay small, so doing a larger initial allocation isn't
such a bad strategy.
More information about the samba-technical