Subject: Re: samba 2.2 lock problem
To: Bill Squier <groo@old-ones.com>
From: Bill Squier <groo@old-ones.com>
List: tech-pkg
Date: 05/31/2001 23:34:30
On Thu, May 31, 2001 at 10:49:35PM -0400, Bill Squier wrote:
> 
> Just saw your post in the tech-pkg archive.  Same thing is happening to me.
> 
> (root, 23) /var/samba>du -sk locks
> 788555  locks
> (root, 24) /var/samba>ls -l locks
> total 788554
> -rw-r--r--  1 root  wheel       3800 May 26 12:58 STATUS..LCK
> -rw-r--r--  1 root  wheel        696 May 30 21:16 brlock.tdb
> -rw-r--r--  1 root  wheel        228 May 31 22:46 browse.dat
> -rw-r--r--  1 root  wheel  807026688 May 31 22:37 connections.tdb
> -rw-r--r--  1 root  wheel        696 May 30 21:16 locking.tdb
> -rw-------  1 root  wheel        696 May 28 19:27 messages.tdb
> -rw-r--r--  1 root  wheel         20 May 28 19:28 nmbd.pid
> -rw-------  1 root  wheel       8192 May 30 21:16 ntdrivers.tdb
> -rw-------  1 root  wheel       8192 May 30 21:16 printing.tdb
> -rw-------  1 root  wheel       8192 May 30 21:16 share_info.tdb
> -rw-r--r--  1 root  wheel         20 May 28 19:28 smbd.pid
> -rw-r--r--  1 root  wheel       8192 May 28 19:32 unexpected.tdb
> 
> Hear anything back?

Also CC'ing tech-pkg since people reported it there.

"All the world looks like Linux".  If you have a system that doesn't have
UBC, you'll want to apply this patch (from Jeremy Allison on Samba's
tech list, http://marc.theaimsgroup.com/?l=samba-technical&m=98901288703284&w=2)

Save the following to a file (say tdb.patch), and from
/usr/pkgsrc/net/samba/work/samba-2.2.0/source/tdb, do:

patch -l <tdb.patch





--- tdb.c       Fri Apr 13 17:36:46 2001
+++ /tmp/tdb.c  Fri May  4 14:35:34 2001
@@ -439,20 +439,24 @@
            the database up to a multiple of TDB_PAGE_SIZE */
        size = TDB_ALIGN(tdb->map_size + size*10, TDB_PAGE_SIZE) - tdb->map_size;
 
-       /* expand the file itself */
-        if (!(tdb->flags & TDB_INTERNAL)) {
-               lseek(tdb->fd, tdb->map_size + size - 1, SEEK_SET);
-               if (write(tdb->fd, &b, 1) != 1) goto fail;
-        }
-
        if (!(tdb->flags & TDB_INTERNAL) && tdb->map_ptr)
                tdb->map_ptr = tdb_munmap(tdb->map_ptr, tdb->map_size);
 
+       /* expand the file itself */
+       if (!(tdb->flags & TDB_INTERNAL)) {
+               if (lseek(tdb->fd, tdb->map_size + size - 1, SEEK_SET)!=tdb->map_size + size - 1)
+                       goto fail;
+               if (write(tdb->fd, &b, 1) != 1) goto fail;
+       }
+
        tdb->map_size += size;
 
        if (tdb->flags & TDB_INTERNAL)
                tdb->map_ptr = realloc(tdb->map_ptr, tdb->map_size);
 
+       if (!(tdb->flags & TDB_NOMMAP))
+               tdb->map_ptr = tdb_mmap(tdb->map_size, 0, tdb->fd);
+
        /* form a new freelist record */
        memset(&rec,'\0',sizeof(rec));
        rec.rec_len = size - sizeof(rec);
@@ -460,9 +464,6 @@
        /* link it into the free list */
        offset = tdb->map_size - size;
        if (tdb_free(tdb, offset, &rec) == -1) goto fail;
-
-       if (!(tdb->flags & TDB_NOMMAP))
-               tdb->map_ptr = tdb_mmap(tdb->map_size, 0, tdb->fd);
 
        tdb_unlock(tdb, -1, F_WRLCK);
        return 0;


-- 
Bill Squier (groo@old-ones.com)                          http://www.netbsd.org

        I know I don't deserve another chance, but this _is_ America,
        and as an American, aren't I entitled to one?  --Sideshow Bob.