cifs: improve symlink handling for smb2+
authorPaulo Alcantara <pc@cjr.nz>
Mon, 3 Oct 2022 21:43:50 +0000 (18:43 -0300)
committerSteve French <stfrench@microsoft.com>
Thu, 13 Oct 2022 14:36:04 +0000 (09:36 -0500)
commit76894f3e2f71177747b8b4763fb180e800279585
treed0382d6389d324b5d7421ee960a60af74415b631
parent977bb6530807a9a8e7f29d7dfba5737135b50df6
cifs: improve symlink handling for smb2+

When creating inode for symlink, the client used to send below
requests to fill it in:

    * create+query_info+close (STATUS_STOPPED_ON_SYMLINK)
    * create(+reparse_flag)+query_info+close (set file attrs)
    * create+ioctl(get_reparse)+close (query reparse tag)

and then for every access to the symlink dentry, the ->link() method
would send another:

    * create+ioctl(get_reparse)+close (parse symlink)

So, in order to improve:

    (i) Get rid of unnecessary roundtrips and then resolve symlinks as
follows:

        * create+query_info+close (STATUS_STOPPED_ON_SYMLINK +
                           parse symlink + get reparse tag)
        * create(+reparse_flag)+query_info+close (set file attrs)

    (ii) Set the resolved symlink target directly in inode->i_link and
         use simple_get_link() for ->link() to simply return it.

Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Reviewed-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
14 files changed:
fs/cifs/cifsfs.c
fs/cifs/cifsglob.h
fs/cifs/cifsproto.h
fs/cifs/dir.c
fs/cifs/file.c
fs/cifs/inode.c
fs/cifs/link.c
fs/cifs/readdir.c
fs/cifs/smb1ops.c
fs/cifs/smb2file.c
fs/cifs/smb2inode.c
fs/cifs/smb2ops.c
fs/cifs/smb2pdu.h
fs/cifs/smb2proto.h