From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Zach Brown <zab@zabbo.net>,
"Maxim V. Patlasov" <mpatlasov@parallels.com>,
Dave Kleikamp <dave.kleikamp@oracle.com>
Subject: [PATCH 07/22] iov_iter: add a shorten call
Date: Mon, 22 Oct 2012 10:15:07 -0500 [thread overview]
Message-ID: <1350918922-6096-8-git-send-email-dave.kleikamp@oracle.com> (raw)
In-Reply-To: <1350918922-6096-1-git-send-email-dave.kleikamp@oracle.com>
From: Zach Brown <zab@zabbo.net>
The generic direct write path wants to shorten its memory vector. It
does this when it finds that it has to perform a partial write due to
LIMIT_FSIZE. .direct_IO() always performs IO on all of the referenced
memory because it doesn't have an argument to specify the length of the
IO.
We add an iov_iter operation for this so that the generic path can ask
to shorten the memory vector without having to know what kind it is.
We're happy to shorten the kernel copy of the iovec array, but we refuse
to shorten the bio_vec array and return an error in this case.
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>
Cc: Zach Brown <zab@zabbo.net>
---
include/linux/fs.h | 5 +++++
mm/iov-iter.c | 14 ++++++++++++++
2 files changed, 19 insertions(+)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index afb1343..1a986ed 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -240,6 +240,7 @@ struct iov_iter_ops {
void (*ii_advance)(struct iov_iter *, size_t);
int (*ii_fault_in_readable)(struct iov_iter *, size_t);
size_t (*ii_single_seg_count)(struct iov_iter *);
+ int (*ii_shorten)(struct iov_iter *, size_t);
};
static inline size_t iov_iter_copy_to_user_atomic(struct page *page,
@@ -274,6 +275,10 @@ static inline size_t iov_iter_single_seg_count(struct iov_iter *i)
{
return i->ops->ii_single_seg_count(i);
}
+static inline int iov_iter_shorten(struct iov_iter *i, size_t count)
+{
+ return i->ops->ii_shorten(i, count);
+}
extern struct iov_iter_ops ii_bvec_ops;
diff --git a/mm/iov-iter.c b/mm/iov-iter.c
index c5d0a9e..fcced89 100644
--- a/mm/iov-iter.c
+++ b/mm/iov-iter.c
@@ -201,6 +201,11 @@ static size_t ii_bvec_single_seg_count(struct iov_iter *i)
return min(i->count, bvec->bv_len - i->iov_offset);
}
+static int ii_bvec_shorten(struct iov_iter *i, size_t count)
+{
+ return -EINVAL;
+}
+
struct iov_iter_ops ii_bvec_ops = {
.ii_copy_to_user_atomic = ii_bvec_copy_to_user_atomic,
.ii_copy_to_user = ii_bvec_copy_to_user,
@@ -209,6 +214,7 @@ struct iov_iter_ops ii_bvec_ops = {
.ii_advance = ii_bvec_advance,
.ii_fault_in_readable = ii_bvec_fault_in_readable,
.ii_single_seg_count = ii_bvec_single_seg_count,
+ .ii_shorten = ii_bvec_shorten,
};
EXPORT_SYMBOL(ii_bvec_ops);
@@ -358,6 +364,13 @@ static size_t ii_iovec_single_seg_count(struct iov_iter *i)
return min(i->count, iov->iov_len - i->iov_offset);
}
+static int ii_iovec_shorten(struct iov_iter *i, size_t count)
+{
+ struct iovec *iov = (struct iovec *)i->data;
+ i->nr_segs = iov_shorten(iov, i->nr_segs, count);
+ return 0;
+}
+
struct iov_iter_ops ii_iovec_ops = {
.ii_copy_to_user_atomic = ii_iovec_copy_to_user_atomic,
.ii_copy_to_user = ii_iovec_copy_to_user,
@@ -366,5 +379,6 @@ struct iov_iter_ops ii_iovec_ops = {
.ii_advance = ii_iovec_advance,
.ii_fault_in_readable = ii_iovec_fault_in_readable,
.ii_single_seg_count = ii_iovec_single_seg_count,
+ .ii_shorten = ii_iovec_shorten,
};
EXPORT_SYMBOL(ii_iovec_ops);
--
1.7.12.3
next prev parent reply other threads:[~2012-10-22 15:15 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-22 15:15 [PATCH v3 00/22] loop: Issue O_DIRECT aio using bio_vec Dave Kleikamp
2012-10-22 15:15 ` [PATCH 01/22] iov_iter: move into its own file Dave Kleikamp
2012-10-22 15:15 ` [PATCH 02/22] iov_iter: iov_iter_copy_from_user() should use non-atomic copy Dave Kleikamp
2012-10-22 15:15 ` [PATCH 03/22] iov_iter: add copy_to_user support Dave Kleikamp
[not found] ` <1350918922-6096-1-git-send-email-dave.kleikamp-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
2012-10-22 15:15 ` [PATCH 04/22] fuse: convert fuse to use iov_iter_copy_[to|from]_user Dave Kleikamp
2012-10-22 15:15 ` [PATCH 05/22] iov_iter: hide iovec details behind ops function pointers Dave Kleikamp
2012-10-22 15:15 ` [PATCH 06/22] iov_iter: add bvec support Dave Kleikamp
2012-10-22 15:15 ` Dave Kleikamp [this message]
2012-10-22 15:15 ` [PATCH 08/22] iov_iter: let callers extract iovecs and bio_vecs Dave Kleikamp
2012-10-22 15:15 ` [PATCH 09/22] dio: create a dio_aligned() helper function Dave Kleikamp
2012-10-22 15:15 ` [PATCH 10/22] dio: Convert direct_IO to use iov_iter Dave Kleikamp
2012-10-22 15:15 ` [PATCH 11/22] dio: add bio_vec support to __blockdev_direct_IO() Dave Kleikamp
2012-10-22 15:15 ` [PATCH 12/22] fs: pull iov_iter use higher up the stack Dave Kleikamp
2012-10-22 15:15 ` [PATCH 13/22] aio: add aio_kernel_() interface Dave Kleikamp
2012-10-22 15:15 ` [PATCH 14/22] aio: add aio support for iov_iter arguments Dave Kleikamp
2012-10-22 15:15 ` [PATCH 15/22] bio: add bvec_length(), like iov_length() Dave Kleikamp
2012-10-22 15:15 ` [PATCH 16/22] loop: use aio to perform io on the underlying file Dave Kleikamp
2012-10-22 15:15 ` [PATCH 17/22] fs: add read_iter and write_iter to several file systems Dave Kleikamp
2012-10-22 15:15 ` [PATCH 18/22] ocfs2: add support for read_iter, write_iter, and direct_IO_bvec Dave Kleikamp
2012-10-22 15:15 ` [PATCH 19/22] ext4: add support for read_iter and write_iter Dave Kleikamp
2012-10-22 15:15 ` [PATCH 20/22] nfs: add support for read_iter, write_iter Dave Kleikamp
2012-10-22 15:21 ` Myklebust, Trond
2012-10-22 15:35 ` Dave Kleikamp
2012-10-22 15:15 ` [PATCH 21/22] btrfs: add support for read_iter and write_iter Dave Kleikamp
2012-10-22 15:15 ` [PATCH 22/22] block_dev: add support for read_iter, write_iter Dave Kleikamp
2012-10-23 0:07 ` [PATCH v3 00/22] loop: Issue O_DIRECT aio using bio_vec Dave Chinner
2012-10-23 0:53 ` Dave Kleikamp
2012-10-23 1:59 ` Dave Chinner
2012-10-23 13:04 ` Christoph Hellwig
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=1350918922-6096-8-git-send-email-dave.kleikamp@oracle.com \
--to=dave.kleikamp@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mpatlasov@parallels.com \
--cc=zab@zabbo.net \
/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).