On Thu, Dec 14, 2017 at 01:55:14PM -0500, J. Bruce Fields wrote: > So actually what happens is if you do a direct io write where some > WRITEs succeed and the one fails, then this: > > if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) { > dreq->flags = 0; > dreq->error = hdr->error; > } > > clears the NFS_ODIRECT_DO_COMMIT flag, so nfs_direct_write_complete > never scheduels the commit calls. It looks like that leaves a bunch of > nfs_pages on some to-be-committed list, so we end up leaking a bunch of > stuff, with the most visible symptom being an unnecessarily sillyrename > on close. > > I can just remove that clear of dreq_flags and that fixes the problem, > but I doubt that's correct. Or, maybe it is. If *any* WRITE(s) involved in this write might need a commit or reschedule, then surely we should run nfs_direct_write_schedule_work and let it sort them out? I'm having trouble seeing why clearing that field partway through could ever be correct. Trond, Anna, does the following look right? --b. >From a5ad80d2f239ed47eef7ad224db5eb6afba84062 Mon Sep 17 00:00:00 2001 From: "J. Bruce Fields" <bfields@xxxxxxxxxx> Date: Fri, 15 Dec 2017 15:25:45 -0500 Subject: [PATCH] NFS: commit direct writes even if they fail partially If some of the WRITE calls making up an O_DIRECT write syscall fail, we neglect to commit, even if some of the WRITEs succeed. We also depend on the commit code to free the reference count on the nfs_page taken in the "if (request_commit)" case at the end of nfs_direct_write_completion(). The problem was originally noticed because ENOSPC's encountered partway through a write would result in a closed file being sillyrenamed when it should have been unlinked. Signed-off-by: J. Bruce Fields <bfields@xxxxxxxxxx> --- fs/nfs/direct.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index d2972d537469..8c10b0562e75 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -775,10 +775,8 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) spin_lock(&dreq->lock); - if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) { - dreq->flags = 0; + if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) dreq->error = hdr->error; - } if (dreq->error == 0) { nfs_direct_good_bytes(dreq, hdr); if (nfs_write_need_commit(hdr)) { -- 2.14.3 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html