Skip to content

Commit

Permalink
gfs2: Fix mmap locking for write faults
Browse files Browse the repository at this point in the history
When a write fault occurs, we need to take the inode glock of the underlying
inode in exclusive mode.  Otherwise, there's no guarantee that the dirty page
will be written back to disk.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
  • Loading branch information
Andreas Gruenbacher committed May 21, 2021
1 parent f5456b5 commit b7f55d9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fs/gfs2/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,9 +540,11 @@ static vm_fault_t gfs2_fault(struct vm_fault *vmf)
struct gfs2_inode *ip = GFS2_I(inode);
struct gfs2_holder gh;
vm_fault_t ret;
u16 state;
int err;

gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
state = (vmf->flags & FAULT_FLAG_WRITE) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
gfs2_holder_init(ip->i_gl, state, 0, &gh);
err = gfs2_glock_nq(&gh);
if (err) {
ret = block_page_mkwrite_return(err);
Expand Down

0 comments on commit b7f55d9

Please sign in to comment.