Skip to content

Commit 64090cb

Browse files
author
Andreas Gruenbacher
committed
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 <[email protected]>
1 parent 0fc3bcd commit 64090cb

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

fs/gfs2/file.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -510,30 +510,32 @@ static vm_fault_t gfs2_page_mkwrite(struct vm_fault *vmf)
510510
goto out_trans_fail;
511511
}
512512

513+
/* Unstuff, if required, and allocate backing blocks for page */
514+
if (gfs2_is_stuffed(ip)) {
515+
err = gfs2_unstuff_dinode(ip, NULL);
516+
if (err) {
517+
ret = block_page_mkwrite_return(err);
518+
goto out_trans_end;
519+
}
520+
}
521+
513522
lock_page(page);
514523
/* If truncated, we must retry the operation, we may have raced
515524
* with the glock demotion code.
516525
*/
517526
if (!PageUptodate(page) || page->mapping != inode->i_mapping) {
518527
ret = VM_FAULT_NOPAGE;
519-
goto out_trans_end;
528+
goto out_page_locked;
520529
}
521530

522-
/* Unstuff, if required, and allocate backing blocks for page */
523-
if (gfs2_is_stuffed(ip)) {
524-
err = gfs2_unstuff_dinode(ip, page);
525-
if (err) {
526-
ret = block_page_mkwrite_return(err);
527-
goto out_trans_end;
528-
}
529-
}
530531
err = gfs2_allocate_page_backing(page, length);
531532
if (err)
532533
ret = block_page_mkwrite_return(err);
533534

534-
out_trans_end:
535+
out_page_locked:
535536
if (ret != VM_FAULT_LOCKED)
536537
unlock_page(page);
538+
out_trans_end:
537539
gfs2_trans_end(sdp);
538540
out_trans_fail:
539541
gfs2_inplace_release(ip);

0 commit comments

Comments
 (0)