Skip to content

Commit d2a7de0

Browse files
trondmypdamschuma-ntap
authored andcommitted
NFS: Fix up O_DIRECT results
if we read or wrote something, we must report it Signed-off-by: Trond Myklebust <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent dd1beb3 commit d2a7de0

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

fs/nfs/direct.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,12 @@ static ssize_t nfs_direct_wait(struct nfs_direct_req *dreq)
353353

354354
result = wait_for_completion_killable(&dreq->completion);
355355

356+
if (!result) {
357+
result = dreq->count;
358+
WARN_ON_ONCE(dreq->count < 0);
359+
}
356360
if (!result)
357361
result = dreq->error;
358-
if (!result)
359-
result = dreq->count;
360362

361363
out:
362364
return (ssize_t) result;
@@ -386,8 +388,10 @@ static void nfs_direct_complete(struct nfs_direct_req *dreq, bool write)
386388

387389
if (dreq->iocb) {
388390
long res = (long) dreq->error;
389-
if (!res)
391+
if (dreq->count != 0) {
390392
res = (long) dreq->count;
393+
WARN_ON_ONCE(dreq->count < 0);
394+
}
391395
dreq->iocb->ki_complete(dreq->iocb, res, 0);
392396
}
393397

0 commit comments

Comments
 (0)