All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Return bytes transfered for partial direct I/O
@ 2017-09-23 23:10 Goldwyn Rodrigues
  2017-09-24  8:32 ` Matthew Wilcox
  2017-10-12  6:20 ` [lkp-robot] 71fa367c22: xfstests.generic.299.fail kernel test robot
  0 siblings, 2 replies; 6+ messages in thread
From: Goldwyn Rodrigues @ 2017-09-23 23:10 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: Goldwyn Rodrigues

In case direct I/O encounters an error midway, it returns the error.
Instead it should be returning the number of bytes transferred so far.

Test case (with ENOSPC):
1. Create an almost full filesystem
2. Create a file, say /mnt/lastfile, until the filesystem is full.
3. Direct write() with count > sizeof /mnt/lastfile.

Result: write() returns -ENOSPC. However, file content has data written
in step 3.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 5fa2211e49ae..0fc1789498ae 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -255,8 +255,6 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async)
 		ret = dio->page_errors;
 	if (ret == 0)
 		ret = dio->io_error;
-	if (ret == 0)
-		ret = transferred;
 
 	if (dio->end_io) {
 		int err;
@@ -284,7 +282,7 @@ static ssize_t dio_complete(struct dio *dio, ssize_t ret, bool is_async)
 	}
 
 	kmem_cache_free(dio_cache, dio);
-	return ret;
+	return transferred ? transferred : ret;
 }
 
 static void dio_aio_complete_work(struct work_struct *work)

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-10-12 15:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-23 23:10 [PATCH] Return bytes transfered for partial direct I/O Goldwyn Rodrigues
2017-09-24  8:32 ` Matthew Wilcox
2017-09-24 13:09   ` Christoph Hellwig
2017-10-12  6:20 ` [lkp-robot] 71fa367c22: xfstests.generic.299.fail kernel test robot
2017-10-12 15:46   ` Goldwyn Rodrigues
2017-10-12 15:46     ` Goldwyn Rodrigues

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.