From: Christoph Hellwig <milosz@adfin.com>
To: linux-kernel@vger.kernel.org
Cc: Christoph Hellwig <hch@infradead.org>,
linux-fsdevel@vger.kernel.org, linux-aio@kvack.org,
Mel Gorman <mgorman@suse.de>,
Volker Lendecke <Volker.Lendecke@sernet.de>,
Tejun Heo <tj@kernel.org>, Jeff Moyer <jmoyer@redhat.com>
Subject: [PATCH 7/7] check for O_NONBLOCK in all read_iter instances
Date: Mon, 15 Sep 2014 16:22:12 -0400 [thread overview]
Message-ID: <c31364dee619b2c813c84437561569441fd5fd61.1410810247.git.milosz@adfin.com> (raw)
In-Reply-To: <cover.1410810247.git.milosz@adfin.com>
Acked-by: Milosz Tanski <milosz@adfin.com>
---
fs/ceph/file.c | 2 ++
fs/cifs/file.c | 6 ++++++
fs/nfs/file.c | 5 ++++-
fs/ocfs2/file.c | 6 ++++++
fs/pipe.c | 3 ++-
fs/read_write.c | 17 +++++++++++------
fs/xfs/xfs_file.c | 4 ++++
mm/shmem.c | 4 ++++
8 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index 4776257..b62e3a5 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -808,6 +808,8 @@ again:
if ((got & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)) == 0 ||
(iocb->ki_filp->f_flags & O_DIRECT) ||
(fi->flags & CEPH_F_SYNC)) {
+ if (flags & O_NONBLOCK)
+ return -EAGAIN;
dout("aio_sync_read %p %llx.%llx %llu~%u got cap refs on %s\n",
inode, ceph_vinop(inode), iocb->ki_pos, (unsigned)len,
diff --git a/fs/cifs/file.c b/fs/cifs/file.c
index 58aecd7..cda6b9e 100644
--- a/fs/cifs/file.c
+++ b/fs/cifs/file.c
@@ -3005,6 +3005,9 @@ ssize_t cifs_user_readv(struct kiocb *iocb, struct iov_iter *to, int flags)
struct cifs_readdata *rdata, *tmp;
struct list_head rdata_list;
+ if (flags & O_NONBLOCK)
+ return -EAGAIN;
+
len = iov_iter_count(to);
if (!len)
return 0;
@@ -3123,6 +3126,9 @@ cifs_strict_readv(struct kiocb *iocb, struct iov_iter *to, int flags)
((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0))
return generic_file_read_iter(iocb, to, flags);
+ if (flags & O_NONBLOCK)
+ return -EAGAIN;
+
/*
* We need to hold the sem to be sure nobody modifies lock list
* with a brlock that prevents reading.
diff --git a/fs/nfs/file.c b/fs/nfs/file.c
index 4072f3a..116bed2 100644
--- a/fs/nfs/file.c
+++ b/fs/nfs/file.c
@@ -170,8 +170,11 @@ nfs_file_read(struct kiocb *iocb, struct iov_iter *to, int flags)
struct inode *inode = file_inode(iocb->ki_filp);
ssize_t result;
- if (iocb->ki_filp->f_flags & O_DIRECT)
+ if (iocb->ki_filp->f_flags & O_DIRECT) {
+ if (flags & O_NONBLOCK)
+ return -EAGAIN;
return nfs_file_direct_read(iocb, to, iocb->ki_pos, true);
+ }
dprintk("NFS: read(%pD2, %zu@%lu)\n",
iocb->ki_filp,
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 418c8a3..a8f7def 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -2474,6 +2474,12 @@ static ssize_t ocfs2_file_read_iter(struct kiocb *iocb,
filp->f_path.dentry->d_name.name,
to->nr_segs); /* GRRRRR */
+ /*
+ * No non-blocking reads for ocfs2 for now. Might be doable with
+ * non-blocking cluster lock helpers.
+ */
+ if (flags & O_NONBLOCK)
+ return -EAGAIN;
if (!inode) {
ret = -EINVAL;
diff --git a/fs/pipe.c b/fs/pipe.c
index d2510ab..74d6749 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -302,7 +302,8 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to, int flags)
*/
if (ret)
break;
- if (filp->f_flags & O_NONBLOCK) {
+ if ((filp->f_flags & O_NONBLOCK) ||
+ (flags & O_NONBLOCK)) {
ret = -EAGAIN;
break;
}
diff --git a/fs/read_write.c b/fs/read_write.c
index 233ea98..4a5f82c 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -832,14 +832,19 @@ static ssize_t do_readv_writev(int type, struct file *file,
file_start_write(file);
}
- if (iter_fn)
+ if (iter_fn) {
ret = do_iter_readv_writev(file, type, iov, nr_segs, tot_len,
pos, iter_fn, flags);
- else if (fnv)
- ret = do_sync_readv_writev(file, iov, nr_segs, tot_len,
- pos, fnv);
- else
- ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn);
+ } else {
+ if (type == READ && (flags & O_NONBLOCK))
+ return -EAGAIN;
+
+ if (fnv)
+ ret = do_sync_readv_writev(file, iov, nr_segs, tot_len,
+ pos, fnv);
+ else
+ ret = do_loop_readv_writev(file, iov, nr_segs, pos, fn);
+ }
if (type != READ)
file_end_write(file);
diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c
index 68847008..0252a31 100644
--- a/fs/xfs/xfs_file.c
+++ b/fs/xfs/xfs_file.c
@@ -247,6 +247,10 @@ xfs_file_read_iter(
XFS_STATS_INC(xs_read_calls);
+ /* XXX: need a non-blocking iolock helper, shouldn't be too hard */
+ if (flags & O_NONBLOCK)
+ return -EAGAIN;
+
if (unlikely(file->f_flags & O_DIRECT))
ioflags |= XFS_IO_ISDIRECT;
if (file->f_mode & FMODE_NOCMTIME)
diff --git a/mm/shmem.c b/mm/shmem.c
index 24c73bce..f5ad85f 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1531,6 +1531,10 @@ static ssize_t shmem_file_read_iter(struct kiocb *iocb, struct iov_iter *to, int
ssize_t retval = 0;
loff_t *ppos = &iocb->ki_pos;
+ /* XXX: should be easily supportable */
+ if (flags & O_NONBLOCK)
+ return -EAGAIN;
+
/*
* Might this read be for a stacking filesystem? Then when reading
* holes of a sparse file, we actually need to allocate those pages,
--
1.7.9.5
next prev parent reply other threads:[~2014-09-15 20:22 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-15 20:20 [RFC PATCH 0/7] Non-blockling buffered fs read (page cache only) Milosz Tanski
2014-09-15 20:20 ` [PATCH 1/7] Prepare for adding a new readv/writev with user flags Milosz Tanski
2014-09-15 20:28 ` Al Viro
2014-09-15 21:15 ` Christoph Hellwig
2014-09-15 21:44 ` Milosz Tanski
2014-09-15 20:20 ` [PATCH 2/7] Define new syscalls readv2,preadv2,writev2,pwritev2 Milosz Tanski
2014-09-16 19:20 ` Jeff Moyer
2014-09-16 19:54 ` Milosz Tanski
2014-09-16 21:03 ` Christoph Hellwig
2014-09-17 15:43 ` Theodore Ts'o
2014-09-17 16:05 ` Milosz Tanski
2014-09-17 16:59 ` Theodore Ts'o
2014-09-17 17:24 ` Zach Brown
2014-09-15 20:20 ` [PATCH 3/7] Export new vector IO (with flags) to userland Milosz Tanski
2014-09-15 20:21 ` [PATCH 4/7] O_NONBLOCK flag for readv2/preadv2 Milosz Tanski
2014-09-16 19:19 ` Jeff Moyer
2014-09-16 19:44 ` Milosz Tanski
2014-09-16 19:53 ` Jeff Moyer
2014-09-15 20:21 ` [PATCH 5/7] documentation updates Christoph Hellwig
2014-09-15 20:21 ` [PATCH 6/7] move flags enforcement to vfs_preadv/vfs_pwritev Christoph Hellwig
2014-09-15 21:15 ` Christoph Hellwig
2014-09-15 21:45 ` Milosz Tanski
2014-09-15 20:22 ` Christoph Hellwig [this message]
2014-09-16 19:27 ` [PATCH 7/7] check for O_NONBLOCK in all read_iter instances Jeff Moyer
2014-09-16 19:45 ` Milosz Tanski
2014-09-16 21:42 ` Dave Chinner
2014-09-17 12:24 ` Benjamin LaHaise
2014-09-17 13:47 ` Theodore Ts'o
2014-09-17 13:56 ` Benjamin LaHaise
2014-09-17 15:33 ` Milosz Tanski
2014-09-17 15:49 ` Theodore Ts'o
2014-09-17 15:52 ` Zach Brown
2014-09-16 21:04 ` Christoph Hellwig
2014-09-16 21:24 ` Jeff Moyer
2014-09-15 20:27 ` [RFC PATCH 0/7] Non-blockling buffered fs read (page cache only) Milosz Tanski
2014-09-15 21:33 ` Andreas Dilger
2014-09-15 22:13 ` Milosz Tanski
2014-09-15 22:36 ` Elliott, Robert (Server Storage)
2014-09-16 18:24 ` Zach Brown
2014-09-19 11:21 ` Christoph Hellwig
2014-09-22 15:48 ` Jeff Moyer
2014-09-22 16:32 ` Milosz Tanski
2014-09-22 16:42 ` Christoph Hellwig
2014-09-22 17:02 ` Milosz Tanski
2014-09-22 16:25 ` Elliott, Robert (Server Storage)
2014-09-15 21:58 ` Jeff Moyer
2014-09-15 22:27 ` Milosz Tanski
2014-09-16 13:44 ` Jeff Moyer
2014-09-19 11:23 ` Christoph Hellwig
2014-09-16 19:30 ` Jeff Moyer
2014-09-16 20:34 ` Milosz Tanski
2014-09-16 20:49 ` Jeff Moyer
2014-09-17 14:49 ` [RFC 1/2] aio: async readahead Benjamin LaHaise
2014-09-17 15:26 ` [RFC 2/2] ext4: async readpage for indirect style inodes Benjamin LaHaise
2014-09-19 11:26 ` [RFC 1/2] aio: async readahead Christoph Hellwig
2014-09-19 16:01 ` Benjamin LaHaise
2014-09-17 22:20 ` [RFC v2 0/5] Non-blockling buffered fs read (page cache only) Milosz Tanski
2014-09-17 22:20 ` [RFC v2 1/5] Prepare for adding a new readv/writev with user flags Milosz Tanski
2014-09-17 22:20 ` [RFC v2 2/5] Define new syscalls readv2,preadv2,writev2,pwritev2 Milosz Tanski
2014-09-18 18:48 ` Darrick J. Wong
2014-09-19 10:52 ` Christoph Hellwig
2014-09-20 0:19 ` Darrick J. Wong
2014-09-17 22:20 ` [RFC v2 3/5] Export new vector IO (with flags) to userland Milosz Tanski
2014-09-17 22:20 ` [RFC v2 4/5] O_NONBLOCK flag for readv2/preadv2 Milosz Tanski
2014-09-19 11:27 ` Christoph Hellwig
2014-09-19 11:59 ` Milosz Tanski
2014-09-22 17:12 ` Jeff Moyer
2014-09-17 22:20 ` [RFC v2 5/5] Check for O_NONBLOCK in all read_iter instances Milosz Tanski
2014-09-19 11:26 ` Christoph Hellwig
2014-09-19 14:42 ` [RFC v2 0/5] Non-blockling buffered fs read (page cache only) Jonathan Corbet
2014-09-19 16:13 ` Volker Lendecke
2014-09-19 17:19 ` Milosz Tanski
2014-09-19 17:33 ` Milosz Tanski
2014-09-22 14:12 ` Jonathan Corbet
2014-09-22 14:24 ` Jeff Moyer
2014-09-22 14:25 ` Christoph Hellwig
2014-09-22 14:30 ` Milosz Tanski
2014-09-24 21:46 ` [RFC v3 0/4] vfs: " Milosz Tanski
2014-09-24 21:46 ` [RFC v3 1/4] vfs: Prepare for adding a new preadv/pwritev with user flags Milosz Tanski
2014-09-24 21:46 ` [RFC v3 2/4] vfs: Define new syscalls preadv2,pwritev2 Milosz Tanski
2014-09-24 21:46 ` [RFC v3 3/4] vfs: Export new vector IO syscalls (with flags) to userland Milosz Tanski
2014-09-24 21:46 ` [RFC v3 4/4] vfs: RWF_NONBLOCK flag for preadv2 Milosz Tanski
2014-09-25 4:06 ` [RFC v3 0/4] vfs: Non-blockling buffered fs read (page cache only) Michael Kerrisk
2014-09-25 11:16 ` Jan Kara
2014-09-25 15:48 ` Milosz Tanski
2014-10-08 2:53 ` Milosz Tanski
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=c31364dee619b2c813c84437561569441fd5fd61.1410810247.git.milosz@adfin.com \
--to=milosz@adfin.com \
--cc=Volker.Lendecke@sernet.de \
--cc=hch@infradead.org \
--cc=jmoyer@redhat.com \
--cc=linux-aio@kvack.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=tj@kernel.org \
/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).