linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: viro@zeniv.linux.org.uk
Cc: dhowells@redhat.com, linux-afs@lists.infradead.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	matthew@wil.cx
Subject: [PATCH 03/10] iov_iter: Make count and iov_offset loff_t not size_t
Date: Mon, 06 Aug 2018 14:16:58 +0100	[thread overview]
Message-ID: <153356141842.1195.6854849320089666173.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <153356139813.1195.8360582774280288285.stgit@warthog.procyon.org.uk>

Make count and iov_offset loff_t not size_t so that they can handle
transactions larger than 4GiB in size and starting at 4GiB or more into a
file on a 32-bit system.

On a 64-bit system, this should make no difference.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/9p/vfs_file.c    |    2 +-
 fs/btrfs/file.c     |    7 ++++---
 fs/nfs/direct.c     |    2 +-
 fs/nfs/file.c       |    4 ++--
 include/linux/uio.h |    6 +++---
 lib/iov_iter.c      |   14 +++++++-------
 net/9p/client.c     |    2 +-
 net/rxrpc/recvmsg.c |    4 ++--
 8 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c
index 03c9e325bfbc..a83b81ea677f 100644
--- a/fs/9p/vfs_file.c
+++ b/fs/9p/vfs_file.c
@@ -384,7 +384,7 @@ v9fs_file_read_iter(struct kiocb *iocb, struct iov_iter *to)
 	struct p9_fid *fid = iocb->ki_filp->private_data;
 	int ret, err = 0;
 
-	p9_debug(P9_DEBUG_VFS, "count %zu offset %lld\n",
+	p9_debug(P9_DEBUG_VFS, "count %llu offset %lld\n",
 		 iov_iter_count(to), iocb->ki_pos);
 
 	ret = p9_client_read(fid, iocb->ki_pos, to, &err);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index 51e77d72068a..48bf2b0af7b5 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -1599,9 +1599,10 @@ static noinline ssize_t __btrfs_buffered_write(struct file *file,
 	while (iov_iter_count(i) > 0) {
 		size_t offset = pos & (PAGE_SIZE - 1);
 		size_t sector_offset;
-		size_t write_bytes = min(iov_iter_count(i),
-					 nrptrs * (size_t)PAGE_SIZE -
-					 offset);
+		size_t write_bytes = min_t(size_t,
+					   iov_iter_count(i),
+					   nrptrs * (size_t)PAGE_SIZE -
+					   offset);
 		size_t num_pages = DIV_ROUND_UP(write_bytes + offset,
 						PAGE_SIZE);
 		size_t reserve_bytes;
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 621c517b325c..3d438aa2650b 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -974,7 +974,7 @@ ssize_t nfs_file_direct_write(struct kiocb *iocb, struct iov_iter *iter)
 	struct nfs_lock_context *l_ctx;
 	loff_t pos, end;
 
-	dfprintk(FILE, "NFS: direct write(%pD2, %zd@%Ld)\n",
+	dfprintk(FILE, "NFS: direct write(%pD2, %lld@%lld)\n",
 		file, iov_iter_count(iter), (long long) iocb->ki_pos);
 
 	result = generic_write_checks(iocb, iter);
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 81cca49a8375..ef4fd7124ca1 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -159,7 +159,7 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to)
 	if (iocb->ki_flags & IOCB_DIRECT)
 		return nfs_file_direct_read(iocb, to);
 
-	dprintk("NFS: read(%pD2, %zu@%lu)\n",
+	dprintk("NFS: read(%pD2, %llu@%lu)\n",
 		iocb->ki_filp,
 		iov_iter_count(to), (unsigned long) iocb->ki_pos);
 
@@ -608,7 +608,7 @@ ssize_t nfs_file_write(struct kiocb *iocb, struct iov_iter *from)
 	if (iocb->ki_flags & IOCB_DIRECT)
 		return nfs_file_direct_write(iocb, from);
 
-	dprintk("NFS: write(%pD2, %zu@%Ld)\n",
+	dprintk("NFS: write(%pD2, %llu@%Ld)\n",
 		file, iov_iter_count(from), (long long) iocb->ki_pos);
 
 	if (IS_SWAPFILE(inode))
diff --git a/include/linux/uio.h b/include/linux/uio.h
index d5f8755bf778..d0655b74fd7e 100644
--- a/include/linux/uio.h
+++ b/include/linux/uio.h
@@ -31,7 +31,7 @@ enum iter_type {
 struct iov_iter {
 	enum iter_type iter_type:8;
 	u8 iter_dir;
-	size_t iov_offset;
+	loff_t iov_offset;
 	size_t count;
 	union {
 		const struct iovec *iov;
@@ -89,7 +89,7 @@ static inline struct iovec iov_iter_iovec(const struct iov_iter *iter)
 {
 	return (struct iovec) {
 		.iov_base = iter->iov->iov_base + iter->iov_offset,
-		.iov_len = min(iter->count,
+		.iov_len = min_t(size_t, iter->count,
 			       iter->iov->iov_len - iter->iov_offset),
 	};
 }
@@ -219,7 +219,7 @@ int iov_iter_npages(const struct iov_iter *i, int maxpages);
 
 const void *dup_iter(struct iov_iter *new, struct iov_iter *old, gfp_t flags);
 
-static inline size_t iov_iter_count(const struct iov_iter *i)
+static inline loff_t iov_iter_count(const struct iov_iter *i)
 {
 	return i->count;
 }
diff --git a/lib/iov_iter.c b/lib/iov_iter.c
index f30ecd263d6e..8231f0e38f20 100644
--- a/lib/iov_iter.c
+++ b/lib/iov_iter.c
@@ -13,7 +13,7 @@
 	size_t left;					\
 	size_t wanted = n;				\
 	__p = i->iov;					\
-	__v.iov_len = min(n, __p->iov_len - skip);	\
+	__v.iov_len = min_t(size_t, n, __p->iov_len - skip);	\
 	if (likely(__v.iov_len)) {			\
 		__v.iov_base = __p->iov_base + skip;	\
 		left = (STEP);				\
@@ -40,7 +40,7 @@
 #define iterate_kvec(i, n, __v, __p, skip, STEP) {	\
 	size_t wanted = n;				\
 	__p = i->kvec;					\
-	__v.iov_len = min(n, __p->iov_len - skip);	\
+	__v.iov_len = min_t(size_t, n, __p->iov_len - skip);	\
 	if (likely(__v.iov_len)) {			\
 		__v.iov_base = __p->iov_base + skip;	\
 		(void)(STEP);				\
@@ -74,7 +74,7 @@
 
 #define iterate_all_kinds(i, n, v, I, B, K) {			\
 	if (likely(n)) {					\
-		size_t skip = i->iov_offset;			\
+		loff_t skip = i->iov_offset;			\
 		switch (iov_iter_type(i)) {			\
 		case ITER_BVEC: {				\
 			struct bio_vec v;			\
@@ -105,7 +105,7 @@
 	if (unlikely(i->count < n))				\
 		n = i->count;					\
 	if (i->count) {						\
-		size_t skip = i->iov_offset;			\
+		loff_t skip = i->iov_offset;			\
 		switch (iov_iter_type(i)) {			\
 		case ITER_BVEC: {				\
 			const struct bio_vec *bvec = i->bvec;	\
@@ -358,7 +358,7 @@ static bool sanity(const struct iov_iter *i)
 	}
 	return true;
 Bad:
-	printk(KERN_ERR "idx = %d, offset = %zd\n", i->idx, i->iov_offset);
+	printk(KERN_ERR "idx = %d, offset = %lld\n", i->idx, i->iov_offset);
 	printk(KERN_ERR "curbuf = %d, nrbufs = %d, buffers = %d\n",
 			pipe->curbuf, pipe->nrbufs, pipe->buffers);
 	for (idx = 0; idx < pipe->buffers; idx++)
@@ -1105,10 +1105,10 @@ size_t iov_iter_single_seg_count(const struct iov_iter *i)
 	case ITER_PIPE:
 		return i->count;	// it is a silly place, anyway
 	case ITER_BVEC:
-		return min(i->count, i->bvec->bv_len - i->iov_offset);
+		return min_t(size_t, i->count, i->bvec->bv_len - i->iov_offset);
 	case ITER_KVEC:
 	case ITER_IOVEC:
-		return min(i->count, i->iov->iov_len - i->iov_offset);
+		return min_t(size_t, i->count, i->iov->iov_len - i->iov_offset);
 	}
 	BUG();
 }
diff --git a/net/9p/client.c b/net/9p/client.c
index 1e853e2a62bb..19b045714206 100644
--- a/net/9p/client.c
+++ b/net/9p/client.c
@@ -1649,7 +1649,7 @@ p9_client_write(struct p9_fid *fid, u64 offset, struct iov_iter *from, int *err)
 	int total = 0;
 	*err = 0;
 
-	p9_debug(P9_DEBUG_9P, ">>> TWRITE fid %d offset %llu count %zd\n",
+	p9_debug(P9_DEBUG_9P, ">>> TWRITE fid %d offset %llu count %llu\n",
 				fid->fid, (unsigned long long) offset,
 				iov_iter_count(from));
 
diff --git a/net/rxrpc/recvmsg.c b/net/rxrpc/recvmsg.c
index 816b19a78809..920f505baedd 100644
--- a/net/rxrpc/recvmsg.c
+++ b/net/rxrpc/recvmsg.c
@@ -633,7 +633,7 @@ int rxrpc_kernel_recv_data(struct socket *sock, struct rxrpc_call *call,
 	size_t offset = 0;
 	int ret;
 
-	_enter("{%d,%s},%zu,%d",
+	_enter("{%d,%s},%llu,%d",
 	       call->debug_id, rxrpc_call_states[call->state],
 	       iov_iter_count(iter), want_more);
 
@@ -693,7 +693,7 @@ int rxrpc_kernel_recv_data(struct socket *sock, struct rxrpc_call *call,
 	if (_service)
 		*_service = call->service_id;
 	mutex_unlock(&call->user_mutex);
-	_leave(" = %d [%zu,%d]", ret, iov_iter_count(iter), *_abort);
+	_leave(" = %d [%llu,%d]", ret, iov_iter_count(iter), *_abort);
 	return ret;
 
 short_data:

  parent reply	other threads:[~2018-08-06 15:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-06 13:16 [PATCH 00/10] iov_iter: Add new iters and use with AFS David Howells
2018-08-06 13:16 ` [PATCH 01/10] iov_iter: Separate type from direction and use accessor functions David Howells
2018-08-06 13:16 ` [PATCH 02/10] iov_iter: Renumber the ITER_* constants in uio.h David Howells
2018-08-06 13:16 ` David Howells [this message]
2018-08-06 13:17 ` [PATCH 04/10] iov_iter: Add mapping and discard iterator types David Howells
2018-08-06 13:17 ` [PATCH 05/10] afs: Better tracing of protocol errors David Howells
2018-08-06 13:17 ` [PATCH 06/10] afs: Set up the iov_iter before calling afs_extract_data() David Howells
2018-08-06 13:17 ` [PATCH 07/10] afs: Use ITER_MAPPING for writing David Howells
2018-08-06 13:17 ` [PATCH 08/10] afs: Add O_DIRECT read support David Howells
2018-08-06 13:17 ` [PATCH 09/10] afs: Add a couple of tracepoints to log I/O errors David Howells
2018-08-06 13:17 ` [PATCH 10/10] afs: Don't invoke the server to read data beyond EOF David Howells
2018-09-13 15:51 [PATCH 00/10] iov_iter: Add new iters and use with AFS David Howells
2018-09-13 15:52 ` [PATCH 03/10] iov_iter: Make count and iov_offset loff_t not size_t David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=153356141842.1195.6854849320089666173.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=linux-afs@lists.infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).