[prev in list] [next in list] [prev in thread] [next in thread] 

List:       git-commits-head
Subject:    gfs2: Fix mmap locking for write faults
From:       Linux Kernel Mailing List <linux-kernel () vger ! kernel ! org>
Date:       2021-05-31 16:36:30
Message-ID: git-mailbomb-linux-master-b7f55d928e75557295c1ac280c291b738905b6fb () kernel ! org
[Download RAW message or body]

Commit:     b7f55d928e75557295c1ac280c291b738905b6fb
Parent:     f5456b5d67cf812fd31fe3e130ca216b2e0908e5
Refname:    refs/heads/master
Web:        https://git.kernel.org/torvalds/c/b7f55d928e75557295c1ac280c291b738905b6fb
Author:     Andreas Gruenbacher <agruenba@redhat.com>
AuthorDate: Sat May 15 17:27:14 2021 +0200
Committer:  Andreas Gruenbacher <agruenba@redhat.com>
CommitDate: Fri May 21 05:16:38 2021 +0200

    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 <agruenba@redhat.com>
---
 fs/gfs2/file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index 493a83e3f5906..8a35a0196b6da 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -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);
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic