source: gpfs_3.1_ker2.6.20/lpp/mmfs/src/gpl-linux/cxiVFSStats.c @ 148

Last change on this file since 148 was 16, checked in by rock, 17 years ago
File size: 3.3 KB
Line 
1/***************************************************************************
2 *
3 * Copyright (C) 2001 International Business Machines
4 * All rights reserved.
5 *
6 * This file is part of the GPFS mmfslinux kernel module.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 *  1. Redistributions of source code must retain the above copyright notice,
13 *     this list of conditions and the following disclaimer.
14 *  2. Redistributions in binary form must reproduce the above copyright
15 *     notice, this list of conditions and the following disclaimer in the
16 *     documentation and/or other materials provided with the distribution.
17 *  3. The name of the author may not be used to endorse or promote products
18 *     derived from this software without specific prior written
19 *     permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 *************************************************************************** */
33/* @(#)17       1.3  src/avs/fs/mmfs/ts/kernext/gpl-linux/cxiVFSStats.c, mmfs, avs_rgpfs24, rgpfs240610b 10/17/02 21:23:19 */
34/*
35 * Linux implementation of VFSStatPoint
36 *
37 */
38
39#include <Shark-gpl.h>
40
41#define DEFINE_VFSSTATS_GBL_VARS /* allocate storage for trace globals */
42
43#include <linux/kernel.h>
44#include <linux/module.h>
45#include <linux/sched.h>
46#include <linux/slab.h>
47
48#include <cxiSystem.h>
49#include <cxiVFSStats.h>
50
51void VFSStatPoint_begin(VFSStatPoint_t *objPtr, enum VFSStatItem i)
52{
53  cxiGetTOD(&(objPtr->beginTime));
54  objPtr->statItem = i;
55}
56
57void VFSStatPoint_end(VFSStatPoint_t *objPtr)
58{
59  cxiTimeStruc_t endTime;
60  cxiTimeStruc_t t;
61
62  if (objPtr->statItem != nullCall)
63  {
64    /* Get the current time and store in endTime */
65    cxiGetTOD(&endTime);
66
67    /* Calculate the new value of totalTime in vfsStats.data[statItem] as
68         totalTime = totalTime + (endTime - beginTime) */
69    t.tv_sec = vfsStats.data[objPtr->statItem].totalTime.tv_sec
70                + endTime.tv_sec - objPtr->beginTime.tv_sec;
71    t.tv_nsec = vfsStats.data[objPtr->statItem].totalTime.tv_nsec
72                 + endTime.tv_nsec - objPtr->beginTime.tv_nsec;
73    if (t.tv_nsec >= 1000000000)
74    {
75      t.tv_sec++;
76      t.tv_nsec -= 1000000000;
77    }
78    else if (t.tv_nsec < 0)
79    {
80      t.tv_sec--;
81      t.tv_nsec += 1000000000;
82    }
83
84    /* update the count and value of totalTime in vfsStats.data[statItem] */
85    vfsStats.data[objPtr->statItem].cnt++;
86    vfsStats.data[objPtr->statItem].totalTime = t;
87  }
88}
89
90#ifdef KCSTRACE
91void cxiKcsTraceInfo(int index, int value)
92{
93  current->kcst_info.data[index] = value;
94}
95#endif
Note: See TracBrowser for help on using the repository browser.