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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/flock.c
          +++ new/usr/src/uts/common/os/flock.c
↓ open down ↓ 19 lines elided ↑ open up ↑
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27   27  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  28   28  /*      All Rights Reserved */
  29   29  
       30 +/*
       31 + * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
       32 + */
       33 +
  30   34  #include <sys/flock_impl.h>
  31   35  #include <sys/vfs.h>
  32   36  #include <sys/t_lock.h>         /* for <sys/callb.h> */
  33   37  #include <sys/callb.h>
  34   38  #include <sys/clconf.h>
  35   39  #include <sys/cladm.h>
  36   40  #include <sys/nbmlock.h>
  37   41  #include <sys/cred.h>
  38   42  #include <sys/policy.h>
  39   43  
↓ open down ↓ 2232 lines elided ↑ open up ↑
2272 2276                  }
2273 2277          }
2274 2278  
2275 2279          SET_LOCK_TO_FIRST_SLEEP_VP(gp, lock, vp);
2276 2280  
2277 2281          if (lock) {
2278 2282                  while (lock->l_vnode == vp) {
2279 2283                          if (IS_REMOTE(lock)) {
2280 2284                                  result = 1;
2281 2285                                  goto done;
     2286 +                        }
     2287 +                        lock = lock->l_next;
     2288 +                }
     2289 +        }
     2290 +
     2291 +done:
     2292 +        mutex_exit(&gp->gp_mutex);
     2293 +        return (result);
     2294 +}
     2295 +
     2296 +/*
     2297 + * Determine whether there are any locks for the given vnode with a remote
     2298 + * sysid matching given sysid.
     2299 + * Used by the new (open source) NFS Lock Manager (NLM)
     2300 + */
     2301 +int
     2302 +flk_has_remote_locks_for_sysid(vnode_t *vp, int sysid)
     2303 +{
     2304 +        lock_descriptor_t *lock;
     2305 +        int result = 0;
     2306 +        graph_t *gp;
     2307 +
     2308 +        if (sysid == 0)
     2309 +                return (0);
     2310 +
     2311 +        gp = flk_get_lock_graph(vp, FLK_USE_GRAPH);
     2312 +        if (gp == NULL) {
     2313 +                return (0);
     2314 +        }
     2315 +
     2316 +        mutex_enter(&gp->gp_mutex);
     2317 +
     2318 +        SET_LOCK_TO_FIRST_ACTIVE_VP(gp, lock, vp);
     2319 +
     2320 +        if (lock) {
     2321 +                while (lock->l_vnode == vp) {
     2322 +                        if (lock->l_flock.l_sysid == sysid) {
     2323 +                                result = 1;
     2324 +                                goto done;
     2325 +                        }
     2326 +                        lock = lock->l_next;
     2327 +                }
     2328 +        }
     2329 +
     2330 +        SET_LOCK_TO_FIRST_SLEEP_VP(gp, lock, vp);
     2331 +
     2332 +        if (lock) {
     2333 +                while (lock->l_vnode == vp) {
     2334 +                        if (lock->l_flock.l_sysid == sysid) {
     2335 +                                result = 1;
     2336 +                                goto done;
2282 2337                          }
2283 2338                          lock = lock->l_next;
2284 2339                  }
2285 2340          }
2286 2341  
2287 2342  done:
2288 2343          mutex_exit(&gp->gp_mutex);
2289 2344          return (result);
2290 2345  }
2291 2346  
↓ open down ↓ 1924 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX