Print this page
3882 remove xmod & friends

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/flock.c
          +++ new/usr/src/uts/common/os/flock.c
↓ open down ↓ 10 lines elided ↑ open up ↑
  11   11   * and limitations under the License.
  12   12   *
  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      -/* ONC_PLUS EXTRACT START */
  22   21  
  23   22  /*
  24   23   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  25   24   * Use is subject to license terms.
  26   25   */
  27   26  
  28   27  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  29   28  /*      All Rights Reserved */
  30   29  
  31   30  #pragma ident   "%Z%%M% %I%     %E% SMI"
↓ open down ↓ 570 lines elided ↑ open up ↑
 602  601          flk_init_callback(newcb, cb_fcn, cbdata);
 603  602  
 604  603          if (cblist == NULL)
 605  604                  return;
 606  605  
 607  606          newcb->cb_prev = cblist->cb_prev;
 608  607          newcb->cb_next = cblist;
 609  608          cblist->cb_prev->cb_next = newcb;
 610  609          cblist->cb_prev = newcb;
 611  610  }
 612      -/* ONC_PLUS EXTRACT END */
 613  611  
 614  612  /*
 615  613   * Initialize the flk_edge_cache data structure and create the
 616  614   * nlm_reg_status array.
 617  615   */
 618  616  
 619  617  void
 620  618  flk_init(void)
 621  619  {
 622  620          uint_t  i;
↓ open down ↓ 354 lines elided ↑ open up ↑
 977  975                   */
 978  976                  if (flk_check_deadlock(request))
 979  977                          return (EDEADLK);
 980  978                  /*
 981  979                   * this thread has to sleep
 982  980                   */
 983  981                  return (flk_wait_execute_request(request));
 984  982          }
 985  983  }
 986  984  
 987      -/* ONC_PLUS EXTRACT START */
 988  985  /*
 989  986   * The actual execution of the request in the simple case is only to
 990  987   * insert the 'request' in the list of active locks if it is not an
 991  988   * UNLOCK.
 992  989   * We have to consider the existing active locks' relation to
 993  990   * this 'request' if they are owned by same process. flk_relation() does
 994  991   * this job and sees to that the dependency graph information is maintained
 995  992   * properly.
 996  993   */
 997  994  
