Print this page
NEX-5665 SMB2 oplock leases
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-15069 smtorture smb2.create.blob is failed
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-5665 SMB2 oplock leases
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-15069 smtorture smb2.create.blob is failed
Reviewed by: Matt Barden <matt.barden@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
NEX-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
SMB-11 SMB2 message parse & dispatch
SMB-12 SMB2 Negotiate Protocol
SMB-13 SMB2 Session Setup
SMB-14 SMB2 Logoff
SMB-15 SMB2 Tree Connect
SMB-16 SMB2 Tree Disconnect
SMB-17 SMB2 Create
SMB-18 SMB2 Close
SMB-19 SMB2 Flush
SMB-20 SMB2 Read
SMB-21 SMB2 Write
SMB-22 SMB2 Lock/Unlock
SMB-23 SMB2 Ioctl
SMB-24 SMB2 Cancel
SMB-25 SMB2 Echo
SMB-26 SMB2 Query Dir
SMB-27 SMB2 Change Notify
SMB-28 SMB2 Query Info
SMB-29 SMB2 Set Info
SMB-30 SMB2 Oplocks
SMB-53 SMB2 Create Context options
(SMB2 code review cleanup 1, 2, 3)
SMB-50 User-mode SMB server
 Includes work by these authors:
 Thomas Keiser <thomas.keiser@nexenta.com>
 Albert Lee <trisk@nexenta.com>
SMB-65 SMB server in non-global zones (use zone_kcred())
SMB-63 taskq_create_proc ... TQ_DYNAMIC puts tasks in p0
re #11974 CIFS Share - Tree connect fails from Windows 7 Clients
SUP-599 smb_oplock_acquire thread deadlock
re #7815 SMB server delivers old modification time...
re #6854 FindFirstFile,FindFirstFileEx,... are not working correctly on Nexenta CIFS-shares
        
*** 19,29 ****
   * CDDL HEADER END
   */
  
  /*
   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
!  * Copyright 2013 Nexenta Systems, Inc. All rights reserved.
   */
  
  #include <sys/sunddi.h>
  #include <sys/nbmlock.h>
  
--- 19,29 ----
   * CDDL HEADER END
   */
  
  /*
   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
!  * Copyright 2017 Nexenta Systems, Inc. All rights reserved.
   */
  
  #include <sys/sunddi.h>
  #include <sys/nbmlock.h>
  
*** 102,120 ****
          fqi = &sr->arg.dirop.fqi;
  
          if ((rc = smbsr_decode_vwv(sr, "w", &fqi->fq_sattr)) == 0)
                  rc = smbsr_decode_data(sr, "%S", sr, &fqi->fq_path.pn_path);
  
!         DTRACE_SMB_2(op__Delete__start, smb_request_t *, sr, smb_fqi_t *, fqi);
  
          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
  }
  
  void
  smb_post_delete(smb_request_t *sr)
  {
!         DTRACE_SMB_1(op__Delete__done, smb_request_t *, sr);
  }
  
  /*
   * smb_com_delete
   *
--- 102,120 ----
          fqi = &sr->arg.dirop.fqi;
  
          if ((rc = smbsr_decode_vwv(sr, "w", &fqi->fq_sattr)) == 0)
                  rc = smbsr_decode_data(sr, "%S", sr, &fqi->fq_path.pn_path);
  
!         DTRACE_SMB_START(op__Delete, smb_request_t *, sr); /* arg.dirop */
  
          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
  }
  
  void
  smb_post_delete(smb_request_t *sr)
  {
!         DTRACE_SMB_DONE(op__Delete, smb_request_t *, sr);
  }
  
  /*
   * smb_com_delete
   *
*** 468,478 ****
   *         -1 - error, err populated with error details
   */
  static int
  smb_delete_remove_file(smb_request_t *sr, smb_error_t *err)
  {
!         int rc, count;
          uint32_t status;
          smb_fqi_t *fqi;
          smb_node_t *node;
          uint32_t flags = 0;
  
--- 468,478 ----
   *         -1 - error, err populated with error details
   */
  static int
  smb_delete_remove_file(smb_request_t *sr, smb_error_t *err)
  {
!         int rc;
          uint32_t status;
          smb_fqi_t *fqi;
          smb_node_t *node;
          uint32_t flags = 0;
  
*** 482,513 ****
          /*
           * Break BATCH oplock before ofile checks. If a client
           * has a file open, this will force a flush or close,
           * which may affect the outcome of any share checking.
           */
!         (void) smb_oplock_break(sr, node,
!             SMB_OPLOCK_BREAK_TO_LEVEL_II | SMB_OPLOCK_BREAK_BATCH);
  
-         /*
-          * Wait (a little) for the oplock break to be
-          * responded to by clients closing handles.
-          * Hold node->n_lock as reader to keep new
-          * ofiles from showing up after we check.
-          */
          smb_node_rdlock(node);
-         for (count = 0; count <= 12; count++) {
                  status = smb_node_delete_check(node);
-                 if (status != NT_STATUS_SHARING_VIOLATION)
-                         break;
-                 smb_node_unlock(node);
-                 delay(MSEC_TO_TICK(100));
-                 smb_node_rdlock(node);
-         }
          if (status != NT_STATUS_SUCCESS) {
                  smb_delete_error(err, NT_STATUS_SHARING_VIOLATION,
                      ERRDOS, ERROR_SHARING_VIOLATION);
-                 smb_node_unlock(node);
                  return (-1);
          }
  
          /*
           * Note, the combination of these two:
--- 482,507 ----
          /*
           * Break BATCH oplock before ofile checks. If a client
           * has a file open, this will force a flush or close,
           * which may affect the outcome of any share checking.
           */
!         status = smb_oplock_break_DELETE(node, NULL);
!         if (status == NT_STATUS_OPLOCK_BREAK_IN_PROGRESS) {
!                 (void) smb_oplock_wait_break(node, 0);
!                 status = 0;
!         }
!         if (status != 0) {
!                 err->status = status;
!                 return (-1);
!         }
  
          smb_node_rdlock(node);
          status = smb_node_delete_check(node);
          if (status != NT_STATUS_SUCCESS) {
+                 smb_node_unlock(node);
                  smb_delete_error(err, NT_STATUS_SHARING_VIOLATION,
                      ERRDOS, ERROR_SHARING_VIOLATION);
                  return (-1);
          }
  
          /*
           * Note, the combination of these two:
*** 542,563 ****
                  flags |= SMB_CATIA;
  
          rc = smb_fsop_remove(sr, sr->user_cr, node->n_dnode,
              node->od_name, flags);
          if (rc != 0) {
-                 if (rc == ENOENT)
-                         smb_delete_error(err, NT_STATUS_OBJECT_NAME_NOT_FOUND,
-                             ERRDOS, ERROR_FILE_NOT_FOUND);
-                 else
                          smbsr_map_errno(rc, err);
! 
!                 smb_node_end_crit(node);
!                 return (-1);
          }
  
          smb_node_end_crit(node);
!         return (0);
  }
  
  
  /*
   * smb_delete_check_path
--- 536,551 ----
                  flags |= SMB_CATIA;
  
          rc = smb_fsop_remove(sr, sr->user_cr, node->n_dnode,
              node->od_name, flags);
          if (rc != 0) {
                  smbsr_map_errno(rc, err);
!                 rc = -1;
          }
  
          smb_node_end_crit(node);
!         return (rc);
  }
  
  
  /*
   * smb_delete_check_path