1. 05 6月, 2020 1 次提交
  2. 04 6月, 2020 1 次提交
  3. 01 6月, 2020 2 次提交
    • J
      cifs: Standardize logging output · a0a3036b
      Joe Perches 提交于
      Use pr_fmt to standardize all logging for fs/cifs.
      
      Some logging output had no CIFS: specific prefix.
      
      Now all output has one of three prefixes:
      
      o CIFS:
      o CIFS: VFS:
      o Root-CIFS:
      
      Miscellanea:
      
      o Convert printks to pr_<level>
      o Neaten macro definitions
      o Remove embedded CIFS: prefixes from formats
      o Convert "illegal" to "invalid"
      o Coalesce formats
      o Add missing '\n' format terminations
      o Consolidate multiple cifs_dbg continuations into single calls
      o More consistent use of upper case first word output logging
      o Multiline statement argument alignment and wrapping
      Signed-off-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      a0a3036b
    • S
      smb3: Add new parm "nodelete" · 82e9367c
      Steve French 提交于
      In order to handle workloads where it is important to make sure that
      a buggy app did not delete content on the drive, the new mount option
      "nodelete" allows standard permission checks on the server to work,
      but prevents on the client any attempts to unlink a file or delete
      a directory on that mount point.  This can be helpful when running
      a little understood app on a network mount that contains important
      content that should not be deleted.
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      CC: Stable <stable@vger.kernel.org>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      82e9367c
  4. 06 5月, 2020 1 次提交
  5. 16 4月, 2020 1 次提交
    • J
      cifs: improve read performance for page size 64KB & cache=strict & vers=2.1+ · 1f641d94
      Jones Syue 提交于
      Found a read performance issue when linux kernel page size is 64KB.
      If linux kernel page size is 64KB and mount options cache=strict &
      vers=2.1+, it does not support cifs_readpages(). Instead, it is using
      cifs_readpage() and cifs_read() with maximum read IO size 16KB, which is
      much slower than read IO size 1MB when negotiated SMB 2.1+. Since modern
      SMB server supported SMB 2.1+ and Max Read Size can reach more than 64KB
      (for example 1MB ~ 8MB), this patch check max_read instead of maxBuf to
      determine whether server support readpages() and improve read performance
      for page size 64KB & cache=strict & vers=2.1+, and for SMB1 it is more
      cleaner to initialize server->max_read to server->maxBuf.
      
      The client is a linux box with linux kernel 4.2.8,
      page size 64KB (CONFIG_ARM64_64K_PAGES=y),
      cpu arm 1.7GHz, and use mount.cifs as smb client.
      The server is another linux box with linux kernel 4.2.8,
      share a file '10G.img' with size 10GB,
      and use samba-4.7.12 as smb server.
      
      The client mount a share from the server with different
      cache options: cache=strict and cache=none,
      mount -tcifs //<server_ip>/Public /cache_strict -overs=3.0,cache=strict,username=<xxx>,password=<yyy>
      mount -tcifs //<server_ip>/Public /cache_none -overs=3.0,cache=none,username=<xxx>,password=<yyy>
      
      The client download a 10GbE file from the server across 1GbE network,
      dd if=/cache_strict/10G.img of=/dev/null bs=1M count=10240
      dd if=/cache_none/10G.img of=/dev/null bs=1M count=10240
      
      Found that cache=strict (without patch) is slower read throughput and
      smaller read IO size than cache=none.
      cache=strict (without patch): read throughput 40MB/s, read IO size is 16KB
      cache=strict (with patch): read throughput 113MB/s, read IO size is 1MB
      cache=none: read throughput 109MB/s, read IO size is 1MB
      
      Looks like if page size is 64KB,
      cifs_set_ops() would use cifs_addr_ops_smallbuf instead of cifs_addr_ops,
      
      	/* check if server can support readpages */
      	if (cifs_sb_master_tcon(cifs_sb)->ses->server->maxBuf <
      			PAGE_SIZE + MAX_CIFS_HDR_SIZE)
      		inode->i_data.a_ops = &cifs_addr_ops_smallbuf;
      	else
      		inode->i_data.a_ops = &cifs_addr_ops;
      
      maxBuf is came from 2 places, SMB2_negotiate() and CIFSSMBNegotiate(),
      (SMB2_MAX_BUFFER_SIZE is 64KB)
      SMB2_negotiate():
      	/* set it to the maximum buffer size value we can send with 1 credit */
      	server->maxBuf = min_t(unsigned int, le32_to_cpu(rsp->MaxTransactSize),
      			       SMB2_MAX_BUFFER_SIZE);
      CIFSSMBNegotiate():
      	server->maxBuf = le32_to_cpu(pSMBr->MaxBufferSize);
      
      Page size 64KB and cache=strict lead to read_pages() use cifs_readpage()
      instead of cifs_readpages(), and then cifs_read() using maximum read IO
      size 16KB, which is much slower than maximum read IO size 1MB.
      (CIFSMaxBufSize is 16KB by default)
      
      	/* FIXME: set up handlers for larger reads and/or convert to async */
      	rsize = min_t(unsigned int, cifs_sb->rsize, CIFSMaxBufSize);
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: NJones Syue <jonessyue@qnap.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      1f641d94
  6. 11 4月, 2020 1 次提交
    • S
      smb3: enable swap on SMB3 mounts · 4e8aea30
      Steve French 提交于
      Add experimental support for allowing a swap file to be on an SMB3
      mount.  There are use cases where swapping over a secure network
      filesystem is preferable. In some cases there are no local
      block devices large enough, and network block devices can be
      hard to setup and secure.  And in some cases there are no
      local block devices at all (e.g. with the recent addition of
      remote boot over SMB3 mounts).
      
      There are various enhancements that can be added later e.g.:
      - doing a mandatory byte range lock over the swapfile (until
      the Linux VFS is modified to notify the file system that an open
      is for a swapfile, when the file can be opened "DENY_ALL" to prevent
      others from opening it).
      - pinning more buffers in the underlying transport to minimize memory
      allocations in the TCP stack under the fs
      - documenting how to create ACLs (on the server) to secure the
      swapfile (or adding additional tools to cifs-utils to make it easier)
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Acked-by: NPavel Shilovsky <pshilov@microsoft.com>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      4e8aea30
  7. 23 3月, 2020 3 次提交
  8. 18 3月, 2020 1 次提交
  9. 25 2月, 2020 3 次提交
    • J
      cifs: Use #define in cifs_dbg · fb4b5f13
      Joe Perches 提交于
      All other uses of cifs_dbg use defines so change this one.
      Signed-off-by: NJoe Perches <joe@perches.com>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      fb4b5f13
    • A
      cifs: fix rename() by ensuring source handle opened with DELETE bit · 86f740f2
      Aurelien Aptel 提交于
      To rename a file in SMB2 we open it with the DELETE access and do a
      special SetInfo on it. If the handle is missing the DELETE bit the
      server will fail the SetInfo with STATUS_ACCESS_DENIED.
      
      We currently try to reuse any existing opened handle we have with
      cifs_get_writable_path(). That function looks for handles with WRITE
      access but doesn't check for DELETE, making rename() fail if it finds
      a handle to reuse. Simple reproducer below.
      
      To select handles with the DELETE bit, this patch adds a flag argument
      to cifs_get_writable_path() and find_writable_file() and the existing
      'bool fsuid_only' argument is converted to a flag.
      
      The cifsFileInfo struct only stores the UNIX open mode but not the
      original SMB access flags. Since the DELETE bit is not mapped in that
      mode, this patch stores the access mask in cifs_fid on file open,
      which is accessible from cifsFileInfo.
      
      Simple reproducer:
      
      	#include <stdio.h>
      	#include <stdlib.h>
      	#include <sys/types.h>
      	#include <sys/stat.h>
      	#include <fcntl.h>
      	#include <unistd.h>
      	#define E(s) perror(s), exit(1)
      
      	int main(int argc, char *argv[])
      	{
      		int fd, ret;
      		if (argc != 3) {
      			fprintf(stderr, "Usage: %s A B\n"
      			"create&open A in write mode, "
      			"rename A to B, close A\n", argv[0]);
      			return 0;
      		}
      
      		fd = openat(AT_FDCWD, argv[1], O_WRONLY|O_CREAT|O_SYNC, 0666);
      		if (fd == -1) E("openat()");
      
      		ret = rename(argv[1], argv[2]);
      		if (ret) E("rename()");
      
      		ret = close(fd);
      		if (ret) E("close()");
      
      		return ret;
      	}
      
      $ gcc -o bugrename bugrename.c
      $ ./bugrename /mnt/a /mnt/b
      rename(): Permission denied
      
      Fixes: 8de9e86c ("cifs: create a helper to find a writeable handle by path name")
      CC: Stable <stable@vger.kernel.org>
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      Reviewed-by: NPaulo Alcantara (SUSE) <pc@cjr.nz>
      86f740f2
    • R
      cifs: don't leak -EAGAIN for stat() during reconnect · fc513fac
      Ronnie Sahlberg 提交于
      If from cifs_revalidate_dentry_attr() the SMB2/QUERY_INFO call fails with an
      error, such as STATUS_SESSION_EXPIRED, causing the session to be reconnected
      it is possible we will leak -EAGAIN back to the application even for
      system calls such as stat() where this is not a valid error.
      
      Fix this by re-trying the operation from within cifs_revalidate_dentry_attr()
      if cifs_get_inode_info*() returns -EAGAIN.
      
      This fixes stat() and possibly also other system calls that uses
      cifs_revalidate_dentry*().
      Signed-off-by: NRonnie Sahlberg <lsahlber@redhat.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NPavel Shilovsky <pshilov@microsoft.com>
      Reviewed-by: NAurelien Aptel <aaptel@suse.com>
      CC: Stable <stable@vger.kernel.org>
      fc513fac
  10. 13 2月, 2020 1 次提交
  11. 04 2月, 2020 1 次提交
  12. 27 1月, 2020 1 次提交
  13. 09 12月, 2019 1 次提交
    • D
      fs: cifs: Delete usage of timespec64_trunc · 918c9009
      Deepa Dinamani 提交于
      timestamp_truncate() is the replacement api for
      timespec64_trunc. timestamp_truncate() additionally clamps
      timestamps to make sure the timestamps lie within the
      permitted range for the filesystem.
      
      Truncate the timestamps in the struct cifs_attr at the
      site of assignment to inode times. This
      helps us use the right fs api timestamp_trucate() to
      perform the truncation.
      
      Also update the ktime_get_* api to match the one used in
      current_time(). This allows for timestamps to be updated
      the same way always.
      Signed-off-by: NDeepa Dinamani <deepa.kernel@gmail.com>
      Cc: stfrench@microsoft.com
      Cc: linux-cifs@vger.kernel.org
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      918c9009
  14. 03 12月, 2019 1 次提交
  15. 28 11月, 2019 1 次提交
  16. 25 11月, 2019 1 次提交
    • A
      CIFS: refactor cifs_get_inode_info() · b8f7442b
      Aurelien Aptel 提交于
      Make logic of cifs_get_inode() much clearer by moving code to sub
      functions and adding comments.
      
      Document the steps this function does.
      
      cifs_get_inode_info() gets and updates a file inode metadata from its
      file path.
      
      * If caller already has raw info data from server they can pass it.
      * If inode already exists (just need to update) caller can pass it.
      
      Step 1: get raw data from server if none was passed
      Step 2: parse raw data into intermediate internal cifs_fattr struct
      Step 3: set fattr uniqueid which is later used for inode number. This
              can sometime be done from raw data
      Step 4: tweak fattr according to mount options (file_mode, acl to mode
              bits, uid, gid, etc)
      Step 5: update or create inode from final fattr struct
      
      * add is_smb1_server() helper
      * add is_inode_cache_good() helper
      * move SMB1-backupcreds-getinfo-retry to separate func
        cifs_backup_query_path_info().
      * move set-uniqueid code to separate func cifs_set_fattr_ino()
      * don't clobber uniqueid from backup cred retry
      * fix some probable corner cases memleaks
      Signed-off-by: NAurelien Aptel <aaptel@suse.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      b8f7442b
  17. 21 10月, 2019 1 次提交
  18. 09 10月, 2019 1 次提交
    • P
      CIFS: Force revalidate inode when dentry is stale · c82e5ac7
      Pavel Shilovsky 提交于
      Currently the client indicates that a dentry is stale when inode
      numbers or type types between a local inode and a remote file
      don't match. If this is the case attributes is not being copied
      from remote to local, so, it is already known that the local copy
      has stale metadata. That's why the inode needs to be marked for
      revalidation in order to tell the VFS to lookup the dentry again
      before openning a file. This prevents unexpected stale errors
      to be returned to the user space when openning a file.
      
      Cc: <stable@vger.kernel.org>
      Signed-off-by: NPavel Shilovsky <pshilov@microsoft.com>
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      c82e5ac7
  19. 26 9月, 2019 1 次提交
  20. 17 9月, 2019 2 次提交
  21. 19 7月, 2019 1 次提交
  22. 08 7月, 2019 2 次提交
  23. 08 5月, 2019 1 次提交
  24. 25 4月, 2019 1 次提交
  25. 05 3月, 2019 1 次提交
    • S
      smb3: make default i/o size for smb3 mounts larger · e8506d25
      Steve French 提交于
      We negotiate rsize mounts (and it can be overridden by user) to
      typically 4MB, so using larger default I/O sizes from userspace
      (changing to 1MB default i/o size returned by stat) the
      performance is much better (and not just for long latency
      network connections) in most use cases for SMB3 than the default I/O
      size (which ends up being 128K for cp and can be even smaller for cp).
      This can be 4x slower or worse depending on network latency.
      
      By changing inode->blocksize from 32K (which was perhaps ok
      for very old SMB1/CIFS) to a larger value, 1MB (but still less than
      max size negotiated with the server which is 4MB, in order to minimize
      risk) it significantly increases performance for the
      noncached case, and slightly increases it for the cached case.
      This can be changed by the user on mount (specifying bsize=
      values from 16K to 16MB) to tune better for performance
      for applications that depend on blocksize.
      Signed-off-by: NSteve French <stfrench@microsoft.com>
      Reviewed-by: NRonnie Sahlberg <lsahlber@redhat.com>
      CC: Stable <stable@vger.kernel.org>
      e8506d25
  26. 11 1月, 2019 1 次提交
  27. 24 12月, 2018 2 次提交
  28. 03 11月, 2018 1 次提交
  29. 24 10月, 2018 3 次提交
  30. 03 9月, 2018 1 次提交