diff options
author | Badari Pulavarty <pbadari@us.ibm.com> | 2006-10-01 02:28:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-10-01 03:39:28 -0400 |
commit | 027445c37282bc1ed26add45e573ad2d3e4860a5 (patch) | |
tree | 93eab101a938ffebaea64703033c8649df4d73f0 /fs/ocfs2/file.c | |
parent | 9ea0f9499d15c49df23e7aac4332d830c40e12d0 (diff) |
[PATCH] Vectorize aio_read/aio_write fileop methods
This patch vectorizes aio_read() and aio_write() methods to prepare for
collapsing all aio & vectored operations into one interface - which is
aio_read()/aio_write().
Signed-off-by: Badari Pulavarty <pbadari@us.ibm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Cc: Michael Holzheu <HOLZHEU@de.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ocfs2/file.c')
-rw-r--r-- | fs/ocfs2/file.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 2bbfa17090cf..d9ba0a931a03 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c | |||
@@ -961,25 +961,23 @@ static inline int ocfs2_write_should_remove_suid(struct inode *inode) | |||
961 | } | 961 | } |
962 | 962 | ||
963 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | 963 | static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, |
964 | const char __user *buf, | 964 | const struct iovec *iov, |
965 | size_t count, | 965 | unsigned long nr_segs, |
966 | loff_t pos) | 966 | loff_t pos) |
967 | { | 967 | { |
968 | struct iovec local_iov = { .iov_base = (void __user *)buf, | ||
969 | .iov_len = count }; | ||
970 | int ret, rw_level = -1, meta_level = -1, have_alloc_sem = 0; | 968 | int ret, rw_level = -1, meta_level = -1, have_alloc_sem = 0; |
971 | u32 clusters; | 969 | u32 clusters; |
972 | struct file *filp = iocb->ki_filp; | 970 | struct file *filp = iocb->ki_filp; |
973 | struct inode *inode = filp->f_dentry->d_inode; | 971 | struct inode *inode = filp->f_dentry->d_inode; |
974 | loff_t newsize, saved_pos; | 972 | loff_t newsize, saved_pos; |
975 | 973 | ||
976 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, | 974 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, |
977 | (unsigned int)count, | 975 | (unsigned int)nr_segs, |
978 | filp->f_dentry->d_name.len, | 976 | filp->f_dentry->d_name.len, |
979 | filp->f_dentry->d_name.name); | 977 | filp->f_dentry->d_name.name); |
980 | 978 | ||
981 | /* happy write of zero bytes */ | 979 | /* happy write of zero bytes */ |
982 | if (count == 0) | 980 | if (iocb->ki_left == 0) |
983 | return 0; | 981 | return 0; |
984 | 982 | ||
985 | if (!inode) { | 983 | if (!inode) { |
@@ -1048,7 +1046,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1048 | } else { | 1046 | } else { |
1049 | saved_pos = iocb->ki_pos; | 1047 | saved_pos = iocb->ki_pos; |
1050 | } | 1048 | } |
1051 | newsize = count + saved_pos; | 1049 | newsize = iocb->ki_left + saved_pos; |
1052 | 1050 | ||
1053 | mlog(0, "pos=%lld newsize=%lld cursize=%lld\n", | 1051 | mlog(0, "pos=%lld newsize=%lld cursize=%lld\n", |
1054 | (long long) saved_pos, (long long) newsize, | 1052 | (long long) saved_pos, (long long) newsize, |
@@ -1081,7 +1079,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1081 | if (!clusters) | 1079 | if (!clusters) |
1082 | break; | 1080 | break; |
1083 | 1081 | ||
1084 | ret = ocfs2_extend_file(inode, NULL, newsize, count); | 1082 | ret = ocfs2_extend_file(inode, NULL, newsize, iocb->ki_left); |
1085 | if (ret < 0) { | 1083 | if (ret < 0) { |
1086 | if (ret != -ENOSPC) | 1084 | if (ret != -ENOSPC) |
1087 | mlog_errno(ret); | 1085 | mlog_errno(ret); |
@@ -1098,7 +1096,7 @@ static ssize_t ocfs2_file_aio_write(struct kiocb *iocb, | |||
1098 | /* communicate with ocfs2_dio_end_io */ | 1096 | /* communicate with ocfs2_dio_end_io */ |
1099 | ocfs2_iocb_set_rw_locked(iocb); | 1097 | ocfs2_iocb_set_rw_locked(iocb); |
1100 | 1098 | ||
1101 | ret = generic_file_aio_write_nolock(iocb, &local_iov, 1, &iocb->ki_pos); | 1099 | ret = generic_file_aio_write_nolock(iocb, iov, nr_segs, iocb->ki_pos); |
1102 | 1100 | ||
1103 | /* buffered aio wouldn't have proper lock coverage today */ | 1101 | /* buffered aio wouldn't have proper lock coverage today */ |
1104 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); | 1102 | BUG_ON(ret == -EIOCBQUEUED && !(filp->f_flags & O_DIRECT)); |
@@ -1132,16 +1130,16 @@ out: | |||
1132 | } | 1130 | } |
1133 | 1131 | ||
1134 | static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | 1132 | static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, |
1135 | char __user *buf, | 1133 | const struct iovec *iov, |
1136 | size_t count, | 1134 | unsigned long nr_segs, |
1137 | loff_t pos) | 1135 | loff_t pos) |
1138 | { | 1136 | { |
1139 | int ret = 0, rw_level = -1, have_alloc_sem = 0; | 1137 | int ret = 0, rw_level = -1, have_alloc_sem = 0; |
1140 | struct file *filp = iocb->ki_filp; | 1138 | struct file *filp = iocb->ki_filp; |
1141 | struct inode *inode = filp->f_dentry->d_inode; | 1139 | struct inode *inode = filp->f_dentry->d_inode; |
1142 | 1140 | ||
1143 | mlog_entry("(0x%p, 0x%p, %u, '%.*s')\n", filp, buf, | 1141 | mlog_entry("(0x%p, %u, '%.*s')\n", filp, |
1144 | (unsigned int)count, | 1142 | (unsigned int)nr_segs, |
1145 | filp->f_dentry->d_name.len, | 1143 | filp->f_dentry->d_name.len, |
1146 | filp->f_dentry->d_name.name); | 1144 | filp->f_dentry->d_name.name); |
1147 | 1145 | ||
@@ -1185,7 +1183,7 @@ static ssize_t ocfs2_file_aio_read(struct kiocb *iocb, | |||
1185 | } | 1183 | } |
1186 | ocfs2_meta_unlock(inode, 0); | 1184 | ocfs2_meta_unlock(inode, 0); |
1187 | 1185 | ||
1188 | ret = generic_file_aio_read(iocb, buf, count, iocb->ki_pos); | 1186 | ret = generic_file_aio_read(iocb, iov, nr_segs, iocb->ki_pos); |
1189 | if (ret == -EINVAL) | 1187 | if (ret == -EINVAL) |
1190 | mlog(ML_ERROR, "generic_file_aio_read returned -EINVAL\n"); | 1188 | mlog(ML_ERROR, "generic_file_aio_read returned -EINVAL\n"); |
1191 | 1189 | ||