Subject: [PATCH] NFS: better handling of short writes in direct write path Immediately return control to the application if a short NFS write is detected in the NFS client's direct write path. This is better behavior than what the direct write path does today, which could result in data appearing at the wrong offset in the file. Eventually this code path should retry short writes at least once before giving up. Signed-off-by: Chuck Lever Signed-off-by: Trond Myklebust --- fs/nfs/direct.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletion(-) diff -X /home/cel/src/linux/dont-diff -Naurp 10-nfs-direct-write-verf/fs/nfs/direct.c 11-nfs-short-direct-write/fs/nfs/direct.c --- 10-nfs-direct-write-verf/fs/nfs/direct.c 2004-10-21 10:40:02.470533000 -0400 +++ 11-nfs-short-direct-write/fs/nfs/direct.c 2004-10-21 10:40:55.690101000 -0400 @@ -310,7 +310,12 @@ retry: goto sync_retry; } - tot_bytes += result; + tot_bytes += result; + + /* in case of a short write: stop now, let the app recover */ + if (result < wdata.args.count) + break; + wdata.args.offset += result; wdata.args.pgbase += result; curpage += wdata.args.pgbase >> PAGE_SHIFT;