Using dbgtext for logging

Dan Cohen1 DANCOH at
Wed Jul 31 03:00:18 MDT 2013


While doing some work on samba logging I've noticed that there are several 
places in the samba code where logging is done directly using the dbgtext 
function. For example: in source3/smbd/oplock.c:initial_break_processing 
(line 267):

static files_struct *initial_break_processing(
    struct smbd_server_connection *sconn, struct file_id id,
    unsigned long file_id)
    files_struct *fsp = NULL;

    if( DEBUGLVL( 3 ) ) {
        dbgtext( "initial_break_processing: called for %s/%u\n",
             file_id_string_tos(&id), (int)file_id);
        dbgtext( "Current oplocks_open (exclusive = %d, levelII = %d)\n",

     * We need to search the file open table for the
     * entry containing this dev and inode, and ensure
     * we have an oplock on it.

    fsp = file_find_dif(sconn, id, file_id);

    if(fsp == NULL) {
        /* The file could have been closed in the meantime - return 
success. */
        if( DEBUGLVL( 3 ) ) {
            dbgtext( "initial_break_processing: cannot find open file with 
" );
            dbgtext( "file_id %s gen_id = %lu", file_id_string_tos(&id), 
            dbgtext( "allowing break to succeed.\n" );
        return NULL;

    /* Ensure we have an oplock on the file */

     * There is a potential race condition in that an oplock could
     * have been broken due to another udp request, and yet there are
     * still oplock break messages being sent in the udp message
     * queue for this file. So return true if we don't have an oplock,
     * as we may have just freed it.

    if(fsp->oplock_type == NO_OPLOCK) {
        if( DEBUGLVL( 3 ) ) {
            dbgtext( "initial_break_processing: file %s ",
            dbgtext( "(file_id = %s gen_id = %lu) has no oplock.\n",
                 file_id_string_tos(&id), fsp->fh->gen_id );
            dbgtext( "Allowing break to succeed regardless.\n" );
        return NULL;

    return fsp;

Calling directly to dbgtext happens also in a few other files such as 
source3/smbd/service.c, source3/smbd/posix_acl.c and more.
This method of logging is on contrary to most of the samba code where 
logging is done using the logging macros DEBUG, DEBUGC etc.

Is avoiding the log macros done in those files deliberately? Is it done 
from any particular reason? Or is it just leftovers from old code or 
something like that?

Dan Cohen
IBM - XIV, Israel
NAS Development Team

More information about the samba-technical mailing list