cifs: smb1: Try failing back to SetFileInfo if SetPathInfo fails
diff mbox series

Message ID 20200714221805.3459-1-lsahlber@redhat.com
State New
Headers show
Series
  • cifs: smb1: Try failing back to SetFileInfo if SetPathInfo fails
Related show

Commit Message

Ronnie Sahlberg July 14, 2020, 10:18 p.m. UTC
RHBZ 1145308

Some very old server may not support SetPathInfo to adjust the timestamps
of directories. For these servers, try to open the directory and use SetFileInfo.

Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/cifsproto.h |  2 +-
 fs/cifs/cifssmb.c   | 39 ++++++++++++++++++++++++++++++++++++++-
 fs/cifs/smb1ops.c   |  4 ++--
 3 files changed, 41 insertions(+), 4 deletions(-)

Comments

kernel test robot July 15, 2020, 1:11 a.m. UTC | #1
Hi Ronnie,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on cifs/for-next]
[also build test WARNING on v5.8-rc5 next-20200714]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ronnie-Sahlberg/cifs-smb1-Try-failing-back-to-SetFileInfo-if-SetPathInfo-fails/20200715-061927
base:   git://git.samba.org/sfrench/cifs-2.6.git for-next
config: i386-randconfig-s002-20200714 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-14) 9.3.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.2-41-g14e84ffc-dirty
        # save the attached .config to linux build tree
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=i386 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

>> fs/cifs/cifssmb.c:5917:1: sparse: sparse: symbol 'CIFSSMBSetPathInfoFB' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
kernel test robot July 15, 2020, 1:24 a.m. UTC | #2
Hi Ronnie,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on cifs/for-next]
[also build test WARNING on v5.8-rc5 next-20200714]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ronnie-Sahlberg/cifs-smb1-Try-failing-back-to-SetFileInfo-if-SetPathInfo-fails/20200715-061927
base:   git://git.samba.org/sfrench/cifs-2.6.git for-next
config: arm64-randconfig-r005-20200714 (attached as .config)
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install arm64 cross compiling tool for clang build
        # apt-get install binutils-aarch64-linux-gnu
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

>> fs/cifs/cifssmb.c:5917:1: warning: no previous prototype for function 'CIFSSMBSetPathInfoFB' [-Wmissing-prototypes]
   CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
   ^
   fs/cifs/cifssmb.c:5916:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int
   ^
   static 
   1 warning generated.
--
   In file included from fs/cifs/cifssmb.c:40:
   In file included from fs/cifs/cifsglob.h:32:
   fs/cifs/smb2pdu.h:28:10: error: 'cifsacl.h' file not found with <angled> include; use "quotes" instead
   #include <cifsacl.h>
            ^~~~~~~~~~~
            "cifsacl.h"
>> fs/cifs/cifssmb.c:5917:1: warning: no previous prototype for function 'CIFSSMBSetPathInfoFB' [-Wmissing-prototypes]
   CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
   ^
   fs/cifs/cifssmb.c:5916:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
   int
   ^
   static 
   1 warning and 1 error generated.

vim +/CIFSSMBSetPathInfoFB +5917 fs/cifs/cifssmb.c

  5915	
  5916	int
> 5917	CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
  5918			     const char *fileName, const FILE_BASIC_INFO *data,
  5919			     const struct nls_table *nls_codepage,
  5920			     struct cifs_sb_info *cifs_sb)
  5921	{
  5922		int oplock = 0;
  5923		struct cifs_open_parms oparms;
  5924		struct cifs_fid fid;
  5925		int rc;
  5926	
  5927		oparms.tcon = tcon;
  5928		oparms.cifs_sb = cifs_sb;
  5929		oparms.desired_access = GENERIC_WRITE;
  5930		oparms.create_options = cifs_create_options(cifs_sb, 0);
  5931		oparms.disposition = FILE_OPEN;
  5932		oparms.path = fileName;
  5933		oparms.fid = &fid;
  5934		oparms.reconnect = false;
  5935	
  5936		rc = CIFS_open(xid, &oparms, &oplock, NULL);
  5937		if (rc)
  5938			goto out;
  5939	
  5940		rc = CIFSSMBSetFileInfo(xid, tcon, data, fid.netfid, current->tgid);
  5941		CIFSSMBClose(xid, tcon, fid.netfid);
  5942	out:
  5943	
  5944		return rc;
  5945	}
  5946	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Steve French July 15, 2020, 4:17 a.m. UTC | #3
patch updated - and merged into cifs-2.6.git for-next pending additional review

On Tue, Jul 14, 2020 at 8:30 PM kernel test robot <lkp@intel.com> wrote:
>
> Hi Ronnie,
>
> Thank you for the patch! Perhaps something to improve:
>
> [auto build test WARNING on cifs/for-next]
> [also build test WARNING on v5.8-rc5 next-20200714]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use  as documented in
> https://git-scm.com/docs/git-format-patch]
>
> url:    https://github.com/0day-ci/linux/commits/Ronnie-Sahlberg/cifs-smb1-Try-failing-back-to-SetFileInfo-if-SetPathInfo-fails/20200715-061927
> base:   git://git.samba.org/sfrench/cifs-2.6.git for-next
> config: arm64-randconfig-r005-20200714 (attached as .config)
> compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
> reproduce (this is a W=1 build):
>         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>         chmod +x ~/bin/make.cross
>         # install arm64 cross compiling tool for clang build
>         # apt-get install binutils-aarch64-linux-gnu
>         # save the attached .config to linux build tree
>         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@intel.com>
>
> All warnings (new ones prefixed by >>):
>
> >> fs/cifs/cifssmb.c:5917:1: warning: no previous prototype for function 'CIFSSMBSetPathInfoFB' [-Wmissing-prototypes]
>    CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
>    ^
>    fs/cifs/cifssmb.c:5916:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
>    int
>    ^
>    static
>    1 warning generated.
> --
>    In file included from fs/cifs/cifssmb.c:40:
>    In file included from fs/cifs/cifsglob.h:32:
>    fs/cifs/smb2pdu.h:28:10: error: 'cifsacl.h' file not found with <angled> include; use "quotes" instead
>    #include <cifsacl.h>
>             ^~~~~~~~~~~
>             "cifsacl.h"
> >> fs/cifs/cifssmb.c:5917:1: warning: no previous prototype for function 'CIFSSMBSetPathInfoFB' [-Wmissing-prototypes]
>    CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
>    ^
>    fs/cifs/cifssmb.c:5916:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
>    int
>    ^
>    static
>    1 warning and 1 error generated.
>
> vim +/CIFSSMBSetPathInfoFB +5917 fs/cifs/cifssmb.c
>
>   5915
>   5916  int
> > 5917  CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
>   5918                       const char *fileName, const FILE_BASIC_INFO *data,
>   5919                       const struct nls_table *nls_codepage,
>   5920                       struct cifs_sb_info *cifs_sb)
>   5921  {
>   5922          int oplock = 0;
>   5923          struct cifs_open_parms oparms;
>   5924          struct cifs_fid fid;
>   5925          int rc;
>   5926
>   5927          oparms.tcon = tcon;
>   5928          oparms.cifs_sb = cifs_sb;
>   5929          oparms.desired_access = GENERIC_WRITE;
>   5930          oparms.create_options = cifs_create_options(cifs_sb, 0);
>   5931          oparms.disposition = FILE_OPEN;
>   5932          oparms.path = fileName;
>   5933          oparms.fid = &fid;
>   5934          oparms.reconnect = false;
>   5935
>   5936          rc = CIFS_open(xid, &oparms, &oplock, NULL);
>   5937          if (rc)
>   5938                  goto out;
>   5939
>   5940          rc = CIFSSMBSetFileInfo(xid, tcon, data, fid.netfid, current->tgid);
>   5941          CIFSSMBClose(xid, tcon, fid.netfid);
>   5942  out:
>   5943
>   5944          return rc;
>   5945  }
>   5946
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Kenneth D'souza July 16, 2020, 1:16 a.m. UTC | #4
Tested-by: Kenneth D'souza <kdsouza@redhat.com>

