Print this page
195 Need replacement for nfs/lockd+klm

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/share.c
          +++ new/usr/src/uts/common/os/share.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  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 2008 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
       26 +/*
       27 + * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
       28 + */
       29 +
  26   30  #include <sys/types.h>
  27   31  #include <sys/sysmacros.h>
  28   32  #include <sys/param.h>
  29   33  #include <sys/systm.h>
  30   34  #include <sys/fcntl.h>
  31   35  #include <sys/vfs.h>
  32   36  #include <sys/vnode.h>
  33   37  #include <sys/share.h>
  34   38  #include <sys/cmn_err.h>
  35   39  #include <sys/kmem.h>
↓ open down ↓ 3 lines elided ↑ open up ↑
  39   43  #include <sys/nbmlock.h>
  40   44  
  41   45  int share_debug = 0;
  42   46  
  43   47  #ifdef DEBUG
  44   48  static void print_shares(struct vnode *);
  45   49  static void print_share(struct shrlock *);
  46   50  #endif
  47   51  
  48   52  static int isreadonly(struct vnode *);
       53 +static void do_cleanshares(struct vnode *, pid_t, int32_t);
  49   54  
       55 +
  50   56  /*
  51   57   * Add the share reservation shr to vp.
  52   58   */
  53   59  int
  54   60  add_share(struct vnode *vp, struct shrlock *shr)
  55   61  {
  56   62          struct shrlocklist *shrl;
  57   63  
  58   64          /*
  59   65           * An access of zero is not legal, however some older clients
↓ open down ↓ 268 lines elided ↑ open up ↑
 328  334          return (found ? 0 : EINVAL);
 329  335  }
 330  336  
 331  337  /*
 332  338   * Clean up all local share reservations that the given process has with
 333  339   * the given file.
 334  340   */
 335  341  void
 336  342  cleanshares(struct vnode *vp, pid_t pid)
 337  343  {
      344 +        do_cleanshares(vp, pid, 0);
      345 +}
      346 +
      347 +/*
      348 + * Cleanup all remote share reservations that
      349 + * were made by the given sysid on given vnode.
      350 + */
      351 +void
      352 +cleanshares_by_sysid(struct vnode *vp, int32_t sysid)
      353 +{
      354 +        if (sysid == 0)
      355 +                return;
      356 +
      357 +        do_cleanshares(vp, 0, sysid);
      358 +}
      359 +
      360 +/*
      361 + * Cleanup share reservations on given vnode made
      362 + * by the either given pid or sysid.
      363 + * If sysid is 0, remove all shares made by given pid,
      364 + * otherwise all shares made by the given sysid will
      365 + * be removed.
      366 + */
      367 +static void
      368 +do_cleanshares(struct vnode *vp, pid_t pid, int32_t sysid)
      369 +{
 338  370          struct shrlock shr;
 339  371  
 340  372          if (vp->v_shrlocks == NULL)
 341  373                  return;
 342  374  
 343  375          shr.s_access = 0;
 344  376          shr.s_deny = 0;
 345  377          shr.s_pid = pid;
 346      -        shr.s_sysid = 0;
      378 +        shr.s_sysid = sysid;
 347  379          shr.s_own_len = 0;
 348  380          shr.s_owner = NULL;
 349  381  
 350  382          (void) del_share(vp, &shr);
 351  383  }
 352  384  
 353  385  static int
 354  386  is_match_for_has_remote(int32_t sysid1, int32_t sysid2)
 355  387  {
 356  388          int result = 0;
↓ open down ↓ 265 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX