aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-02-11 13:56:46 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2015-03-12 23:50:23 -0400
commit66ee59af630fd8d5f4f56fb28162857e629aa0ab (patch)
treed1c4293f986fcb20824c90a2ab5f3f4e62543f8a /fs
parent96b62a57193494010eed66ca0739c93eb4653162 (diff)
fs: remove ki_nbytes
There is no need to pass the total request length in the kiocb, as we already get passed in through the iov_iter argument. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/aio.c34
-rw-r--r--fs/ceph/file.c2
-rw-r--r--fs/nfs/direct.c2
-rw-r--r--fs/ocfs2/file.c8
-rw-r--r--fs/read_write.c8
-rw-r--r--fs/udf/file.c2
6 files changed, 24 insertions, 32 deletions
diff --git a/fs/aio.c b/fs/aio.c
index 118a2e0088d8..667054c7c067 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1344,12 +1344,13 @@ typedef ssize_t (rw_iter_op)(struct kiocb *, struct iov_iter *);
1344static ssize_t aio_setup_vectored_rw(struct kiocb *kiocb, 1344static ssize_t aio_setup_vectored_rw(struct kiocb *kiocb,
1345 int rw, char __user *buf, 1345 int rw, char __user *buf,
1346 unsigned long *nr_segs, 1346 unsigned long *nr_segs,
1347 size_t *len,
1347 struct iovec **iovec, 1348 struct iovec **iovec,
1348 bool compat) 1349 bool compat)
1349{ 1350{
1350 ssize_t ret; 1351 ssize_t ret;
1351 1352
1352 *nr_segs = kiocb->ki_nbytes; 1353 *nr_segs = *len;
1353 1354
1354#ifdef CONFIG_COMPAT 1355#ifdef CONFIG_COMPAT
1355 if (compat) 1356 if (compat)
@@ -1364,21 +1365,22 @@ static ssize_t aio_setup_vectored_rw(struct kiocb *kiocb,
1364 if (ret < 0) 1365 if (ret < 0)
1365 return ret; 1366 return ret;
1366 1367
1367 /* ki_nbytes now reflect bytes instead of segs */ 1368 /* len now reflect bytes instead of segs */
1368 kiocb->ki_nbytes = ret; 1369 *len = ret;
1369 return 0; 1370 return 0;
1370} 1371}
1371 1372
1372static ssize_t aio_setup_single_vector(struct kiocb *kiocb, 1373static ssize_t aio_setup_single_vector(struct kiocb *kiocb,
1373 int rw, char __user *buf, 1374 int rw, char __user *buf,
1374 unsigned long *nr_segs, 1375 unsigned long *nr_segs,
1376 size_t len,
1375 struct iovec *iovec) 1377 struct iovec *iovec)
1376{ 1378{
1377 if (unlikely(!access_ok(!rw, buf, kiocb->ki_nbytes))) 1379 if (unlikely(!access_ok(!rw, buf, len)))
1378 return -EFAULT; 1380 return -EFAULT;
1379 1381
1380 iovec->iov_base = buf; 1382 iovec->iov_base = buf;
1381 iovec->iov_len = kiocb->ki_nbytes; 1383 iovec->iov_len = len;
1382 *nr_segs = 1; 1384 *nr_segs = 1;
1383 return 0; 1385 return 0;
1384} 1386}
@@ -1388,7 +1390,7 @@ static ssize_t aio_setup_single_vector(struct kiocb *kiocb,
1388 * Performs the initial checks and io submission. 1390 * Performs the initial checks and io submission.
1389 */ 1391 */
1390static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode, 1392static ssize_t aio_run_iocb(struct kiocb *req, unsigned opcode,
1391 char __user *buf, bool compat) 1393 char __user *buf, size_t len, bool compat)
1392{ 1394{
1393 struct file *file = req->ki_filp; 1395 struct file *file = req->ki_filp;
1394 ssize_t ret; 1396 ssize_t ret;
@@ -1423,21 +1425,21 @@ rw_common:
1423 if (!rw_op && !iter_op) 1425 if (!rw_op && !iter_op)
1424 return -EINVAL; 1426 return -EINVAL;
1425 1427
1426 ret = (opcode == IOCB_CMD_PREADV || 1428 if (opcode == IOCB_CMD_PREADV || opcode == IOCB_CMD_PWRITEV)
1427 opcode == IOCB_CMD_PWRITEV) 1429 ret = aio_setup_vectored_rw(req, rw, buf, &nr_segs,
1428 ? aio_setup_vectored_rw(req, rw, buf, &nr_segs, 1430 &len, &iovec, compat);
1429 &iovec, compat) 1431 else
1430 : aio_setup_single_vector(req, rw, buf, &nr_segs, 1432 ret = aio_setup_single_vector(req, rw, buf, &nr_segs,
1431 iovec); 1433 len, iovec);
1432 if (!ret) 1434 if (!ret)
1433 ret = rw_verify_area(rw, file, &req->ki_pos, req->ki_nbytes); 1435 ret = rw_verify_area(rw, file, &req->ki_pos, len);
1434 if (ret < 0) { 1436 if (ret < 0) {
1435 if (iovec != inline_vecs) 1437 if (iovec != inline_vecs)
1436 kfree(iovec); 1438 kfree(iovec);
1437 return ret; 1439 return ret;
1438 } 1440 }
1439 1441
1440 req->ki_nbytes = ret; 1442 len = ret;
1441 1443
1442 /* XXX: move/kill - rw_verify_area()? */ 1444 /* XXX: move/kill - rw_verify_area()? */
1443 /* This matches the pread()/pwrite() logic */ 1445 /* This matches the pread()/pwrite() logic */
@@ -1450,7 +1452,7 @@ rw_common:
1450 file_start_write(file); 1452 file_start_write(file);
1451 1453
1452 if (iter_op) { 1454 if (iter_op) {
1453 iov_iter_init(&iter, rw, iovec, nr_segs, req->ki_nbytes); 1455 iov_iter_init(&iter, rw, iovec, nr_segs, len);
1454 ret = iter_op(req, &iter); 1456 ret = iter_op(req, &iter);
1455 } else { 1457 } else {
1456 ret = rw_op(req, iovec, nr_segs, req->ki_pos); 1458 ret = rw_op(req, iovec, nr_segs, req->ki_pos);
@@ -1553,10 +1555,10 @@ static int io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
1553 req->ki_obj.user = user_iocb; 1555 req->ki_obj.user = user_iocb;
1554 req->ki_user_data = iocb->aio_data; 1556 req->ki_user_data = iocb->aio_data;
1555 req->ki_pos = iocb->aio_offset; 1557 req->ki_pos = iocb->aio_offset;
1556 req->ki_nbytes = iocb->aio_nbytes;
1557 1558
1558 ret = aio_run_iocb(req, iocb->aio_lio_opcode, 1559 ret = aio_run_iocb(req, iocb->aio_lio_opcode,
1559 (char __user *)(unsigned long)iocb->aio_buf, 1560 (char __user *)(unsigned long)iocb->aio_buf,
1561 iocb->aio_nbytes,
1560 compat); 1562 compat);
1561 if (ret) 1563 if (ret)
1562 goto out_put_req; 1564 goto out_put_req;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 905986dd4c3c..081c4e3f9e49 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -807,7 +807,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to)
807{ 807{
808 struct file *filp = iocb->ki_filp; 808 struct file *filp = iocb->ki_filp;
809 struct ceph_file_info *fi = filp->private_data; 809 struct ceph_file_info *fi = filp->private_data;
810 size_t len = iocb->ki_nbytes; 810 size_t len = iov_iter_count(to);
811 struct inode *inode = file_inode(filp); 811 struct inode *inode = file_inode(filp);
812 struct ceph_inode_info *ci = ceph_inode(inode); 812 struct ceph_inode_info *ci = ceph_inode(inode);
813 struct page *pinned_page = NULL; 813 struct page *pinned_page = NULL;
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c
index 7077521acdf4..27cebf164070 100644
--- a/fs/nfs/direct.c
+++ b/fs/nfs/direct.c
@@ -265,7 +265,7 @@ ssize_t nfs_direct_IO(int rw, struct kiocb *iocb, struct iov_iter *iter, loff_t
265 265
266 return -EINVAL; 266 return -EINVAL;
267#else 267#else
268 VM_BUG_ON(iocb->ki_nbytes != PAGE_SIZE); 268 VM_BUG_ON(iov_iter_count(iter) != PAGE_SIZE);
269 269
270 if (rw == READ) 270 if (rw == READ)
271 return nfs_file_direct_read(iocb, iter, pos); 271 return nfs_file_direct_read(iocb, iter, pos);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 46e0d4e857c7..266845de2100 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2280,7 +2280,7 @@ static ssize_t ocfs2_file_write_iter(struct kiocb *iocb,
2280 file->f_path.dentry->d_name.name, 2280 file->f_path.dentry->d_name.name,
2281 (unsigned int)from->nr_segs); /* GRRRRR */ 2281 (unsigned int)from->nr_segs); /* GRRRRR */
2282 2282
2283 if (iocb->ki_nbytes == 0) 2283 if (count == 0)
2284 return 0; 2284 return 0;
2285 2285
2286 appending = file->f_flags & O_APPEND ? 1 : 0; 2286 appending = file->f_flags & O_APPEND ? 1 : 0;
@@ -2330,8 +2330,7 @@ relock:
2330 } 2330 }
2331 2331
2332 can_do_direct = direct_io; 2332 can_do_direct = direct_io;
2333 ret = ocfs2_prepare_inode_for_write(file, ppos, 2333 ret = ocfs2_prepare_inode_for_write(file, ppos, count, appending,
2334 iocb->ki_nbytes, appending,
2335 &can_do_direct, &has_refcount); 2334 &can_do_direct, &has_refcount);
2336 if (ret < 0) { 2335 if (ret < 0) {
2337 mlog_errno(ret); 2336 mlog_errno(ret);
@@ -2339,8 +2338,7 @@ relock:
2339 } 2338 }
2340 2339
2341 if (direct_io && !is_sync_kiocb(iocb)) 2340 if (direct_io && !is_sync_kiocb(iocb))
2342 unaligned_dio = ocfs2_is_io_unaligned(inode, iocb->ki_nbytes, 2341 unaligned_dio = ocfs2_is_io_unaligned(inode, count, *ppos);
2343 *ppos);
2344 2342
2345 /* 2343 /*
2346 * We can't complete the direct I/O as requested, fall back to 2344 * We can't complete the direct I/O as requested, fall back to
diff --git a/fs/read_write.c b/fs/read_write.c
index 8e1b68786d66..f8b8fc1316ab 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -343,7 +343,6 @@ ssize_t vfs_iter_read(struct file *file, struct iov_iter *iter, loff_t *ppos)
343 343
344 init_sync_kiocb(&kiocb, file); 344 init_sync_kiocb(&kiocb, file);
345 kiocb.ki_pos = *ppos; 345 kiocb.ki_pos = *ppos;
346 kiocb.ki_nbytes = iov_iter_count(iter);
347 346
348 iter->type |= READ; 347 iter->type |= READ;
349 ret = file->f_op->read_iter(&kiocb, iter); 348 ret = file->f_op->read_iter(&kiocb, iter);
@@ -366,7 +365,6 @@ ssize_t vfs_iter_write(struct file *file, struct iov_iter *iter, loff_t *ppos)
366 365
367 init_sync_kiocb(&kiocb, file); 366 init_sync_kiocb(&kiocb, file);
368 kiocb.ki_pos = *ppos; 367 kiocb.ki_pos = *ppos;
369 kiocb.ki_nbytes = iov_iter_count(iter);
370 368
371 iter->type |= WRITE; 369 iter->type |= WRITE;
372 ret = file->f_op->write_iter(&kiocb, iter); 370 ret = file->f_op->write_iter(&kiocb, iter);
@@ -426,7 +424,6 @@ ssize_t do_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *pp
426 424
427 init_sync_kiocb(&kiocb, filp); 425 init_sync_kiocb(&kiocb, filp);
428 kiocb.ki_pos = *ppos; 426 kiocb.ki_pos = *ppos;
429 kiocb.ki_nbytes = len;
430 427
431 ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos); 428 ret = filp->f_op->aio_read(&kiocb, &iov, 1, kiocb.ki_pos);
432 if (-EIOCBQUEUED == ret) 429 if (-EIOCBQUEUED == ret)
@@ -446,7 +443,6 @@ ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *p
446 443
447 init_sync_kiocb(&kiocb, filp); 444 init_sync_kiocb(&kiocb, filp);
448 kiocb.ki_pos = *ppos; 445 kiocb.ki_pos = *ppos;
449 kiocb.ki_nbytes = len;
450 iov_iter_init(&iter, READ, &iov, 1, len); 446 iov_iter_init(&iter, READ, &iov, 1, len);
451 447
452 ret = filp->f_op->read_iter(&kiocb, &iter); 448 ret = filp->f_op->read_iter(&kiocb, &iter);
@@ -510,7 +506,6 @@ ssize_t do_sync_write(struct file *filp, const char __user *buf, size_t len, lof
510 506
511 init_sync_kiocb(&kiocb, filp); 507 init_sync_kiocb(&kiocb, filp);
512 kiocb.ki_pos = *ppos; 508 kiocb.ki_pos = *ppos;
513 kiocb.ki_nbytes = len;
514 509
515 ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos); 510 ret = filp->f_op->aio_write(&kiocb, &iov, 1, kiocb.ki_pos);
516 if (-EIOCBQUEUED == ret) 511 if (-EIOCBQUEUED == ret)
@@ -530,7 +525,6 @@ ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t len, lo
530 525
531 init_sync_kiocb(&kiocb, filp); 526 init_sync_kiocb(&kiocb, filp);
532 kiocb.ki_pos = *ppos; 527 kiocb.ki_pos = *ppos;
533 kiocb.ki_nbytes = len;
534 iov_iter_init(&iter, WRITE, &iov, 1, len); 528 iov_iter_init(&iter, WRITE, &iov, 1, len);
535 529
536 ret = filp->f_op->write_iter(&kiocb, &iter); 530 ret = filp->f_op->write_iter(&kiocb, &iter);
@@ -719,7 +713,6 @@ static ssize_t do_iter_readv_writev(struct file *filp, int rw, const struct iove
719 713
720 init_sync_kiocb(&kiocb, filp); 714 init_sync_kiocb(&kiocb, filp);
721 kiocb.ki_pos = *ppos; 715 kiocb.ki_pos = *ppos;
722 kiocb.ki_nbytes = len;
723 716
724 iov_iter_init(&iter, rw, iov, nr_segs, len); 717 iov_iter_init(&iter, rw, iov, nr_segs, len);
725 ret = fn(&kiocb, &iter); 718 ret = fn(&kiocb, &iter);
@@ -737,7 +730,6 @@ static ssize_t do_sync_readv_writev(struct file *filp, const struct iovec *iov,
737 730
738 init_sync_kiocb(&kiocb, filp); 731 init_sync_kiocb(&kiocb, filp);
739 kiocb.ki_pos = *ppos; 732 kiocb.ki_pos = *ppos;
740 kiocb.ki_nbytes = len;
741 733
742 ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos); 734 ret = fn(&kiocb, iov, nr_segs, kiocb.ki_pos);
743 if (ret == -EIOCBQUEUED) 735 if (ret == -EIOCBQUEUED)
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 08f3555fbeac..9c0b6da9dbb3 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -122,7 +122,7 @@ static ssize_t udf_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
122 struct file *file = iocb->ki_filp; 122 struct file *file = iocb->ki_filp;
123 struct inode *inode = file_inode(file); 123 struct inode *inode = file_inode(file);
124 int err, pos; 124 int err, pos;
125 size_t count = iocb->ki_nbytes; 125 size_t count = iov_iter_count(from);
126 struct udf_inode_info *iinfo = UDF_I(inode); 126 struct udf_inode_info *iinfo = UDF_I(inode);
127 127
128 mutex_lock(&inode->i_mutex); 128 mutex_lock(&inode->i_mutex);