On Fri, 2009-01-09 at 08:57 -0600, Matt Brookings wrote:
> This would not work because users can be deleted out of the hash tree
> anywhere.  It appears your patch assumes a FILO ordering of user additions
> and deletions.
I have not been able to explain properly. It would be FIFO.

> If the hashes, 'a' through 'd' existed, and the 'b' hash directory cleared
> out, your method would fail to backfill correctly.
Let's take an example
suppose
there are 100 users (with 100 directories) in /var/vpopmail/domains
there are 100 users (with 100 directories) in /var/vpopmail/domains/0
there are 100 users (with 100 directories) in /var/vpopmail/domains/1
there are 100 users (with 100 directories) in /var/vpopmail/domains/2
there are 50  users (with  50 direcotires) in /var/vpopmail/domains/3

Now let say I delete a user who has a directory
in /var/vpopmail/domains/1
The backfill code will put the entry '1' in the first line in the file
dir_control_free.
Also let us say that we delete two users in /var/vpopmail/domains/2
The backfill code in vdeluser will put entry '2' twice in the file
dir_control_free

So after deleting 3 users, the file dir_control_free will have 3 lines
1
2
2


So now we have 99 users in /var/vpopmail/domains/1
and    we have 98 users in /var/vpopmail/domains/2

Now the modified vadduser will call a function called backfill() which
will open this file, lock the file and pickup the first line, delete the
line and return the value as user_hash

#ifdef USERS_BIG_DIR
  /* go into a user hash dir if required */
  if (!(user_hash = backfill(domain)))
  {
  open_big_dir(domain, uid, gid);
  user_hash = next_big_dir(uid, gid);
  close_big_dir(domain, uid, gid);
  chdir(user_hash);
  }
#endif

Each time the function backfill() is called it will deplete the file
dir_control_free by one line and will always return the first line as
the user_hash. When all lines get depleted, backfill() will return NULL
in which case the regular dir_control will again come into effect and
start from where it had left earlier.

The advantage of this method is that you can use the find command to
generate the missing directories in dir_control_free to catch up with
the actual dir_control.

Another way to explain this is that when backfill is in operation,
dir_control stops working and when backfill() gets depleted and stops
working, dir_control starts working


!DSPAM:496b235e32678184414047!

Reply via email to