From patchwork Mon Nov 10 16:40:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milosz Tanski X-Patchwork-Id: 5267451 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0DCD0C11AC for ; Mon, 10 Nov 2014 16:44:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7C19720172 for ; Mon, 10 Nov 2014 16:44:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4A1FD20142 for ; Mon, 10 Nov 2014 16:44:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752880AbaKJQoC (ORCPT ); Mon, 10 Nov 2014 11:44:02 -0500 Received: from mail-qc0-f176.google.com ([209.85.216.176]:56746 "EHLO mail-qc0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753005AbaKJQkh (ORCPT ); Mon, 10 Nov 2014 11:40:37 -0500 Received: by mail-qc0-f176.google.com with SMTP id x3so6020287qcv.21 for ; Mon, 10 Nov 2014 08:40:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=0UuEuXeFaSoTn8OkxCPCLt3kOb0vj76nxwGDu0KB0ZM=; b=XgYZNLBrAY2umhTxOdSuMRlG0w5yXhcI+6UAtzM75LrIyF0DC78RwiFAyMXO1uA8pL Q3g+6S66Fka5qDoAz56zJo8olIviGSJr53zaMS+0OeTD3pT9y0OBHwViQ1R0woyPjcPw f5QS+p938Kafh3idHZiHczc5wce7aZr6hxJR0tFwkLcfXKdV49TC8ProRvKBTgOjcNBM hYjiyzi2Tyc2j8st/gHPzTyXTrCRTxZd7tOeU/6ODkcoVX3ZdDYKoHhUuhfCPxvX/2vJ YbeIhKczX3Vmx8e8DQui3gRWVvoR6v6qoNaMyGax6K5z+VKOgM/4fQ1QR3Ku0/2n2wS0 eYNg== X-Gm-Message-State: ALoCoQmMBIqxCKBmcSjGQRuNyDoBxGnaTfg0o3cfHqXC9FFHu5ZUbxXLV1gAwAaRX1CxIzk9Pube X-Received: by 10.140.43.6 with SMTP id d6mr42015331qga.104.1415637636733; Mon, 10 Nov 2014 08:40:36 -0800 (PST) Received: from adfin.com ([65.244.82.98]) by mx.google.com with ESMTPSA id u2sm701618qae.15.2014.11.10.08.40.34 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 10 Nov 2014 08:40:35 -0800 (PST) From: Milosz Tanski To: linux-kernel@vger.kernel.org Cc: Christoph Hellwig , linux-fsdevel@vger.kernel.org, linux-aio@kvack.org, Mel Gorman , Volker Lendecke , Tejun Heo , Jeff Moyer , Theodore Ts'o , Al Viro , linux-api@vger.kernel.org, Michael Kerrisk , linux-arch@vger.kernel.org, linux-scsi@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH v6 1/7] vfs: Prepare for adding a new preadv/pwritev with user flags. Date: Mon, 10 Nov 2014 11:40:24 -0500 Message-Id: X-Mailer: git-send-email 2.0.0 In-Reply-To: References: In-Reply-To: References: Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Plumbing the flags argument through the vfs code so they can be passed down to __generic_file_(read/write)_iter function that do the acctual work. Signed-off-by: Milosz Tanski Reviewed-by: Christoph Hellwig Reviewed-by: Jeff Moyer --- drivers/target/target_core_file.c | 6 +++--- fs/nfsd/vfs.c | 4 ++-- fs/read_write.c | 27 +++++++++++++++------------ fs/splice.c | 2 +- include/linux/aio.h | 2 ++ include/linux/fs.h | 4 ++-- 6 files changed, 25 insertions(+), 20 deletions(-) diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index 7d6cdda..58d9a6d 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -350,9 +350,9 @@ static int fd_do_rw(struct se_cmd *cmd, struct scatterlist *sgl, set_fs(get_ds()); if (is_write) - ret = vfs_writev(fd, &iov[0], sgl_nents, &pos); + ret = vfs_writev(fd, &iov[0], sgl_nents, &pos, 0); else - ret = vfs_readv(fd, &iov[0], sgl_nents, &pos); + ret = vfs_readv(fd, &iov[0], sgl_nents, &pos, 0); set_fs(old_fs); @@ -528,7 +528,7 @@ fd_execute_write_same(struct se_cmd *cmd) old_fs = get_fs(); set_fs(get_ds()); - rc = vfs_writev(f, &iov[0], iov_num, &pos); + rc = vfs_writev(f, &iov[0], iov_num, &pos, 0); set_fs(old_fs); vfree(iov); diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 989129e..ef01c78 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -872,7 +872,7 @@ __be32 nfsd_readv(struct file *file, loff_t offset, struct kvec *vec, int vlen, oldfs = get_fs(); set_fs(KERNEL_DS); - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset); + host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset, 0); set_fs(oldfs); return nfsd_finish_read(file, count, host_err); } @@ -960,7 +960,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file, /* Write the data. */ oldfs = get_fs(); set_fs(KERNEL_DS); - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos); + host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos, 0); set_fs(oldfs); if (host_err < 0) goto out_nfserr; diff --git a/fs/read_write.c b/fs/read_write.c index 7d9318c..94b2d34 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -653,7 +653,8 @@ unsigned long iov_shorten(struct iovec *iov, unsigned long nr_segs, size_t to) EXPORT_SYMBOL(iov_shorten); static ssize_t do_iter_readv_writev(struct file *filp, int rw, const struct iovec *iov, - unsigned long nr_segs, size_t len, loff_t *ppos, iter_fn_t fn) + unsigned long nr_segs, size_t len, loff_t *ppos, iter_fn_t fn, + int flags) { struct kiocb kiocb; struct iov_iter iter; @@ -662,6 +663,7 @@ static ssize_t do_iter_readv_writev(struct file *filp, int rw, const struct iove init_sync_kiocb(&kiocb, filp); kiocb.ki_pos = *ppos; kiocb.ki_nbytes = len; + kiocb.ki_rwflags = flags; iov_iter_init(&iter, rw, iov, nr_segs, len); ret = fn(&kiocb, &iter); @@ -800,7 +802,8 @@ out: static ssize_t do_readv_writev(int type, struct file *file, const struct iovec __user * uvector, - unsigned long nr_segs, loff_t *pos) + unsigned long nr_segs, loff_t *pos, + int flags) { size_t tot_len; struct iovec iovstack[UIO_FASTIOV]; @@ -834,7 +837,7 @@ static ssize_t do_readv_writev(int type, struct file *file, if (iter_fn) ret = do_iter_readv_writev(file, type, iov, nr_segs, tot_len, - pos, iter_fn); + pos, iter_fn, flags); else if (fnv) ret = do_sync_readv_writev(file, iov, nr_segs, tot_len, pos, fnv); @@ -857,27 +860,27 @@ out: } ssize_t vfs_readv(struct file *file, const struct iovec __user *vec, - unsigned long vlen, loff_t *pos) + unsigned long vlen, loff_t *pos, int flags) { if (!(file->f_mode & FMODE_READ)) return -EBADF; if (!(file->f_mode & FMODE_CAN_READ)) return -EINVAL; - return do_readv_writev(READ, file, vec, vlen, pos); + return do_readv_writev(READ, file, vec, vlen, pos, flags); } EXPORT_SYMBOL(vfs_readv); ssize_t vfs_writev(struct file *file, const struct iovec __user *vec, - unsigned long vlen, loff_t *pos) + unsigned long vlen, loff_t *pos, int flags) { if (!(file->f_mode & FMODE_WRITE)) return -EBADF; if (!(file->f_mode & FMODE_CAN_WRITE)) return -EINVAL; - return do_readv_writev(WRITE, file, vec, vlen, pos); + return do_readv_writev(WRITE, file, vec, vlen, pos, flags); } EXPORT_SYMBOL(vfs_writev); @@ -890,7 +893,7 @@ SYSCALL_DEFINE3(readv, unsigned long, fd, const struct iovec __user *, vec, if (f.file) { loff_t pos = file_pos_read(f.file); - ret = vfs_readv(f.file, vec, vlen, &pos); + ret = vfs_readv(f.file, vec, vlen, &pos, 0); if (ret >= 0) file_pos_write(f.file, pos); fdput_pos(f); @@ -910,7 +913,7 @@ SYSCALL_DEFINE3(writev, unsigned long, fd, const struct iovec __user *, vec, if (f.file) { loff_t pos = file_pos_read(f.file); - ret = vfs_writev(f.file, vec, vlen, &pos); + ret = vfs_writev(f.file, vec, vlen, &pos, 0); if (ret >= 0) file_pos_write(f.file, pos); fdput_pos(f); @@ -942,7 +945,7 @@ SYSCALL_DEFINE5(preadv, unsigned long, fd, const struct iovec __user *, vec, if (f.file) { ret = -ESPIPE; if (f.file->f_mode & FMODE_PREAD) - ret = vfs_readv(f.file, vec, vlen, &pos); + ret = vfs_readv(f.file, vec, vlen, &pos, 0); fdput(f); } @@ -966,7 +969,7 @@ SYSCALL_DEFINE5(pwritev, unsigned long, fd, const struct iovec __user *, vec, if (f.file) { ret = -ESPIPE; if (f.file->f_mode & FMODE_PWRITE) - ret = vfs_writev(f.file, vec, vlen, &pos); + ret = vfs_writev(f.file, vec, vlen, &pos, 0); fdput(f); } @@ -1014,7 +1017,7 @@ static ssize_t compat_do_readv_writev(int type, struct file *file, if (iter_fn) ret = do_iter_readv_writev(file, type, iov, nr_segs, tot_len, - pos, iter_fn); + pos, iter_fn, 0); else if (fnv) ret = do_sync_readv_writev(file, iov, nr_segs, tot_len, pos, fnv); diff --git a/fs/splice.c b/fs/splice.c index f5cb9ba..9591b9f 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -576,7 +576,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec, old_fs = get_fs(); set_fs(get_ds()); /* The cast to a user pointer is valid due to the set_fs() */ - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos); + res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos, 0); set_fs(old_fs); return res; diff --git a/include/linux/aio.h b/include/linux/aio.h index d9c92da..9c1d499 100644 --- a/include/linux/aio.h +++ b/include/linux/aio.h @@ -52,6 +52,8 @@ struct kiocb { * this is the underlying eventfd context to deliver events to. */ struct eventfd_ctx *ki_eventfd; + + int ki_rwflags; }; static inline bool is_sync_kiocb(struct kiocb *kiocb) diff --git a/include/linux/fs.h b/include/linux/fs.h index a957d43..9ed5711 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1538,9 +1538,9 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *); extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t *); extern ssize_t vfs_readv(struct file *, const struct iovec __user *, - unsigned long, loff_t *); + unsigned long, loff_t *, int); extern ssize_t vfs_writev(struct file *, const struct iovec __user *, - unsigned long, loff_t *); + unsigned long, loff_t *, int); struct super_operations { struct inode *(*alloc_inode)(struct super_block *sb);