From patchwork Mon Jul 21 17:35:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 4597721 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C3D8BC0514 for ; Mon, 21 Jul 2014 17:36:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E1E9920109 for ; Mon, 21 Jul 2014 17:36:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB19A200FE for ; Mon, 21 Jul 2014 17:36:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933379AbaGURgY (ORCPT ); Mon, 21 Jul 2014 13:36:24 -0400 Received: from mail-qg0-f51.google.com ([209.85.192.51]:56489 "EHLO mail-qg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932502AbaGURgU (ORCPT ); Mon, 21 Jul 2014 13:36:20 -0400 Received: by mail-qg0-f51.google.com with SMTP id a108so5775396qge.10 for ; Mon, 21 Jul 2014 10:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:from:date:message-id:subject:to:content-type; bh=5nvo6P1BMyppm/mX/YB9ULZ0/5xjm6oDSU9PeQuty2E=; b=A3Npn435PgFp3ZPziE41ouy+cZmg3JRbaWqv/Ose/i7Jx2TphrQkmLEnVUCZCHNyGx enwRp+pc891zoHs0hgUv8hTSZ4U/YTIsscMk3F92QkOfoLoDPfz2beo5pdm5JZpc12ro jMmfD/8UJ7tU07u7SXp65cpvbLvy9ugXVUskYKcZ+Pp5nNnez0G8sJzEGEQihXnqidLU hjKLWtAqiSb0yt38Gy01rn4O/sFZ84y987QKskW/7Z921PoH6mJ3zwLSU+OIl2Ukxuud mDVH15Gko0c0RRB9Joj/4lM4UFf0+xXxJhFwSpTxhh2wxAJ4+IcfKwawwxPO8G9sGWy9 dZDg== X-Received: by 10.224.120.68 with SMTP id c4mr45101316qar.17.1405964179528; Mon, 21 Jul 2014 10:36:19 -0700 (PDT) MIME-Version: 1.0 Received: by 10.140.101.107 with HTTP; Mon, 21 Jul 2014 10:35:59 -0700 (PDT) From: Steve French Date: Mon, 21 Jul 2014 12:35:59 -0500 Message-ID: Subject: [PATCH][SMB3] fallocate worker function To: "linux-cifs@vger.kernel.org" , samba-technical Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, T_TVD_MIME_EPI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From 08c80cdc50e0d327234288cb0f628fdf5e80bc8d Mon Sep 17 00:00:00 2001 From: Steve French Date: Sat, 19 Jul 2014 21:44:58 -0500 Subject: [PATCH] [CIFS] Add worker function to set allocation size Adds setinfo worker function for SMB2/SMB3 support of SET_ALLOCATION_INFORMATION Attached is one approach for adding the worker function to extend a file's allocation size over SMB2/SMB3 mounts. It is a very small change to add a parm to SMB2_set_eof and seems the easiest way. I have experimented with two ways of using this patch - via the fallocate VFS interface (in which we have to be careful and check that we are not going to shrink the file so that we follow the Linux semantics) and an cifs/smb3 specific ioctl. Before adding the second patch though, I am waiting for more information. I have asked for clarification from Microsoft and also from JRA on the behavior on the two server types (since I may have found a Samba server bug) when testing this. Signed-off-by: Steve French --- fs/cifs/smb2inode.c | 2 +- fs/cifs/smb2ops.c | 3 ++- fs/cifs/smb2pdu.c | 10 +++++++--- fs/cifs/smb2proto.h | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) FILE_BASIC_INFO *buf); From 08c80cdc50e0d327234288cb0f628fdf5e80bc8d Mon Sep 17 00:00:00 2001 From: Steve French Date: Sat, 19 Jul 2014 21:44:58 -0500 Subject: [PATCH] [CIFS] Add worker function to set allocation size Adds setinfo worker function for SMB2/SMB3 support of SET_ALLOCATION_INFORMATION Signed-off-by: Steve French --- fs/cifs/smb2inode.c | 2 +- fs/cifs/smb2ops.c | 3 ++- fs/cifs/smb2pdu.c | 10 +++++++--- fs/cifs/smb2proto.h | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/fs/cifs/smb2inode.c b/fs/cifs/smb2inode.c index 84c012a..0150182 100644 --- a/fs/cifs/smb2inode.c +++ b/fs/cifs/smb2inode.c @@ -91,7 +91,7 @@ smb2_open_op_close(const unsigned int xid, struct cifs_tcon *tcon, case SMB2_OP_SET_EOF: tmprc = SMB2_set_eof(xid, tcon, fid.persistent_fid, fid.volatile_fid, current->tgid, - (__le64 *)data); + (__le64 *)data, false); break; case SMB2_OP_SET_INFO: tmprc = SMB2_set_info(xid, tcon, fid.persistent_fid, diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 787844b..ae1bff3 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -19,6 +19,7 @@ #include #include +#include #include "cifsglob.h" #include "smb2pdu.h" #include "smb2proto.h" @@ -687,7 +688,7 @@ smb2_set_file_size(const unsigned int xid, struct cifs_tcon *tcon, { __le64 eof = cpu_to_le64(size); return SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid, - cfile->fid.volatile_fid, cfile->pid, &eof); + cfile->fid.volatile_fid, cfile->pid, &eof, false); } static int diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index b0b260d..49d14b6 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2325,7 +2325,7 @@ SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon, int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, - u64 volatile_fid, u32 pid, __le64 *eof) + u64 volatile_fid, u32 pid, __le64 *eof, bool is_falloc) { struct smb2_file_eof_info info; void *data; @@ -2336,8 +2336,12 @@ SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, data = &info; size = sizeof(struct smb2_file_eof_info); - return send_set_info(xid, tcon, persistent_fid, volatile_fid, pid, - FILE_END_OF_FILE_INFORMATION, 1, &data, &size); + if (is_falloc) + return send_set_info(xid, tcon, persistent_fid, volatile_fid, + pid, FILE_ALLOCATION_INFORMATION, 1, &data, &size); + else + return send_set_info(xid, tcon, persistent_fid, volatile_fid, + pid, FILE_END_OF_FILE_INFORMATION, 1, &data, &size); } int diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index 0ce48db..67e8ce8 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h @@ -139,7 +139,7 @@ extern int SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon, __le16 *target_file); extern int SMB2_set_eof(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, u32 pid, - __le64 *eof); + __le64 *eof, bool is_fallocate); extern int SMB2_set_info(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid, FILE_BASIC_INFO *buf); -- 1.9.3