On Wed, Jul 15, 2020 at 9:47 AM Steve French <smfrench@gmail.com> wrote:
>
> patch updated - and merged into cifs-2.6.git for-next pending additional review
>
> On Tue, Jul 14, 2020 at 8:30 PM kernel test robot <lkp@intel.com> wrote:
> >
> > Hi Ronnie,
> >
> > Thank you for the patch! Perhaps something to improve:
> >
> > [auto build test WARNING on cifs/for-next]
> > [also build test WARNING on v5.8-rc5 next-20200714]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use  as documented in
> > https://git-scm.com/docs/git-format-patch]
> >
> > url:    https://github.com/0day-ci/linux/commits/Ronnie-Sahlberg/cifs-smb1-Try-failing-back-to-SetFileInfo-if-SetPathInfo-fails/20200715-061927
> > base:   git://git.samba.org/sfrench/cifs-2.6.git for-next
> > config: arm64-randconfig-r005-20200714 (attached as .config)
> > compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project 02946de3802d3bc65bc9f2eb9b8d4969b5a7add8)
> > reproduce (this is a W=1 build):
> >         wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
> >         chmod +x ~/bin/make.cross
> >         # install arm64 cross compiling tool for clang build
> >         # apt-get install binutils-aarch64-linux-gnu
> >         # save the attached .config to linux build tree
> >         COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=arm64
> >
> > If you fix the issue, kindly add following tag as appropriate
> > Reported-by: kernel test robot <lkp@intel.com>
> >
> > All warnings (new ones prefixed by >>):
> >
> > >> fs/cifs/cifssmb.c:5917:1: warning: no previous prototype for function 'CIFSSMBSetPathInfoFB' [-Wmissing-prototypes]
> >    CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
> >    ^
> >    fs/cifs/cifssmb.c:5916:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
> >    int
> >    ^
> >    static
> >    1 warning generated.
> > --
> >    In file included from fs/cifs/cifssmb.c:40:
> >    In file included from fs/cifs/cifsglob.h:32:
> >    fs/cifs/smb2pdu.h:28:10: error: 'cifsacl.h' file not found with <angled> include; use "quotes" instead
> >    #include <cifsacl.h>
> >             ^~~~~~~~~~~
> >             "cifsacl.h"
> > >> fs/cifs/cifssmb.c:5917:1: warning: no previous prototype for function 'CIFSSMBSetPathInfoFB' [-Wmissing-prototypes]
> >    CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
> >    ^
> >    fs/cifs/cifssmb.c:5916:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
> >    int
> >    ^
> >    static
> >    1 warning and 1 error generated.
> >
> > vim +/CIFSSMBSetPathInfoFB +5917 fs/cifs/cifssmb.c
> >
> >   5915
> >   5916  int
> > > 5917  CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
> >   5918                       const char *fileName, const FILE_BASIC_INFO *data,
> >   5919                       const struct nls_table *nls_codepage,
> >   5920                       struct cifs_sb_info *cifs_sb)
> >   5921  {
> >   5922          int oplock = 0;
> >   5923          struct cifs_open_parms oparms;
> >   5924          struct cifs_fid fid;
> >   5925          int rc;
> >   5926
> >   5927          oparms.tcon = tcon;
> >   5928          oparms.cifs_sb = cifs_sb;
> >   5929          oparms.desired_access = GENERIC_WRITE;
> >   5930          oparms.create_options = cifs_create_options(cifs_sb, 0);
> >   5931          oparms.disposition = FILE_OPEN;
> >   5932          oparms.path = fileName;
> >   5933          oparms.fid = &fid;
> >   5934          oparms.reconnect = false;
> >   5935
> >   5936          rc = CIFS_open(xid, &oparms, &oplock, NULL);
> >   5937          if (rc)
> >   5938                  goto out;
> >   5939
> >   5940          rc = CIFSSMBSetFileInfo(xid, tcon, data, fid.netfid, current->tgid);
> >   5941          CIFSSMBClose(xid, tcon, fid.netfid);
> >   5942  out:
> >   5943
> >   5944          return rc;
> >   5945  }
> >   5946
> >
> > ---
> > 0-DAY CI Kernel Test Service, Intel Corporation
> > https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>
>
>
> --
> Thanks,
>
> Steve
>

Patch
diff mbox series

diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h
index 7a836ec0438e..c1cd3fff0b60 100644
--- a/fs/cifs/cifsproto.h
+++ b/fs/cifs/cifsproto.h
@@ -344,7 +344,7 @@  extern int CIFSSMBQFSPosixInfo(const unsigned int xid, struct cifs_tcon *tcon,
 extern int CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 			const char *fileName, const FILE_BASIC_INFO *data,
 			const struct nls_table *nls_codepage,
-			int remap_special_chars);
+			struct cifs_sb_info *cifs_sb);
 extern int CIFSSMBSetFileInfo(const unsigned int xid, struct cifs_tcon *tcon,
 			const FILE_BASIC_INFO *data, __u16 fid,
 			__u32 pid_of_opener);
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c
index bf41ee048396..eac525c1be5e 100644
--- a/fs/cifs/cifssmb.c
+++ b/fs/cifs/cifssmb.c
@@ -5914,9 +5914,41 @@  CIFSSMBSetFileDisposition(const unsigned int xid, struct cifs_tcon *tcon,
 }
 
 int
+CIFSSMBSetPathInfoFB(const unsigned int xid, struct cifs_tcon *tcon,
+		     const char *fileName, const FILE_BASIC_INFO *data,
+		     const struct nls_table *nls_codepage,
+		     struct cifs_sb_info *cifs_sb)
+{
+	int oplock = 0;
+	struct cifs_open_parms oparms;
+	struct cifs_fid fid;
+	int rc;
+
+	oparms.tcon = tcon;
+	oparms.cifs_sb = cifs_sb;
+	oparms.desired_access = GENERIC_WRITE;
+	oparms.create_options = cifs_create_options(cifs_sb, 0);
+	oparms.disposition = FILE_OPEN;
+	oparms.path = fileName;
+	oparms.fid = &fid;
+	oparms.reconnect = false;
+
+	rc = CIFS_open(xid, &oparms, &oplock, NULL);
+	if (rc)
+		goto out;
+
+	rc = CIFSSMBSetFileInfo(xid, tcon, data, fid.netfid, current->tgid);
+	CIFSSMBClose(xid, tcon, fid.netfid);
+out:
+
+	return rc;
+}
+
+int
 CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 		   const char *fileName, const FILE_BASIC_INFO *data,
-		   const struct nls_table *nls_codepage, int remap)
+		   const struct nls_table *nls_codepage,
+		     struct cifs_sb_info *cifs_sb)
 {
 	TRANSACTION2_SPI_REQ *pSMB = NULL;
 	TRANSACTION2_SPI_RSP *pSMBr = NULL;
@@ -5925,6 +5957,7 @@  CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 	int bytes_returned = 0;
 	char *data_offset;
 	__u16 params, param_offset, offset, byte_count, count;
+	int remap = cifs_remap(cifs_sb);
 
 	cifs_dbg(FYI, "In SetTimes\n");
 
@@ -5987,6 +6020,10 @@  CIFSSMBSetPathInfo(const unsigned int xid, struct cifs_tcon *tcon,
 	if (rc == -EAGAIN)
 		goto SetTimesRetry;
 
+	if (rc == -EOPNOTSUPP)
+		return CIFSSMBSetPathInfoFB(xid, tcon, fileName, data,
+					    nls_codepage, cifs_sb);
+
 	return rc;
 }
 
diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
index 197ed455e657..80287c26cfac 100644
--- a/fs/cifs/smb1ops.c
+++ b/fs/cifs/smb1ops.c
@@ -688,7 +688,7 @@  cifs_mkdir_setinfo(struct inode *inode, const char *full_path,
 	dosattrs = cifsInode->cifsAttrs|ATTR_READONLY;
 	info.Attributes = cpu_to_le32(dosattrs);
 	rc = CIFSSMBSetPathInfo(xid, tcon, full_path, &info, cifs_sb->local_nls,
-				cifs_remap(cifs_sb));
+				cifs_sb);
 	if (rc == 0)
 		cifsInode->cifsAttrs = dosattrs;
 }
@@ -783,7 +783,7 @@  smb_set_file_info(struct inode *inode, const char *full_path,
 	tcon = tlink_tcon(tlink);
 
 	rc = CIFSSMBSetPathInfo(xid, tcon, full_path, buf, cifs_sb->local_nls,
-				cifs_remap(cifs_sb));
+				cifs_sb);
 	if (rc == 0) {
 		cinode->cifsAttrs = le32_to_cpu(buf->Attributes);
 		goto out;