Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0d88f6e8 authored by Dave Chinner's avatar Dave Chinner Committed by Linus Torvalds
Browse files

nfs: don't call __mark_inode_dirty while holding i_lock



nfs_scan_commit() is called with the inode->i_lock held, but it then
calls __mark_inode_dirty() while still holding the lock. This causes
a deadlock.

Push the inode->i_lock into nfs_scan_commit() so it can protect only
the parts of the code it needs to and can be dropped before the call
to __mark_inode_dirty() to avoid the deadlock.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Tested-by: default avatarWill Simoneau <simoneau@ele.uri.edu>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 95042f9e
Loading
Loading
Loading
Loading
+4 −2
Original line number Original line Diff line number Diff line
@@ -542,11 +542,15 @@ nfs_scan_commit(struct inode *inode, struct list_head *dst, pgoff_t idx_start, u
	if (!nfs_need_commit(nfsi))
	if (!nfs_need_commit(nfsi))
		return 0;
		return 0;


	spin_lock(&inode->i_lock);
	ret = nfs_scan_list(nfsi, dst, idx_start, npages, NFS_PAGE_TAG_COMMIT);
	ret = nfs_scan_list(nfsi, dst, idx_start, npages, NFS_PAGE_TAG_COMMIT);
	if (ret > 0)
	if (ret > 0)
		nfsi->ncommit -= ret;
		nfsi->ncommit -= ret;
	spin_unlock(&inode->i_lock);

	if (nfs_need_commit(NFS_I(inode)))
	if (nfs_need_commit(NFS_I(inode)))
		__mark_inode_dirty(inode, I_DIRTY_DATASYNC);
		__mark_inode_dirty(inode, I_DIRTY_DATASYNC);

	return ret;
	return ret;
}
}
#else
#else
@@ -1483,9 +1487,7 @@ int nfs_commit_inode(struct inode *inode, int how)
	res = nfs_commit_set_lock(NFS_I(inode), may_wait);
	res = nfs_commit_set_lock(NFS_I(inode), may_wait);
	if (res <= 0)
	if (res <= 0)
		goto out_mark_dirty;
		goto out_mark_dirty;
	spin_lock(&inode->i_lock);
	res = nfs_scan_commit(inode, &head, 0, 0);
	res = nfs_scan_commit(inode, &head, 0, 0);
	spin_unlock(&inode->i_lock);
	if (res) {
	if (res) {
		int error;
		int error;