From patchwork Wed Oct 9 20:58:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 3011661 Return-Path: X-Original-To: patchwork-cifs-client@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1E9099F245 for ; Wed, 9 Oct 2013 20:58:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 129C520160 for ; Wed, 9 Oct 2013 20:58:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D072020138 for ; Wed, 9 Oct 2013 20:58:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754228Ab3JIU6m (ORCPT ); Wed, 9 Oct 2013 16:58:42 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:37406 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752550Ab3JIU6l (ORCPT ); Wed, 9 Oct 2013 16:58:41 -0400 Received: by mail-pb0-f45.google.com with SMTP id mc17so1494438pbc.32 for ; Wed, 09 Oct 2013 13:58:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=O0ZPwHu8ZbgnIbBZIf+sTWl53FOinpx4RE8TOOhZmLc=; b=JEVtawm2fV1vxzjY1RyvwlDw9QSvIXZv2mQru2MDBST+RH9gmlYrffnx/IeYjjD6Jp i4imLseLVWYLlHEtOKtDAKmMN4umruHKR0rx2kJiYBh691QBXbdMe5cOn5a9jvjzqmpY xX0tyT34Py0s39cQZF5CGYRRMLFsLc4AhyfXAqgLJMzH4zmno2gN09MSXM9B+fgZnYKU X+OxEqRz7fGIn8VJzYxQdk6VYjmavYPRYrEZzFU/xbUSkiN2Qxv1A/qTEmdO7O7fJaeW TeCU+igPZQj5EtlFv8Y4V+EXL8820cUSq5SjUV+DQbG7fyLBWJzd5vLVTK7vEkVqhO8C TTAg== MIME-Version: 1.0 X-Received: by 10.67.4.227 with SMTP id ch3mr11913782pad.74.1381352319729; Wed, 09 Oct 2013 13:58:39 -0700 (PDT) Received: by 10.68.125.106 with HTTP; Wed, 9 Oct 2013 13:58:39 -0700 (PDT) Date: Wed, 9 Oct 2013 15:58:39 -0500 Message-ID: Subject: [PATCHv2] [CIFS] Query device characteristics at mount time from server on SMB2/3 not just on cifs mounts From: Steve French To: "linux-cifs@vger.kernel.org" , linux-fsdevel , 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=-7.0 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 Currently SMB2 and SMB3 mounts do not query the device information at mount time from the server at mount time as is done for cifs. These can be useful for debugging. This is a minor patch, that extends the previous one (which added ability to query file system attributes at mount time - this returns the device characteristics - also via in /proc/fs/cifs/DebugData) In second version of patch, I also correct the fs information levels we were using (we were calling the "passthrough" levels which work, but are 0x100 higher than the documented levels for SMB2). Signed-off-by: Steve French --- fs/cifs/smb2ops.c | 5 ++++- fs/cifs/smb2pdu.c | 31 +++++++++++++++++++++++-------- fs/cifs/smb2proto.h | 2 +- 3 files changed, 28 insertions(+), 10 deletions(-) const __u32 pid, const __u64 length, const __u64 offset, diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index a53e205..71a3460 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -229,7 +229,10 @@ smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon) if (rc) return; - SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid); + SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, + FS_ATTRIBUTE_INFORMATION); + SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, + FS_DEVICE_INFORMATION); SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); return; } diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 2ade58b..c822d9a 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -2347,17 +2347,27 @@ qfsinf_exit: int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, - u64 persistent_fid, u64 volatile_fid) + u64 persistent_fid, u64 volatile_fid, int level) { struct smb2_query_info_rsp *rsp = NULL; struct kvec iov; int rc = 0; - int resp_buftype; + int resp_buftype, max_len, min_len; struct cifs_ses *ses = tcon->ses; unsigned int rsp_len, offset; - rc = build_qfs_info_req(&iov, tcon, SMB_QUERY_FS_ATTRIBUTE_INFO, - sizeof(FILE_SYSTEM_ATTRIBUTE_INFO), + if (level == FS_DEVICE_INFORMATION) { + max_len = sizeof(FILE_SYSTEM_DEVICE_INFO); + min_len = sizeof(FILE_SYSTEM_DEVICE_INFO); + } else if (level == FS_ATTRIBUTE_INFORMATION) { + max_len = sizeof(FILE_SYSTEM_ATTRIBUTE_INFO); + min_len = MIN_FS_ATTR_INFO_SIZE; + } else { + cifs_dbg(FYI, "Invalid qfsinfo level %d", level); + return -EINVAL; + } + + rc = build_qfs_info_req(&iov, tcon, level, max_len, persistent_fid, volatile_fid); if (rc) return rc; @@ -2371,12 +2381,17 @@ SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, rsp_len = le32_to_cpu(rsp->OutputBufferLength); offset = le16_to_cpu(rsp->OutputBufferOffset); - rc = validate_buf(offset, rsp_len, &rsp->hdr, MIN_FS_ATTR_INFO_SIZE); - if (!rc) { + rc = validate_buf(offset, rsp_len, &rsp->hdr, min_len); + if (rc) + goto qfsattr_exit; + + if (level == FS_ATTRIBUTE_INFORMATION) memcpy(&tcon->fsAttrInfo, 4 /* RFC1001 len */ + offset + (char *)&rsp->hdr, min_t(unsigned int, - rsp_len, sizeof(FILE_SYSTEM_ATTRIBUTE_INFO))); - } + rsp_len, max_len)); + else if (level == FS_DEVICE_INFORMATION) + memcpy(&tcon->fsDevInfo, 4 /* RFC1001 len */ + offset + + (char *)&rsp->hdr, sizeof(FILE_SYSTEM_DEVICE_INFO)); qfsattr_exit: free_rsp_buf(resp_buftype, iov.iov_base); diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index 68dc00d..313813e 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h @@ -151,7 +151,7 @@ extern int SMB2_QFS_info(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_file_id, u64 volatile_file_id, struct kstatfs *FSData); extern int SMB2_QFS_attr(const unsigned int xid, struct cifs_tcon *tcon, - u64 persistent_file_id, u64 volatile_file_id); + u64 persistent_file_id, u64 volatile_file_id, int lvl); extern int SMB2_lock(const unsigned int xid, struct cifs_tcon *tcon, const __u64 persist_fid, const __u64 volatile_fid,