Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2079814ybb; Fri, 29 Mar 2019 18:31:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwJ1GOG5M3JsdMfBKHU3PT5WF5yKrIleSXvtFra9ox4Tpba8hlLFz3b+qowGddRPLdojyWv X-Received: by 2002:a63:1410:: with SMTP id u16mr47266412pgl.420.1553909462593; Fri, 29 Mar 2019 18:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553909462; cv=none; d=google.com; s=arc-20160816; b=DW5cbfIQp3BniqBg3+AWWI1UGCHEqRpU9mI/ZO7H48Jn3hXaeXc3whMIIXwyjvKrVK MncFmU034l1MwFsrkcHB/BqVgLWnmYDXlTgrjnAk0+Cy57MfiiVE4bEH5JiB46mPCuLw aiOjGbioB/SQpYMs3Arv2S4Zt/u1ujqSWh7Q2joRMoz7fCbiMSBZokQZl7RXQf4NxSXF eMrroIGzWb+7Jo8HLZPWdKZemOepvdW+ztID7IPwdO/vLR+f/dk7j/EQ1wLxwb9neNnf HpbK1G+CNwQmVeAGvJ2hnsbe8UyLcx2bAtLFnCVkO1g4lr0fCIcRfPHEH21Y9E00ig7u cyDA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jw21n4aPnTt/g68ZN0i6BfBC7SSxJrehSR0MPdLW3mA=; b=Lvl2LoJZGZyKpVB3YC/wR89ZZStCbl8EIsO7qjtOtVhBiNz7SEaugjD2auVeRL3LCs ywebrLqNrvXYyUWqTh5BoDvQFVXlKQ6J3ffJdnQLVV+YQ8m9vb1GOg4qwwTzGzTYXLOe 8ddaAB5hpJjGty/CAUNlBHok4zEqZ+i5Y6Rczic4bdF/uQvK2DT93EJ+7vDDNRP0UdDh T5gwzXn6nODpZ8smV93nGdhdreHLcp+gH0de9Xu6wLLMXbNUzLofi1qvzcWZUUGDqYtU H119x1cTfMF0IckB4yRAvp4N/aNcufdKscAmtndnQFjE+TlwykaJJNjguU8wIOg3yg20 5q6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nZrQ1FbT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j25si3183862pgb.531.2019.03.29.18.30.47; Fri, 29 Mar 2019 18:31:02 -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=nZrQ1FbT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731191AbfC3B3p (ORCPT + 99 others); Fri, 29 Mar 2019 21:29:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:36636 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731143AbfC3B3n (ORCPT ); Fri, 29 Mar 2019 21:29:43 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1537921773; Sat, 30 Mar 2019 01:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553909381; bh=Ld17Ts8EguEtdBANXvK4BSvgHUl7P5Q7ElyxdwpVK9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nZrQ1FbTE3v+wsX6Wy/A9MCZQPMhl8BJniTzVGW6ygsa+sQ+FaKTh1N0SRo5xuHbb miwrLVFzTj0G+qPyz71cS8t1q0kfyDRw+S3aRw550bvp1cYUN4ZCb7L5lYCCVw6fas SFwIcUbkETnofrYHyhWdDfAyJxtAo1CM/3oZWPhA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Steve French , Sasha Levin , linux-cifs@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 25/57] cifs: fallback to older infolevels on findfirst queryinfo retry Date: Fri, 29 Mar 2019 21:28:18 -0400 Message-Id: <20190330012854.32212-25-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190330012854.32212-1-sashal@kernel.org> References: <20190330012854.32212-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Steve French [ 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 020f49c15b30..b59ebed4f615 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -780,43 +780,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