Print this page
pbchk
pbchk
cleanup port_free_event_local() semantics

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/portfs/port_fop.c
          +++ new/usr/src/uts/common/fs/portfs/port_fop.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26   26  /*
  27      - * Copyright (c) 2018, Joyent, Inc.
       27 + * Copyright 2020 Joyent, Inc.
  28   28   */
  29   29  
  30   30  /*
  31   31   * File Events Notification
  32   32   * ------------------------
  33   33   *
  34   34   * The File Events Notification facility provides file and directory change
  35   35   * notification. It is implemented as an event source(PORT_SOURCE_FILE)
  36   36   * under the Event Ports framework. Therefore the API is an extension to
  37   37   * the Event Ports API.
↓ open down ↓ 212 lines elided ↑ open up ↑
 250  250  
 251  251  
 252  252  /*
 253  253   * Fem hooks.
 254  254   */
 255  255  const fs_operation_def_t        port_vnodesrc_template[] = {
 256  256          VOPNAME_OPEN,           { .femop_open = port_fop_open },
 257  257          VOPNAME_READ,           { .femop_read = port_fop_read },
 258  258          VOPNAME_WRITE,          { .femop_write = port_fop_write },
 259  259          VOPNAME_MAP,            { .femop_map = port_fop_map },
 260      -        VOPNAME_SETATTR,        { .femop_setattr = port_fop_setattr },
      260 +        VOPNAME_SETATTR,        { .femop_setattr = port_fop_setattr },
 261  261          VOPNAME_CREATE,         { .femop_create = port_fop_create },
 262  262          VOPNAME_REMOVE,         { .femop_remove = port_fop_remove },
 263  263          VOPNAME_LINK,           { .femop_link = port_fop_link },
 264  264          VOPNAME_RENAME,         { .femop_rename = port_fop_rename },
 265  265          VOPNAME_MKDIR,          { .femop_mkdir = port_fop_mkdir },
 266  266          VOPNAME_RMDIR,          { .femop_rmdir = port_fop_rmdir },
 267  267          VOPNAME_READDIR,        { .femop_readdir = port_fop_readdir },
 268  268          VOPNAME_SYMLINK,        { .femop_symlink = port_fop_symlink },
 269      -        VOPNAME_SETSECATTR,     { .femop_setsecattr = port_fop_setsecattr },
      269 +        VOPNAME_SETSECATTR,     { .femop_setsecattr = port_fop_setsecattr },
 270  270          VOPNAME_VNEVENT,        { .femop_vnevent = port_fop_vnevent },
 271  271          NULL,   NULL
 272  272  };
 273  273  
 274  274  /*
 275  275   * Fsem - vfs ops hooks
 276  276   */
 277  277  const fs_operation_def_t        port_vfssrc_template[] = {
 278      -        VFSNAME_UNMOUNT,        { .fsemop_unmount = port_fop_unmount },
      278 +        VFSNAME_UNMOUNT,        { .fsemop_unmount = port_fop_unmount },
 279  279          NULL,   NULL
 280  280  };
 281  281  
 282  282  fem_t *fop_femop;
 283  283  fsem_t *fop_fsemop;
 284  284  
 285  285  static fem_t *
 286  286  port_fop_femop()
 287  287  {
 288  288          fem_t *femp;
↓ open down ↓ 183 lines elided ↑ open up ↑
 472  472          port_kevent_t   *pkevp;
 473  473  
 474  474  
 475  475          ASSERT(MUTEX_HELD(&pfcp->pfc_lock));
 476  476  
 477  477          pkevp = pfp->pfop_pev;
 478  478          pfp->pfop_pev = NULL;
 479  479  
 480  480          if (pkevp != NULL) {
 481  481                  (void) port_remove_done_event(pkevp);
 482      -                port_free_event_local(pkevp, 0);
      482 +                port_free_event_local(pkevp, B_TRUE);
 483  483          }
 484  484  
 485  485          port_pcache_delete(pfcp, pfp);
 486  486  
 487  487          if (pfp->pfop_cname != NULL)
 488  488                  kmem_free(pfp->pfop_cname, pfp->pfop_clen + 1);
 489  489          kmem_free(pfp, sizeof (portfop_t));
 490  490          if (pfcp->pfc_objcount == 0)
 491  491                  cv_signal(&pfcp->pfc_lclosecv);
 492  492  }
↓ open down ↓ 230 lines elided ↑ open up ↑
 723  723          }
 724  724          return (pfp);
 725  725  }
 726  726  
 727  727  /*
 728  728   * Given the file name, get the vnode and also the directory vnode
 729  729   * On return, the vnodes are held (VN_HOLD). The caller has to VN_RELE
 730  730   * the vnode(s).
 731  731   */
 732  732  int
 733      -port_fop_getdvp(void *objptr, vnode_t **vp, vnode_t **dvp,
 734      -        char **cname, int *len, int follow)
      733 +port_fop_getdvp(void *objptr, vnode_t **vp, vnode_t **dvp, char **cname,
      734 +    int *len, int follow)
 735  735  {
 736  736          int error = 0;
 737  737          struct pathname pn;
 738  738          char *fname;
 739  739  
 740  740          if (get_udatamodel() == DATAMODEL_NATIVE) {
 741  741                  fname = ((file_obj_t *)objptr)->fo_name;
 742  742  #ifdef  _SYSCALL32_IMPL
 743  743          } else {
 744  744                  fname = (caddr_t)(uintptr_t)((file_obj32_t *)objptr)->fo_name;
↓ open down ↓ 63 lines elided ↑ open up ↑
 808  808  
 809  809  
 810  810  /*
 811  811   * Compare time stamps and generate an event if it has changed.
 812  812   * Note that the port cache pointer will be valid due to a reference
 813  813   * to the port. We need to grab the port cache lock and verify that
 814  814   * the pfp is still the same before proceeding to deliver an event.
 815  815   */
 816  816  static void
 817  817  port_check_timestamp(portfop_cache_t *pfcp, vnode_t *vp, vnode_t *dvp,
 818      -        portfop_t *pfp, void *objptr, uintptr_t object)
      818 +    portfop_t *pfp, void *objptr, uintptr_t object)
 819  819  {
 820  820          vattr_t         vatt;
 821  821          portfop_vp_t    *pvp = vp->v_fopdata;
 822  822          int             events = 0;
 823  823          port_kevent_t   *pkevp;
 824  824          file_obj_t      *fobj;
 825  825          portfop_t       *tpfp;
 826  826  
 827  827          /*
 828  828           * If time stamps are specified, get attributes and compare.
↓ open down ↓ 266 lines elided ↑ open up ↑
1095 1095  }
1096 1096  
1097 1097  
1098 1098  /*
1099 1099   * Allocate and add a portfop_t to the per port cache. Also add the portfop_t
1100 1100   * to the vnode's list. The association is identified by the object pointer
1101 1101   * address and pid.
1102 1102   */
1103 1103  int
1104 1104  port_pfp_setup(portfop_t **pfpp, port_t *pp, vnode_t *vp, portfop_cache_t *pfcp,
1105      -        uintptr_t object, int events, void *user, char *cname, int clen,
1106      -        vnode_t *dvp)
     1105 +    uintptr_t object, int events, void *user, char *cname, int clen,
     1106 +    vnode_t *dvp)
1107 1107  {
1108 1108          portfop_t       *pfp = NULL;
1109 1109          port_kevent_t   *pkevp;
1110 1110          fem_t           *femp;
1111 1111          int             error = 0;
1112 1112          portfop_vp_t    *pvp;
1113 1113  
1114 1114  
1115 1115          /*
1116 1116           * The port cache mutex is held.
↓ open down ↓ 486 lines elided ↑ open up ↑
1603 1603  static void
1604 1604  port_close_fop(void *arg, int port, pid_t pid, int lastclose)
1605 1605  {
1606 1606          port_t          *pp = arg;
1607 1607          portfop_cache_t *pfcp;
1608 1608          portfop_t       **hashtbl;
1609 1609          portfop_t       *pfp;
1610 1610          portfop_t       *pfpnext;
1611 1611          int             index, i;
1612 1612          port_source_t   *pse;
1613      -        vnode_t         *tdvp = NULL;
     1613 +        vnode_t *tdvp = NULL;
1614 1614          vnode_t         *vpl[PORTFOP_NVP];
1615 1615  
1616 1616          pse = port_getsrc(pp, PORT_SOURCE_FILE);
1617 1617  
1618 1618          /*
1619 1619           * No source or no cache, nothing to do.
1620 1620           */
1621 1621          if (pse == NULL ||
1622 1622              (pfcp = (portfop_cache_t *)pse->portsrc_data) == NULL)
1623 1623                  return;
↓ open down ↓ 349 lines elided ↑ open up ↑
1973 1973          if (op & FOP_ACCESS_MASK) {
1974 1974                  event  |= FILE_ACCESS;
1975 1975          }
1976 1976          if (op & FOP_ATTRIB_MASK) {
1977 1977                  event  |= FILE_ATTRIB;
1978 1978          }
1979 1979          if (op & FOP_TRUNC_MASK) {
1980 1980                  event  |= FILE_TRUNC;
1981 1981          }
1982 1982          if (event) {
1983      -                port_fop_sendevent(vp,  event, NULL, NULL);
     1983 +                port_fop_sendevent(vp, event, NULL, NULL);
1984 1984          }
1985 1985  }
1986 1986  
1987 1987  static int port_forceunmount(vfs_t *vfsp)
1988 1988  {
1989 1989          char *fsname = vfssw[vfsp->vfs_fstype].vsw_name;
1990 1990  
1991 1991          if (fsname == NULL) {
1992 1992                  return (0);
1993 1993          }
↓ open down ↓ 370 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX