diff options
author | Abhijith Das <adas@redhat.com> | 2007-09-14 00:35:27 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2007-10-10 03:56:14 -0400 |
commit | b4c20166dcfca106f0f416bfce200099ed76ab18 (patch) | |
tree | 474e8c3bda161953202793c0801ab00a5b5433de /fs/gfs2/ops_file.c | |
parent | 1ad38c437fa33f85ba4b6a85ea8c5478ee72d5bd (diff) |
[GFS2] flocks from same process trip kernel BUG at fs/gfs2/glock.c:1118!
This patch adds a new flag to the gfs2_holder structure GL_FLOCK.
It is set on holders of glocks representing flocks. This flag is
checked in add_to_queue() and a process is permitted to queue more
than one holder onto a glock if it is set. This solves the issue
of a process not being able to do multiple flocks on the same file.
Through a single descriptor, a process can now promote and demote
flocks. Through multiple descriptors a process can now queue
multiple flocks on the same file. There's still the problem of
a process deadlocking itself (because gfs2 blocking locks are not
interruptible) by queueing incompatible deadlock.
Signed-off-by: Abhijith Das <adas@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2/ops_file.c')
-rw-r--r-- | fs/gfs2/ops_file.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/fs/gfs2/ops_file.c b/fs/gfs2/ops_file.c index 94d76ace0b95..46a9e10ff17b 100644 --- a/fs/gfs2/ops_file.c +++ b/fs/gfs2/ops_file.c | |||
@@ -571,7 +571,8 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
571 | int error = 0; | 571 | int error = 0; |
572 | 572 | ||
573 | state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; | 573 | state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; |
574 | flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE; | 574 | flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE |
575 | | GL_FLOCK; | ||
575 | 576 | ||
576 | mutex_lock(&fp->f_fl_mutex); | 577 | mutex_lock(&fp->f_fl_mutex); |
577 | 578 | ||
@@ -579,21 +580,19 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
579 | if (gl) { | 580 | if (gl) { |
580 | if (fl_gh->gh_state == state) | 581 | if (fl_gh->gh_state == state) |
581 | goto out; | 582 | goto out; |
582 | gfs2_glock_hold(gl); | ||
583 | flock_lock_file_wait(file, | 583 | flock_lock_file_wait(file, |
584 | &(struct file_lock){.fl_type = F_UNLCK}); | 584 | &(struct file_lock){.fl_type = F_UNLCK}); |
585 | gfs2_glock_dq_uninit(fl_gh); | 585 | gfs2_glock_dq_wait(fl_gh); |
586 | gfs2_holder_reinit(state, flags, fl_gh); | ||
586 | } else { | 587 | } else { |
587 | error = gfs2_glock_get(GFS2_SB(&ip->i_inode), | 588 | error = gfs2_glock_get(GFS2_SB(&ip->i_inode), |
588 | ip->i_no_addr, &gfs2_flock_glops, | 589 | ip->i_no_addr, &gfs2_flock_glops, |
589 | CREATE, &gl); | 590 | CREATE, &gl); |
590 | if (error) | 591 | if (error) |
591 | goto out; | 592 | goto out; |
593 | gfs2_holder_init(gl, state, flags, fl_gh); | ||
594 | gfs2_glock_put(gl); | ||
592 | } | 595 | } |
593 | |||
594 | gfs2_holder_init(gl, state, flags, fl_gh); | ||
595 | gfs2_glock_put(gl); | ||
596 | |||
597 | error = gfs2_glock_nq(fl_gh); | 596 | error = gfs2_glock_nq(fl_gh); |
598 | if (error) { | 597 | if (error) { |
599 | gfs2_holder_uninit(fl_gh); | 598 | gfs2_holder_uninit(fl_gh); |