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-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-1643 dtrace provider for smbsrv
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Matt Barden <matt.barden@nexenta.com>
NEX-5311 SMB1 Create_Temp should return an untagged ASCII string
Reviewed by: Gordon Ross <gwr@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)

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbsrv/smb_create.c
          +++ new/usr/src/uts/common/fs/smbsrv/smb_create.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
  23      - * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
       23 + * Copyright 2017 Nexenta Systems, Inc.  All rights reserved.
  24   24   */
  25   25  
  26   26  #include <smbsrv/smb_kproto.h>
  27   27  
  28   28  #define SMB_CREATE_NAMEBUF_SZ   16
  29   29  
  30   30  /*
  31   31   * Create a new file, or truncate an existing file to zero length,
  32   32   * open the file and return a fid.  The file is specified using a
  33   33   * fully qualified name relative to the tree.
↓ open down ↓ 6 lines elided ↑ open up ↑
  40   40  
  41   41          bzero(op, sizeof (sr->arg.open));
  42   42  
  43   43          rc = smbsr_decode_vwv(sr, "wl", &op->dattr, &op->mtime.tv_sec);
  44   44          if (rc == 0)
  45   45                  rc = smbsr_decode_data(sr, "%S", sr, &op->fqi.fq_path.pn_path);
  46   46  
  47   47          op->create_disposition = FILE_OVERWRITE_IF;
  48   48          op->create_options = FILE_NON_DIRECTORY_FILE;
  49   49  
  50      -        DTRACE_SMB_2(op__Create__start, smb_request_t *, sr,
  51      -            struct open_param *, op);
       50 +        DTRACE_SMB_START(op__Create, smb_request_t *, sr); /* arg.open */
  52   51  
  53   52          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
  54   53  }
  55   54  
  56   55  void
  57   56  smb_post_create(smb_request_t *sr)
  58   57  {
  59      -        DTRACE_SMB_1(op__Create__done, smb_request_t *, sr);
       58 +        DTRACE_SMB_DONE(op__Create, smb_request_t *, sr);
  60   59  }
  61   60  
  62   61  smb_sdrc_t
  63   62  smb_com_create(smb_request_t *sr)
  64   63  {
  65   64          if (smb_common_create(sr) != NT_STATUS_SUCCESS)
  66   65                  return (SDRC_ERROR);
  67   66  
  68   67          if (smbsr_encode_result(sr, 1, 0, "bww", 1, sr->smb_fid, 0))
  69   68                  return (SDRC_ERROR);
↓ open down ↓ 12 lines elided ↑ open up ↑
  82   81          int rc;
  83   82  
  84   83          bzero(op, sizeof (sr->arg.open));
  85   84  
  86   85          rc = smbsr_decode_vwv(sr, "wl", &op->dattr, &op->mtime.tv_sec);
  87   86          if (rc == 0)
  88   87                  rc = smbsr_decode_data(sr, "%S", sr, &op->fqi.fq_path.pn_path);
  89   88  
  90   89          op->create_disposition = FILE_CREATE;
  91   90  
  92      -        DTRACE_SMB_2(op__CreateNew__start, smb_request_t *, sr,
  93      -            struct open_param *, op);
       91 +        DTRACE_SMB_START(op__CreateNew, smb_request_t *, sr); /* arg.open */
  94   92  
  95   93          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
  96   94  }
  97   95  
  98   96  void
  99   97  smb_post_create_new(smb_request_t *sr)
 100   98  {
 101      -        DTRACE_SMB_1(op__CreateNew__done, smb_request_t *, sr);
       99 +        DTRACE_SMB_DONE(op__CreateNew, smb_request_t *, sr);
 102  100  }
 103  101  
 104  102  smb_sdrc_t
 105  103  smb_com_create_new(smb_request_t *sr)
 106  104  {
 107  105          if (smb_common_create(sr) != NT_STATUS_SUCCESS)
 108  106                  return (SDRC_ERROR);
 109  107  
 110  108          if (smbsr_encode_result(sr, 1, 0, "bww", 1, sr->smb_fid, 0))
 111  109                  return (SDRC_ERROR);
↓ open down ↓ 13 lines elided ↑ open up ↑
 125  123          int rc;
 126  124  
 127  125          bzero(op, sizeof (sr->arg.open));
 128  126  
 129  127          rc = smbsr_decode_vwv(sr, "wl", &reserved, &op->mtime.tv_sec);
 130  128          if (rc == 0)
 131  129                  rc = smbsr_decode_data(sr, "%S", sr, &op->fqi.fq_path.pn_path);
 132  130  
 133  131          op->create_disposition = FILE_CREATE;
 134  132  
 135      -        DTRACE_SMB_2(op__CreateTemporary__start, smb_request_t *, sr,
 136      -            struct open_param *, op);
      133 +        DTRACE_SMB_START(op__CreateTemporary, smb_request_t *, sr);
 137  134  
 138  135          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 139  136  }
 140  137  
 141  138  void
 142  139  smb_post_create_temporary(smb_request_t *sr)
 143  140  {
 144      -        DTRACE_SMB_1(op__CreateTemporary__done, smb_request_t *, sr);
      141 +        DTRACE_SMB_DONE(op__CreateTemporary, smb_request_t *, sr);
 145  142  }
 146  143  
 147  144  smb_sdrc_t
 148  145  smb_com_create_temporary(smb_request_t *sr)
 149  146  {
 150  147          static uint16_t tmp_id = 10000;
 151  148          struct open_param *op = &sr->arg.open;
 152  149          char name[SMB_CREATE_NAMEBUF_SZ];
 153  150          char *buf;
 154  151          uint16_t bcc;
↓ open down ↓ 3 lines elided ↑ open up ↑
 158  155          bcc += snprintf(name, SMB_CREATE_NAMEBUF_SZ, "tt%05d.tmp", tmp_id);
 159  156  
 160  157          buf = smb_srm_zalloc(sr, MAXPATHLEN);
 161  158          (void) snprintf(buf, MAXPATHLEN, "%s\\%s",
 162  159              op->fqi.fq_path.pn_path, name);
 163  160          op->fqi.fq_path.pn_path = buf;
 164  161  
 165  162          if (smb_common_create(sr) != NT_STATUS_SUCCESS)
 166  163                  return (SDRC_ERROR);
 167  164  
 168      -        if (smbsr_encode_result(sr, 1, VAR_BCC, "bww%S", 1, sr->smb_fid,
      165 +        if (smbsr_encode_result(sr, 1, VAR_BCC, "bww%s", 1, sr->smb_fid,
 169  166              VAR_BCC, sr, name))
 170  167                  return (SDRC_ERROR);
 171  168  
 172  169          return (SDRC_SUCCESS);
 173  170  }
 174  171  
 175  172  /*
 176  173   * Common create file function.  The file is opened in compatibility
 177  174   * mode with read/write access.
 178  175   */
↓ open down ↓ 13 lines elided ↑ open up ↑
 192  189              op->fqi.fq_path.pn_path);
 193  190  
 194  191          if (sr->smb_flg & SMB_FLAGS_OPLOCK) {
 195  192                  if (sr->smb_flg & SMB_FLAGS_OPLOCK_NOTIFY_ANY)
 196  193                          op->op_oplock_level = SMB_OPLOCK_BATCH;
 197  194                  else
 198  195                          op->op_oplock_level = SMB_OPLOCK_EXCLUSIVE;
 199  196          } else {
 200  197                  op->op_oplock_level = SMB_OPLOCK_NONE;
 201  198          }
 202      -        op->op_oplock_levelII = B_FALSE;
 203  199  
 204  200          status = smb_common_open(sr);
      201 +        if (status == 0 && op->op_oplock_level != SMB_OPLOCK_NONE) {
      202 +                /* Oplock req. in op->op_oplock_level etc. */
      203 +                smb1_oplock_acquire(sr, B_FALSE);
      204 +        }
 205  205  
 206  206          if (op->op_oplock_level == SMB_OPLOCK_NONE) {
 207  207                  sr->smb_flg &=
 208  208                      ~(SMB_FLAGS_OPLOCK | SMB_FLAGS_OPLOCK_NOTIFY_ANY);
 209  209          }
 210  210  
 211  211          if (status)
 212  212                  smbsr_status(sr, status, 0, 0);
 213  213  
 214  214          return (status);
 215  215  }
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX