Print this page
basic fsh prototype (no comments yet)

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/fs/vfs.c
          +++ new/usr/src/uts/common/fs/vfs.c
↓ open down ↓ 76 lines elided ↑ open up ↑
  77   77  #include <sys/policy.h>
  78   78  #include <sys/ctfs.h>
  79   79  #include <sys/objfs.h>
  80   80  #include <sys/console.h>
  81   81  #include <sys/reboot.h>
  82   82  #include <sys/attr.h>
  83   83  #include <sys/zio.h>
  84   84  #include <sys/spa.h>
  85   85  #include <sys/lofi.h>
  86   86  #include <sys/bootprops.h>
       87 +#include <sys/fsh.h>
       88 +#include <sys/fsh_impl.h>
  87   89  
  88   90  #include <vm/page.h>
  89   91  
  90   92  #include <fs/fs_subr.h>
  91   93  /* Private interfaces to create vopstats-related data structures */
  92   94  extern void             initialize_vopstats(vopstats_t *);
  93   95  extern vopstats_t       *get_fstype_vopstats(struct vfs *, struct vfssw *);
  94   96  extern vsk_anchor_t     *get_vskstat_anchor(struct vfs *);
  95   97  
  96   98  static void vfs_clearmntopt_nolock(mntopts_t *, const char *, int);
↓ open down ↓ 112 lines elided ↑ open up ↑
 209  211          (mntopt_t *)&mntopts[0]
 210  212  };
 211  213  
 212  214  /*
 213  215   * File system operation dispatch functions.
 214  216   */
 215  217  
 216  218  int
 217  219  fsop_mount(vfs_t *vfsp, vnode_t *mvp, struct mounta *uap, cred_t *cr)
 218  220  {
 219      -        return (*(vfsp)->vfs_op->vfs_mount)(vfsp, mvp, uap, cr);
      221 +        return (fsh_mount(vfsp, mvp, uap, cr));
 220  222  }
 221  223  
 222  224  int
 223  225  fsop_unmount(vfs_t *vfsp, int flag, cred_t *cr)
 224  226  {
 225      -        return (*(vfsp)->vfs_op->vfs_unmount)(vfsp, flag, cr);
      227 +        return (fsh_unmount(vfsp, flag, cr));
 226  228  }
 227  229  
 228  230  int
 229  231  fsop_root(vfs_t *vfsp, vnode_t **vpp)
 230  232  {
 231  233          refstr_t *mntpt;
 232      -        int ret = (*(vfsp)->vfs_op->vfs_root)(vfsp, vpp);
      234 +        int ret = fsh_root(vfsp, vpp);
 233  235          /*
 234  236           * Make sure this root has a path.  With lofs, it is possible to have
 235  237           * a NULL mountpoint.
 236  238           */
 237  239          if (ret == 0 && vfsp->vfs_mntpt != NULL && (*vpp)->v_path == NULL) {
 238  240                  mntpt = vfs_getmntpoint(vfsp);
 239  241                  vn_setpath_str(*vpp, refstr_value(mntpt),
 240  242                      strlen(refstr_value(mntpt)));
 241  243                  refstr_rele(mntpt);
 242  244          }
 243  245  
 244  246          return (ret);
 245  247  }
 246  248  
 247  249  int
 248  250  fsop_statfs(vfs_t *vfsp, statvfs64_t *sp)
 249  251  {
 250      -        return (*(vfsp)->vfs_op->vfs_statvfs)(vfsp, sp);
      252 +        return (fsh_statfs(vfsp, sp));
 251  253  }
 252  254  
 253  255  int
 254  256  fsop_sync(vfs_t *vfsp, short flag, cred_t *cr)
 255  257  {
 256  258          return (*(vfsp)->vfs_op->vfs_sync)(vfsp, flag, cr);
 257  259  }
 258  260  
 259  261  int
 260  262  fsop_vget(vfs_t *vfsp, vnode_t **vpp, fid_t *fidp)
↓ open down ↓ 6 lines elided ↑ open up ↑
 267  269           *
 268  270           * This guarantees that sysattr fids are larger than other fids
 269  271           * for this vfs. If the vfs supports the sysattr view interface
 270  272           * (as indicated by VFSFT_SYSATTR_VIEWS), we cannot have a size
 271  273           * collision with XATTR_FIDSZ.
 272  274           */
 273  275          if (vfs_has_feature(vfsp, VFSFT_SYSATTR_VIEWS) &&
 274  276              fidp->fid_len == XATTR_FIDSZ)
 275  277                  return (xattr_dir_vget(vfsp, vpp, fidp));
 276  278  
 277      -        return (*(vfsp)->vfs_op->vfs_vget)(vfsp, vpp, fidp);
      279 +        return (fsh_vget(vfsp, vpp, fidp));
 278  280  }
 279  281  
 280  282  int
 281  283  fsop_mountroot(vfs_t *vfsp, enum whymountroot reason)
 282  284  {
 283  285          return (*(vfsp)->vfs_op->vfs_mountroot)(vfsp, reason);
 284  286  }
 285  287  
 286  288  void
 287  289  fsop_freefs(vfs_t *vfsp)
↓ open down ↓ 233 lines elided ↑ open up ↑
 521  523          vfsp->vfs_count = 0;
 522  524          vfsp->vfs_next = vfsp;
 523  525          vfsp->vfs_prev = vfsp;
 524  526          vfsp->vfs_zone_next = vfsp;
 525  527          vfsp->vfs_zone_prev = vfsp;
 526  528          vfsp->vfs_lofi_minor = 0;
 527  529          sema_init(&vfsp->vfs_reflock, 1, NULL, SEMA_DEFAULT, NULL);
 528  530          vfsimpl_setup(vfsp);
 529  531          vfsp->vfs_data = (data);
 530  532          vfs_setops((vfsp), (op));
      533 +        vfsp->vfs_fshrecord = fsh_fsrec_create();
 531  534  }
 532  535  
 533  536  /*
 534  537   * Allocate and initialize the vfs implementation private data
 535  538   * structure, vfs_impl_t.
 536  539   */
 537  540  void
 538  541  vfsimpl_setup(vfs_t *vfsp)
 539  542  {
 540  543          int i;
↓ open down ↓ 1237 lines elided ↑ open up ↑
1778 1781                          if (vskap != NULL) {
1779 1782                                  vfs_lock_wait(vfsp);
1780 1783                                  if (vfsp->vfs_flag & VFS_STATS) {
1781 1784                                          vfsp->vfs_vskap = vskap;
1782 1785                                  }
1783 1786                                  vfs_unlock(vfsp);
1784 1787                          }
1785 1788                  }
1786 1789                  /* Return vfsp to caller. */
1787 1790                  *vfspp = vfsp;
     1791 +                fsh_exec_create_callbacks(vfsp);
1788 1792          }
1789 1793  errout:
1790 1794          vfs_freeopttbl(&mnt_mntopts);
1791 1795          if (resource != NULL)
1792 1796                  kmem_free(resource, strlen(resource) + 1);
1793 1797          if (mountpt != NULL)
1794 1798                  kmem_free(mountpt, strlen(mountpt) + 1);
1795 1799          /*
1796 1800           * It is possible we errored prior to adding to mount in progress
1797 1801           * table. Must free vnode we acquired with successful lookupname.
↓ open down ↓ 2514 lines elided ↑ open up ↑
4312 4316           */
4313 4317  
4314 4318          /* If FEM was in use, make sure everything gets cleaned up */
4315 4319          if (vfsp->vfs_femhead) {
4316 4320                  ASSERT(vfsp->vfs_femhead->femh_list == NULL);
4317 4321                  mutex_destroy(&vfsp->vfs_femhead->femh_lock);
4318 4322                  kmem_free(vfsp->vfs_femhead, sizeof (*(vfsp->vfs_femhead)));
4319 4323                  vfsp->vfs_femhead = NULL;
4320 4324          }
4321 4325  
     4326 +        /* FSH cleanup */
     4327 +        fsh_fsrec_destroy(vfsp->vfs_fshrecord);
     4328 +        vfsp->vfs_fshrecord = NULL;
     4329 +
4322 4330          if (vfsp->vfs_implp)
4323 4331                  vfsimpl_teardown(vfsp);
4324 4332          sema_destroy(&vfsp->vfs_reflock);
4325 4333          kmem_cache_free(vfs_cache, vfsp);
4326 4334  }
4327 4335  
4328 4336  /*
4329 4337   * Increments the vfs reference count by one atomically.
4330 4338   */
4331 4339  void
↓ open down ↓ 6 lines elided ↑ open up ↑
4338 4346  /*
4339 4347   * Decrements the vfs reference count by one atomically. When
4340 4348   * vfs reference count becomes zero, it calls the file system
4341 4349   * specific vfs_freevfs() to free up the resources.
4342 4350   */
4343 4351  void
4344 4352  vfs_rele(vfs_t *vfsp)
4345 4353  {
4346 4354          ASSERT(vfsp->vfs_count != 0);
4347 4355          if (atomic_add_32_nv(&vfsp->vfs_count, -1) == 0) {
     4356 +                fsh_exec_destroy_callbacks(vfsp);
4348 4357                  VFS_FREEVFS(vfsp);
4349 4358                  lofi_remove(vfsp);
4350 4359                  if (vfsp->vfs_zone)
4351 4360                          zone_rele_ref(&vfsp->vfs_implp->vi_zone_ref,
4352 4361                              ZONE_REF_VFS);
4353 4362                  vfs_freemnttab(vfsp);
4354 4363                  vfs_free(vfsp);
4355 4364          }
4356 4365  }
4357 4366  
↓ open down ↓ 454 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX