[OpenAFS-devel] [PATCH] fix file locking crash on linux

Christopher Allen Wing wingc@engin.umich.edu
Fri, 9 Feb 2007 17:55:55 -0500 (EST)


Following up, I built openafs-stable-1_4_x from CVS today on RHEL5, which 
includes this patch, and I re-enabled afs_linux_flock (which is disabled 
in current CVS).  It seemed to work correctly and didn't crash.  RHEL5 is 
2.6.18 based thus it uses the new API.

I haven't tried 2.4 yet, maybe I will try RHEL3 next week.

-chris


On Thu, 8 Feb 2007, Christopher Allen Wing wrote:

> The following fixes the crash and seems ok on RHEL4 (2.6.9 kernel).  I 
> haven't tried it on newer 2.6 kernels.  I might have an opportunity to try it 
> out on RHEL5 tomorrow, which is 2.6.18 based and thus has the 'new' API for 
> flock_lock_file*().
>
> I believe it is safe to just clear FL_SLEEP in the structure handed to us, 
> assuming that we want to retain the current semantics (tell the kernel never 
> to wait when we ask it to perform a locking operation):
>
>
> --- openafs-1.4.x/src/afs/LINUX/osi_vnodeops.c.orig	2007-02-08 
> 14:22:27.000000000 -0500
> +++ openafs-1.4.x/src/afs/LINUX/osi_vnodeops.c	2007-02-08 14:28:26.000000000 
> -0500
> @@ -475,10 +475,8 @@
>     if ((code == 0 || flp->fl_type == F_UNLCK) &&
>         (cmd == F_SETLK || cmd == F_SETLKW)) {
> #ifdef AFS_LINUX26_ENV
> -       struct file_lock flp2;
> -       flp2 = *flp;
> -       flp2.fl_flags &=~ FL_SLEEP;
> -       code = posix_lock_file(fp, &flp2);
> +       flp->fl_flags &=~ FL_SLEEP;
> +       code = posix_lock_file(fp, flp);
> #else
>        code = posix_lock_file(fp, flp, 0);
> #endif @@ -534,10 +532,8 @@
>
>     if ((code == 0 || flp->fl_type == F_UNLCK) &&
>         (cmd == F_SETLK || cmd == F_SETLKW)) {
> -       struct file_lock flp2;
> -       flp2 = *flp;
> -       flp2.fl_flags &=~ FL_SLEEP;
> -       code = flock_lock_file_wait(fp, &flp2);
> +       flp->fl_flags &=~ FL_SLEEP;
> +       code = flock_lock_file_wait(fp, flp);
>        if (code && flp->fl_type != F_UNLCK) {
>            struct AFS_FLOCK flock2;
>            flock2 = flock;
>
>
>
> Anyone interested in trying this on linux-2.4 or linux-2.6.17+?
>
>
> -Chris
> wingc@engin.umich.edu
> _______________________________________________
> OpenAFS-devel mailing list
> OpenAFS-devel@openafs.org
> https://lists.openafs.org/mailman/listinfo/openafs-devel
>
>