Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932256Ab3GYR7x (ORCPT ); Thu, 25 Jul 2013 13:59:53 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:19909 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756822Ab3GYRwE (ORCPT ); Thu, 25 Jul 2013 13:52:04 -0400 From: Dave Kleikamp To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Andrew Morton , "Maxim V. Patlasov" , Zach Brown , Dave Kleikamp , "Theodore Ts'o" , Andreas Dilger , linux-ext4@vger.kernel.org Subject: [PATCH V8 22/33] ext4: add support for read_iter and write_iter Date: Thu, 25 Jul 2013 12:50:48 -0500 Message-Id: <1374774659-13121-23-git-send-email-dave.kleikamp@oracle.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1374774659-13121-1-git-send-email-dave.kleikamp@oracle.com> References: <1374774659-13121-1-git-send-email-dave.kleikamp@oracle.com> X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4335 Lines: 125 use the generic_file_read_iter(), create ext4_file_write_iter() based on ext4_file_write(), and make ext4_file_write() a wrapper around ext4_file_write_iter(). Signed-off-by: Dave Kleikamp Cc: Zach Brown Cc: "Theodore Ts'o" Cc: Andreas Dilger Cc: linux-ext4@vger.kernel.org --- fs/ext4/file.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 6f4cc56..c25d48a 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -74,12 +74,11 @@ void ext4_unwritten_wait(struct inode *inode) * or one thread will zero the other's data, causing corruption. */ static int -ext4_unaligned_aio(struct inode *inode, const struct iovec *iov, - unsigned long nr_segs, loff_t pos) +ext4_unaligned_aio(struct inode *inode, struct iov_iter *iter, loff_t pos) { struct super_block *sb = inode->i_sb; int blockmask = sb->s_blocksize - 1; - size_t count = iov_length(iov, nr_segs); + size_t count = iov_iter_count(iter); loff_t final_size = pos + count; if (pos >= inode->i_size) @@ -92,8 +91,8 @@ ext4_unaligned_aio(struct inode *inode, const struct iovec *iov, } static ssize_t -ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov, - unsigned long nr_segs, loff_t pos) +ext4_file_dio_write(struct kiocb *iocb, struct iov_iter *iter, + loff_t pos) { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; @@ -101,11 +100,11 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov, int unaligned_aio = 0; ssize_t ret; int overwrite = 0; - size_t length = iov_length(iov, nr_segs); + size_t length = iov_iter_count(iter); if (ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS) && !is_sync_kiocb(iocb)) - unaligned_aio = ext4_unaligned_aio(inode, iov, nr_segs, pos); + unaligned_aio = ext4_unaligned_aio(inode, iter, pos); /* Unaligned direct AIO must be serialized; see comment above */ if (unaligned_aio) { @@ -146,7 +145,7 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov, overwrite = 1; } - ret = __generic_file_aio_write(iocb, iov, nr_segs, &iocb->ki_pos); + ret = __generic_file_write_iter(iocb, iter, &iocb->ki_pos); mutex_unlock(&inode->i_mutex); if (ret > 0 || ret == -EIOCBQUEUED) { @@ -165,8 +164,7 @@ ext4_file_dio_write(struct kiocb *iocb, const struct iovec *iov, } static ssize_t -ext4_file_write(struct kiocb *iocb, const struct iovec *iov, - unsigned long nr_segs, loff_t pos) +ext4_file_write_iter(struct kiocb *iocb, struct iov_iter *iter, loff_t pos) { struct inode *inode = file_inode(iocb->ki_filp); ssize_t ret; @@ -178,22 +176,24 @@ ext4_file_write(struct kiocb *iocb, const struct iovec *iov, if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) { struct ext4_sb_info *sbi = EXT4_SB(inode->i_sb); - size_t length = iov_length(iov, nr_segs); + size_t length = iov_iter_count(iter); if ((pos > sbi->s_bitmap_maxbytes || (pos == sbi->s_bitmap_maxbytes && length > 0))) return -EFBIG; if (pos + length > sbi->s_bitmap_maxbytes) { - nr_segs = iov_shorten((struct iovec *)iov, nr_segs, - sbi->s_bitmap_maxbytes - pos); + ret = iov_iter_shorten(iter, + sbi->s_bitmap_maxbytes - pos); + if (ret) + return ret; } } if (unlikely(iocb->ki_filp->f_flags & O_DIRECT)) - ret = ext4_file_dio_write(iocb, iov, nr_segs, pos); + ret = ext4_file_dio_write(iocb, iter, pos); else - ret = generic_file_aio_write(iocb, iov, nr_segs, pos); + ret = generic_file_write_iter(iocb, iter, pos); return ret; } @@ -607,8 +607,8 @@ const struct file_operations ext4_file_operations = { .llseek = ext4_llseek, .read = do_sync_read, .write = do_sync_write, - .aio_read = generic_file_aio_read, - .aio_write = ext4_file_write, + .read_iter = generic_file_read_iter, + .write_iter = ext4_file_write_iter, .unlocked_ioctl = ext4_ioctl, #ifdef CONFIG_COMPAT .compat_ioctl = ext4_compat_ioctl, -- 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/