From owner-freebsd-audit Wed Aug 8 7:47:19 2001 Delivered-To: freebsd-audit@freebsd.org Received: from freebsd.org.ru (sweet.etrust.ru [194.84.67.5]) by hub.freebsd.org (Postfix) with ESMTP id C1C2B37B40A for ; Wed, 8 Aug 2001 07:47:13 -0700 (PDT) (envelope-from osa@freebsd.org.ru) Received: by freebsd.org.ru (Postfix, from userid 1000) id 26BD674; Wed, 8 Aug 2001 18:47:11 +0400 (MSD) Date: Wed, 8 Aug 2001 18:47:11 +0400 From: "Sergey A. Osokin" To: audit@FreeBSD.org Subject: [PATCH] libdevstat have two compute statistics functions Message-ID: <20010808184710.A87195@freebsd.org.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.3.20i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --envbJBWh7q8WU6mo Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello. After last commit into libdevstat, devstat.c containes 2 compute statistics functions: old compute_stats() and new devstat_compute_statistics(). I believe that compute_stats() is not necessary any more and we should remove it. devstat_compute_statistics() is a superset for compute_stats(). Thanks. -- Rgdz, /"\ Sergey Osokin aka oZZ, \ / ASCII RIBBON CAMPAIGN osa@freebsd.org.ru X AGAINST HTML MAIL http://freebsd.org.ru/~osa/ / \ --envbJBWh7q8WU6mo Content-Type: text/plain; charset=koi8-r Content-Disposition: attachment; filename="patch-devstat.c" Content-Transfer-Encoding: 8bit --- devstat.c.orig Wed Aug 8 14:44:11 2001 +++ devstat.c Wed Aug 8 14:55:21 2001 @@ -1129,89 +1129,16 @@ long double *mb_per_second, long double *blocks_per_second, long double *ms_per_transaction) { - u_int64_t totalbytes, totaltransfers, totalblocks; - char *func_name = "compute_stats"; - - /* - * current is the only mandatory field. - */ - if (current == NULL) { - snprintf(devstat_errbuf, sizeof(devstat_errbuf), - "%s: current stats structure was NULL", - func_name); - return(-1); - } - - totalbytes = (current->bytes_written + current->bytes_read) - - ((previous) ? (previous->bytes_written + - previous->bytes_read) : 0); - - if (total_bytes) - *total_bytes = totalbytes; - - totaltransfers = (current->num_reads + - current->num_writes + - current->num_other) - - ((previous) ? - (previous->num_reads + - previous->num_writes + - previous->num_other) : 0); - if (total_transfers) - *total_transfers = totaltransfers; - - if (transfers_per_second) { - if (etime > 0.0) { - *transfers_per_second = totaltransfers; - *transfers_per_second /= etime; - } else - *transfers_per_second = 0.0; - } - - if (kb_per_transfer) { - *kb_per_transfer = totalbytes; - *kb_per_transfer /= 1024; - if (totaltransfers > 0) - *kb_per_transfer /= totaltransfers; - else - *kb_per_transfer = 0.0; - } - - if (mb_per_second) { - *mb_per_second = totalbytes; - *mb_per_second /= 1024 * 1024; - if (etime > 0.0) - *mb_per_second /= etime; - else - *mb_per_second = 0.0; - } - - totalblocks = totalbytes; - if (current->block_size > 0) - totalblocks /= current->block_size; - else - totalblocks /= 512; - - if (total_blocks) - *total_blocks = totalblocks; - - if (blocks_per_second) { - *blocks_per_second = totalblocks; - if (etime > 0.0) - *blocks_per_second /= etime; - else - *blocks_per_second = 0.0; - } - - if (ms_per_transaction) { - if (totaltransfers > 0) { - *ms_per_transaction = etime; - *ms_per_transaction /= totaltransfers; - *ms_per_transaction *= 1000; - } else - *ms_per_transaction = 0.0; - } - - return(0); + return(devstat_compute_statistics(current, previous, etime, + DSM_TOTAL_BYTES, total_bytes, + DSM_TOTAL_TRANSFERS, total_transfers, + DSM_TOTAL_BLOCKS, total_blocks, + DSM_KB_PER_TRANSFER, kb_per_transfer, + DSM_TRANSFERS_PER_SECOND, transfers_per_second, + DSM_MB_PER_SECOND, mb_per_second, + DSM_BLOCKS_PER_SECOND, blocks_per_second, + DSM_MS_PER_TRANSACTION, ms_per_transaction, + DSM_NONE)); } long double --envbJBWh7q8WU6mo-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message