1. 01 5月, 2009 1 次提交
    • S
      [CIFS] rename cifs_strndup to cifs_strndup_from_ucs · d185cda7
      Steve French 提交于
      In most cases, cifs_strndup is converting from Unicode (UCS2 / UTF-32) to
      the configured local code page for the Linux mount (usually UTF8), so
      Jeff suggested that to make it more clear that cifs_strndup is doing
      a conversion not just memory allocation and copy, rename the function
      to including "from_ucs" (ie Unicode)
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      d185cda7
  2. 21 4月, 2009 1 次提交
  3. 17 4月, 2009 1 次提交
  4. 18 3月, 2009 1 次提交
  5. 12 3月, 2009 3 次提交
    • S
      [CIFS] work around bug in Samba server handling for posix open · 64cc2c63
      Steve French 提交于
      Samba server (version 3.3.1 and earlier, and 3.2.8 and earlier) incorrectly
      required the O_CREAT flag on posix open (even when a file was not being
      created).  This disables posix open (create is still ok) after the first
      attempt returns EINVAL (and logs an error, once, recommending that they
      update their server).
      Acked-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      64cc2c63
    • S
      [CIFS] Add new nostrictsync cifs mount option to avoid slow SMB flush · be652445
      Steve French 提交于
      If this mount option is set, when an application does an
      fsync call then the cifs client does not send an SMB Flush
      to the server (to force the server to write all dirty data
      for this file immediately to disk), although cifs still sends
      all dirty (cached) file data to the server and waits for the
      server to respond to the write write.  Since SMB Flush can be
      very slow, and some servers may be reliable enough (to risk
      delaying slightly flushing the data to disk on the server),
      turning on this option may be useful to improve performance for
      applications that fsync too much, at a small risk of server
      crash.  If this mount option is not set, by default cifs will
      send an SMB flush request (and wait for a response) on every
      fsync call.
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      be652445
    • S
      [CIFS] Send SMB flush in cifs_fsync · b298f223
      Steve French 提交于
      In contrast to the now-obsolete smbfs, cifs does not send SMB_COM_FLUSH
      in response to an explicit fsync(2) to guarantee that all volatile data
      is written to stable storage on the server side, provided the server
      honors the request (which, to my knowledge, is true for Windows and
      Samba with 'strict sync' enabled).
      This patch modifies the cifs_fsync implementation to restore the
      fsync-behavior of smbfs by triggering SMB_COM_FLUSH after sending
      outstanding data on the client side to the server.
      Signed-off-by: NHorst Reiterer <horst.reiterer@gmail.com>
      Acked-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      b298f223
  6. 21 2月, 2009 3 次提交
    • S
      [CIFS] Fix multiuser mounts so server does not invalidate earlier security contexts · eca6acf9
      Steve French 提交于
      When two different users mount the same Windows 2003 Server share using CIFS,
      the first session mounted can be invalidated.  Some servers invalidate the first
      smb session when a second similar user (e.g. two users who get mapped by server to "guest")
      authenticates an smb session from the same client.
      
      By making sure that we set the 2nd and subsequent vc numbers to nonzero values,
      this ensures that we will not have this problem.
      
      Fixes Samba bug 6004, problem description follows:
      How to reproduce:
      
      - configure an "open share" (full permissions to Guest user) on Windows 2003
      Server (I couldn't reproduce the problem with Samba server or Windows older
      than 2003)
      - mount the share twice with different users who will be authenticated as guest.
      
       noacl,noperm,user=john,dir_mode=0700,domain=DOMAIN,rw
       noacl,noperm,user=jeff,dir_mode=0700,domain=DOMAIN,rw
      
      Result:
      
      - just the mount point mounted last is accessible:
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      eca6acf9
    • S
      [CIFS] improve posix semantics of file create · c3b2a0c6
      Steve French 提交于
      Samba server added support for a new posix open/create/mkdir operation
      a year or so ago, and we added support to cifs for mkdir to use it,
      but had not added the corresponding code to file create.
      
      The following patch helps improve the performance of the cifs create
      path (to Samba and servers which support the cifs posix protocol
      extensions).  Using Connectathon basic test1, with 2000 files, the
      performance improved about 15%, and also helped reduce network traffic
      (17% fewer SMBs sent over the wire) due to saving a network round trip
      for the SetPathInfo on every file create.
      
      It should also help the semantics (and probably the performance) of
      write (e.g. when posix byte range locks are on the file) on file
      handles opened with posix create, and adds support for a few flags
      which would have to be ignored otherwise.
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      c3b2a0c6
    • S
      [CIFS] Fix oops in cifs_strfromUCS_le mounting to servers which do not specify their OS · 69765529
      Steve French 提交于
      Fixes kernel bug #10451 http://bugzilla.kernel.org/show_bug.cgi?id=10451
      
      Certain NAS appliances do not set the operating system or network operating system
      fields in the session setup response on the wire.  cifs was oopsing on the unexpected
      zero length response fields (when trying to null terminate a zero length field).
      
      This fixes the oops.
      Acked-by: NJeff Layton <jlayton@redhat.com>
      CC: stable <stable@kernel.org>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      69765529
  7. 29 1月, 2009 1 次提交
    • S
      [CIFS] revalidate parent inode when rmdir done within that directory · 42c24544
      Steve French 提交于
      When a search is pending of a parent directory, and a child directory
      within it is removed, we need to reset the parent directory's time
      so that we don't reuse the (now stale) search results.
      
      Thanks to Gunter Kukkukk for reporting this:
      
      > got the following failure notification on irc #samba:
      >
      > A user was updating from subversion 1.4 to 1.5, where the
      > repository is located on a samba share (independent of
      > unix extensions = Yes or No).
      > svn 1.4 did work, 1.5 does not.
      >
      > The user did a lot of stracing of subversion - and wrote a
      > testapplet to simulate the failing behaviour.
      > I've converted the C++ source to C and added some error cases.
      >
      > When using "./testdir" on a local file system, "result2"
      > is always (nil) as expected - cifs vfs behaves different here!
      >
      >   ./testdir /mnt/cifs/mounted/share
      >
      > returns a (failing) valid pointer.
      Acked-by: NDave Kleikamp <shaggy@us.ibm.com>
      Acked-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      42c24544
  8. 26 12月, 2008 3 次提交
    • S
      [CIFS] make sure that DFS pathnames are properly formed · c6fbba05
      Steve French 提交于
      The paths in a DFS request are supposed to only have a single preceding
      backslash, but we are sending them with a double backslash. This is
      exposing a bug in Windows where it also sends a path in the response
      that has a double backslash.
      
      The existing code that builds the mount option string however expects a
      double backslash prefix in a couple of places when it tries to use the
      path returned by build_path_from_dentry. Fix compose_mount_options to
      expect properly formed DFS paths (single backslash at front).
      
      Also clean up error handling in that function. There was a possible
      NULL pointer dereference and situations where a partially built option
      string would be returned.
      
      Tested against Samba 3.0.28-ish server and Samba 3.3 and Win2k8.
      
      CC: Stable <stable@kernel.org>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      c6fbba05
    • S
      [CIFS] Can not mount with prefixpath if root directory of share is inaccessible · 8be0ed44
      Steve French 提交于
      Windows allows you to deny access to the top of a share, but permit access to
      a directory lower in the path.  With the prefixpath feature of cifs
      (ie mounting \\server\share\directory\subdirectory\etc.) this should have
      worked if the user specified a prefixpath which put the root of the mount
      at a directory to which he had access, but we still were doing a lookup
      on the root of the share (null path) when we should have been doing it on
      the prefixpath subdirectory.
      
      This fixes Samba bug # 5925
      Acked-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      8be0ed44
    • S
      [CIFS] add mount option to send mandatory rather than advisory locks · 13a6e42a
      Steve French 提交于
      Some applications/subsystems require mandatory byte range locks
      (as is used for Windows/DOS/OS2 etc). Sending advisory (posix style)
      byte range lock requests (instead of mandatory byte range locks) can
      lead to problems for these applications (which expect that other
      clients be prevented from writing to portions of the file which
      they have locked and are updating).  This mount option allows
      mounting cifs with the new mount option "forcemand" (or
      "forcemandatorylock") in order to have the cifs client use mandatory
      byte range locks (ie SMB/CIFS/Windows/NTFS style locks) rather than
      posix byte range lock requests, even if the server would support
      posix byte range lock requests.  This has no effect if the server
      does not support the CIFS Unix Extensions (since posix style locks
      require support for the CIFS Unix Extensions), but for mounts
      to Samba servers this can be helpful for Wine and applications
      that require mandatory byte range locks.
      Acked-by: NJeff Layton <jlayton@redhat.com>
      CC: Alexander Bokovoy <ab@samba.org>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      13a6e42a
  9. 19 11月, 2008 1 次提交
  10. 29 10月, 2008 1 次提交
    • S
      [CIFS] Reduce number of socket retries in large write path · edf1ae40
      Steve French 提交于
      CIFS in some heavy stress conditions cifs could get EAGAIN
      repeatedly in smb_send2 which led to repeated retries and eventually
      failure of large writes which could lead to data corruption.
      
      There are three changes that were suggested by various network
      developers:
      
      1) convert cifs from non-blocking to blocking tcp sendmsg
      (we left in the retry on failure)
      2) change cifs to not set sendbuf and rcvbuf size for the socket
      (let tcp autotune the buffer sizes since that works much better
      in the TCP stack now)
      3) if we have a partial frame sent in smb_send2, mark the tcp
      session as invalid (close the socket and reconnect) so we do
      not corrupt the remaining part of the SMB with the beginning
      of the next SMB.
      
      This does not appear to hurt performance measurably and has
      been run in various scenarios, but it definately removes
      a corruption that we were seeing in some high stress
      test cases.
      Acked-by: NShirish Pargaonkar <shirishp@us.ibm.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      edf1ae40
  11. 23 10月, 2008 1 次提交
    • S
      [CIFS] improve setlease handling · 84210e91
      Steve French 提交于
      fcntl(F_SETLEASE) currently is not exported by cifs (nor by local file
      systems) so cifs grants leases based on how other local processes have
      opened the file not by whether the file is cacheable (oplocked).  This
      adds the check to make sure that the file is cacheable on the client
      before checking whether we can grant the lease locally
      (generic_setlease).  It also adds a mount option for cifs (locallease)
      if the user wants to override this and try to grant leases even
      if the server did not grant oplock.
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      84210e91
  12. 20 10月, 2008 1 次提交
  13. 28 8月, 2008 2 次提交
  14. 26 8月, 2008 1 次提交
  15. 06 8月, 2008 1 次提交
  16. 11 6月, 2008 1 次提交
  17. 21 5月, 2008 1 次提交
  18. 13 5月, 2008 1 次提交
    • J
      fix memory leak in CIFSFindNext · 6353450a
      Jeff Layton 提交于
      When CIFSFindNext gets back an -EBADF from a call, it sets the return
      code of the function to 0 and eventually exits. Doing this makes the
      cleanup at the end of the function skip freeing the SMB buffer, so
      we need to make sure we free the buffer explicitly when doing this.
      
      If we don't you end up with errors like this when unplugging the cifs
      kernel module:
      
      slab error in kmem_cache_destroy(): cache `cifs_request': Can't free all objects
       [<c046bdbf>] kmem_cache_destroy+0x61/0xf3
       [<e0f03045>] cifs_destroy_request_bufs+0x14/0x28 [cifs]
       [<e0f2016e>] exit_cifs+0x1e/0x80 [cifs]
       [<c043aeae>] sys_delete_module+0x192/0x1b8
       [<c04451fd>] audit_syscall_entry+0x14b/0x17d
       [<c0405413>] syscall_call+0x7/0xb
       =======================
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      6353450a
  19. 28 4月, 2008 1 次提交
  20. 05 4月, 2008 1 次提交
  21. 14 2月, 2008 1 次提交
    • S
      [CIFS] fixup prefixpaths which contain multiple path components · 03a143c9
      Steve French 提交于
      Currently, when we get a prefixpath as part of mount, the kernel only
      changes the first character to be a '/' or '\' depending on whether
      posix extensions are enabled. This is problematic as it expects
      mount.cifs to pass in the correct delimiter in the rest of the
      prefixpath. But, mount.cifs may not know *what* the correct delimiter
      is. It's a chicken and egg problem.
      
      Note that mount.cifs should not do conversion of the
      prefixpath - if we want posix behavior then '\' is legal in a path
      (and we have had bugs in the distant path to prove to me that
      customers sometimes have apps that require '\').  The kernel code
      assumes that the path passed in is posix (and current code will handle
      the first path component fine but was broken for Windows mounts
      for "deep" prefixpaths unless the user specified a prefixpath with '\'
      deep in it.   So e.g. with current kernel code:
      
      1) mount to //server/share/dir1 will work to all server types
      2) mount to //server/share/dir1/subdir1 will work to Samba
      3) mount to //server/share/dir1\\subdir1 will work to Windows
      
      But case two would fail to Windows without the fix.
      With the kernel cifs module fix case two now works.
      
      First analyzed by Jeff Layton and Simo Sorce
      
      CC: Jeff Layton <jlayton@redhat.com>
      CC: Simo Sorce <simo@samba.org>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      03a143c9
  22. 31 12月, 2007 3 次提交
  23. 21 11月, 2007 1 次提交
    • J
      [CIFS] Fix potential data corruption when writing out cached dirty pages · cea21805
      Jeff Layton 提交于
      Fix RedHat bug 329431
      
      The idea here is separate "conscious" from "unconscious" flushes.
      Conscious flushes are those due to a fsync() or close(). Unconscious
      ones are flushes that occur as a side effect of some other operation or
      due to memory pressure.
      
      Currently, when an error occurs during an unconscious flush (ENOSPC or
      EIO), we toss out the page and don't preserve that error to report to
      the user when a conscious flush occurs. If after the unconscious flush,
      there are no more dirty pages for the inode, the conscious flush will
      simply return success even though there were previous errors when writing
      out pages. This can lead to data corruption.
      
      The easiest way to reproduce this is to mount up a CIFS share that's
      very close to being full or where the user is very close to quota. mv
      a file to the share that's slightly larger than the quota allows. The
      writes will all succeed (since they go to pagecache). The mv will do a
      setattr to set the new file's attributes. This calls
      filemap_write_and_wait,
      which will return an error since all of the pages can't be written out.
      Then later, when the flush and release ops occur, there are no more
      dirty pages in pagecache for the file and those operations return 0. mv
      then assumes that the file was written out correctly and deletes the
      original.
      
      CIFS already has a write_behind_rc variable where it stores the results
      from earlier flushes, but that value is only reported in cifs_close.
      Since the VFS ignores the return value from the release operation, this
      isn't helpful. We should be reporting this error during the flush
      operation.
      
      This patch does the following:
      
      1) changes cifs_fsync to use filemap_write_and_wait and cifs_flush and also
      sync to check its return code. If it returns successful, they then check
      the value of write_behind_rc to see if an earlier flush had reported any
      errors. If so, they return that error and clear write_behind_rc.
      
      2) sets write_behind_rc in a few other places where pages are written
      out as a side effect of other operations and the code waits on them.
      
      3) changes cifs_setattr to only call filemap_write_and_wait for
      ATTR_SIZE changes.
      
      4) makes cifs_writepages accurately distinguish between EIO and ENOSPC
      errors when writing out pages.
      
      Some simple testing indicates that the patch works as expected and that
      it fixes the reproduceable known problem.
      Acked-by: NDave Kleikamp <shaggy@austin.rr.com>
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      cea21805
  24. 17 11月, 2007 1 次提交
  25. 10 11月, 2007 1 次提交
    • J
      [CIFS] fix oops on second mount to same server when null auth is used · 9b8f5f57
      Jeff Layton 提交于
      When a share is mounted using no username, cifs_mount sets
      volume_info.username as a NULL pointer, and the sesInfo userName as an
      empty string. The volume_info.username is passed to a couple of other
      functions to see if there is an existing unc or tcp connection that can
      be used. These functions assume that the username will be a valid
      string that can be passed to strncmp. If the pointer is NULL, then the
      kernel will oops if there's an existing session to which the string
      can be compared.
      
      This patch changes cifs_mount to set volume_info.username to an empty
      string in this situation, which prevents the oops and should make it
      so that the comparison to other null auth sessions match.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      9b8f5f57
  26. 09 11月, 2007 1 次提交
  27. 01 11月, 2007 1 次提交
    • S
      [CIFS] when mount helper missing fix slash wrong direction in share · 1fb64bfc
      Steve French 提交于
      Kernel bugzilla bug #9228
      
      If mount helper (mount.cifs) missing, mounts with form like
      //10.11.12.13/c$ would not work (only mounts with slash e.g.
      //10.11.12.13\\c$ would work) due to problem with slash supposed
      to be converted to backslash by the mount helper (which is not
      there).
      
      If we fail on converting an IPv4 address in in4_pton then
      try to canonicalize the first slash (ie between sharename
      and host ip address) if necessary.  If we have to retry
      to check for IPv6 address the slash is already converted
      if necessary.
      Signed-off-by: NSteve French <sfrench@us.ibm.com>
      1fb64bfc
  28. 30 10月, 2007 1 次提交
  29. 18 10月, 2007 2 次提交
  30. 15 10月, 2007 1 次提交