Skip to contentSkip to conversation

GFS2: return conflicts for GETLK

PATCH New David Teigland 2 participants 3 messages Jun 8, 2007 – Jun 9, 2007 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 GFS2: return conflicts for GETLK

We weren't returning the correct result when GETLK found a conflict, which is indicated by userspace passing back a 1.

fs/gfs2/locking/dlm/plock.c +5 -1
Index: linux-quilt/fs/gfs2/locking/dlm/plock.c
===================================================================
@@ -254,16 +254,20 @@
 	}
 	spin_unlock(&ops_lock);
 
+	/* info.rv from userspace is 1 for conflict, 0 for no-conflict,
+	   -ENOENT if there are no locks on the file */
+
 	rv = op->info.rv;
 
 	fl->fl_type = F_UNLCK;
 	if (rv == -ENOENT)
 		rv = 0;
-	else if (rv == 0 && op->info.pid != fl->fl_pid) {
+	else if (rv > 1) {
 		fl->fl_type = (op->info.ex) ? F_WRLCK : F_RDLCK;
 		fl->fl_pid = op->info.pid;
 		fl->fl_start = op->info.start;
 		fl->fl_end = op->info.end;
+		rv = 0;
 	}
 
 	kfree(op);
#1 lore raw

PATCH 1/1 GFS2: return conflicts for GETLK

We weren't returning the correct result when GETLK found a conflict, which is indicated by userspace passing back a 1.
(Typo in the previous post of this patch.)

Signed-off-by Abhijith Das <adas redhat com>
Signed-off-by David Teigland <teigland redhat com>
fs/gfs2/locking/dlm/plock.c +5 -1
Index: linux-quilt/fs/gfs2/locking/dlm/plock.c
===================================================================
@@ -254,16 +254,20 @@
 	}
 	spin_unlock(&ops_lock);
 
+	/* info.rv from userspace is 1 for conflict, 0 for no-conflict,
+	   -ENOENT if there are no locks on the file */
+
 	rv = op->info.rv;
 
 	fl->fl_type = F_UNLCK;
 	if (rv == -ENOENT)
 		rv = 0;
-	else if (rv == 0 && op->info.pid != fl->fl_pid) {
+	else if (rv > 0) {
 		fl->fl_type = (op->info.ex) ? F_WRLCK : F_RDLCK;
 		fl->fl_pid = op->info.pid;
 		fl->fl_start = op->info.start;
 		fl->fl_end = op->info.end;
+		rv = 0;
 	}
 
 	kfree(op);
#2 lore raw

Hi,

Now added to the GFS2 -nmw git tree. Thanks,

Steve.

Quoted 33 lines · David Teigland

We weren't returning the correct result when GETLK found a conflict, which is indicated by userspace passing back a 1.
(Typo in the previous post of this patch.)

Signed-off-by Abhijith Das <adas redhat com>
Signed-off-by David Teigland <teigland redhat com>

Index: linux-quilt/fs/gfs2/locking/dlm/plock.c
===================================================================

fs/gfs2/locking/dlm/plock.c +5 -1
@@ -254,16 +254,20 @@
 	}
 	spin_unlock(&ops_lock);
 
+	/* info.rv from userspace is 1 for conflict, 0 for no-conflict,
+	   -ENOENT if there are no locks on the file */
+
 	rv = op->info.rv;
 
 	fl->fl_type = F_UNLCK;
 	if (rv == -ENOENT)
 		rv = 0;
-	else if (rv == 0 && op->info.pid != fl->fl_pid) {
+	else if (rv > 0) {
 		fl->fl_type = (op->info.ex) ? F_WRLCK : F_RDLCK;
 		fl->fl_pid = op->info.pid;
 		fl->fl_start = op->info.start;
 		fl->fl_end = op->info.end;
+		rv = 0;
 	}
 
 	kfree(op);