NFS: Remove call to igrab() from nfs_writepage()
We always ensure that the nfs_open_context holds a reference to the dentry, so the test in nfs_writepage() for whether or not the inode is referenced is redundant. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
This commit is contained in:
parent
49a70f2786
commit
87a4ce1608
|
@ -317,24 +317,12 @@ int nfs_writepage(struct page *page, struct writeback_control *wbc)
|
||||||
struct nfs_open_context *ctx;
|
struct nfs_open_context *ctx;
|
||||||
struct inode *inode = page->mapping->host;
|
struct inode *inode = page->mapping->host;
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
int inode_referenced = 0;
|
|
||||||
int priority = wb_priority(wbc);
|
int priority = wb_priority(wbc);
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
|
nfs_inc_stats(inode, NFSIOS_VFSWRITEPAGE);
|
||||||
nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
|
nfs_add_stats(inode, NFSIOS_WRITEPAGES, 1);
|
||||||
|
|
||||||
/*
|
|
||||||
* Note: We need to ensure that we have a reference to the inode
|
|
||||||
* if we are to do asynchronous writes. If not, waiting
|
|
||||||
* in nfs_wait_on_request() may deadlock with clear_inode().
|
|
||||||
*
|
|
||||||
* If igrab() fails here, then it is in any case safe to
|
|
||||||
* call nfs_wb_page(), since there will be no pending writes.
|
|
||||||
*/
|
|
||||||
if (igrab(inode) != 0)
|
|
||||||
inode_referenced = 1;
|
|
||||||
|
|
||||||
/* Ensure we've flushed out any previous writes */
|
/* Ensure we've flushed out any previous writes */
|
||||||
nfs_wb_page_priority(inode, page, priority);
|
nfs_wb_page_priority(inode, page, priority);
|
||||||
|
|
||||||
|
@ -349,7 +337,7 @@ int nfs_writepage(struct page *page, struct writeback_control *wbc)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
lock_kernel();
|
lock_kernel();
|
||||||
if (!IS_SYNC(inode) && inode_referenced) {
|
if (!IS_SYNC(inode)) {
|
||||||
err = nfs_writepage_async(ctx, inode, page, 0, offset);
|
err = nfs_writepage_async(ctx, inode, page, 0, offset);
|
||||||
if (!wbc->for_writepages)
|
if (!wbc->for_writepages)
|
||||||
nfs_flush_mapping(page->mapping, wbc, wb_priority(wbc));
|
nfs_flush_mapping(page->mapping, wbc, wb_priority(wbc));
|
||||||
|
@ -366,8 +354,6 @@ int nfs_writepage(struct page *page, struct writeback_control *wbc)
|
||||||
put_nfs_open_context(ctx);
|
put_nfs_open_context(ctx);
|
||||||
out:
|
out:
|
||||||
unlock_page(page);
|
unlock_page(page);
|
||||||
if (inode_referenced)
|
|
||||||
iput(inode);
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue