From patchwork Mon Sep 12 05:36:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 12973259 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 389D3ECAAA1 for ; Mon, 12 Sep 2022 05:36:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229510AbiILFge (ORCPT ); Mon, 12 Sep 2022 01:36:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiILFge (ORCPT ); Mon, 12 Sep 2022 01:36:34 -0400 Received: from mail-vk1-xa31.google.com (mail-vk1-xa31.google.com [IPv6:2607:f8b0:4864:20::a31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35D6F1AD84 for ; Sun, 11 Sep 2022 22:36:32 -0700 (PDT) Received: by mail-vk1-xa31.google.com with SMTP id g185so3654182vkb.13 for ; Sun, 11 Sep 2022 22:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date; bh=a4HITrssL9lZzOzrCQRucdis7ZBIvQg9YWyrnqcN5vQ=; b=hCjl4J0E5bHi6xZpeMSIw3rLqUTnOhwHIsxQIhHPFi/HCFUJYJnC33eu+bV0gSGilj d3E2cD4un3gFj78Fu1ggymQyjp/OgXAA/ygFXZx4q2w80pGLogaeymSWYH2xq7mlqTXd w+Gs41O2v3qtrN7eKQ6IFwgr6jpxali4ay/oBIhxnYoYkqdFm6LNOaQvZproCsnD5u2S AAhiK5qDu34FYsSlq4IzqZHM2+ICCi/S4FQqAWB7Hepd+YrYjwuIJ/a4njUqebnuXxIj AOeD65+CGniIXwB9+uwU5oFNdUBrK0SSxZ+xQ7X58aqEzxVEFGtJVL1T60hREN+tuvNq pFWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date; bh=a4HITrssL9lZzOzrCQRucdis7ZBIvQg9YWyrnqcN5vQ=; b=yL9UuBY3ybdwk0aIds0j1IWPY5fG1clIX3699qC9OpGlcQk/ACSyw3srohNI88LLrE /wyuzxjCOmZmcqyZ9sxSXgPkO02palaLYLf2xcjh4TS8KlElx3mJIxOSGojUbo2miFjW osC7882b+kgdp/GTBpgMZRagu1AAHjshLtw0J+pUcAtmLB38xSWP3WafGOy8mJs2wKiA 9f0sPB7IVm17UwhwL8ZxbnJZb+59SYYKNCx+yDDxuFTGK1EQh7qQOOIPiME/cf2egEXg uBSPIGBAleg/h6wtqtEiCUWCMW1tgdAbGyVz32IoAEdIn1AXvD7Bx7endzRpPgmYb80z jPBQ== X-Gm-Message-State: ACgBeo19PVueCYjvzC2d4KbW2awyu+sHdWroOvtG5vG72rC1StiFxBAP 5uyVucomljXsV94s5xhTKaCkXs1O71/2TMCQ5PFO2cZETPw= X-Google-Smtp-Source: AA6agR7/Jh1/FGcgHek5mUy5wZbYIUdspD8MZ2KULLT9rMElUd3UnSKyt54ebSYcOBBQjBp/SBYI625PDaAE5YNEmvE= X-Received: by 2002:a1f:918d:0:b0:3a1:e376:7463 with SMTP id t135-20020a1f918d000000b003a1e3767463mr4874860vkd.38.1662960991032; Sun, 11 Sep 2022 22:36:31 -0700 (PDT) MIME-Version: 1.0 From: Steve French Date: Mon, 12 Sep 2022 00:36:20 -0500 Message-ID: Subject: [PATCH][SMB3.1.1 client] fallback to query fs all info if posix query fs not supported To: CIFS , samba-technical Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org A version of Samba that I was testing, supported POSIX extensions, but not the query fs info level. Fall back to query fs all info if POSIX query fs info not supported. Also fixes the problem that compounding wasn't being used for posix qfs info in this path (statfs) but was being used in others, so improves performance of posix query fs info. From 2ef78530111e0ddb55b32585c9df4cfe666fb891 Mon Sep 17 00:00:00 2001 From: Steve French Date: Sun, 11 Sep 2022 19:49:04 -0500 Subject: [PATCH] smb311: fallback to query fs all info if posix query fs not supported A version of Samba, supported POSIX extensions, but not the query fs info level. Fall back to query fs all info if POSIX query fs info not supported. Also fixes the problem that compounding wasn't being used for posix qfs info in this path (statfs) but was being used in others, so improves performance of posix query fs info. Signed-off-by: Steve French --- fs/cifs/smb2ops.c | 44 ++++++++++++++++++++++++++------------------ fs/cifs/smb2pdu.c | 2 +- fs/cifs/smb2proto.h | 2 ++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 421be43af425..54002d1ef5c3 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -2557,31 +2557,39 @@ static int smb311_queryfs(const unsigned int xid, struct cifs_tcon *tcon, struct cifs_sb_info *cifs_sb, struct kstatfs *buf) { + struct smb2_query_info_rsp *rsp; + struct kvec rsp_iov = {NULL, 0}; + FILE_SYSTEM_POSIX_INFO *info = NULL; + int buftype = CIFS_NO_BUFFER; int rc; - __le16 srch_path = 0; /* Null - open root of share */ - u8 oplock = SMB2_OPLOCK_LEVEL_NONE; - struct cifs_open_parms oparms; - struct cifs_fid fid; if (!tcon->posix_extensions) return smb2_queryfs(xid, tcon, cifs_sb, buf); - oparms.tcon = tcon; - oparms.desired_access = FILE_READ_ATTRIBUTES; - oparms.disposition = FILE_OPEN; - oparms.create_options = cifs_create_options(cifs_sb, 0); - oparms.fid = &fid; - oparms.reconnect = false; - - rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL, - NULL, NULL); - if (rc) - return rc; + rc = smb2_query_info_compound(xid, tcon, "", + FILE_READ_ATTRIBUTES, + FS_POSIX_INFORMATION, + SMB2_O_INFO_FILESYSTEM, + sizeof(FILE_SYSTEM_POSIX_INFO), + &rsp_iov, &buftype, cifs_sb); + if (rc == -EIO) /* some posix servers didn't support this info level */ + return smb2_queryfs(xid, tcon, cifs_sb, buf); + else if (rc) + goto pqfs_exit; - rc = SMB311_posix_qfs_info(xid, tcon, fid.persistent_fid, - fid.volatile_fid, buf); + rsp = (struct smb2_query_info_rsp *)rsp_iov.iov_base; buf->f_type = SMB2_SUPER_MAGIC; - SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); + info = (FILE_SYSTEM_POSIX_INFO *)( + le16_to_cpu(rsp->OutputBufferOffset) + (char *)rsp); + rc = smb2_validate_iov(le16_to_cpu(rsp->OutputBufferOffset), + le32_to_cpu(rsp->OutputBufferLength), + &rsp_iov, + sizeof(FILE_SYSTEM_POSIX_INFO)); + if (!rc) + copy_posix_fs_info_to_kstatfs(info, buf); + +pqfs_exit: + free_rsp_buf(buftype, rsp_iov.iov_base); return rc; } diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 6352ab32c7e7..01f0cc1620bd 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c @@ -5251,7 +5251,7 @@ smb2_copy_fs_info_to_kstatfs(struct smb2_fs_full_size_info *pfs_inf, return; } -static void +void copy_posix_fs_info_to_kstatfs(FILE_SYSTEM_POSIX_INFO *response_data, struct kstatfs *kst) { diff --git a/fs/cifs/smb2proto.h b/fs/cifs/smb2proto.h index 3f740f24b96a..c96c6cad90a4 100644 --- a/fs/cifs/smb2proto.h +++ b/fs/cifs/smb2proto.h @@ -267,6 +267,8 @@ extern int smb2_validate_and_copy_iov(unsigned int offset, extern void smb2_copy_fs_info_to_kstatfs( struct smb2_fs_full_size_info *pfs_inf, struct kstatfs *kst); +extern void copy_posix_fs_info_to_kstatfs(FILE_SYSTEM_POSIX_INFO *response_data, + struct kstatfs *kst); extern int smb311_crypto_shash_allocate(struct TCP_Server_Info *server); extern int smb311_update_preauth_hash(struct cifs_ses *ses, struct TCP_Server_Info *server, -- 2.34.1