Author: mckusick
Date: Thu Apr 19 18:03:24 2012
New Revision: 234466
URL: http://svn.freebsd.org/changeset/base/234466

Log:
  MFC of 233627, 234024, 234025, and 234026
  
  Restore per mount-point counts of synchronous and asynchronous
  reads and writes associated with UFS and MSDOS filesystems.
  
  MFS 233627:
  Keep track of the mount point associated with a special device
  to enable the collection of counts of synchronous and asynchronous
  reads and writes for its associated filesystem. The counts are
  displayed using `mount -v'.
  
  Ensure that buffers used for paging indicate the vnode from
  which they are operating so that counts of paging I/O operations
  from the filesystem are collected.
  
  This checkin only adds the setting of the mount point for the
  UFS/FFS filesystem, but it would be trivial to add the setting
  and clearing of the mount point at filesystem mount/unmount
  time for other filesystems too.
  
  Reviewed by: kib
  
  MFC 234024:
  Drop an unnecessary setting of si_mountpt when updating a UFS mount point.
  Clearly it must have been set when the mount was done.
  
  Reviewed by: kib
  
  MFC 234025:
  Add I/O accounting to msdos filesystem.
  
  Suggested and reviewed by: kib
  
  MFC 234026:
  Expand locking around identification of filesystem mount point when
  accounting for I/O counts at completion of I/O operation. Also switch
  from using global devmtx to vnode mutex to reduce contention.
  
  Suggested and reviewed by: kib

Modified:
  stable/9/sys/fs/msdosfs/msdosfs_vfsops.c
  stable/9/sys/geom/geom_vfs.c
  stable/9/sys/sys/conf.h
  stable/9/sys/ufs/ffs/ffs_vfsops.c
  stable/9/sys/vm/vnode_pager.c
Directory Properties:
  stable/9/sys/   (props changed)
  stable/9/sys/amd64/include/xen/   (props changed)
  stable/9/sys/boot/   (props changed)
  stable/9/sys/boot/i386/efi/   (props changed)
  stable/9/sys/boot/ia64/efi/   (props changed)
  stable/9/sys/boot/ia64/ski/   (props changed)
  stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
  stable/9/sys/boot/powerpc/ofw/   (props changed)
  stable/9/sys/cddl/contrib/opensolaris/   (props changed)
  stable/9/sys/conf/   (props changed)
  stable/9/sys/contrib/dev/acpica/   (props changed)
  stable/9/sys/contrib/octeon-sdk/   (props changed)
  stable/9/sys/contrib/pf/   (props changed)
  stable/9/sys/contrib/x86emu/   (props changed)
  stable/9/sys/fs/   (props changed)
  stable/9/sys/fs/ntfs/   (props changed)
  stable/9/sys/i386/conf/XENHVM   (props changed)
  stable/9/sys/kern/subr_witness.c   (props changed)

Modified: stable/9/sys/fs/msdosfs/msdosfs_vfsops.c
==============================================================================
--- stable/9/sys/fs/msdosfs/msdosfs_vfsops.c    Thu Apr 19 16:13:15 2012        
(r234465)
+++ stable/9/sys/fs/msdosfs/msdosfs_vfsops.c    Thu Apr 19 18:03:24 2012        
(r234466)
@@ -401,6 +401,8 @@ msdosfs_mount(struct mount *mp)
                return error;
        }
 
+       if (devvp->v_type == VCHR && devvp->v_rdev != NULL)
+               devvp->v_rdev->si_mountpt = mp;
        vfs_mountedfrom(mp, from);
 #ifdef MSDOSFS_DEBUG
        printf("msdosfs_mount(): mp %p, pmp %p, inusemap %p\n", mp, pmp, 
pmp->pm_inusemap);
@@ -843,6 +845,8 @@ msdosfs_unmount(struct mount *mp, int mn
        }
 #endif
        DROP_GIANT();
+       if (pmp->pm_devvp->v_type == VCHR && pmp->pm_devvp->v_rdev != NULL)
+               pmp->pm_devvp->v_rdev->si_mountpt = NULL;
        g_topology_lock();
        g_vfs_close(pmp->pm_cp);
        g_topology_unlock();

Modified: stable/9/sys/geom/geom_vfs.c
==============================================================================
--- stable/9/sys/geom/geom_vfs.c        Thu Apr 19 16:13:15 2012        
(r234465)
+++ stable/9/sys/geom/geom_vfs.c        Thu Apr 19 18:03:24 2012        
(r234466)
@@ -70,6 +70,9 @@ g_vfs_done(struct bio *bip)
 {
        struct buf *bp;
        int vfslocked;
+       struct mount *mp;
+       struct vnode *vp;
+       struct cdev *cdevp;
 
        /*
         * Provider ('bio_to') could have withered away sometime
@@ -81,12 +84,50 @@ g_vfs_done(struct bio *bip)
        if (bip->bio_from->provider == NULL)
                bip->bio_to = NULL;
 
+       /*
+        * Collect statistics on synchronous and asynchronous read
+        * and write counts for disks that have associated filesystems.
+        * Since this is run by the g_up thread it is single threaded and
+        * we do not need to use atomic increments on the counters.
+        */
+       bp = bip->bio_caller2;
+       vp = bp->b_vp;
+       if (vp == NULL) {
+               mp = NULL;
+       } else {
+               /*
+                * If not a disk vnode, use its associated mount point
+                * otherwise use the mountpoint associated with the disk.
+                */
+               VI_LOCK(vp);
+               if (vp->v_type != VCHR ||
+                   (cdevp = vp->v_rdev) == NULL ||
+                   cdevp->si_devsw == NULL ||
+                   (cdevp->si_devsw->d_flags & D_DISK) == 0)
+                       mp = vp->v_mount;
+               else
+                       mp = cdevp->si_mountpt;
+               VI_UNLOCK(vp);
+       }
+       if (mp != NULL) {
+               if (bp->b_iocmd == BIO_WRITE) {
+                       if (LK_HOLDER(bp->b_lock.lk_lock) == LK_KERNPROC)
+                               mp->mnt_stat.f_asyncwrites++;
+                       else
+                               mp->mnt_stat.f_syncwrites++;
+               } else {
+                       if (LK_HOLDER(bp->b_lock.lk_lock) == LK_KERNPROC)
+                               mp->mnt_stat.f_asyncreads++;
+                       else
+                               mp->mnt_stat.f_syncreads++;
+               }
+       }
+
        if (bip->bio_error) {
                printf("g_vfs_done():");
                g_print_bio(bip);
                printf("error = %d\n", bip->bio_error);
        }
-       bp = bip->bio_caller2;
        bp->b_error = bip->bio_error;
        bp->b_ioflags = bip->bio_flags;
        if (bip->bio_error)

Modified: stable/9/sys/sys/conf.h
==============================================================================
--- stable/9/sys/sys/conf.h     Thu Apr 19 16:13:15 2012        (r234465)
+++ stable/9/sys/sys/conf.h     Thu Apr 19 18:03:24 2012        (r234466)
@@ -52,7 +52,7 @@ struct cdevsw;
 struct file;
 
 struct cdev {
-       void            *__si_reserved;
+       struct mount    *si_mountpt;
        u_int           si_flags;
 #define        SI_ETERNAL      0x0001  /* never destroyed */
 #define SI_ALIAS       0x0002  /* carrier of alias name */

Modified: stable/9/sys/ufs/ffs/ffs_vfsops.c
==============================================================================
--- stable/9/sys/ufs/ffs/ffs_vfsops.c   Thu Apr 19 16:13:15 2012        
(r234465)
+++ stable/9/sys/ufs/ffs/ffs_vfsops.c   Thu Apr 19 18:03:24 2012        
(r234466)
@@ -1050,6 +1050,8 @@ ffs_mountfs(devvp, mp, td)
                        ffs_flushfiles(mp, FORCECLOSE, td);
                        goto out;
                }
+               if (devvp->v_type == VCHR && devvp->v_rdev != NULL)
+                       devvp->v_rdev->si_mountpt = mp;
                if (fs->fs_snapinum[0] != 0)
                        ffs_snapshot_mount(mp);
                fs->fs_fmod = 1;
@@ -1295,6 +1297,8 @@ ffs_unmount(mp, mntflags)
        g_vfs_close(ump->um_cp);
        g_topology_unlock();
        PICKUP_GIANT();
+       if (ump->um_devvp->v_type == VCHR && ump->um_devvp->v_rdev != NULL)
+               ump->um_devvp->v_rdev->si_mountpt = NULL;
        vrele(ump->um_devvp);
        dev_rel(ump->um_dev);
        mtx_destroy(UFS_MTX(ump));

Modified: stable/9/sys/vm/vnode_pager.c
==============================================================================
--- stable/9/sys/vm/vnode_pager.c       Thu Apr 19 16:13:15 2012        
(r234465)
+++ stable/9/sys/vm/vnode_pager.c       Thu Apr 19 18:03:24 2012        
(r234466)
@@ -541,6 +541,7 @@ vnode_pager_input_smlfs(object, m)
                        bp->b_data = (caddr_t)sf_buf_kva(sf) + i * bsize;
                        bp->b_blkno = fileaddr;
                        pbgetbo(bo, bp);
+                       bp->b_vp = vp;
                        bp->b_bcount = bsize;
                        bp->b_bufsize = bsize;
                        bp->b_runningbufspace = bp->b_bufsize;
@@ -558,6 +559,7 @@ vnode_pager_input_smlfs(object, m)
                        /*
                         * free the buffer header back to the swap buffer pool
                         */
+                       bp->b_vp = NULL;
                        pbrelbo(bp);
                        relpbuf(bp, &vnode_pbuf_freecnt);
                        if (error)
@@ -916,6 +918,7 @@ vnode_pager_generic_getpages(vp, m, byte
        bp->b_wcred = crhold(curthread->td_ucred);
        bp->b_blkno = firstaddr;
        pbgetbo(bo, bp);
+       bp->b_vp = vp;
        bp->b_bcount = size;
        bp->b_bufsize = size;
        bp->b_runningbufspace = bp->b_bufsize;
@@ -942,6 +945,7 @@ vnode_pager_generic_getpages(vp, m, byte
        /*
         * free the buffer header back to the swap buffer pool
         */
+       bp->b_vp = NULL;
        pbrelbo(bp);
        relpbuf(bp, &vnode_pbuf_freecnt);
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to