diff options
author | Dan Williams <dan.j.williams@intel.com> | 2018-03-16 20:36:44 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2018-05-23 02:18:31 -0400 |
commit | a77d478642f12ade58fdfac335ae464df1944a1e (patch) | |
tree | 1d4597c7dc0e90d457d9fc49f57deef20b34d7bd | |
parent | b3a9a0c36e1f7b9e2e6cf965c2bb973624f2b3b9 (diff) |
dax: Report bytes remaining in dax_iomap_actor()
In preparation for protecting the dax read(2) path from media errors
with copy_to_iter_mcsafe() (via dax_copy_to_iter()), convert the
implementation to report the bytes successfully transferred.
Cc: <x86@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | fs/dax.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -991,6 +991,7 @@ dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data, | |||
991 | struct iov_iter *iter = data; | 991 | struct iov_iter *iter = data; |
992 | loff_t end = pos + length, done = 0; | 992 | loff_t end = pos + length, done = 0; |
993 | ssize_t ret = 0; | 993 | ssize_t ret = 0; |
994 | size_t xfer; | ||
994 | int id; | 995 | int id; |
995 | 996 | ||
996 | if (iov_iter_rw(iter) == READ) { | 997 | if (iov_iter_rw(iter) == READ) { |
@@ -1054,19 +1055,20 @@ dax_iomap_actor(struct inode *inode, loff_t pos, loff_t length, void *data, | |||
1054 | * vfs_write(), depending on which operation we are doing. | 1055 | * vfs_write(), depending on which operation we are doing. |
1055 | */ | 1056 | */ |
1056 | if (iov_iter_rw(iter) == WRITE) | 1057 | if (iov_iter_rw(iter) == WRITE) |
1057 | map_len = dax_copy_from_iter(dax_dev, pgoff, kaddr, | 1058 | xfer = dax_copy_from_iter(dax_dev, pgoff, kaddr, |
1058 | map_len, iter); | 1059 | map_len, iter); |
1059 | else | 1060 | else |
1060 | map_len = dax_copy_to_iter(dax_dev, pgoff, kaddr, | 1061 | xfer = dax_copy_to_iter(dax_dev, pgoff, kaddr, |
1061 | map_len, iter); | 1062 | map_len, iter); |
1062 | if (map_len <= 0) { | ||
1063 | ret = map_len ? map_len : -EFAULT; | ||
1064 | break; | ||
1065 | } | ||
1066 | 1063 | ||
1067 | pos += map_len; | 1064 | pos += xfer; |
1068 | length -= map_len; | 1065 | length -= xfer; |
1069 | done += map_len; | 1066 | done += xfer; |
1067 | |||
1068 | if (xfer == 0) | ||
1069 | ret = -EFAULT; | ||
1070 | if (xfer < map_len) | ||
1071 | break; | ||
1070 | } | 1072 | } |
1071 | dax_read_unlock(id); | 1073 | dax_read_unlock(id); |
1072 | 1074 | ||