From patchwork Tue Jun 23 06:31:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 6658981 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id EF7B89F399 for ; Tue, 23 Jun 2015 06:31:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 16BB620584 for ; Tue, 23 Jun 2015 06:31:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0F6482057F for ; Tue, 23 Jun 2015 06:31:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753530AbbFWGbx (ORCPT ); Tue, 23 Jun 2015 02:31:53 -0400 Received: from mail-lb0-f173.google.com ([209.85.217.173]:36748 "EHLO mail-lb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752120AbbFWGbn (ORCPT ); Tue, 23 Jun 2015 02:31:43 -0400 Received: by lbbpo10 with SMTP id po10so246840lbb.3 for ; Mon, 22 Jun 2015 23:31:41 -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=htNWRlKBDcJDq7Y0Q9wiKyvQMwA0eewZ0k11JTidpLY=; b=eLfvvbOdC8vFiB5ujNIJFp/6OvTAYc744f4pEWLqZLSWw5CnmusDAi9C2+HBPI0ChV /SddFrtTZG+7Er480DI4XO5reujwxJVR+2NNtZblw366A7MjG5k3Q0YZ90Cu45h9Bj4n iIb3ojLzDQM4QiA2RLlCeROSibmuRr36mblmLgckBrEDe9EyoGPzyhAGHICzqeYugs/h +2lXgFCMSkFNPW7hHtg+s3DP1nrzICj+f48yHYkfJG9rpq3IOB+UFPRsyAjSrf08dVsM buc7XOOHMuqSX8xD6Uu4UZP86iOBLg1DhIjLwkrzW3KZfo/7EUGZFwpqhszNsRpLMEyy okuQ== X-Received: by 10.112.52.2 with SMTP id p2mr33570176lbo.8.1435041101325; Mon, 22 Jun 2015 23:31:41 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.51.164 with HTTP; Mon, 22 Jun 2015 23:31:21 -0700 (PDT) From: Steve French Date: Tue, 23 Jun 2015 01:31:21 -0500 Message-ID: Subject: CIFS QPathInfo fallback to buggy servers To: Gregor Beck , "linux-cifs@vger.kernel.org" Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Spam-Status: No, score=-8.2 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 In cleaning out old email found some older patches of yours that implemented a fall back on QueryPathInfo to older QueryInfo levels for mounts to NetApp CIFS servers. I cleaned up (correcting some things Jeff Layton had pointed out on the mailing list) and combined patches 2 through 4 of your series which is attached but untested since I don't have a NetApp filer. I did merge the first one of the series (which was harmless) but was holding off on the remaining till they were cleaned up and tested. If you still have access to test these, I can consider them. From c32e6f2ee387ccf4a7db34128662a870e413edad Mon Sep 17 00:00:00 2001 From: Steve French Date: Tue, 23 Jun 2015 01:25:12 -0500 Subject: [PATCH] [CIFS] add functions for cifs query info to fall back to Some servers such as NetApp didn't support the normal info levels Signed-off-by: Gregor Beck --- fs/cifs/cifsproto.h | 6 ++++ fs/cifs/cifssmb.c | 87 ++++++++++++++++++++++++++++++++++++----------------- 2 files changed, 66 insertions(+), 27 deletions(-) diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index c63fd1d..5372046 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -249,6 +249,12 @@ extern int CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon, const char *search_Name, FILE_ALL_INFO *data, int legacy /* whether to use old info level */, const struct nls_table *nls_codepage, int remap); +extern int CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon, + const char *search_name, FILE_BASIC_INFO *data, + const struct nls_table *nls_codepage, int remap); +extern int CIFSSMBQPathInfoStandard(const unsigned int xid, struct cifs_tcon *tcon, + const char *search_name, FILE_STANDARD_INFO *data, + const struct nls_table *nls_codepage, int remap); extern int SMBQueryInformation(const unsigned int xid, struct cifs_tcon *tcon, const char *search_name, FILE_ALL_INFO *data, const struct nls_table *nls_codepage, int remap); diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 672ef35..f87e85f 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -4089,13 +4089,13 @@ QFileInfoRetry: return rc; } -int -CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon, - const char *search_name, FILE_ALL_INFO *data, - int legacy /* old style infolevel */, - const struct nls_table *nls_codepage, int remap) +static int +CIFSSMBQPathInfoImpl(const unsigned int xid, struct cifs_tcon *tcon, + const char *search_name, + void *data, int size, + __u16 level, __u16 bcc, + const struct nls_table *nls_codepage, int remap) { - /* level 263 SMB_QUERY_FILE_ALL_INFO */ TRANSACTION2_QPI_REQ *pSMB = NULL; TRANSACTION2_QPI_RSP *pSMBr = NULL; int rc = 0; @@ -4103,7 +4103,7 @@ CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon, int name_len; __u16 params, byte_count; - /* cifs_dbg(FYI, "In QPathInfo path %s\n", search_name); */ + cifs_dbg(FYI, "In QPathInfo level %u path %s", level, search_name); QPathInfoRetry: rc = smb_init(SMB_COM_TRANSACTION2, 15, tcon, (void **) &pSMB, (void **) &pSMBr); @@ -4142,10 +4142,7 @@ QPathInfoRetry: byte_count = params + 1 /* pad */ ; pSMB->TotalParameterCount = cpu_to_le16(params); pSMB->ParameterCount = pSMB->TotalParameterCount; - if (legacy) - pSMB->InformationLevel = cpu_to_le16(SMB_INFO_STANDARD); - else - pSMB->InformationLevel = cpu_to_le16(SMB_QUERY_FILE_ALL_INFO); + pSMB->InformationLevel = cpu_to_le16(level); pSMB->Reserved4 = 0; inc_rfc1001_len(pSMB, byte_count); pSMB->ByteCount = cpu_to_le16(byte_count); @@ -4159,25 +4156,10 @@ QPathInfoRetry: if (rc) /* BB add auto retry on EOPNOTSUPP? */ rc = -EIO; - else if (!legacy && get_bcc(&pSMBr->hdr) < 40) + else if (get_bcc(&pSMBr->hdr) < bcc) rc = -EIO; /* bad smb */ - else if (legacy && get_bcc(&pSMBr->hdr) < 24) - rc = -EIO; /* 24 or 26 expected but we do not read - last field */ else if (data) { - int size; __u16 data_offset = le16_to_cpu(pSMBr->t2.DataOffset); - - /* - * On legacy responses we do not read the last field, - * EAsize, fortunately since it varies by subdialect and - * also note it differs on Set vs Get, ie two bytes or 4 - * bytes depending but we don't care here. - */ - if (legacy) - size = sizeof(FILE_INFO_STANDARD); - else - size = sizeof(FILE_ALL_INFO); memcpy((char *) data, (char *) &pSMBr->hdr.Protocol + data_offset, size); } else @@ -4191,6 +4173,57 @@ QPathInfoRetry: } int +CIFSSMBQPathInfo(const unsigned int xid, struct cifs_tcon *tcon, + const char *search_name, FILE_ALL_INFO *data, + int legacy /* old style infolevel */, + const struct nls_table *nls_codepage, int remap) +{ + if (legacy) { + /* + * 24 or 26 expected but on legacy responses we do not read the + * last field, EAsize, fortunately since it varies by subdialect + * and also note it differs on Set vs. Get, ie two bytes or 4 + * bytes depending but we don't care here + */ + return CIFSSMBQPathInfoImpl(xid, tcon, search_name, + data, sizeof(FILE_INFO_STANDARD), + SMB_INFO_STANDARD, + sizeof(FILE_INFO_STANDARD), + nls_codepage, remap); + } else { + return CIFSSMBQPathInfoImpl(xid, tcon, search_name, + data, sizeof(FILE_ALL_INFO), + SMB_QUERY_FILE_ALL_INFO, + sizeof(FILE_ALL_INFO), + nls_codepage, remap); + } +} + +int +CIFSSMBQPathInfoBasic(const unsigned int xid, struct cifs_tcon *tcon, + const char *search_name, FILE_BASIC_INFO *data, + const struct nls_table *nls_codepage, int remap) +{ + return CIFSSMBQPathInfoImpl(xid, tcon, search_name, + data, sizeof(FILE_BASIC_INFO), + SMB_QUERY_FILE_BASIC_INFO, + sizeof(FILE_BASIC_INFO), + nls_codepage, remap); +} + +int +CIFSSMBQPathInfoStandard(const unsigned int xid, struct cifs_tcon *tcon, + const char *search_name, FILE_STANDARD_INFO *data, + const struct nls_table *nls_codepage, int remap) +{ + return CIFSSMBQPathInfoImpl(xid, tcon, search_name, + data, sizeof(FILE_STANDARD_INFO), + SMB_QUERY_FILE_STANDARD_INFO, + sizeof(FILE_STANDARD_INFO), + nls_codepage, remap); +} + +int CIFSSMBUnixQFileInfo(const unsigned int xid, struct cifs_tcon *tcon, u16 netfid, FILE_UNIX_BASIC_INFO *pFindData) { -- 1.9.1