From: Dmitry Kurochkin Date: Tue, 1 Feb 2011 06:38:11 +0000 (+0300) Subject: Shared Rock::DirMap version 8. X-Git-Tag: take01~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f70912794767d7148e0a4d72aaf8a2a6e9fd559f;p=thirdparty%2Fsquid.git Shared Rock::DirMap version 8. --- diff --git a/src/DiskIO/IpcIo/IpcIoFile.cc b/src/DiskIO/IpcIo/IpcIoFile.cc index 9246e6c479..f6e7f84500 100644 --- a/src/DiskIO/IpcIo/IpcIoFile.cc +++ b/src/DiskIO/IpcIo/IpcIoFile.cc @@ -12,6 +12,7 @@ #include "DiskIO/WriteRequest.h" #include "ipc/Messages.h" #include "ipc/Port.h" +#include "ipc/StrandCoord.h" #include "ipc/UdsOp.h" CBDATA_CLASS_INIT(IpcIoFile); @@ -43,7 +44,17 @@ IpcIoFile::open(int flags, mode_t mode, RefCount callback) if (IamDiskProcess()) { error_ = !DiskerOpen(dbName, flags, mode); + if (error_) + return; + ioRequestor->ioCompletedNotification(); + + Ipc::HereIamMessage ann(Ipc::StrandCoord(KidIdentifier, getpid())); + ann.strand.tag = dbName; + Ipc::TypedMsgHdr message; + ann.pack(message); + SendMessage(Ipc::coordinatorAddr, message); + return; } diff --git a/src/fs/rock/RockSwapDir.cc b/src/fs/rock/RockSwapDir.cc index 32f4c4363d..e1779c917c 100644 --- a/src/fs/rock/RockSwapDir.cc +++ b/src/fs/rock/RockSwapDir.cc @@ -156,6 +156,15 @@ Rock::SwapDir::init() // are refcounted. We up our count once to avoid implicit delete's. RefCountReference(); + if (!map && (!UsingSmp() || IamDiskProcess())) { + // XXX: polish, validateOptions() has same code + const int64_t eLimitHi = 0xFFFFFF; // Core sfileno maximum + const int64_t eLimitLo = 0; // dynamic shrinking unsupported + const int64_t eWanted = (maximumSize() - HeaderSize)/max_objsize; + const int64_t eAllowed = min(max(eLimitLo, eWanted), eLimitHi); + map = new DirMap(path, eAllowed); + } + DiskIOModule *m = DiskIOModule::Find("IpcIo"); // TODO: configurable? assert(m); io = m->createStrategy(); @@ -184,10 +193,6 @@ Rock::SwapDir::parse(int anIndex, char *aPath) repl = createRemovalPolicy(Config.replPolicy); - // map size is set when shared memory segment is created - if (!map) - map = new DirMap(path); - validateOptions(); } @@ -225,15 +230,16 @@ Rock::SwapDir::validateOptions() if (ps > 0 && (max_objsize % ps != 0)) fatal("Rock store max-size should be a multiple of page size"); - /* + /* XXX: should we support resize? const int64_t eLimitHi = 0xFFFFFF; // Core sfileno maximum - const int64_t eLimitLo = map.entryLimit(); // dynamic shrinking unsupported + const int64_t eLimitLo = map->entryLimit(); // dynamic shrinking unsupported const int64_t eWanted = (maximumSize() - HeaderSize)/max_objsize; const int64_t eAllowed = min(max(eLimitLo, eWanted), eLimitHi); - map.resize(eAllowed); // the map may decide to use an even lower limit + map->resize(eAllowed); // the map may decide to use an even lower limit */ + /* XXX: misplaced, map is not yet created // Note: We could try to shrink max_size now. It is stored in KB so we // may not be able to make it match the end of the last entry exactly. const int64_t mapRoundWasteMx = max_objsize*sizeof(long)*8; @@ -253,6 +259,7 @@ Rock::SwapDir::validateOptions() debugs(47, 0, "\tdisk space waste: " << totalWaste << " bytes"); debugs(47, 0, "WARNING: Rock store config wastes space."); } + */ if (!repl) { debugs(47,0, "ERROR: Rock cache_dir[" << index << "] " << @@ -260,7 +267,8 @@ Rock::SwapDir::validateOptions() // not fatal because it can be added later } - cur_size = (HeaderSize + max_objsize * map->entryCount()) >> 10; + // XXX: misplaced, map is not yet created + //cur_size = (HeaderSize + max_objsize * map->entryCount()) >> 10; } void @@ -415,6 +423,9 @@ Rock::SwapDir::ioCompletedNotification() fatalf("Rock cache_dir failed to open db file: %s", filePath); } + if (!map) + map = new DirMap(path); + cur_size = (HeaderSize + max_objsize * map->entryCount()) >> 10; // TODO: lower debugging level diff --git a/src/ipc/Strand.cc b/src/ipc/Strand.cc index 9c7e926249..54f82585ab 100644 --- a/src/ipc/Strand.cc +++ b/src/ipc/Strand.cc @@ -41,17 +41,6 @@ void Ipc::Strand::registerSelf() Must(!isRegistered); HereIamMessage ann(StrandCoord(KidIdentifier, getpid())); - - // announce that we are responsible for our cache_dir if needed - // XXX: misplaced - if (IamDiskProcess()) { - const int myDisk = KidIdentifier % Config.cacheSwap.n_processes; - if (const SwapDir *sd = dynamic_cast(INDEXSD(myDisk))) { - ann.strand.tag = sd->path; - ann.strand.tag.append("/rock"); // XXX: scope boundary violation - } - } - TypedMsgHdr message; ann.pack(message); SendMessage(coordinatorAddr, message); diff --git a/src/main.cc b/src/main.cc index 5adfa0edc2..1aaebde76c 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1370,15 +1370,6 @@ SquidMain(int argc, char **argv) Ip::ProbeTransport(); // determine IPv4 or IPv6 capabilities before parsing. - debugs(0,0, HERE << '1'); - if (IamMasterProcess()) { - debugs(0,0, HERE << '2'); - new Rock::DirMap("/home/dikk/projects/factory/squid/rock_smp/rock1", 1000); - new Rock::DirMap("/home/dikk/projects/factory/squid/rock_smp/rock2", 1000); - new Rock::DirMap("/home/dikk/projects/factory/squid/rock_smp/rock3", 1000); - } - debugs(0,0, HERE << '3'); - parse_err = parseConfigFile(ConfigFile); Mem::Report();