Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/vnode.h
          +++ new/usr/src/uts/common/sys/vnode.h
↓ open down ↓ 13 lines elided ↑ open up ↑
  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   21  
  22   22  /*
  23   23   * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
  24      - * Copyright 2016 Joyent, Inc.
       24 + * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  25   25   */
  26   26  
  27   27  /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T     */
  28   28  /*        All Rights Reserved   */
  29   29  
  30   30  /*
  31   31   * University Copyright- Copyright (c) 1982, 1986, 1988
  32   32   * The Regents of the University of California
  33   33   * All Rights Reserved
  34   34   *
↓ open down ↓ 179 lines elided ↑ open up ↑
 214  214   *     v_data
 215  215   *     v_vfsp
 216  216   *     v_stream
 217  217   *     v_type
 218  218   *     v_rdev
 219  219   *
 220  220   * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD.
 221  221   * In particular, file systems should not access other fields; they may
 222  222   * change or even be removed.  The functionality which was once provided
 223  223   * by these fields is available through vn_* functions.
 224      - *
 225      - * VNODE PATH THEORY:
 226      - * In each vnode, the v_path field holds a cached version of the canonical
 227      - * filesystem path which that node represents.  Because vnodes lack contextual
 228      - * information about their own name or position in the VFS hierarchy, this path
 229      - * must be calculated when the vnode is instantiated by operations such as
 230      - * fop_create, fop_lookup, or fop_mkdir.  During said operations, both the
 231      - * parent vnode (and its cached v_path) and future name are known, so the
 232      - * v_path of the resulting object can easily be set.
 233      - *
 234      - * The caching nature of v_path is complicated in the face of directory
 235      - * renames.  Filesystem drivers are responsible for calling vn_renamepath when
 236      - * a fop_rename operation succeeds.  While the v_path on the renamed vnode will
 237      - * be updated, existing children of the directory (direct, or at deeper levels)
 238      - * will now possess v_path caches which are stale.
 239      - *
 240      - * It is expensive (and for non-directories, impossible) to recalculate stale
 241      - * v_path entries during operations such as vnodetopath.  The best time during
 242      - * which to correct such wrongs is the same as when v_path is first
 243      - * initialized: during fop_create/fop_lookup/fop_mkdir/etc, where adequate
 244      - * context is available to generate the current path.
 245      - *
 246      - * In order to quickly detect stale v_path entries (without full lookup
 247      - * verification) to trigger a v_path update, the v_path_stamp field has been
 248      - * added to vnode_t.  As part of successful fop_create/fop_lookup/fop_mkdir
 249      - * operations, where the name and parent vnode are available, the following
 250      - * rules are used to determine updates to the child:
 251      - *
 252      - * 1. If the parent lacks a v_path, clear any existing v_path and v_path_stamp
 253      - *    on the child.  Until the parent v_path is refreshed to a valid state, the
 254      - *    child v_path must be considered invalid too.
 255      - *
 256      - * 2. If the child lacks a v_path (implying v_path_stamp == 0), it inherits the
 257      - *    v_path_stamp value from its parent and its v_path is updated.
 258      - *
 259      - * 3. If the child v_path_stamp is less than v_path_stamp in the parent, it is
 260      - *    an indication that the child v_path is stale.  The v_path is updated and
 261      - *    v_path_stamp in the child is set to the current hrtime().
 262      - *
 263      - *    It does _not_ inherit the parent v_path_stamp in order to propagate the
 264      - *    the time of v_path invalidation through the directory structure.  This
 265      - *    prevents concurrent invalidations (operating with a now-incorrect v_path)
 266      - *    at deeper levels in the tree from persisting.
 267      - *
 268      - * 4. If the child v_path_stamp is greater or equal to the parent, no action
 269      - *    needs to be taken.
 270      - *
 271      - * Note that fop_rename operations do not follow this ruleset.  They perform an
 272      - * explicit update of v_path and v_path_stamp (setting it to the current time)
 273      - *
 274      - * With these constraints in place, v_path invalidations and updates should
 275      - * proceed in a timely manner as vnodes are accessed.  While there still are
 276      - * limited cases where vnodetopath operations will fail, the risk is minimized.
 277  224   */
 278  225  
 279  226  struct fem_head;        /* from fem.h */
 280  227  
 281  228  typedef struct vnode {
 282  229          kmutex_t        v_lock;         /* protects vnode fields */
 283  230          uint_t          v_flag;         /* vnode flags (see below) */
 284  231          uint_t          v_count;        /* reference count */
 285  232          void            *v_data;        /* private data for fs */
 286  233          struct vfs      *v_vfsp;        /* ptr to containing VFS */
↓ open down ↓ 6 lines elided ↑ open up ↑
 293  240          struct vfs      *v_vfsmountedhere; /* ptr to vfs mounted here */
 294  241          struct vnodeops *v_op;          /* vnode operations */
 295  242          struct page     *v_pages;       /* vnode pages list */
 296  243          struct filock   *v_filocks;     /* ptr to filock list */
 297  244          struct shrlocklist *v_shrlocks; /* ptr to shrlock list */
 298  245          krwlock_t       v_nbllock;      /* sync for NBMAND locks */
 299  246          kcondvar_t      v_cv;           /* synchronize locking */
 300  247          void            *v_locality;    /* hook for locality info */
 301  248          struct fem_head *v_femhead;     /* fs monitoring */
 302  249          char            *v_path;        /* cached path */
 303      -        hrtime_t        v_path_stamp;   /* timestamp for cached path */
 304  250          uint_t          v_rdcnt;        /* open for read count  (VREG only) */
 305  251          uint_t          v_wrcnt;        /* open for write count (VREG only) */
 306  252          u_longlong_t    v_mmap_read;    /* mmap read count */
 307  253          u_longlong_t    v_mmap_write;   /* mmap write count */
 308  254          void            *v_mpssdata;    /* info for large page mappings */
 309  255          void            *v_fopdata;     /* list of file ops event watches */
 310  256          kmutex_t        v_vsd_lock;     /* protects v_vsd field */
 311  257          struct vsd_node *v_vsd;         /* vnode specific data */
 312  258          struct vnode    *v_xattrdir;    /* unnamed extended attr dir (GFS) */
 313  259          uint_t          v_count_dnlc;   /* dnlc reference count */
↓ open down ↓ 471 lines elided ↑ open up ↑
 785  731   * need to know about rename before it occurs.
 786  732   */
 787  733  typedef enum vnevent    {
 788  734          VE_SUPPORT      = 0,    /* Query */
 789  735          VE_RENAME_SRC   = 1,    /* Rename, with vnode as source */
 790  736          VE_RENAME_DEST  = 2,    /* Rename, with vnode as target/destination */
 791  737          VE_REMOVE       = 3,    /* Remove of vnode's name */
 792  738          VE_RMDIR        = 4,    /* Remove of directory vnode's name */
 793  739          VE_CREATE       = 5,    /* Create with vnode's name which exists */
 794  740          VE_LINK         = 6,    /* Link with vnode's name as source */
 795      -        VE_RENAME_DEST_DIR = 7, /* Rename with vnode as target dir */
      741 +        VE_RENAME_DEST_DIR      = 7,    /* Rename with vnode as target dir */
 796  742          VE_MOUNTEDOVER  = 8,    /* File or Filesystem got mounted over vnode */
 797  743          VE_TRUNCATE = 9,        /* Truncate */
 798  744          VE_PRE_RENAME_SRC = 10, /* Pre-rename, with vnode as source */
 799  745          VE_PRE_RENAME_DEST = 11, /* Pre-rename, with vnode as target/dest. */
 800  746          VE_PRE_RENAME_DEST_DIR = 12, /* Pre-rename with vnode as target dir */
 801  747          VE_RENAME_SRC_DIR = 13, /* Rename with vnode as source dir */
 802  748          VE_RESIZE       = 14    /* Resize/truncate to non-zero offset */
 803  749  } vnevent_t;
 804  750  
 805  751  /*
↓ open down ↓ 534 lines elided ↑ open up ↑
1340 1286  vn_vfslocks_entry_t *vn_vfslocks_getlock(void *);
1341 1287  void    vn_vfslocks_rele(vn_vfslocks_entry_t *);
1342 1288  boolean_t vn_is_reparse(vnode_t *, cred_t *, caller_context_t *);
1343 1289  
1344 1290  void vn_copypath(struct vnode *src, struct vnode *dst);
1345 1291  void vn_setpath_str(struct vnode *vp, const char *str, size_t len);
1346 1292  void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp,
1347 1293      const char *path, size_t plen);
1348 1294  void vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len);
1349 1295  
1350      -/* Private vnode manipulation functions */
1351      -void vn_clearpath(vnode_t *, hrtime_t);
1352      -void vn_updatepath(vnode_t *, vnode_t *, const char *);
1353      -
1354      -
1355 1296  /* Vnode event notification */
1356 1297  void    vnevent_rename_src(vnode_t *, vnode_t *, char *, caller_context_t *);
1357 1298  void    vnevent_rename_dest(vnode_t *, vnode_t *, char *, caller_context_t *);
1358 1299  void    vnevent_remove(vnode_t *, vnode_t *, char *, caller_context_t *);
1359 1300  void    vnevent_rmdir(vnode_t *, vnode_t *, char *, caller_context_t *);
1360 1301  void    vnevent_create(vnode_t *, caller_context_t *);
1361 1302  void    vnevent_link(vnode_t *, caller_context_t *);
1362 1303  void    vnevent_rename_dest_dir(vnode_t *, vnode_t *, char *,
1363 1304      caller_context_t *ct);
1364 1305  void    vnevent_mountedover(vnode_t *, caller_context_t *);
↓ open down ↓ 28 lines elided ↑ open up ↑
1393 1334  int xattr_dir_lookup(vnode_t *, vnode_t **, int, cred_t *);
1394 1335  
1395 1336  /* Reparse Point */
1396 1337  void reparse_point_init(void);
1397 1338  
1398 1339  /* Context identification */
1399 1340  u_longlong_t    fs_new_caller_id();
1400 1341  
1401 1342  int     vn_vmpss_usepageio(vnode_t *);
1402 1343  
1403      -/* Empty v_path placeholder */
1404      -extern char *vn_vpath_empty;
1405      -
1406 1344  /*
1407 1345   * Needed for use of IS_VMODSORT() in kernel.
1408 1346   */
1409 1347  extern uint_t pvn_vmodsort_supported;
1410 1348  
1411 1349  #define VN_HOLD(vp)     { \
1412 1350          mutex_enter(&(vp)->v_lock); \
1413 1351          (vp)->v_count++; \
1414 1352          mutex_exit(&(vp)->v_lock); \
1415 1353  }
↓ open down ↓ 99 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX