HAMMER 61E/Many: Features
authorMatthew Dillon <dillon@dragonflybsd.org>
Mon, 14 Jul 2008 20:27:54 +0000 (20:27 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Mon, 14 Jul 2008 20:27:54 +0000 (20:27 +0000)
* Implement hammer iostats.

sys/vfs/hammer/hammer.h
sys/vfs/hammer/hammer_flusher.c
sys/vfs/hammer/hammer_io.c
sys/vfs/hammer/hammer_pfs.c
sys/vfs/hammer/hammer_vfsops.c
sys/vfs/hammer/hammer_vnops.c

index 5da87ba..e2907e6 100644 (file)
@@ -31,7 +31,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.117 2008/07/14 03:20:49 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer.h,v 1.118 2008/07/14 20:27:54 dillon Exp $
  */
 /*
  * This header file contains structures used internally by the HAMMERFS
@@ -790,6 +790,14 @@ extern int64_t hammer_stats_btree_elements;
 extern int64_t hammer_stats_btree_splits;
 extern int64_t hammer_stats_btree_iterations;
 extern int64_t hammer_stats_record_iterations;
+extern int64_t hammer_stats_file_read;
+extern int64_t hammer_stats_file_write;
+extern int64_t hammer_stats_file_iopsr;
+extern int64_t hammer_stats_file_iopsw;
+extern int64_t hammer_stats_disk_read;
+extern int64_t hammer_stats_disk_write;
+extern int64_t hammer_stats_inode_flushes;
+extern int64_t hammer_stats_commits;
 extern int hammer_count_dirtybufspace;
 extern int hammer_count_refedbufs;
 extern int hammer_count_reservations;
index ec5a92b..fbdd389 100644 (file)
@@ -31,7 +31,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer_flusher.c,v 1.40 2008/07/14 03:20:49 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_flusher.c,v 1.41 2008/07/14 20:27:54 dillon Exp $
  */
 /*
  * HAMMER dependancy flusher thread
@@ -264,8 +264,6 @@ hammer_flusher_flush(hammer_mount_t hmp)
                                flg->total_count, flg->refs);
                }
                hammer_start_transaction_fls(&hmp->flusher.trans, hmp);
-               if (hammer_debug_general & 0x0001)
-                       kprintf("T");
 
                /*
                 * If the previous flush cycle just about exhausted our
@@ -402,6 +400,7 @@ hammer_flusher_slave_thread(void *arg)
                for (i = 0; i < info->count; ++i) {
                        ip = info->work_array[i];
                        hammer_flusher_flush_inode(ip, &hmp->flusher.trans);
+                       ++hammer_stats_inode_flushes;
                }
                info->count = 0;
                info->runstate = 0;
@@ -688,6 +687,7 @@ done:
        hammer_unlock(&hmp->flusher.finalize_lock);
        if (--hmp->flusher.finalize_want == 0)
                wakeup(&hmp->flusher.finalize_want);
+       hammer_stats_commits += final;
 }
 
 /*
index 30099a3..5477af9 100644 (file)
@@ -31,7 +31,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer_io.c,v 1.49 2008/07/14 03:20:49 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_io.c,v 1.50 2008/07/14 20:27:54 dillon Exp $
  */
 /*
  * IO Primitives and buffer cache management
@@ -177,13 +177,15 @@ hammer_io_read(struct vnode *devvp, struct hammer_io *io, hammer_off_t limit)
 
        if ((bp = io->bp) == NULL) {
                hammer_count_io_running_read += io->bytes;
-#if 1
-               error = cluster_read(devvp, limit, io->offset, io->bytes,
-                                    HAMMER_CLUSTER_SIZE,
-                                    HAMMER_CLUSTER_BUFS, &io->bp);
-#else
-               error = bread(devvp, io->offset, io->bytes, &io->bp);
-#endif
+               if (hammer_cluster_enable) {
+                       error = cluster_read(devvp, limit,
+                                            io->offset, io->bytes,
+                                            HAMMER_CLUSTER_SIZE,
+                                            HAMMER_CLUSTER_BUFS, &io->bp);
+               } else {
+                       error = bread(devvp, io->offset, io->bytes, &io->bp);
+               }
+               hammer_stats_disk_read += io->bytes;
                hammer_count_io_running_read -= io->bytes;
                if (error == 0) {
                        bp = io->bp;
@@ -761,12 +763,15 @@ hammer_io_complete(struct buf *bp)
         * Deal with people waiting for I/O to drain
         */
        if (iou->io.running) {
+               hammer_stats_disk_write += iou->io.bytes;
                hammer_count_io_running_write -= iou->io.bytes;
                iou->io.hmp->io_running_space -= iou->io.bytes;
                if (iou->io.hmp->io_running_space == 0)
                        wakeup(&iou->io.hmp->io_running_space);
                KKASSERT(iou->io.hmp->io_running_space >= 0);
                iou->io.running = 0;
+       } else {
+               hammer_stats_disk_read += iou->io.bytes;
        }
 
        if (iou->io.waiting) {
@@ -1012,6 +1017,7 @@ hammer_io_direct_read(hammer_mount_t hmp, struct bio *bio,
                        nbio->bio_caller_info1.uvalue32 = leaf->data_crc;
                }
 #endif
+               hammer_stats_disk_read += bp->b_bufsize;
                vn_strategy(volume->devvp, nbio);
        }
        hammer_rel_volume(volume, 0);
@@ -1119,6 +1125,7 @@ hammer_io_direct_write(hammer_mount_t hmp, hammer_record_t record,
                        nbio = push_bio(nbio);
                        nbio->bio_offset = volume->ondisk->vol_buf_beg +
                                           zone2_offset;
+                       hammer_stats_disk_write += bp->b_bufsize;
                        vn_strategy(volume->devvp, nbio);
                }
                hammer_rel_volume(volume, 0);
index cf4f28e..6402a18 100644 (file)
@@ -31,7 +31,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer_pfs.c,v 1.1 2008/07/12 02:47:39 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_pfs.c,v 1.2 2008/07/14 20:27:54 dillon Exp $
  */
 /*
  * HAMMER PFS ioctls - Manage pseudo-fs configurations
@@ -302,6 +302,7 @@ hammer_pfs_rollback(hammer_transaction_t trans,
        struct hammer_cursor cursor;
        struct hammer_base_elm key_cur;
        int error;
+       int seq;
 
        bzero(&cmirror, sizeof(cmirror));
        bzero(&key_cur, sizeof(key_cur));
@@ -311,6 +312,8 @@ hammer_pfs_rollback(hammer_transaction_t trans,
        key_cur.create_tid = 1;
        key_cur.rec_type = HAMMER_MIN_RECTYPE;
 
+       seq = trans->hmp->flusher.act;
+
 retry:
        error = hammer_init_cursor(trans, &cursor, NULL, NULL);
        if (error) {
@@ -359,6 +362,14 @@ retry:
                        error = hammer_pfs_delete_at_cursor(&cursor, trunc_tid);
                }
 
+               while (hammer_flusher_meta_halflimit(trans->hmp) ||
+                      hammer_flusher_undo_exhausted(trans, 2)) {
+                       hammer_unlock_cursor(&cursor, 0);
+                       hammer_flusher_wait(trans->hmp, seq);
+                       hammer_lock_cursor(&cursor, 0);
+                       seq = hammer_flusher_async_one(trans->hmp);
+               }
+
                if (error == 0)
                        error = hammer_btree_iterate(&cursor);
        }
index 8cee5f1..85cd42d 100644 (file)
@@ -31,7 +31,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer_vfsops.c,v 1.63 2008/07/14 03:20:49 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_vfsops.c,v 1.64 2008/07/14 20:27:54 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -75,6 +75,16 @@ int64_t hammer_stats_btree_elements;
 int64_t hammer_stats_btree_splits;
 int64_t hammer_stats_btree_iterations;
 int64_t hammer_stats_record_iterations;
+
+int64_t hammer_stats_file_read;
+int64_t hammer_stats_file_write;
+int64_t hammer_stats_file_iopsr;
+int64_t hammer_stats_file_iopsw;
+int64_t hammer_stats_disk_read;
+int64_t hammer_stats_disk_write;
+int64_t hammer_stats_inode_flushes;
+int64_t hammer_stats_commits;
+
 int hammer_count_dirtybufspace;                /* global */
 int hammer_count_refedbufs;            /* global */
 int hammer_count_reservations;
@@ -140,6 +150,7 @@ SYSCTL_INT(_vfs_hammer, OID_AUTO, count_nodes, CTLFLAG_RD,
           &hammer_count_nodes, 0, "");
 SYSCTL_QUAD(_vfs_hammer, OID_AUTO, count_extra_space_used, CTLFLAG_RD,
           &hammer_count_extra_space_used, 0, "");
+
 SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_btree_searches, CTLFLAG_RD,
           &hammer_stats_btree_searches, 0, "");
 SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_btree_lookups, CTLFLAG_RD,
@@ -156,6 +167,24 @@ SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_btree_iterations, CTLFLAG_RD,
           &hammer_stats_btree_iterations, 0, "");
 SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_record_iterations, CTLFLAG_RD,
           &hammer_stats_record_iterations, 0, "");
+
+SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_file_read, CTLFLAG_RD,
+          &hammer_stats_file_read, 0, "");
+SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_file_write, CTLFLAG_RD,
+          &hammer_stats_file_write, 0, "");
+SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_file_iopsr, CTLFLAG_RD,
+          &hammer_stats_file_iopsr, 0, "");
+SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_file_iopsw, CTLFLAG_RD,
+          &hammer_stats_file_iopsw, 0, "");
+SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_disk_read, CTLFLAG_RD,
+          &hammer_stats_disk_read, 0, "");
+SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_disk_write, CTLFLAG_RD,
+          &hammer_stats_disk_write, 0, "");
+SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_inode_flushes, CTLFLAG_RD,
+          &hammer_stats_inode_flushes, 0, "");
+SYSCTL_QUAD(_vfs_hammer, OID_AUTO, stats_commits, CTLFLAG_RD,
+          &hammer_stats_commits, 0, "");
+
 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_dirtybufspace, CTLFLAG_RD,
           &hammer_count_dirtybufspace, 0, "");
 SYSCTL_INT(_vfs_hammer, OID_AUTO, count_refedbufs, CTLFLAG_RD,
index d63d834..c6624cd 100644 (file)
@@ -31,7 +31,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/vfs/hammer/hammer_vnops.c,v 1.91 2008/07/14 03:20:49 dillon Exp $
+ * $DragonFly: src/sys/vfs/hammer/hammer_vnops.c,v 1.92 2008/07/14 20:27:54 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -275,6 +275,7 @@ hammer_vop_read(struct vop_read_args *ap)
                bqrelse(bp);
                if (error)
                        break;
+               hammer_stats_file_read += n;
        }
        if ((ip->flags & HAMMER_INODE_RO) == 0 &&
            (ip->hmp->mp->mnt_flag & MNT_NOATIME) == 0) {
@@ -486,6 +487,7 @@ hammer_vop_write(struct vop_write_args *ap)
                        }
                        break;
                }
+               hammer_stats_file_write += n;
                /* bp->b_flags |= B_CLUSTEROK; temporarily disabled */
                if (ip->ino_data.size < uio->uio_offset) {
                        ip->ino_data.size = uio->uio_offset;
@@ -534,6 +536,7 @@ hammer_vop_access(struct vop_access_args *ap)
        gid_t gid;
        int error;
 
+       ++hammer_stats_file_iopsr;
        uid = hammer_to_unix_xid(&ip->ino_data.uid);
        gid = hammer_to_unix_xid(&ip->ino_data.gid);
 
@@ -596,6 +599,7 @@ hammer_vop_ncreate(struct vop_ncreate_args *ap)
         * Create a transaction to cover the operations we perform.
         */
        hammer_start_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsw;
 
        /*
         * Create a new filesystem object of the requested type.  The
@@ -670,6 +674,7 @@ hammer_vop_getattr(struct vop_getattr_args *ap)
         * by stat is different from the more involved fsid used in the
         * mount structure.
         */
+       ++hammer_stats_file_iopsr;
        vap->va_fsid = ip->pfsm->fsid_udev ^ (u_int32_t)ip->obj_asof ^
                       (u_int32_t)(ip->obj_asof >> 32);
 
@@ -767,6 +772,7 @@ hammer_vop_nresolve(struct vop_nresolve_args *ap)
        ispfs = 0;
 
        hammer_simple_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsr;
 
        for (i = 0; i < nlen; ++i) {
                if (ncp->nc_name[i] == '@' && ncp->nc_name[i+1] == '@') {
@@ -951,6 +957,7 @@ hammer_vop_nlookupdotdot(struct vop_nlookupdotdot_args *ap)
        }
 
        hammer_simple_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsr;
 
        ip = hammer_get_inode(&trans, dip, parent_obj_id,
                              asof, parent_obj_localization,
@@ -993,6 +1000,7 @@ hammer_vop_nlink(struct vop_nlink_args *ap)
         * Create a transaction to cover the operations we perform.
         */
        hammer_start_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsw;
 
        /*
         * Add the filesystem object to the directory.  Note that neither
@@ -1042,6 +1050,7 @@ hammer_vop_nmkdir(struct vop_nmkdir_args *ap)
         * Create a transaction to cover the operations we perform.
         */
        hammer_start_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsw;
 
        /*
         * Create a new filesystem object of the requested type.  The
@@ -1111,6 +1120,7 @@ hammer_vop_nmknod(struct vop_nmknod_args *ap)
         * Create a transaction to cover the operations we perform.
         */
        hammer_start_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsw;
 
        /*
         * Create a new filesystem object of the requested type.  The
@@ -1161,6 +1171,7 @@ hammer_vop_open(struct vop_open_args *ap)
 {
        hammer_inode_t ip;
 
+       ++hammer_stats_file_iopsr;
        ip = VTOI(ap->a_vp);
 
        if ((ap->a_mode & FWRITE) && (ip->flags & HAMMER_INODE_RO))
@@ -1208,6 +1219,7 @@ hammer_vop_readdir(struct vop_readdir_args *ap)
        int r;
        int dtype;
 
+       ++hammer_stats_file_iopsr;
        ip = VTOI(ap->a_vp);
        uio = ap->a_uio;
        saveoff = uio->uio_offset;
@@ -1406,6 +1418,7 @@ hammer_vop_readlink(struct vop_readlink_args *ap)
         * Long version
         */
        hammer_simple_transaction(&trans, ip->hmp);
+       ++hammer_stats_file_iopsr;
        hammer_init_cursor(&trans, &cursor, &ip->cache[1], ip);
 
        /*
@@ -1459,6 +1472,7 @@ hammer_vop_nremove(struct vop_nremove_args *ap)
        }
 
        hammer_start_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsw;
        error = hammer_dounlink(&trans, ap->a_nch, ap->a_dvp, ap->a_cred, 0);
        hammer_done_transaction(&trans);
 
@@ -1499,6 +1513,7 @@ hammer_vop_nrename(struct vop_nrename_args *ap)
                return (error);
 
        hammer_start_transaction(&trans, fdip->hmp);
+       ++hammer_stats_file_iopsw;
 
        /*
         * Remove tncp from the target directory and then link ip as
@@ -1616,6 +1631,7 @@ hammer_vop_nrmdir(struct vop_nrmdir_args *ap)
        }
 
        hammer_start_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsw;
        error = hammer_dounlink(&trans, ap->a_nch, ap->a_dvp, ap->a_cred, 0);
        hammer_done_transaction(&trans);
 
@@ -1653,6 +1669,7 @@ hammer_vop_setattr(struct vop_setattr_args *ap)
        }
 
        hammer_start_transaction(&trans, ip->hmp);
+       ++hammer_stats_file_iopsw;
        error = 0;
 
        if (vap->va_flags != VNOVAL) {
@@ -1858,6 +1875,7 @@ hammer_vop_nsymlink(struct vop_nsymlink_args *ap)
         * Create a transaction to cover the operations we perform.
         */
        hammer_start_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsw;
 
        /*
         * Create a new filesystem object of the requested type.  The
@@ -1944,6 +1962,7 @@ hammer_vop_nwhiteout(struct vop_nwhiteout_args *ap)
        }
 
        hammer_start_transaction(&trans, dip->hmp);
+       ++hammer_stats_file_iopsw;
        error = hammer_dounlink(&trans, ap->a_nch, ap->a_dvp,
                                ap->a_cred, ap->a_flags);
        hammer_done_transaction(&trans);
@@ -1960,6 +1979,7 @@ hammer_vop_ioctl(struct vop_ioctl_args *ap)
 {
        struct hammer_inode *ip = ap->a_vp->v_data;
 
+       ++hammer_stats_file_iopsr;
        return(hammer_ioctl(ip, ap->a_command, ap->a_data,
                            ap->a_fflag, ap->a_cred));
 }
@@ -2289,6 +2309,7 @@ hammer_vop_bmap(struct vop_bmap_args *ap)
        int     error;
        int     blksize;
 
+       ++hammer_stats_file_iopsr;
        ip = ap->a_vp->v_data;
 
        /*