Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp2080772ybb; Fri, 29 Mar 2019 18:32:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqysBYSXIBmTlP7LFH/8YnEjrAxX25tY+85IrWDqvr0Td6kPt3ZZTDB4x9DyDC9RXbZTXbdI X-Received: by 2002:a63:330e:: with SMTP id z14mr1048959pgz.4.1553909548619; Fri, 29 Mar 2019 18:32:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553909548; cv=none; d=google.com; s=arc-20160816; b=IDeXNnQ5H4mRY5JLAFCreC6RAmC0HrtRqjLya0kkIe0IVA2X5kbLR++C9Iw09JZzbK q6lJLVTtPysLYZ/HKjyaczj/HF7qGpgkJHg+UqUjuMmY5TneNPjJeC7fmqN+i1GAqGKQ tFpMMTyoU3CpDWU5A3VTEah9Vaaz5HZh2NHHzI5Rj9dNPvSOHinKOGg8//iHCT4arP+x lbD+ILpi2MVzBNbVExM1ukQik7vq9pJsvwABquB8/eOH5wk0UY8DqEU7e4EWwOH/Mb8O u/asK5vJrPyGUSLcMd0Fa5jgtNTMIJX1ReCj5SZtYUlccbF8rwhBTEVztUmq8JJqvUhJ CubQ== 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=+LecoHRUmpg0EDKDhCeKn9dAwUBPX4io56AGHjtsmr0=; b=b0wEfNtMjlXOzCPWx8zby+4KkRLoWuBuNmx7P2ZHokDkesKoDYSgjwfT0Pch7fzjwC 67/Av1zK8b9umEKUV+oXVdt051xdhv/N6nJlILxzi+YxIhrZxCuR2W5PmLyQypXCVitL RPY3XibQGO19ruhA4795V/cCUAakePKaJzs5Ev6VbfoQACx9CClRnqLJAH1CBphnGeev fAfboyzje53xJVCPZIoWr7OFaQHQHOrs5Zj/GHqIA2X5cNvlH1cyPUmFPqh1dRiNgayw QZvuJndiJvPTWMn4wYqGnQewnFs8g1lUPqI0CT2nSC8voapnKvWKDSYbuxPyWNZDfmv0 16+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kcrlbwsL; 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 g26si2975600pfi.28.2019.03.29.18.32.13; Fri, 29 Mar 2019 18:32:28 -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=kcrlbwsL; 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 S1731813AbfC3Ba7 (ORCPT + 99 others); Fri, 29 Mar 2019 21:30:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:38262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731784AbfC3Ba5 (ORCPT ); Fri, 29 Mar 2019 21:30:57 -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 1C2D62184C; Sat, 30 Mar 2019 01:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553909456; bh=kh6x85vlARnyrHOWz1eLCy80ymVjJzn7TIMHAgPuY18=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kcrlbwsLpu/XwEH8MQWjH/tKen9veYuA4QC+TjaOm6JgQxV4joLwQ2X7DHFi0IozW 4ZbjfVyhl04ul0VGtVr93KwV3kVMZPauQGvy8E+peYWPfPnH6VIS3vJyL8U7TOPPgW tIwS8BF2PFRUHKJ+6Meoa8ITNqSk9hpA1jwQE0dU= 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.14 16/37] cifs: fallback to older infolevels on findfirst queryinfo retry Date: Fri, 29 Mar 2019 21:29:59 -0400 Message-Id: <20190330013020.379-16-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190330013020.379-1-sashal@kernel.org> References: <20190330013020.379-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 a90a637ae79a..6fd4a6a75234 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -779,43 +779,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