Merge branch 'locks' of git://linux-nfs.org/~bfields/linux
[pandora-kernel.git] / fs / gfs2 / ops_file.c
index 28773ca..7eb4b28 100644 (file)
@@ -571,7 +571,8 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
        int error = 0;
 
        state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
-       flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE;
+       flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE 
+               | GL_FLOCK;
 
        mutex_lock(&fp->f_fl_mutex);
 
@@ -579,21 +580,19 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl)
        if (gl) {
                if (fl_gh->gh_state == state)
                        goto out;
-               gfs2_glock_hold(gl);
                flock_lock_file_wait(file,
                                     &(struct file_lock){.fl_type = F_UNLCK});
-               gfs2_glock_dq_uninit(fl_gh);
+               gfs2_glock_dq_wait(fl_gh);
+               gfs2_holder_reinit(state, flags, fl_gh);
        } else {
                error = gfs2_glock_get(GFS2_SB(&ip->i_inode),
                                      ip->i_no_addr, &gfs2_flock_glops,
                                      CREATE, &gl);
                if (error)
                        goto out;
+               gfs2_holder_init(gl, state, flags, fl_gh);
+               gfs2_glock_put(gl);
        }
-
-       gfs2_holder_init(gl, state, flags, fl_gh);
-       gfs2_glock_put(gl);
-
        error = gfs2_glock_nq(fl_gh);
        if (error) {
                gfs2_holder_uninit(fl_gh);