Print this page
Build provider 3rd arg from smb_request_t
hacking...
NEX-1643 dtrace provider for smbsrv
Also illumos 1841:
 DTrace smb provider was mis-implemented, doesn't exist.
Add back handlers for read/write raw, so that
 legacy dtrace consumers can find the probes.
Kill extra arg in smb_negotiate
Fix missing "done" probe with smb_notify
Add example consumer: smb-trace.d
fix soi_pid

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/smbsrv/smb_write.c
          +++ new/usr/src/uts/common/fs/smbsrv/smb_write.c
↓ open down ↓ 53 lines elided ↑ open up ↑
  54   54          param = kmem_zalloc(sizeof (smb_rw_param_t), KM_SLEEP);
  55   55          sr->arg.rw = param;
  56   56          param->rw_magic = SMB_RW_MAGIC;
  57   57  
  58   58          rc = smbsr_decode_vwv(sr, "wwl", &sr->smb_fid, &count, &off);
  59   59  
  60   60          param->rw_count = (uint32_t)count;
  61   61          param->rw_offset = (uint64_t)off;
  62   62          param->rw_vdb.vdb_uio.uio_loffset = (offset_t)param->rw_offset;
  63   63  
  64      -        DTRACE_SMB_2(op__Write__start, smb_request_t *, sr,
  65      -            smb_rw_param_t *, param);
       64 +        DTRACE_SMB_1(op__Write__start, smb_request_t *, sr); /* arg.rw */
  66   65  
  67   66          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
  68   67  }
  69   68  
  70   69  void
  71   70  smb_post_write(smb_request_t *sr)
  72   71  {
  73      -        DTRACE_SMB_2(op__Write__done, smb_request_t *, sr,
  74      -            smb_rw_param_t *, sr->arg.rw);
       72 +        DTRACE_SMB_1(op__Write__done, smb_request_t *, sr); /* arg.rw */
  75   73  
  76   74          kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
  77   75  }
  78   76  
  79   77  smb_sdrc_t
  80   78  smb_com_write(smb_request_t *sr)
  81   79  {
  82   80          smb_rw_param_t *param = sr->arg.rw;
  83   81          int rc;
  84   82  
↓ open down ↓ 59 lines elided ↑ open up ↑
 144  142                  rc = smbsr_decode_vwv(sr, "wwll12.", &sr->smb_fid,
 145  143                      &count, &off, &param->rw_last_write);
 146  144          } else {
 147  145                  rc = smbsr_decode_vwv(sr, "wwll", &sr->smb_fid,
 148  146                      &count, &off, &param->rw_last_write);
 149  147          }
 150  148  
 151  149          param->rw_count = (uint32_t)count;
 152  150          param->rw_offset = (uint64_t)off;
 153  151  
 154      -        DTRACE_SMB_2(op__WriteAndClose__start, smb_request_t *, sr,
 155      -            smb_rw_param_t *, param);
      152 +        DTRACE_SMB_1(op__WriteAndClose__start, smb_request_t *, sr); /* arg.rw */
 156  153  
 157  154          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 158  155  }
 159  156  
 160  157  void
 161  158  smb_post_write_and_close(smb_request_t *sr)
 162  159  {
 163      -        DTRACE_SMB_2(op__WriteAndClose__done, smb_request_t *, sr,
 164      -            smb_rw_param_t *, sr->arg.rw);
      160 +        DTRACE_SMB_1(op__WriteAndClose__done, smb_request_t *, sr); /* arg.rw */
 165  161  
 166  162          kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
 167  163  }
 168  164  
 169  165  smb_sdrc_t
 170  166  smb_com_write_and_close(smb_request_t *sr)
 171  167  {
 172  168          smb_rw_param_t *param = sr->arg.rw;
 173  169          uint16_t count;
 174  170          int rc = 0;
↓ open down ↓ 67 lines elided ↑ open up ↑
 242  238  
 243  239          param = kmem_zalloc(sizeof (smb_rw_param_t), KM_SLEEP);
 244  240          sr->arg.rw = param;
 245  241          param->rw_magic = SMB_RW_MAGIC;
 246  242  
 247  243          rc = smbsr_decode_vwv(sr, "wwlw", &sr->smb_fid, &count, &off, &remcnt);
 248  244  
 249  245          param->rw_count = (uint32_t)count;
 250  246          param->rw_offset = (uint64_t)off;
 251  247  
 252      -        DTRACE_SMB_2(op__WriteAndUnlock__start, smb_request_t *, sr,
 253      -            smb_rw_param_t *, param);
      248 +        DTRACE_SMB_1(op__WriteAndUnlock__start, smb_request_t *, sr); /* arg.rw */
 254  249  
 255  250          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 256  251  }
 257  252  
 258  253  void
 259  254  smb_post_write_and_unlock(smb_request_t *sr)
 260  255  {
 261      -        DTRACE_SMB_2(op__WriteAndUnlock__done, smb_request_t *, sr,
 262      -            smb_rw_param_t *, sr->arg.rw);
      256 +        DTRACE_SMB_1(op__WriteAndUnlock__done, smb_request_t *, sr); /* arg.rw */
 263  257  
 264  258          kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
 265  259  }
 266  260  
 267  261  smb_sdrc_t
 268  262  smb_com_write_and_unlock(smb_request_t *sr)
 269  263  {
 270  264          smb_rw_param_t *param = sr->arg.rw;
 271  265          uint32_t lk_pid;
 272  266          uint32_t status;
↓ open down ↓ 45 lines elided ↑ open up ↑
 318  312                      ERRDOS, ERROR_NOT_LOCKED);
 319  313                  return (SDRC_ERROR);
 320  314          }
 321  315  
 322  316          rc = smbsr_encode_result(sr, 1, 0, "bww", 1,
 323  317              (uint16_t)param->rw_count, 0);
 324  318          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 325  319  }
 326  320  
 327  321  /*
      322 + * The SMB_COM_WRITE_RAW protocol was a negotiated option introduced in
      323 + * SMB Core Plus to maximize performance when writing a large block
      324 + * of data to a server.  It's obsolete and no longer supported.
      325 + *
      326 + * We keep a handler for it so the dtrace provider can see if
      327 + * the client tried to use this command.
      328 + */
      329 +smb_sdrc_t
      330 +smb_pre_write_raw(smb_request_t *sr)
      331 +{
      332 +        smb_rw_param_t *param;
      333 +        uint32_t off_low;
      334 +        uint32_t timeout;
      335 +        uint32_t off_high;
      336 +        uint16_t datalen;
      337 +        uint16_t total;
      338 +        int rc;
      339 +
      340 +        param = kmem_zalloc(sizeof (smb_rw_param_t), KM_SLEEP);
      341 +        sr->arg.rw = param;
      342 +
      343 +        if (sr->smb_wct == 12) {
      344 +                rc = smbsr_decode_vwv(sr, "ww2.llw4.ww", &sr->smb_fid, &total,
      345 +                    &off_low, &timeout, &param->rw_mode, &datalen,
      346 +                    &param->rw_dsoff);
      347 +
      348 +                param->rw_offset = (uint64_t)off_low;
      349 +        } else {
      350 +                rc = smbsr_decode_vwv(sr, "ww2.llw4.wwl", &sr->smb_fid, &total,
      351 +                    &off_low, &timeout, &param->rw_mode, &datalen,
      352 +                    &param->rw_dsoff, &off_high);
      353 +
      354 +                param->rw_offset = ((uint64_t)off_high << 32) | off_low;
      355 +        }
      356 +
      357 +        param->rw_count = (uint32_t)datalen;
      358 +        param->rw_total = (uint32_t)total;
      359 +
      360 +        DTRACE_SMB_1(op__WriteRaw__start, smb_request_t *, sr); /* arg.rw */
      361 +
      362 +        return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
      363 +}
      364 +
      365 +void
      366 +smb_post_write_raw(smb_request_t *sr)
      367 +{
      368 +        DTRACE_SMB_1(op__WriteRaw__done, smb_request_t *, sr); /* arg.rw */
      369 +
      370 +        kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
      371 +}
      372 +
      373 +smb_sdrc_t
      374 +smb_com_write_raw(struct smb_request *sr)
      375 +{
      376 +        smbsr_error(sr, NT_STATUS_NOT_SUPPORTED, ERRDOS,
      377 +            ERROR_NOT_SUPPORTED);
      378 +        return (SDRC_ERROR);
      379 +}
      380 +
      381 +/*
 328  382   * Write bytes to a file (SMB Core).  This request was extended in
 329  383   * LM 0.12 to support 64-bit offsets, indicated by sending a wct of
 330  384   * 14, instead of 12, and including additional offset information.
 331  385   *
 332  386   * A ByteCount of 0 does not truncate the file - use SMB_COM_WRITE
 333  387   * to truncate a file.  A zero length merely transfers zero bytes.
 334  388   *
 335  389   * If bit 0 of WriteMode is set, Fid must refer to a disk file and
 336  390   * the data must be on stable storage before responding.
 337  391   *
↓ open down ↓ 42 lines elided ↑ open up ↑
 380  434  
 381  435          /*
 382  436           * Work-around a Win7 bug, where it fails to set the
 383  437           * CAP_LARGE_WRITEX flag during session setup.  Assume
 384  438           * a large write if the data remaining is >= 64k.
 385  439           */
 386  440          if ((sr->session->capabilities & CAP_LARGE_WRITEX) != 0 ||
 387  441              (sr->smb_data.max_bytes > (sr->smb_data.chain_offset + 0xFFFF)))
 388  442                  param->rw_count |= ((uint32_t)datalen_high << 16);
 389  443  
 390      -        DTRACE_SMB_2(op__WriteX__start, smb_request_t *, sr,
 391      -            smb_rw_param_t *, param);
      444 +        DTRACE_SMB_1(op__WriteX__start, smb_request_t *, sr); /* arg.rw */
 392  445  
 393  446          return ((rc == 0) ? SDRC_SUCCESS : SDRC_ERROR);
 394  447  }
 395  448  
 396  449  void
 397  450  smb_post_write_andx(smb_request_t *sr)
 398  451  {
 399      -        DTRACE_SMB_2(op__WriteX__done, smb_request_t *, sr,
 400      -            smb_rw_param_t *, sr->arg.rw);
      452 +        DTRACE_SMB_1(op__WriteX__done, smb_request_t *, sr); /* arg.rw */
 401  453  
 402  454          kmem_free(sr->arg.rw, sizeof (smb_rw_param_t));
 403  455  }
 404  456  
 405  457  smb_sdrc_t
 406  458  smb_com_write_andx(smb_request_t *sr)
 407  459  {
 408  460          smb_rw_param_t *param = sr->arg.rw;
 409  461          uint16_t count_high;
 410  462          uint16_t count_low;
↓ open down ↓ 174 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX