Skip to content

Commit b7f55d9

Browse files
author
Andreas Gruenbacher
committed
gfs2: Fix mmap locking for write faults
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 <[email protected]>
1 parent f5456b5 commit b7f55d9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fs/gfs2/file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,11 @@ static vm_fault_t gfs2_fault(struct vm_fault *vmf)
540540
struct gfs2_inode *ip = GFS2_I(inode);
541541
struct gfs2_holder gh;
542542
vm_fault_t ret;
543+
u16 state;
543544
int err;
544545

545-
gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &gh);
546+
state = (vmf->flags & FAULT_FLAG_WRITE) ? LM_ST_EXCLUSIVE : LM_ST_SHARED;
547+
gfs2_holder_init(ip->i_gl, state, 0, &gh);
546548
err = gfs2_glock_nq(&gh);
547549
if (err) {
548550
ret = block_page_mkwrite_return(err);

0 commit comments

Comments
 (0)