Bug 154990

Summary: dlm returns incorrect result to userspace on lock error
Product: [Retired] Red Hat Cluster Suite Reporter: Christine Caulfield <ccaulfie>
Component: dlmAssignee: Christine Caulfield <ccaulfie>
Status: CLOSED ERRATA QA Contact: Cluster QE <mspqa-list>
Severity: medium Docs Contact:
Priority: medium    
Version: 4CC: cluster-maint
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: RHBA-2005-735 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-10-07 16:54:31 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Christine Caulfield 2005-04-15 13:44:15 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050328 Firefox/1.0.2 Fedora/1.0.2-3

Description of problem:
If an error occurs in a dlm_lock() operation done from userspace, the dlm returns an incorrect error code. In fact it often returns just a large random number which the library interprets as a lockID.



Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
Run the following program:

#include <inttypes.h>
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
#include "libdlm.h"

int main(int argc, char *argv[])
{
    int status;
    int lockid;

    status = lock_resource("LOCKNAME", -1, /* -1 is not a valid lock mode */
                           0, &lockid);

    printf("lock status = %d, errno = %d\n", status, errno);
}


Actual Results:  The program hangs in libdlm waiting for the DLM to deliver an AST which never comes (because the lock call was in error)

Expected Results:  The output:
"lock status = -1, errno = 22"

Additional info:

The following patch fixes it:

diff -u -p -r1.24.2.1 device.c
--- device.c    2 Feb 2005 09:55:08 -0000       1.24.2.1
+++ device.c    15 Apr 2005 13:18:22 -0000
@@ -975,6 +975,9 @@ static int do_user_lock(struct file_info
                           bast_routine : NULL,
                          kparams->range.ra_end ? &kparams->range : NULL);
 
+       if (status)
+               goto out_err;
+
        /* If it succeeded (this far) with a new lock then keep track of
           it on the file's lkb list */
        if (!status && !(kparams->flags & DLM_LKF_CONVERT)) {

Comment 1 Christine Caulfield 2005-04-21 14:03:04 UTC
Fixed on FC4 branch

Comment 2 Christine Caulfield 2005-06-28 12:42:05 UTC
Also now fixed on RHEL4 branch so it should appear in U2

Comment 4 Red Hat Bugzilla 2005-10-07 16:54:31 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2005-735.html