18 Sep, 2021

1 commit


14 Sep, 2021

1 commit

  • checkpatch complains about source files with filenames (e.g. in
    these cases just below the SPDX header in comments at the top of
    various files in fs/cifs). It also is helpful to change this now
    so will be less confusing when the parent directory is renamed
    e.g. from fs/cifs to fs/smb_client (or fs/smbfs)

    Reviewed-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Steve French
     

26 Aug, 2021

1 commit

  • So far, the fscache implementation we had supports only
    a small set of use cases. Particularly for files opened
    with O_RDONLY.

    This commit enables it even for rw based file opens. It
    also enables the reuse of cached data in case of mount
    option (cache=singleclient) where it is guaranteed that
    this is the only client (and server) which operates on
    the files. There's also a single line change in fscache.c
    to get around a bug seen in fscache.

    Signed-off-by: Shyam Prasad N
    Acked-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Shyam Prasad N
     

13 Aug, 2021

1 commit

  • When rename is executed on directory which has files for which
    close is deferred, then rename will fail with EACCES.

    This patch will try to close all deferred files when EACCES is received
    and retry rename on a directory.

    Signed-off-by: Rohith Surabattula
    Cc: stable@vger.kernel.org # 5.13
    Reviewed-by: Shyam Prasad N
    Signed-off-by: Steve French

    Rohith Surabattula
     

21 Jun, 2021

2 commits


06 May, 2021

1 commit

  • Pull cifs updates from Steve French:
    "Ten CIFS/SMB3 changes - including two marked for stable - including
    some important multichannel fixes, as well as support for handle
    leases (deferred close) and shutdown support:

    - some important multichannel fixes

    - support for handle leases (deferred close)

    - shutdown support (which is also helpful since it enables multiple
    xfstests)

    - enable negotiating stronger encryption by default (GCM256)

    - improve wireshark debugging by allowing more options for root to
    dump decryption keys

    SambaXP and the SMB3 Plugfest test event are going on now so I am
    expecting more patches over the next few days due to extra testing
    (including more multichannel fixes)"

    * tag '5.13-rc-smb3-part2' of git://git.samba.org/sfrench/cifs-2.6:
    fs/cifs: Fix resource leak
    Cifs: Fix kernel oops caused by deferred close for files.
    cifs: fix regression when mounting shares with prefix paths
    cifs: use echo_interval even when connection not ready.
    cifs: detect dead connections only when echoes are enabled.
    smb3.1.1: allow dumping keys for multiuser mounts
    smb3.1.1: allow dumping GCM256 keys to improve debugging of encrypted shares
    cifs: add shutdown support
    cifs: Deferred close for files
    smb3.1.1: enable negotiating stronger encryption by default

    Linus Torvalds
     

05 May, 2021

1 commit


04 May, 2021

2 commits

  • Various filesystem support the shutdown ioctl which is used by various
    xfstests. The shutdown ioctl sets a flag on the superblock which
    prevents open, unlink, symlink, hardlink, rmdir, create etc.
    on the file system until unmount and remounted. The two flags supported
    in this patch are:

    FSOP_GOING_FLAGS_LOGFLUSH and FSOP_GOING_FLAGS_NOLOGFLUSH

    which require very little other than blocking new operations (since
    we do not cache writes to metadata on the client with cifs.ko).
    FSOP_GOING_FLAGS_DEFAULT is not supported yet, but could be added in
    the future but would need to call syncfs or equivalent to write out
    pending data on the mount.

    With this patch various xfstests now work including tests 043 through
    046 for example.

    Signed-off-by: Steve French
    Reviewed-by: Aurelien Aptel

    Steve French
     
  • When file is closed, SMB2 close request is not sent to server
    immediately and is deferred for acregmax defined interval. When file is
    reopened by same process for read or write, the file handle
    is reused if an oplock is held.

    When client receives a oplock/lease break, file is closed immediately
    if reference count is zero, else oplock is downgraded.

    Signed-off-by: Rohith Surabattula
    Reviewed-by: Shyam Prasad N
    Signed-off-by: Steve French

    Rohith Surabattula
     