↓ open down ↓ 38 lines elided ↑ open up ↑
1036 1033  
1037 1034          /*
1038 1035           * insert in active queue
1039 1036           */
1040 1037  
1041 1038          if (request->l_type != F_UNLCK)
1042 1039                  flk_insert_active_lock(request);
1043 1040  
1044 1041          return (0);
1045 1042  }
1046      -/* ONC_PLUS EXTRACT END */
1047 1043  
1048 1044  /*
1049 1045   * 'request' is blocked by some one therefore we put it into sleep queue.
1050 1046   */
1051 1047  static int
1052 1048  flk_wait_execute_request(lock_descriptor_t *request)
1053 1049  {
1054 1050          graph_t *gp = request->l_graph;
1055 1051          callb_cpr_t     *cprp;          /* CPR info from callback */
1056 1052          struct flock_globals *fg;
↓ open down ↓ 1179 lines elided ↑ open up ↑
2236 2232                          }
2237 2233                          lock = lock->l_next;
2238 2234                  }
2239 2235          }
2240 2236  
2241 2237  done:
2242 2238          mutex_exit(&gp->gp_mutex);
2243 2239          return (result);
2244 2240  }
2245 2241  
2246      -/* ONC_PLUS EXTRACT START */
2247 2242  /*
2248 2243   * Determine whether there are any locks for the given vnode with a remote
2249 2244   * sysid.  Returns zero if not, non-zero if there are.
2250 2245   *
2251 2246   * Note that the return value from this function is potentially invalid
2252 2247   * once it has been returned.  The caller is responsible for providing its
2253 2248   * own synchronization mechanism to ensure that the return value is useful
2254 2249   * (e.g., see nfs_lockcompletion()).
2255 2250   */
2256 2251  int
↓ open down ↓ 350 lines elided ↑ open up ↑
2607 2602                  STACK_POP(link_stack, l_stack);
2608 2603                  flk_wakeup(lock, 1);
2609 2604                  flk_free_lock(lock);
2610 2605          }
2611 2606  
2612 2607          CHECK_SLEEPING_LOCKS(gp);
2613 2608          CHECK_ACTIVE_LOCKS(gp);
2614 2609          CHECK_OWNER_LOCKS(gp, pid, sysid, vp);
2615 2610          mutex_exit(&gp->gp_mutex);
2616 2611  }
2617      -/* ONC_PLUS EXTRACT END */
2618 2612  
2619 2613  
2620 2614  /*
2621 2615   * Called from 'fs' read and write routines for files that have mandatory
2622 2616   * locking enabled.
2623 2617   */
2624 2618  
2625 2619  int
2626 2620  chklock(
2627 2621          struct vnode    *vp,
↓ open down ↓ 18 lines elided ↑ open up ↑
2646 2640                  bf.l_pid = ct->cc_pid;
2647 2641                  bf.l_sysid = ct->cc_sysid;
2648 2642          }
2649 2643          i = (fmode & (FNDELAY|FNONBLOCK)) ? INOFLCK : INOFLCK|SLPFLCK;
2650 2644          if ((i = reclock(vp, &bf, i, 0, offset, NULL)) != 0 ||
2651 2645              bf.l_type != F_UNLCK)
2652 2646                  error = i ? i : EAGAIN;
2653 2647          return (error);
2654 2648  }
2655 2649  
2656      -/* ONC_PLUS EXTRACT START */
2657 2650  /*
2658 2651   * convoff - converts the given data (start, whence) to the
2659 2652   * given whence.
2660 2653   */
2661 2654  int
2662 2655  convoff(vp, lckdat, whence, offset)
2663 2656          struct vnode    *vp;
2664 2657          struct flock64  *lckdat;
2665 2658          int             whence;
2666 2659          offset_t        offset;
↓ open down ↓ 32 lines elided ↑ open up ↑
2699 2692                  /* FALLTHRU */
2700 2693          case 0:
2701 2694                  break;
2702 2695          default:
2703 2696                  return (EINVAL);
2704 2697          }
2705 2698  
2706 2699          lckdat->l_whence = (short)whence;
2707 2700          return (0);
2708 2701  }
2709      -/* ONC_PLUS EXTRACT END */
2710 2702  
2711 2703  
2712 2704  /*      proc_graph function definitions */
2713 2705  
2714 2706  /*
2715 2707   * Function checks for deadlock due to the new 'lock'. If deadlock found
2716 2708   * edges of this lock are freed and returned.
2717 2709   */
2718 2710  
2719 2711  static int
↓ open down ↓ 343 lines elided ↑ open up ↑
3063 3055                  pep = flk_get_proc_edge();
3064 3056                  pep->to_proc = toproc;
3065 3057                  pep->refcount = 1;
3066 3058                  toproc->incount++;
3067 3059                  pep->next = fromproc->edge;
3068 3060                  fromproc->edge = pep;
3069 3061          }
3070 3062          mutex_exit(&flock_lock);
3071 3063  }
3072 3064  
3073      -/* ONC_PLUS EXTRACT START */
3074 3065  /*
3075 3066   * Set the control status for lock manager requests.
3076 3067   *
3077 3068   */
3078 3069  
3079 3070  /*
3080 3071   * PSARC case 1997/292
3081 3072   *
3082 3073   * Requires: "nlmid" must be >= 1 and <= clconf_maximum_nodeid().
3083 3074   * Effects: Set the state of the NLM server identified by "nlmid"
↓ open down ↓ 601 lines elided ↑ open up ↑
3685 3676                          if (IS_LOCKMGR(lock) && lock->l_zoneid == zoneid) {
3686 3677                                  ASSERT(IS_ACTIVE(lock));
3687 3678                                  flk_delete_active_lock(lock, 0);
3688 3679                                  flk_wakeup(lock, 1);
3689 3680                                  flk_free_lock(lock);
3690 3681                          }
3691 3682                  }
3692 3683                  mutex_exit(&gp->gp_mutex);
3693 3684          }
3694 3685  }
3695      -/* ONC_PLUS EXTRACT END */
3696 3686  
3697 3687  
3698 3688  /*
3699 3689   * Wait until a lock is granted, cancelled, or interrupted.
3700 3690   */
3701 3691  
3702 3692  static void
3703 3693  wait_for_lock(lock_descriptor_t *request)
3704 3694  {
3705 3695          graph_t *gp = request->l_graph;
↓ open down ↓ 2 lines elided ↑ open up ↑
3708 3698  
3709 3699          while (!(IS_GRANTED(request)) && !(IS_CANCELLED(request)) &&
3710 3700              !(IS_INTERRUPTED(request))) {
3711 3701                  if (!cv_wait_sig(&request->l_cv, &gp->gp_mutex)) {
3712 3702                          flk_set_state(request, FLK_INTERRUPTED_STATE);
3713 3703                          request->l_state |= INTERRUPTED_LOCK;
3714 3704                  }
3715 3705          }
3716 3706  }
3717 3707  
3718      -/* ONC_PLUS EXTRACT START */
3719 3708  /*
3720 3709   * Create an flock structure from the existing lock information
3721 3710   *
3722 3711   * This routine is used to create flock structures for the lock manager
3723 3712   * to use in a reclaim request.  Since the lock was originated on this
3724 3713   * host, it must be conforming to UNIX semantics, so no checking is
3725 3714   * done to make sure it falls within the lower half of the 32-bit range.
3726 3715   */
3727 3716  
3728 3717  static void
↓ open down ↓ 134 lines elided ↑ open up ↑
3863 3852                  } else {
3864 3853                          flrp->l_start = blocker->l_start;
3865 3854                          if (blocker->l_end == MAX_U_OFFSET_T)
3866 3855                                  flrp->l_len = 0;
3867 3856                          else
3868 3857                                  flrp->l_len = blocker->l_end -
3869 3858                                          blocker->l_start + 1;
3870 3859                  }
3871 3860          }
3872 3861  }
3873      -/* ONC_PLUS EXTRACT END */
3874 3862  
3875 3863  /*
3876 3864   * PSARC case 1997/292
3877 3865   */
3878 3866  /*
3879 3867   * This is the public routine exported by flock.h.
3880 3868   */
3881 3869  void
3882 3870  cl_flk_change_nlm_state_to_unknown(int nlmid)
3883 3871  {
↓ open down ↓ 346 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX