Print this page
OS-3969 lx brand: reading process map induces many DNLC scans
        
*** 19,28 ****
--- 19,29 ----
   * CDDL HEADER END
   */
  
  /*
   * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
+  * Copyright (c) 2015, Joyent, Inc. All rights reserved.
   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
   */
  
  /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T     */
  /*        All Rights Reserved   */
*** 55,64 ****
--- 56,66 ----
  #include <sys/dirent.h>
  #include <c2/audit.h>
  #include <sys/zone.h>
  #include <sys/dnlc.h>
  #include <sys/fs/snode.h>
+ #include <sys/brand.h>
  
  /* Controls whether paths are stored with vnodes. */
  int vfs_vnode_path = 1;
  
  int
*** 1406,1417 ****
                  mutex_exit(&vp->v_lock);
          }
  
          pn_free(&pn);
  
!         if (vp->v_type != VDIR) {
                  /*
                   * If we don't have a directory, try to find it in the dnlc via
                   * reverse lookup.  Once this is found, we can use the regular
                   * directory search to find the full path.
                   */
                  if ((pvp = dnlc_reverse_lookup(vp, path, MAXNAMELEN)) != NULL) {
--- 1408,1432 ----
                  mutex_exit(&vp->v_lock);
          }
  
          pn_free(&pn);
  
!         if (PROC_IS_BRANDED(curproc)) {
                  /*
+                  * If v_path doesn't work out and we're in a branded zone,
+                  * we're not going to bother doing more work here:  because
+                  * directories from the global can be lofs mounted into odd
+                  * locations (e.g., /native in an lx zone), it is likely that
+                  * the DNLC reverse lookup will yield nothing.  Indeed, the
+                  * only certainty is that the DNLC reverse lookup will be
+                  * exceedingly painful; we save ourselves the substantial
+                  * grief of scanning the entire DNLC and kick out with ENOENT
+                  * in this case.
+                  */
+                 ret = ENOENT;
+         } else if (vp->v_type != VDIR) {
+                 /*
                   * If we don't have a directory, try to find it in the dnlc via
                   * reverse lookup.  Once this is found, we can use the regular
                   * directory search to find the full path.
                   */
                  if ((pvp = dnlc_reverse_lookup(vp, path, MAXNAMELEN)) != NULL) {