28 Apr, 2021

1 commit

  • Pull vfs inode type handling updates from Al Viro:
    "We should never change the type bits of ->i_mode or the method tables
    (->i_op and ->i_fop) of a live inode.

    Unfortunately, not all filesystems took care to prevent that"

    * 'work.inode-type-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    spufs: fix bogosity in S_ISGID handling
    9p: missing chunk of "fs/9p: Don't update file type when updating file attributes"
    openpromfs: don't do unlock_new_inode() until the new inode is set up
    hostfs_mknod(): don't bother with init_special_inode()
    cifs: have cifs_fattr_to_inode() refuse to change type on live inode
    cifs: have ->mkdir() handle race with another client sanely
    do_cifs_create(): don't set ->i_mode of something we had not created
    gfs2: be careful with inode refresh
    ocfs2_inode_lock_update(): make sure we don't change the type bits of i_mode
    orangefs_inode_is_stale(): i_mode type bits do *not* form a bitmap...
    vboxsf: don't allow to change the inode type
    afs: Fix updating of i_mode due to 3rd party change
    ceph: don't allow type or device number to change on non-I_NEW inodes
    ceph: fix up error handling with snapdirs
    new helper: inode_wrong_type()

    Linus Torvalds
     

26 Apr, 2021

6 commits

  • Improves directory metadata caching

    Signed-off-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Ronnie Sahlberg
     
  • Needed for the final patch in the directory caching series

    Signed-off-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Ronnie Sahlberg
     
  • build_path_from_dentry() open-codes dentry_path_raw(). The reason
    we can't use dentry_path_raw() in there (and postprocess the
    result as needed) is that the callers of build_path_from_dentry()
    expect that the object to be freed on cleanup and the string to
    be used are at the same address. That's painful, since the path
    is naturally built end-to-beginning - we start at the leaf and
    go through the ancestors, accumulating the pathname.

    Life would be easier if we left the buffer allocation to callers.
    It wouldn't be exact-sized buffer, but none of the callers keep
    the result for long - it's always freed before the caller returns.
    So there's no need to do exact-sized allocation; better use
    __getname()/__putname(), same as we do for pathname arguments
    of syscalls. What's more, there's no need to do allocation under
    spinlocks, so GFP_ATOMIC is not needed.

    Next patch will replace the open-coded dentry_path_raw() (in
    build_path_from_dentry_optional_prefix()) with calling the real
    thing. This patch only introduces wrappers for allocating/freeing
    the buffers and switches to new calling conventions:
    build_path_from_dentry(dentry, buf)
    expects buf to be address of a page-sized object or NULL,
    return value is a pathname built inside that buffer on success,
    ERR_PTR(-ENOMEM) if buf is NULL and ERR_PTR(-ENAMETOOLONG) if
    the pathname won't fit into page. Note that we don't need to
    check for failure when allocating the buffer in the caller -
    build_path_from_dentry() will do the right thing.

    Signed-off-by: Al Viro
    Signed-off-by: Steve French

    Al Viro
     
  • ... and adjust the callers.

    Signed-off-by: Al Viro
    Signed-off-by: Steve French

    Al Viro
     
  • Signed-off-by: Al Viro
    Signed-off-by: Steve French

    Al Viro
     
  • While reviewing a patch clarifying locks and locking hierarchy I
    realized some locks were unused.

    This commit removes old data and code that isn't actually used
    anywhere, or hidden in ifdefs which cannot be enabled from the kernel
    config.

    * The uid/gid trees and associated locks are left-overs from when
    uid/sid mapping had an extra caching layer on top of the keyring and
    are now unused.
    See commit faa65f07d21e ("cifs: simplify id_to_sid and sid_to_id mapping code")
    from 2012.

    * cifs_oplock_break_ops is a left-over from when slow_work was remplaced
    by regular workqueue and is now unused.
    See commit 9b646972467f ("cifs: use workqueue instead of slow-work")
    from 2010.

    * CIFSSMBSetAttrLegacy is SMB1 cruft dealing with some legacy
    NT4/Win9x behaviour.

    * Remove CONFIG_CIFS_DNOTIFY_EXPERIMENTAL left-overs. This was already
    partially removed in 392e1c5dc9cc ("cifs: rename and clarify CIFS_ASYNC_OP and CIFS_NO_RESP")
    from 2019. Kill it completely.

    * Another candidate that was considered but spared is
    CONFIG_CIFS_NFSD_EXPORT which has an empty implementation and cannot
    be enabled by a config option (although it is listed but disabled with
    "BROKEN" as a dep). It's unclear whether this could even function
    today in its current form but it has it's own .c file and Kconfig
    entry which is a bit more involved to remove and might make a come
    back?

    Signed-off-by: Aurelien Aptel
    Signed-off-by: Steve French

    Aurelien Aptel
     

20 Mar, 2021

1 commit

  • Applications that create and extend and write to a file do not
    expect to see 0 allocation size. When file is extended,
    set its allocation size to a plausible value until we have a
    chance to query the server for it. When the file is cached
    this will prevent showing an impossible number of allocated
    blocks (like 0). This fixes e.g. xfstests 614 which does

    1) create a file and set its size to 64K
    2) mmap write 64K to the file
    3) stat -c %b for the file (to query the number of allocated blocks)

    It was failing because we returned 0 blocks. Even though we would
    return the correct cached file size, we returned an impossible
    allocation size.

    Signed-off-by: Steve French
    CC:
    Reviewed-by: Aurelien Aptel

    Steve French
     

13 Mar, 2021

2 commits


08 Mar, 2021

1 commit

  • inode_wrong_type(inode, mode) returns true if setting inode->i_mode
    to given value would've changed the inode type. We have enough of
    those checks open-coded to make a helper worthwhile.

    Signed-off-by: Al Viro

    Al Viro
     

27 Feb, 2021

1 commit

  • Pull cifs updates from Steve French:

    - improvements to mode bit conversion, chmod and chown when using
    cifsacl mount option

    - two new mount options for controlling attribute caching

    - improvements to crediting and reconnect, improved debugging

    - reconnect fix

    - add SMB3.1.1 dialect to default dialects for vers=3

    * tag '5.12-smb3-part1' of git://git.samba.org/sfrench/cifs-2.6: (27 commits)
    cifs: update internal version number
    cifs: use discard iterator to discard unneeded network data more efficiently
    cifs: introduce helper for finding referral server to improve DFS target resolution
    cifs: check all path components in resolved dfs target
    cifs: fix DFS failover
    cifs: fix nodfs mount option
    cifs: fix handling of escaped ',' in the password mount argument
    cifs: Add new parameter "acregmax" for distinct file and directory metadata timeout
    cifs: convert revalidate of directories to using directory metadata cache timeout
    cifs: Add new mount parameter "acdirmax" to allow caching directory metadata
    cifs: If a corrupted DACL is returned by the server, bail out.
    cifs: minor simplification to smb2_is_network_name_deleted
    TCON Reconnect during STATUS_NETWORK_NAME_DELETED
    cifs: cleanup a few le16 vs. le32 uses in cifsacl.c
    cifs: Change SIDs in ACEs while transferring file ownership.
    cifs: Retain old ACEs when converting between mode bits and ACL.
    cifs: Fix cifsacl ACE mask for group and others.
    cifs: clarify hostname vs ip address in /proc/fs/cifs/DebugData
    cifs: change confusing field serverName (to ip_addr)
    cifs: Fix inconsistent IS_ERR and PTR_ERR
    ...

    Linus Torvalds
     

26 Feb, 2021

2 commits

  • The new optional mount parameter "acregmax" allows a different
    timeout for file metadata ("acdirmax" now allows controlling timeout
    for directory metadata). Setting "actimeo" still works as before,
    and changes timeout for both files and directories, but
    specifying "acregmax" or "acdirmax" allows overriding the
    default more granularly which can be a big performance benefit
    on some workloads. "acregmax" is already used by NFS as a mount
    parameter (albeit with a larger default and thus looser caching).

    Suggested-by: Tom Talpey
    Reviewed-By: Tom Talpey
    Reviewed-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Steve French
     
  • The new optional mount parm, "acdirmax" allows caching the metadata
    for a directory longer than file metadata, which can be very helpful
    for performance. Convert cifs_inode_needs_reval to check acdirmax
    for revalidating directory metadata.

    Signed-off-by: Steve French
    Reviewed-by: Ronnie Sahlberg
    Reviewed-By: Tom Talpey
    Signed-off-by: Steve French

    Steve French
     

24 Jan, 2021

3 commits

  • Extend some inode methods with an additional user namespace argument. A
    filesystem that is aware of idmapped mounts will receive the user
    namespace the mount has been marked with. This can be used for
    additional permission checking and also to enable filesystems to
    translate between uids and gids if they need to. We have implemented all
    relevant helpers in earlier patches.

    As requested we simply extend the exisiting inode method instead of
    introducing new ones. This is a little more code churn but it's mostly
    mechanical and doesnt't leave us with additional inode methods.

    Link: https://lore.kernel.org/r/20210121131959.646623-25-christian.brauner@ubuntu.com
    Cc: Christoph Hellwig
    Cc: David Howells
    Cc: Al Viro
    Cc: linux-fsdevel@vger.kernel.org
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Christian Brauner

    Christian Brauner
     
  • The generic_fillattr() helper fills in the basic attributes associated
    with an inode. Enable it to handle idmapped mounts. If the inode is
    accessed through an idmapped mount map it into the mount's user
    namespace before we store the uid and gid. If the initial user namespace
    is passed nothing changes so non-idmapped mounts will see identical
    behavior as before.

    Link: https://lore.kernel.org/r/20210121131959.646623-12-christian.brauner@ubuntu.com
    Cc: Christoph Hellwig
    Cc: David Howells
    Cc: Al Viro
    Cc: linux-fsdevel@vger.kernel.org
    Reviewed-by: Christoph Hellwig
    Reviewed-by: James Morris
    Signed-off-by: Christian Brauner

    Christian Brauner
     
  • When file attributes are changed most filesystems rely on the
    setattr_prepare(), setattr_copy(), and notify_change() helpers for
    initialization and permission checking. Let them handle idmapped mounts.
    If the inode is accessed through an idmapped mount map it into the
    mount's user namespace. Afterwards the checks are identical to
    non-idmapped mounts. If the initial user namespace is passed nothing
    changes so non-idmapped mounts will see identical behavior as before.

    Helpers that perform checks on the ia_uid and ia_gid fields in struct
    iattr assume that ia_uid and ia_gid are intended values and have already
    been mapped correctly at the userspace-kernelspace boundary as we
    already do today. If the initial user namespace is passed nothing
    changes so non-idmapped mounts will see identical behavior as before.

    Link: https://lore.kernel.org/r/20210121131959.646623-8-christian.brauner@ubuntu.com
    Cc: Christoph Hellwig
    Cc: David Howells
    Cc: Al Viro
    Cc: linux-fsdevel@vger.kernel.org
    Reviewed-by: Christoph Hellwig
    Signed-off-by: Christian Brauner

    Christian Brauner
     

14 Dec, 2020

6 commits

  • Signed-off-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Ronnie Sahlberg
     
  • Can now be accessed via the ctx

    Signed-off-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Ronnie Sahlberg
     
  • We can already access these from cifs_sb->ctx so we no longer need
    a local copy in cifs_sb.

    Signed-off-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Ronnie Sahlberg
     
  • When compiling with W=1 I noticed various functions that
    did not follow proper style in describing (in the comments)
    the parameters passed in to the function. For example:

    fs/cifs/inode.c:2236: warning: Function parameter or member 'mode' not described in 'cifs_wait_bit_killable'

    I did not address the style warnings in two of the six files
    (connect.c and misc.c) in order to reduce risk of merge
    conflict with pending patches. We can update those later.

    Signed-off-by: Steve French

    Steve French
     
  • With the "cifsacl" mount option, the mode bits set on the file/dir
    is converted to corresponding ACEs in DACL. However, only the
    ALLOWED ACEs were being set for "owner" and "group" SIDs. Since
    owner is a subset of group, and group is a subset of
    everyone/world SID, in order to properly emulate unix perm groups,
    we need to add DENIED ACEs. If we don't do that, "owner" and "group"
    SIDs could get more access rights than they should. Which is what
    was happening. This fixes it.

    We try to keep the "preferred" order of ACEs, i.e. DENYs followed
    by ALLOWs. However, for a small subset of cases we cannot
    maintain the preferred order. In that case, we'll end up with the
    DENY ACE for group after the ALLOW for the owner.

    If owner SID == group SID, use the more restrictive
    among the two perm bits and convert them to ACEs.

    Also, for reverse mapping, i.e. to convert ACL to unix perm bits,
    for the "others" bits, we needed to add the masked bits of the
    owner and group masks to others mask.

    Updated version of patch fixes a problem noted by the kernel
    test robot.

    Reported-by: kernel test robot
    Signed-off-by: Shyam Prasad N
    Signed-off-by: Steve French

    Shyam Prasad N
     
  • In preparation to enable -Wimplicit-fallthrough for Clang, fix multiple
    warnings by explicitly adding multiple break/goto statements instead of
    just letting the code fall through to the next case.

    Link: https://github.com/KSPP/linux/issues/115
    Signed-off-by: Gustavo A. R. Silva
    Signed-off-by: Steve French

    Gustavo A. R. Silva
     

24 Oct, 2020

1 commit

  • This is needed so when mounting to Windows we do not
    misinterpret various special files created by Linux (WSL) as symlinks.
    An earlier patch addressed readdir. This patch fixes stat (getattr).

    With this patch:
      File: /mnt1/char
      Size: 0          Blocks: 0          IO Block: 16384  character special file
    Device: 34h/52d Inode: 844424930132069  Links: 1     Device type: 0,0
    Access: (0755/crwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
    Access: 2020-10-21 17:46:51.839458900 -0500
    Modify: 2020-10-21 17:46:51.839458900 -0500
    Change: 2020-10-21 18:30:39.797358800 -0500
     Birth: -
      File: /mnt1/fifo
      Size: 0          Blocks: 0          IO Block: 16384  fifo
    Device: 34h/52d Inode: 1125899906842722  Links: 1
    Access: (0755/prwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
    Access: 2020-10-21 16:21:37.259249700 -0500
    Modify: 2020-10-21 16:21:37.259249700 -0500
    Change: 2020-10-21 18:30:39.797358800 -0500
     Birth: -
      File: /mnt1/block
      Size: 0          Blocks: 0          IO Block: 16384  block special file
    Device: 34h/52d Inode: 844424930132068  Links: 1     Device type: 0,0
    Access: (0755/brwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
    Access: 2020-10-21 17:10:47.913103200 -0500
    Modify: 2020-10-21 17:10:47.913103200 -0500
    Change: 2020-10-21 18:30:39.796725500 -0500
     Birth: -

    without the patch all show up incorrectly as symlinks with annoying "operation not supported error also returned"
      File: /mnt1/charstat: cannot read symbolic link '/mnt1/char': Operation not supported

      Size: 0          Blocks: 0          IO Block: 16384  symbolic link
    Device: 34h/52d Inode: 844424930132069  Links: 1
    Access: (0000/l---------)  Uid: (    0/    root)   Gid: (    0/    root)
    Access: 2020-10-21 17:46:51.839458900 -0500
    Modify: 2020-10-21 17:46:51.839458900 -0500
    Change: 2020-10-21 18:30:39.797358800 -0500
     Birth: -
      File: /mnt1/fifostat: cannot read symbolic link '/mnt1/fifo': Operation not supported

      Size: 0          Blocks: 0          IO Block: 16384  symbolic link
    Device: 34h/52d Inode: 1125899906842722  Links: 1
    Access: (0000/l---------)  Uid: (    0/    root)   Gid: (    0/    root)
    Access: 2020-10-21 16:21:37.259249700 -0500
    Modify: 2020-10-21 16:21:37.259249700 -0500
    Change: 2020-10-21 18:30:39.797358800 -0500
     Birth: -
      File: /mnt1/blockstat: cannot read symbolic link '/mnt1/block': Operation not supported

      Size: 0          Blocks: 0          IO Block: 16384  symbolic link
    Device: 34h/52d Inode: 844424930132068  Links: 1
    Access: (0000/l---------)  Uid: (    0/    root)   Gid: (    0/    root)
    Access: 2020-10-21 17:10:47.913103200 -0500
    Modify: 2020-10-21 17:10:47.913103200 -0500
    Change: 2020-10-21 18:30:39.796725500 -0500

    Signed-off-by: Steve French
    Reviewed-by: Ronnie Sahlberg

    Steve French
     

16 Oct, 2020

1 commit

  • RHBZ: 1848178

    Some calls that set attributes, like utimensat(), are not supposed to return
    -EINTR and thus do not have handlers for this in glibc which causes us
    to leak -EINTR to the applications which are also unprepared to handle it.

    For example tar will break if utimensat() return -EINTR and abort unpacking
    the archive. Other applications may break too.

    To handle this we add checks, and retry, for -EINTR in cifs_setattr()

    Signed-off-by: Ronnie Sahlberg
    Signed-off-by: Steve French

    Ronnie Sahlberg
     

07 Sep, 2020

1 commit

  • RHBZ: 1871246

    If during cifs_lookup()/get_inode_info() we encounter a DFS link
    and we use the cifsacl or modefromsid mount options we must suppress
    any -EREMOTE errors that triggers or else we will not be able to follow
    the DFS link and automount the target.

    This fixes an issue with modefromsid/cifsacl where these mountoptions
    would break DFS and we would no longer be able to access the share.

    Signed-off-by: Ronnie Sahlberg
    Reviewed-by: Paulo Alcantara (SUSE)
    Signed-off-by: Steve French

    Ronnie Sahlberg
     

03 Aug, 2020

1 commit

  • Fix build warning by removing unused variable 'server':

    fs/cifs/inode.c:1089:26: warning:
    variable server set but not used [-Wunused-but-set-variable]
    1089 | struct TCP_Server_Info *server;
    | ^~~~~~

    Signed-off-by: Wei Yongjun
    Signed-off-by: Steve French
    Reviewed-by: Aurelien Aptel

    Wei Yongjun
     

24 Jul, 2020

1 commit

  • This reverts commit 9ffad9263b467efd8f8dc7ae1941a0a655a2bab2.

    Upon additional testing with older servers, it was found that
    the original commit introduced a regression when using the old SMB1
    dialect and rsyncing over an existing file.

    The patch will need to be respun to address this, likely including
    a larger refactoring of the SMB1 and SMB3 rename code paths to make
    it less confusing and also to address some additional rename error
    cases that SMB3 may be able to workaround.

    Signed-off-by: Steve French
    Reported-by: Patrick Fernie
    CC: Stable
    Acked-by: Ronnie Sahlberg
    Acked-by: Pavel Shilovsky
    Acked-by: Zhang Xiaoxu

    Steve French
     

02 Jul, 2020

1 commit

  • When xfstest generic/035, we found the target file was deleted
    if the rename return -EACESS.

    In cifs_rename2, we unlink the positive target dentry if rename
    failed with EACESS or EEXIST, even if the target dentry is positived
    before rename. Then the existing file was deleted.

    We should just delete the target file which created during the
    rename.

    Reported-by: Hulk Robot
    Signed-off-by: Zhang Xiaoxu
    Cc: stable@vger.kernel.org
    Signed-off-by: Steve French
    Reviewed-by: Aurelien Aptel

    Zhang Xiaoxu
     

24 Jun, 2020

1 commit

  • As the man description of the truncate, if the size changed,
    then the st_ctime and st_mtime fields should be updated. But
    in cifs, we doesn't do it.

    It lead the xfstests generic/313 failed.

    So, add the ATTR_MTIME|ATTR_CTIME flags on attrs when change
    the file size

    Reported-by: Hulk Robot
    Signed-off-by: Zhang Xiaoxu
    Signed-off-by: Steve French

    Zhang Xiaoxu