Skip to content

Commit 2a1b95d

Browse files
piastrypopcornmix
authored andcommitted
CIFS: Fix splice read for non-cached files
commit 9c25702 upstream. Currently we call copy_page_to_iter() for uncached reading into a pipe. This is wrong because it treats pages as VFS cache pages and copies references rather than actual data. When we are trying to read from the pipe we end up calling page_cache_pipe_buf_confirm() which returns -ENODATA. This error is translated into 0 which is returned to a user. This issue is reproduced by running xfs-tests suite (generic test #249) against mount points with "cache=none". Fix it by mapping pages manually and calling copy_to_iter() that copies data into the pipe. Signed-off-by: Pavel Shilovsky <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 79bebad commit 2a1b95d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

fs/cifs/file.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2884,7 +2884,15 @@ cifs_readdata_to_iov(struct cifs_readdata *rdata, struct iov_iter *iter)
28842884
for (i = 0; i < rdata->nr_pages; i++) {
28852885
struct page *page = rdata->pages[i];
28862886
size_t copy = min_t(size_t, remaining, PAGE_SIZE);
2887-
size_t written = copy_page_to_iter(page, 0, copy, iter);
2887+
size_t written;
2888+
2889+
if (unlikely(iter->type & ITER_PIPE)) {
2890+
void *addr = kmap_atomic(page);
2891+
2892+
written = copy_to_iter(addr, copy, iter);
2893+
kunmap_atomic(addr);
2894+
} else
2895+
written = copy_page_to_iter(page, 0, copy, iter);
28882896
remaining -= written;
28892897
if (written < copy && iov_iter_count(iter) > 0)
28902898
break;

0 commit comments

Comments
 (0)