]> git.ipfire.org Git - thirdparty/squid.git/blob - src/fs/coss/StoreFScoss.cc
ported COSS enhancements from squid-2.5 code (dated ~ July 25-29, 2003).
[thirdparty/squid.git] / src / fs / coss / StoreFScoss.cc
1
2 /*
3 * $Id: StoreFScoss.cc,v 1.2 2003/08/27 21:19:38 wessels Exp $
4 *
5 * DEBUG: section 47 Store Directory Routines
6 * AUTHOR: Robert Collins
7 *
8 * SQUID Web Proxy Cache http://www.squid-cache.org/
9 * ----------------------------------------------------------
10 *
11 * Squid is the result of efforts by numerous individuals from
12 * the Internet community; see the CONTRIBUTORS file for full
13 * details. Many organizations have provided support for Squid's
14 * development; see the SPONSORS file for full details. Squid is
15 * Copyrighted (C) 2001 by the Regents of the University of
16 * California; see the COPYRIGHT file for full details. Squid
17 * incorporates software developed and/or copyrighted by other
18 * sources; see the CREDITS file for full details.
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
33 *
34 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
35 */
36
37 #include "StoreFileSystem.h"
38 #include "fs/coss/StoreFScoss.h"
39 #include "store_coss.h"
40 #include "Store.h"
41
42 struct _coss_stats coss_stats;
43
44 static void storeCossStats(StoreEntry *);
45
46 StoreFScoss StoreFScoss::_instance;
47
48 StoreFileSystem &
49 StoreFScoss::GetInstance()
50 {
51 return _instance;
52 }
53
54 StoreFScoss::StoreFScoss()
55 {
56 FsAdd(*this);
57 }
58
59 char const *
60 StoreFScoss::type() const
61 {
62 return "coss";
63 }
64
65 void
66 StoreFScoss::done()
67 {
68 /* memPoolDestroy(&coss_index_pool); XXX Should be here? */
69 cachemgrRegister("coss", "COSS Stats", storeCossStats, 0, 1);
70 initialised = false;
71 }
72
73 SwapDir *
74 StoreFScoss::createSwapDir()
75 {
76 SwapDir *result = new CossSwapDir;
77 return result;
78 }
79
80
81 void
82 StoreFScoss::setup()
83 {
84 assert(!initialised);
85
86 coss_index_pool = memPoolCreate("COSS index data", sizeof(CossIndexNode));
87 initialised = true;
88 }
89
90 static void
91 storeCossStats(StoreEntry * sentry)
92 {
93 const char *tbl_fmt = "%10s %10d %10d %10d\n";
94 storeAppendPrintf(sentry, "\n OPS SUCCESS FAIL\n");
95 storeAppendPrintf(sentry, tbl_fmt,
96 "open", coss_stats.open.ops, coss_stats.open.success, coss_stats.open.fail);
97 storeAppendPrintf(sentry, tbl_fmt,
98 "create", coss_stats.create.ops, coss_stats.create.success, coss_stats.create.fail);
99 storeAppendPrintf(sentry, tbl_fmt,
100 "close", coss_stats.close.ops, coss_stats.close.success, coss_stats.close.fail);
101 storeAppendPrintf(sentry, tbl_fmt,
102 "unlink", coss_stats.unlink.ops, coss_stats.unlink.success, coss_stats.unlink.fail);
103 storeAppendPrintf(sentry, tbl_fmt,
104 "read", coss_stats.read.ops, coss_stats.read.success, coss_stats.read.fail);
105 storeAppendPrintf(sentry, tbl_fmt,
106 "write", coss_stats.write.ops, coss_stats.write.success, coss_stats.write.fail);
107 storeAppendPrintf(sentry, tbl_fmt,
108 "s_write", coss_stats.stripe_write.ops, coss_stats.stripe_write.success, coss_stats.stripe_write.fail);
109
110 storeAppendPrintf(sentry, "\n");
111 storeAppendPrintf(sentry, "stripes: %d\n", coss_stats.stripes);
112 storeAppendPrintf(sentry, "alloc.alloc: %d\n", coss_stats.alloc.alloc);
113 storeAppendPrintf(sentry, "alloc.realloc: %d\n", coss_stats.alloc.realloc);
114 storeAppendPrintf(sentry, "alloc.collisions: %d\n", coss_stats.alloc.collisions);
115 storeAppendPrintf(sentry, "disk_overflows: %d\n", coss_stats.disk_overflows);
116 storeAppendPrintf(sentry, "stripe_overflows: %d\n", coss_stats.stripe_overflows);
117 storeAppendPrintf(sentry, "open_mem_hits: %d\n", coss_stats.open_mem_hits);
118 storeAppendPrintf(sentry, "open_mem_misses: %d\n", coss_stats.open_mem_misses);
119 }