Commit f1884d61 authored by Christian Mohrbacher's avatar Christian Mohrbacher

Merge branch '706-iter-io-v6' into 'v6'

Resolve "NFS export: after file manipulation on NFS client, different content on NFS server (BeeGFS client) and NFS client (RT #7237)"

See merge request beegfs/projects0!480
parents b8dfac08 b436e791
......@@ -33,7 +33,6 @@
#define INITIAL_FIND_PAGES (256) // search initially for this number of pages
#ifndef KERNEL_HAS_ITER_PIPE
#if defined(KERNEL_HAS_AIO_WRITE_BUF)
static ssize_t FhgfsOps_buffered_aio_write(struct kiocb *iocb, const char __user *buf, size_t count,
loff_t pos);
......@@ -48,7 +47,6 @@ static ssize_t FhgfsOps_buffered_aio_read(struct kiocb *iocb, const struct iovec
static ssize_t FhgfsOps_buffered_write_iter(struct kiocb *iocb, struct iov_iter *from);
static ssize_t FhgfsOps_buffered_read_iter(struct kiocb *iocb, struct iov_iter *to);
#endif // LINUX_VERSION_CODE
#endif
/**
* Operations for files with cache type "buffered" and "none".
......@@ -70,7 +68,6 @@ struct file_operations fhgfs_file_buffered_ops =
.compat_ioctl = FhgfsOpsIoctl_compatIoctl,
#endif // CONFIG_COMPAT
#ifndef KERNEL_HAS_ITER_PIPE
#ifdef KERNEL_HAS_ITER_FILE_SPLICE_WRITE
.splice_read = generic_file_splice_read,
.splice_write = iter_file_splice_write,
......@@ -86,7 +83,6 @@ struct file_operations fhgfs_file_buffered_ops =
.aio_read = FhgfsOps_buffered_aio_read,
.aio_write = FhgfsOps_buffered_aio_write,
#endif // LINUX_VERSION_CODE
#endif
#ifdef KERNEL_HAS_GENERIC_FILE_SENDFILE
.sendfile = generic_file_sendfile, // removed in 2.6.23 (now handled via splice)
......@@ -1095,7 +1091,6 @@ ssize_t FhgfsOps_read_iter(struct kiocb *iocb, struct iov_iter *to)
return retVal;
}
#ifndef KERNEL_HAS_ITER_PIPE
#if defined(KERNEL_HAS_AIO_WRITE_BUF)
static ssize_t FhgfsOps_buffered_aio_read(struct kiocb *iocb, char __user *buf, size_t count,
loff_t pos)
......@@ -1153,7 +1148,11 @@ static ssize_t FhgfsOps_buffered_read_iter(struct kiocb *iocb, struct iov_iter *
FhgfsOpsHelper_logOpDebug(app, file_dentry(iocb->ki_filp), iocb->ki_filp->f_mapping->host,
__func__, "(offset: %lld; nr_segs: %lu)", (long long)iocb->ki_pos, to->nr_segs);
#ifdef KERNEL_HAS_ITER_PIPE
if (!(to->type & (ITER_BVEC | ITER_PIPE)))
#else
if (!(to->type & ITER_BVEC))
#endif
{
struct iovec iov;
struct iov_iter iter = *to;
......@@ -1196,7 +1195,7 @@ static ssize_t FhgfsOps_buffered_read_iter(struct kiocb *iocb, struct iov_iter *
if (!buffer)
return -ENOMEM;
kaddr = kmap_atomic(buffer);
kaddr = kmap(buffer);
{
ssize_t readRes;
size_t copyRes;
......@@ -1213,21 +1212,28 @@ static ssize_t FhgfsOps_buffered_read_iter(struct kiocb *iocb, struct iov_iter *
if (readRes <= 0)
break;
#ifdef KERNEL_HAS_ITER_PIPE
// do not use copy_page_to_iter with pipe targets since that would not actually *copy*
// the page but *link* it instead. our subsequent uses of the page would clobber it
// badly, and us freeing it while the pipe still has a reference would also not be
// very good.
copyRes = copy_to_iter(kaddr, readRes, to);
#else
copyRes = copy_page_to_iter(buffer, 0, readRes, to);
#endif
if (copyRes < readRes)
readRes = copyRes;
totalReadRes += readRes;
}
}
kunmap_atomic(kaddr);
kunmap(buffer);
__free_page(buffer);
}
return totalReadRes;
}
#endif // LINUX_VERSION_CODE
#endif
ssize_t FhgfsOps_write(struct file* file, const char __user *buf, size_t size,
......@@ -1451,7 +1457,6 @@ ssize_t FhgfsOps_write_iter(struct kiocb *iocb, struct iov_iter *from)
return retVal;
}
#ifndef KERNEL_HAS_ITER_PIPE
#if defined(KERNEL_HAS_AIO_WRITE_BUF)
static ssize_t FhgfsOps_buffered_aio_write(struct kiocb *iocb, const char __user *buf, size_t count,
loff_t pos)
......@@ -1552,7 +1557,7 @@ static ssize_t FhgfsOps_buffered_write_iter(struct kiocb *iocb, struct iov_iter
if (!buffer)
return -ENOMEM;
kaddr = kmap_atomic(buffer);
kaddr = kmap(buffer);
{
ssize_t writeRes;
size_t copyRes;
......@@ -1576,14 +1581,13 @@ static ssize_t FhgfsOps_buffered_write_iter(struct kiocb *iocb, struct iov_iter
break;
}
}
kunmap_atomic(kaddr);
kunmap(buffer);
__free_page(buffer);
}
return totalWriteRes;
}
#endif // LINUX_VERSION_CODE
#endif
#ifdef KERNEL_HAS_FSYNC_RANGE /* added in vanilla 3.1 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment