fcntl F_SETLKW64 failing on Solaris

David Collier-Brown davecb at canada.sun.com
Tue Jan 8 11:50:03 GMT 2002


Well, the pstack seems to be showing us a problem  with fd
10 (0xA), command F_UNLCK, as we saw before...

---
6881:  smbd
 ff21630c __fcntl  (a, 22, 22, ffbef248, 215a8, 115aac) + c
 00115aac tdb_brlock (1ce6c8, 4f2c4, 3, 22, 0, 116f2c) + 60
 001173e0 write_unlock_record (1ce6c8, 4f2c4, 399de24c, ffbef3f0,
21dc0,
ff1c0d48) + 14
 001174ac do_delete (1ce6c8, 4f2c4, ffbef3f0, ffbef3f0, 0, 26cea8) +
50
 00117b00 tdb_delete (ffbef3f0, ffbef480, 1a4b58, ffbef480, 0, 2eef1)
+ 3c
 000e9f94 del_share_entry (0, 1, 2eef1, ffbef500, ffbef59c, 2eef1) +
200
 000ea044 del_share_mode (26d5e0, ffbef59c, 0, 0, 63007a68, 63000000)
+ 2c
 00061a30 close_normal_file (26d5e0, 1, 0, 4, 74, ffbef680) + 64
 00061df0 close_file (26d5e0, 1, 3ff, 19ec00, 0, 221da1) + 30
 000502b0 reply_close (26d908, 211931, 221d79, 2e, f000, 50120) + 190
 0006b18c switch_message (4, 211931, 221d79, 2e, f000, 2119bd) + 514
 0006b218 construct_reply (211931, 221d79, 2e, f000, 0, ffbefbe1) + 60
 0006b4c4 process_smb (211931, 221d79, ea60, 1, 0, 0) + 1bc
 0006bec4 smbd_process (1, 8b, 186a0, 1, ff238fbc, 128ca0) + 134
 0002efe0 main     (0, ffbefd3c, ffbefd44, 1b7e08, 0, 0) + 7a8
 0002d8d0 _start   (0, 0, 0, 0, 0, 0) + 5c
---

The pfiles entry for file 10 says
---
  10: S_IFREG mode:0644 dev:136,3 ino:97602 uid:0 gid:0 size:622592
      O_RDWR|O_LARGEFILE
     advisory read lock set by process 27796
--

and the code says:
--
       if (fcntl(tdb->fd,lck_type,&fl)) {
                if (!probe) {
                        TDB_LOG((tdb, 5,"tdb_brlock failed at offset
%d rw_type=%d lck_type=%d\n",
                                 offset, rw_type, lck_type));
                }
                /* errno set by fcntl */
                return TDB_ERRCODE(TDB_ERR_LOCK, -1);
---

probe is a parameter, usually but not always set to 0:

--
  File  Function            Line
1 tdb.c tdb_lock             199 } else if
                                
(tdb_brlock(tdb,FREELIST_TOP+4*list,ltype,F_SET
                                 LKW, 0)) {
2 tdb.c tdb_unlock           227 tdb_brlock(tdb, FREELIST_TOP+4*list,
F_UNLCK,
                                 F_SETLKW, 0);
3 tdb.c lock_record         1015 return off ? tdb_brlock(tdb, off,
F_RDLCK,
                                 F_SETLKW, 0) : 0;
4 tdb.c write_lock_record   1029 return tdb_brlock(tdb, off, F_WRLCK,
F_SETLK,
                                 1);
--

I'd reccomend  forcing probe true and adding a
log call to record the tdb name and fd, plus the errno.The errno
should be one of:
---
EAGAIN    the  file  is
            currently   being   mapped  to  virtual  memory  using
            mmap(2)

EBADF The fildes argument is not a valid open file  descriptor
	or 
	the type of lock, l_type,  is
            a  shared  lock  (F_RDLCK),  and fildes is not a valid
            file descriptor open for reading; or the type of  lock
            l_type  is  an  exclusive lock (F_WRLCK) and fildes is
            not a valid file descriptor open for writing.

 EFAULT the arg argument points to an illegal address.

 EINTR The cmd argument is F_SETLKW  or  F_SETLKW64  and  the
            function was interrupted by a signal.

EINVAL the data pointed to by arg is not valid or  fildes
            refers to a file that does not support locking.

 EIO   An I/O error occurred while reading from or writing to
            the file system.

 ENOLCK satisfying the lock or unlock request
            would result in the number of locked  regions  in  the
            system exceeding a system-imposed limit.

 EOVERFLOW  One of the values to be returned cannot be represented
            correctly (it was 64-bit on a 32-bit system)
 	  or if l_len is non-zero,
            the largest, offset of any byte in the requested  seg-
            ment  cannot  be represented correctly in an object of
            type off64_t.
 EDEADLK the  lock
            is  blocked by some lock from another process and put-
            ting the calling process to sleep,  waiting  for  that
            lock to become free would cause a deadlock.
---

I suspect we're seeing a Solaris-specific bug, but without
the errno I'm puzzled as to what we should do about it.
ENOLCK would be easier to deal with than EOVERFLOW, and
harder than EIO ir EINTR...

--dave
-- 
David Collier-Brown,           | Always do right. This will gratify 
Americas Customer Engineering, | some people and astonish the rest.
SunPS Integration Services.    |                      -- Mark Twain
(905) 415-2849                 | davecb at canada.sun.com




More information about the samba-technical mailing list