diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2021-06-17 23:04:14 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2021-06-29 10:56:51 +0200 |
commit | 64090cbe4bff240e9a5266e956fcaf449ea6b327 (patch) | |
tree | 8e527d666714e0b2c2f6cc306603245dc5b8e576 /fs/gfs2 | |
parent | 0fc3bcd6b6e34281254658bef27c45ec8c19e50c (diff) |
gfs2: Unstuff before locking page in gfs2_page_mkwrite
In gfs2_page_mkwrite, unstuff inodes before locking the page. That
way, we won't have to pass in the locked page to gfs2_unstuff_inode,
and gfs2_unstuff_inode can look up and lock the page itself.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/file.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index cf16d61f46ec..4a14616b2c0a 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c @@ -510,30 +510,32 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf) goto out_trans_fail; } + /* Unstuff, if required, and allocate backing blocks for page */ + if (gfs2_is_stuffed(ip)) { + err = gfs2_unstuff_dinode(ip, NULL); + if (err) { + ret = block_page_mkwrite_return(err); + goto out_trans_end; + } + } + lock_page(page); /* If truncated, we must retry the operation, we may have raced * with the glock demotion code. */ if (!PageUptodate(page) || page->mapping != inode->i_mapping) { ret = VM_FAULT_NOPAGE; - goto out_trans_end; + goto out_page_locked; } - /* Unstuff, if required, and allocate backing blocks for page */ - if (gfs2_is_stuffed(ip)) { - err = gfs2_unstuff_dinode(ip, page); - if (err) { - ret = block_page_mkwrite_return(err); - goto out_trans_end; - } - } err = gfs2_allocate_page_backing(page, length); if (err) ret = block_page_mkwrite_return(err); -out_trans_end: +out_page_locked: if (ret != VM_FAULT_LOCKED) unlock_page(page); +out_trans_end: gfs2_trans_end(sdp); out_trans_fail: gfs2_inplace_release(ip); |