Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp884448yba; Thu, 18 Apr 2019 11:10:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQWa/pveOiI+EGGbEQXa6zI0l7YMumzs+6KMefsmNGKZY0XE/zsq0MZsvbyB1adVNQXSTM X-Received: by 2002:a63:d1f:: with SMTP id c31mr88517796pgl.353.1555611037051; Thu, 18 Apr 2019 11:10:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555611037; cv=none; d=google.com; s=arc-20160816; b=ZQcmik8W9oI9U1AlYNWi6KjnipaSnSSA0Bfq5TKCs450EI+NcKXVyng9Fxa4Pp3ytW 3JAxghLG377qyEUuFnjScWLrRQgIJygY70OsEOt/Gp3upv/Taz0hBX0f7/0tZt+4zW8M Me2rhuEjPOLvITpFHFhx2EW4fuk22c2Q+LDaW2rrM4PZKj5HB1gwiMCXNZ9CcIkdJPV3 vrlrBuTibwSxRGK8O3StpRD4VlFhD2CRRFSeu6UPKiH+pTjvW7l9ChynNnQoMLOsfBwo nQKgX5lEyc4yKjPqhQP3K03IQSNMlBoMlXSxgG9K/+UAynQbaxPf6HqyKbY2g0BX/4Dp l8MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=d6cy5UKwvO0MclOjZiXneCSAc0kJpLsFqtUjOjZZ6Uo=; b=BdytxJscpWI3p1d2m0PrzwKOJS8sY2AGHVTyJKxmcI+CAtv3eSQzz1bLvhzBAfY11X UMIdgpsNItlOoT+n/f3NFa8Q2lP5G/9ivLDwmxu/rmkJqoAHVPzFNsXFlETuhnwLV1Mh a+LLPpHRAkg8uf4wIteyxxirZNvVH1o+dnTPlMo64ckqACD0zuJPRsVj6E4PnJ9uXL4h 9VS703ZyvmHJPmBqvFq/P9S7LwdCeryeEaLywq93DNtdOVGxJgsXRmOWF8vFBIOW8VMQ 99fcI6Jj3K6qc7CvgqA62YuxSQHHPJdtm2e+LwxH5+XIDVfmdrAozPx9WSnl/TQfVqXo Fjpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O3RK0oaL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c12si2370486pgq.390.2019.04.18.11.10.21; Thu, 18 Apr 2019 11:10:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O3RK0oaL; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403860AbfDRSIb (ORCPT + 99 others); Thu, 18 Apr 2019 14:08:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:39652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403841AbfDRSI2 (ORCPT ); Thu, 18 Apr 2019 14:08:28 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CB63C206B6; Thu, 18 Apr 2019 18:08:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555610907; bh=DxaSwiWBw6cqwOKC7yVdKNrtbvbZFmt0ga84WftdQfs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O3RK0oaLjpVzRhDrmm5DfMpR3JEQeXxaMP4+qub8aq/Bd0yFGBmpjEkRiinCvNIHC gRMS7ZH9aTFEilr0NBQld7SxOsDOBA9wssj4DhLu+XRBW2wgvpKGSPBILpTW1WZj8b Mz6jOvTi9NmmFXNLhpHsMjplvkO9iNl8+MrTYCIU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steve French , Sasha Levin Subject: [PATCH 4.9 37/50] cifs: fallback to older infolevels on findfirst queryinfo retry Date: Thu, 18 Apr 2019 19:57:48 +0200 Message-Id: <20190418160427.095307117@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418160422.455656724@linuxfoundation.org> References: <20190418160422.455656724@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 3b7960caceafdfc2cdfe2850487f8d091eb41144 ] In cases where queryinfo fails, we have cases in cifs (vers=1.0) where with backupuid mounts we retry the query info with findfirst. This doesn't work to some NetApp servers which don't support WindowsXP (and later) infolevel 261 (SMB_FIND_FILE_ID_FULL_DIR_INFO) so in this case use other info levels (in this case it will usually be level 257, SMB_FIND_FILE_DIRECTORY_INFO). (Also fixes some indentation) See kernel bugzilla 201435 Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/inode.c | 67 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 57c938ffeb6e..a8a2fc9ae056 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -771,43 +771,50 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, } else if ((rc == -EACCES) && backup_cred(cifs_sb) && (strcmp(server->vals->version_string, SMB1_VERSION_STRING) == 0)) { - /* - * For SMB2 and later the backup intent flag is already - * sent if needed on open and there is no path based - * FindFirst operation to use to retry with - */ + /* + * For SMB2 and later the backup intent flag is already + * sent if needed on open and there is no path based + * FindFirst operation to use to retry with + */ - srchinf = kzalloc(sizeof(struct cifs_search_info), - GFP_KERNEL); - if (srchinf == NULL) { - rc = -ENOMEM; - goto cgii_exit; - } + srchinf = kzalloc(sizeof(struct cifs_search_info), + GFP_KERNEL); + if (srchinf == NULL) { + rc = -ENOMEM; + goto cgii_exit; + } - srchinf->endOfSearch = false; + srchinf->endOfSearch = false; + if (tcon->unix_ext) + srchinf->info_level = SMB_FIND_FILE_UNIX; + else if ((tcon->ses->capabilities & + tcon->ses->server->vals->cap_nt_find) == 0) + srchinf->info_level = SMB_FIND_FILE_INFO_STANDARD; + else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) srchinf->info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO; + else /* no srvino useful for fallback to some netapp */ + srchinf->info_level = SMB_FIND_FILE_DIRECTORY_INFO; - srchflgs = CIFS_SEARCH_CLOSE_ALWAYS | - CIFS_SEARCH_CLOSE_AT_END | - CIFS_SEARCH_BACKUP_SEARCH; + srchflgs = CIFS_SEARCH_CLOSE_ALWAYS | + CIFS_SEARCH_CLOSE_AT_END | + CIFS_SEARCH_BACKUP_SEARCH; - rc = CIFSFindFirst(xid, tcon, full_path, - cifs_sb, NULL, srchflgs, srchinf, false); - if (!rc) { - data = - (FILE_ALL_INFO *)srchinf->srch_entries_start; + rc = CIFSFindFirst(xid, tcon, full_path, + cifs_sb, NULL, srchflgs, srchinf, false); + if (!rc) { + data = (FILE_ALL_INFO *)srchinf->srch_entries_start; - cifs_dir_info_to_fattr(&fattr, - (FILE_DIRECTORY_INFO *)data, cifs_sb); - fattr.cf_uniqueid = le64_to_cpu( - ((SEARCH_ID_FULL_DIR_INFO *)data)->UniqueId); - validinum = true; + cifs_dir_info_to_fattr(&fattr, + (FILE_DIRECTORY_INFO *)data, cifs_sb); + fattr.cf_uniqueid = le64_to_cpu( + ((SEARCH_ID_FULL_DIR_INFO *)data)->UniqueId); + validinum = true; - cifs_buf_release(srchinf->ntwrk_buf_start); - } - kfree(srchinf); - if (rc) - goto cgii_exit; + cifs_buf_release(srchinf->ntwrk_buf_start); + } + kfree(srchinf); + if (rc) + goto cgii_exit; } else goto cgii_exit; -- 2.19.1