Add disk_isbusy(), iostat_isbusy().

This commit is contained in:
ad 2009-04-04 07:30:09 +00:00
parent 088cca6a88
commit 4307e10df2
4 changed files with 31 additions and 9 deletions

View File

@ -1,7 +1,7 @@
/* $NetBSD: subr_disk.c,v 1.94 2009/01/22 14:38:35 yamt Exp $ */
/* $NetBSD: subr_disk.c,v 1.95 2009/04/04 07:30:10 ad Exp $ */
/*-
* Copyright (c) 1996, 1997, 1999, 2000 The NetBSD Foundation, Inc.
* Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.94 2009/01/22 14:38:35 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_disk.c,v 1.95 2009/04/04 07:30:10 ad Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -271,6 +271,16 @@ disk_unbusy(struct disk *diskp, long bcount, int read)
iostat_unbusy(diskp->dk_stats, bcount, read);
}
/*
* Return true if disk has an I/O operation in flight.
*/
bool
disk_isbusy(struct disk *diskp)
{
return iostat_isbusy(diskp->dk_stats);
}
/*
* Set the physical blocksize of a disk, in bytes.
* Only necessary if blocksize != DEV_BSIZE.

View File

@ -1,8 +1,8 @@
/* $NetBSD: subr_iostat.c,v 1.16 2009/01/22 14:38:35 yamt Exp $ */
/* $NetBSD: subr_iostat.c,v 1.17 2009/04/04 07:30:10 ad Exp $ */
/* NetBSD: subr_disk.c,v 1.69 2005/05/29 22:24:15 christos Exp */
/*-
* Copyright (c) 1996, 1997, 1999, 2000 The NetBSD Foundation, Inc.
* Copyright (c) 1996, 1997, 1999, 2000, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -68,7 +68,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.16 2009/01/22 14:38:35 yamt Exp $");
__KERNEL_RCSID(0, "$NetBSD: subr_iostat.c,v 1.17 2009/04/04 07:30:10 ad Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@ -222,6 +222,16 @@ iostat_unbusy(struct io_stats *stats, long bcount, int read)
}
}
/*
* Return non-zero if a device has an I/O request in flight.
*/
bool
iostat_isbusy(struct io_stats *stats)
{
return stats->io_busy != 0;
}
/*
* Increment the seek counter. This does look almost redundant but it
* abstracts the stats gathering.

View File

@ -1,4 +1,4 @@
/* $NetBSD: disk.h,v 1.51 2008/04/28 20:24:10 martin Exp $ */
/* $NetBSD: disk.h,v 1.52 2009/04/04 07:30:09 ad Exp $ */
/*-
* Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
@ -502,6 +502,7 @@ void disk_init(struct disk *, const char *, const struct dkdriver *);
void disk_destroy(struct disk *);
void disk_busy(struct disk *);
void disk_unbusy(struct disk *, long, int);
bool disk_isbusy(struct disk *);
void disk_blocksize(struct disk *, int);
struct disk *disk_find(const char *);
int disk_ioctl(struct disk *, u_long, void *, int, struct lwp *);

View File

@ -1,7 +1,7 @@
/* $NetBSD: iostat.h,v 1.9 2008/04/28 20:24:10 martin Exp $ */
/* $NetBSD: iostat.h,v 1.10 2009/04/04 07:30:09 ad Exp $ */
/*-
* Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
* Copyright (c) 1996, 1997, 2004, 2009 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@ -98,6 +98,7 @@ TAILQ_HEAD(iostatlist_head, io_stats); /* the iostatlist is a TAILQ */
void iostat_init(void);
void iostat_busy(struct io_stats *);
void iostat_unbusy(struct io_stats *, long, int);
bool iostat_isbusy(struct io_stats *);
struct io_stats *iostat_find(const char *);
struct io_stats *iostat_alloc(int32_t, void *, const char *);
void iostat_free(struct io_stats *);