[OpenAFS-devel] afs locking on linux 2.4.x

Pavel Semerad semerad@ss1000.ms.mff.cuni.cz
Fri, 1 Jun 2001 12:07:54 +0200


Hi,
locking on linux 2.4.x does not work. 2.4.x uses internally 64bit offsets
(start and end of lock) and end is set to 64 bit int max. When it converts
to struct flock, len is set to 0xffffffff (cut off high 32 bits) and afs_lockctl
decides it is byte-range locking. So on 2.4.x kernel there should be used flock64
instead of flock (flock64 is typedef to flock on 64bit systems such as sparc64
and ia64):


--- afs/LINUX/osi_vnodeops.c 09:06:44	1.1.1.10
+++ afs/LINUX/osi_vnodeops.c 11:25:51	1.11
@@ -508,7 +508,11 @@ static int afs_linux_lock(struct file *f
     int code = 0;
     struct vcache *vcp = (struct vcache*)FILE_INODE(fp);
     cred_t *credp = crref();
+#ifdef AFS_LINUX24_ENV
+    struct flock64 flock;
+#else
     struct flock flock;
+#endif
     
     /* Convert to a lock format afs_lockctl understands. */
     memset((char*)&flock, 0, sizeof(flock));
--- afs/VNOPS/afs_vnop_flock.c 09:38:37	1.1.1.5
+++ afs/VNOPS/afs_vnop_flock.c 11:25:51	1.9
@@ -534,16 +541,21 @@ struct AFS_UCRED *acred; {
 	   with it in.  However, they fail in race conditions.  The question is
 	   what to do for people who don't have source to their application;
 	   this way at least, they can get work done */
+#ifdef AFS_LINUX24_ENV
+	if (af->l_len == OFFSET_MAX)
+	    af->l_len = 0;	/* since some systems indicate it as EOF */
+#else
 	if (af->l_len == 0x7fffffff)
 	    af->l_len = 0;	/* since some systems indicate it as EOF */
 #ifdef AFS_LINUX_64BIT_KERNEL
 	if (af->l_len == LONG_MAX)
 	    af->l_len = 0;      /* since some systems indicate it as EOF */
 #endif
+#endif
 	/* next line makes byte range locks always succeed,
 	   even when they should block */
 	if (af->l_whence != 0 || af->l_start != 0 || af->l_len != 0) {




Pavel Semerad