]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Shared Rock::DirMap version 8.
authorDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Tue, 1 Feb 2011 06:38:11 +0000 (09:38 +0300)
committerDmitry Kurochkin <dmitry.kurochkin@measurement-factory.com>
Tue, 1 Feb 2011 06:38:11 +0000 (09:38 +0300)
src/DiskIO/IpcIo/IpcIoFile.cc
src/fs/rock/RockSwapDir.cc
src/ipc/Strand.cc
src/main.cc

index 9246e6c4790e6109bb25782c5e5d17f3858a7aa5..f6e7f8450025df987d84657263e4fbb2c5578932 100644 (file)
@@ -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<IORequestor> 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;
        }        
 
index 32f4c4363d0f996e930aeb9a9b4059720064f03a..e1779c917c9019aac9b1334635c181d5532be96d 100644 (file)
@@ -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
index 9c7e926249bfeb2d479f4a422bdcebb8b2908874..54f82585ab2ae880dd132937f807fc4f6333f91d 100644 (file)
@@ -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<const SwapDir*>(INDEXSD(myDisk))) {
-            ann.strand.tag = sd->path;
-            ann.strand.tag.append("/rock"); // XXX: scope boundary violation
-               }
-       }
-
     TypedMsgHdr message;
     ann.pack(message);
     SendMessage(coordinatorAddr, message);
index 5adfa0edc2c2bed77f719c7f292cab2b4695452d..1aaebde76c58acaee8adb1dc73aa8fa71833ecc0 100644 (file)
@@ -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();