Bug 762782 (GLUSTER-1050)

Summary: fcntl F_GETLK lock calls do not return correct flock on non-linux systems
Product: [Community] GlusterFS Reporter: Pavan Vilas Sondur <pavan>
Component: protocolAssignee: Pranith Kumar K <pkarampu>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: mainlineCC: anush, gluster-bugs, vijay
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Solaris   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: ---
Regression: RTP Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Pavan Vilas Sondur 2010-07-06 03:50:14 UTC
Test Plan:
1. Call a fcntl lock as following:
   sample flock structure:
   flock.l_type = F_WRLCK;
   flock.l_start = 0;
   flock.l_len   = 0; //whole file
   flock.l_whence = SEEK_START;
   
   fcntl (fd, F_SETLK, &flock);

2. While the above lock is taken (not unlocked) and fd not closed issue another fcntl call as a F_GETLK as following:
   flock.l_type = F_RDLCK;
   flock.l_start = 0;
   flock.l_len = 0; //whole file
   flock.l_whence = SEEK_START;

   fcntl (fd, F_GETLK, &flock);

This call should result in the flock structure changing to a type of F_UNLCK and the pid of the conflicting lock (pid of the process used in step 1) along with the other structures getting filled appropriately.

The bug is hit, where the l_type returned changes when the server is non-linux (Solaris). Verify on a Solaris server setup that the conflicting lock's flock is exactly the same.

Comment 1 Pavan Vilas Sondur 2010-07-06 06:35:43 UTC
server/protocol's getlk implementation needs to convert the flock on the system to glfs own flock before returning it to the client to prevent misinterpretation of the flock structure.

Comment 2 Anand Avati 2010-07-14 18:44:24 UTC
PATCH: http://patches.gluster.com/patch/3592 in master (v2 [PATCH BUG:1050] protocol/server Convert-OS-specific-lock-value-to-Glusterfs-lock)

Comment 3 Anand Avati 2010-07-14 18:44:49 UTC
PATCH: http://patches.gluster.com/patch/3594 in release-3.0 (v2 [PATCH BRANCH:release-3.0 BUG:1050] protocol/server: Convert OS specific lock value to Gluster lock value)

Comment 4 Pranith Kumar K 2010-07-15 03:31:56 UTC
test case URL:
http://test.gluster.com/show_bug.cgi?id=80