What follows is a patch to 1.1.8 for a possible way to implement a helper
unlinkd.  Someone just needs to put in the code that implements the
interprocess protocol...
>> #1. Something that's dead easy to do that'll give an immediate 20%
>> improvement on our box is to has a seperate process doing the
>> unlink()'s. i.e. spawn off
>>	perl -nle unlink
>> and write the name of the files to the process instead of trying to do
>> it in squid. Nice and easy to do.
> I've had this on my todo list for a while, but have been out of round
> tuits for just as long.  The thing you have to watch out for is
> reuse of the file after you have queued the unlink (i.e. you don't
> want squid to request an unlink, reuse the file (overwrite it), and then
> have the cooperating process come along and unlink it).
> The simplist way to synchronise the two is to leave the file
> number set in the file bitmap and defer the clear until the unlink
> process acknowledges it.  Whilst I don't think perl the right tool
> to implement the unlink daemon, it would become
>	perl -ple unlink
>
> I think this would speed up the reload process considerably.
> RebuildFromDisk would just need to temporarily set the fileno in the
> filemap.
>
> - Mark.
Note: line numbers will be out in store.c
*** /tmp/T0a004Nk	Tue Mar 18 22:02:13 1997
--- store.c	Tue Mar 18 21:52:52 1997
***************
*** 1241,1248 ****
          put_free_8k_page(mem->e_swap_buf);
          file_close(fd);
          if (e->swap_file_number != -1) {
! 	    file_map_bit_reset(e->swap_file_number);
! 	    safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 0);
              e->swap_file_number = -1;
          }
          storeRelease(e);
--- 1241,1247 ----
          put_free_8k_page(mem->e_swap_buf);
          file_close(fd);
          if (e->swap_file_number != -1) {
! 	    queue_unlinkrequest(e->swap_file_number, 0);
              e->swap_file_number = -1;
          }
          storeRelease(e);
***************
*** 1404,1410 ****
              storeSwapFullPath(sfileno, swapfile);
          if (x != 6) {
              if (opt_unlink_on_reload && swapfile[0])
! 		safeunlink(swapfile, 0);
              continue;
          }
          if (sfileno < 0 || sfileno >= MAX_SWAP_FILE)
--- 1403,1410 ----
              storeSwapFullPath(sfileno, swapfile);
          if (x != 6) {
              if (opt_unlink_on_reload && swapfile[0])
! 		if (!file_map_bit_test(sfileno))
! 		    queue_unlinkrequest(sfileno, 0);
              continue;
          }
          if (sfileno < 0 || sfileno >= MAX_SWAP_FILE)
***************
*** 1418,1430 ****
              if (stat(swapfile, &sb) < 0) {
                  debug(50, 3, "storeRebuildFromDisk: Swap file missing: '%s': %s: %s.\n", url, swapfile, xstrerror());
                  if (opt_unlink_on_reload)
! 		    safeunlink(swapfile, 1);
                  continue;
              }
              /* Empty swap file? */
              if (sb.st_size == 0) {
                  if (opt_unlink_on_reload)
! 		    safeunlink(swapfile, 1);
                  continue;
              }
              /* Wrong size? */
--- 1418,1430 ----
              if (stat(swapfile, &sb) < 0) {
                  debug(50, 3, "storeRebuildFromDisk: Swap file missing: '%s': %s: %s.\n", url, swapfile, xstrerror());
                  if (opt_unlink_on_reload)
! 		    queue_unlinkrequest(sfileno, 1);
                  continue;
              }
              /* Empty swap file? */
              if (sb.st_size == 0) {
                  if (opt_unlink_on_reload)
! 		    queue_unlinkrequest(sfileno, 1);
                  continue;
              }
              /* Wrong size? */
***************
*** 1441,1447 ****
                  /* already have a newer object in memory, throw old one away */
                  debug(20, 3, "storeRebuildFromDisk: Replaced: %s\n", url);
                  if (opt_unlink_on_reload)
! 		    safeunlink(swapfile, 1);
                  rebuildData->dupcount++;
                  continue;
              }
--- 1441,1447 ----
                  /* already have a newer object in memory, throw old one away */
                  debug(20, 3, "storeRebuildFromDisk: Replaced: %s\n", url);
                  if (opt_unlink_on_reload)
! 		    queue_unlinkrequest(sfileno, 1);
                  rebuildData->dupcount++;
                  continue;
              }
***************
*** 2080,2087 ****
          debug(20, 5, "storeRelease: Release anonymous object\n");
  
      if (e->swap_status == SWAP_OK && (e->swap_file_number > -1)) {
! 	(void) safeunlink(storeSwapFullPath(e->swap_file_number, NULL), 1);
! 	file_map_bit_reset(e->swap_file_number);
          e->swap_file_number = -1;
          store_swap_size -= (e->object_len + 1023) >> 10;
          HTTPCacheInfo->proto_purgeobject(HTTPCacheInfo,
--- 2080,2086 ----
          debug(20, 5, "storeRelease: Release anonymous object\n");
  
      if (e->swap_status == SWAP_OK && (e->swap_file_number > -1)) {
! 	queue_unlinkrequest(e->swap_file_number, 1);
          e->swap_file_number = -1;
          store_swap_size -= (e->object_len + 1023) >> 10;
          HTTPCacheInfo->proto_purgeobject(HTTPCacheInfo,
*** /tmp/T0a004Nk	Tue Mar 18 22:02:15 1997
--- tools.c	Tue Mar 18 22:01:54 1997
***************
*** 469,474 ****
--- 469,504 ----
      return (err);
  }
  
+ void
+ queue_unlinkrequest(int filenumber, int quiet)
+ {
+     static int which_child;
+     int	nth_child;
+     LOCAL_ARRAY(char, swapfile, MAXPATHLEN);
+ 
+     file_map_bit_set(filenumber);
+     storeSwapFullPath(filenumber, swapfile);
+     nth_child = (++which_child%Config.unlinkProcs)
+     send unlink swapfile to nth_child process;
+ }
+ 
+ /* child process acknowledges the unlink, make the fileno available for reuse */
+ void
+ receive_unlinkack()
+ {
+     LOCAL_ARRAY(char, swapfile, MAXPATHLEN);
+     int filenumber;
+     char *p;
+ 
+     read acknowledgement from child into swapfile array;
+ 
+     if (!(p = strrchr('/', swapfile))
+ 	return; /* garbled */
+     p++;
+     filenumber = strtoul(p, NULL, 0);
+     file_map_bit_reset(filenumber);
+ }
+ 
  /* leave a privilegied section. (Give up any privilegies)
   * Routines that need privilegies can rap themselves in enter_suid()
   * and leave_suid()
Received on Tue Mar 18 1997 - 03:16:06 MST
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:34:43 MST