[PATCH][SMB3] Cleanup sparse file support by creating worker function for it
David Disseldorp
ddiss at suse.de
Fri Aug 15 03:51:52 MDT 2014
On Thu, 14 Aug 2014 16:44:15 -0500, Steve French wrote:
> Simply move code to new function (for clarity). The new function
> sets or clears the sparse file attribute flag.
>
> Signed-off-by: Steve French <smfrench at gmail.com>
> ---
> fs/cifs/smb2ops.c | 82 ++++++++++++++++++++++++++++++++++---------------------
> 1 file changed, 51 insertions(+), 31 deletions(-)
>
> diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
> index 7463436..04a86cc 100644
> --- a/fs/cifs/smb2ops.c
> +++ b/fs/cifs/smb2ops.c
> @@ -731,6 +731,54 @@ smb2_sync_write(const unsigned int xid, struct
> cifsFileInfo *cfile,
> return SMB2_write(xid, parms, written, iov, nr_segs);
> }
>
> +/* Set or clear the SPARSE_FILE attribute based on value passed in setsparse */
> +static bool smb2_set_sparse(const unsigned int xid, struct cifs_tcon *tcon,
> + struct cifsFileInfo *cfile, struct inode *inode, __u8 setsparse)
> +{
> + struct cifsInodeInfo *cifsi;
> + int rc;
> +
> + cifsi = CIFS_I(inode);
> +
> + /* if file already sparse don't bother setting sparse again */
> + if ((cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && setsparse)
> + return true; /* already sparse */
> +
> + if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE) && !setsparse)
> + return true; /* already not sparse */
> +
> +
Drop one of the empty lines above. Looks good otherwise.
Reviewed-by: David Disseldorp <ddiss at samba.org>
Cheers, David
More information about the samba-technical
mailing list