From: Dmitry Monakhov <dmonakhov@openvz.org>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
Dmitry Monakhov <dmonakhov@openvz.org>
Subject: [PATCH 02/16] vfs: check kiocb->ki_flags instead filp->fl_flags
Date: Sat, 4 Apr 2015 23:13:11 +0400 [thread overview]
Message-ID: <1428174805-853-3-git-send-email-dmonakhov@openvz.org> (raw)
In-Reply-To: <1428174805-853-1-git-send-email-dmonakhov@openvz.org>
generic_write_checks now accept kiocb as an argument
Unfortunetly it is impossible to get rid of old interface because some crappy
do not support write_iter interface so leave __generic_write_checks as backward
compatibility helper.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
---
include/linux/fs.h | 8 +++++++-
mm/filemap.c | 13 +++++++------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4c20030..992685e 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2570,7 +2570,7 @@ extern int sb_min_blocksize(struct super_block *, int);
extern int generic_file_mmap(struct file *, struct vm_area_struct *);
extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *);
-int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk);
+int __generic_write_checks(struct file * file, loff_t *pos, size_t *count, int isblk, int append);
extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *);
extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *);
extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *);
@@ -2798,6 +2798,12 @@ static inline bool is_nonblock_kiocb(struct kiocb *kiocb)
return kiocb->ki_flags & IOCB_NONBLOCK;
}
+static inline int generic_write_checks(struct kiocb *iocb, loff_t *pos, size_t *count, int isblk)
+{
+ return __generic_write_checks(iocb->ki_filp, pos, count, isblk,
+ is_append_kiocb(iocb));
+}
+
/* XXX: this is obsolete helper, and will be removed soon.
* One should use io_direct_kiocb() instead */
static inline bool io_is_direct(struct file *filp)
diff --git a/mm/filemap.c b/mm/filemap.c
index 876f4e6..b519824 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -1694,7 +1694,7 @@ generic_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
loff_t *ppos = &iocb->ki_pos;
loff_t pos = *ppos;
- if (io_is_direct(file)) {
+ if (is_direct_kiocb(iocb)) {
struct address_space *mapping = file->f_mapping;
struct inode *inode = mapping->host;
size_t count = iov_iter_count(iter);
@@ -2260,7 +2260,8 @@ EXPORT_SYMBOL(read_cache_page_gfp);
* Returns appropriate error code that caller should return or
* zero in case that write should be allowed.
*/
-inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, int isblk)
+inline int __generic_write_checks(struct file *file, loff_t *pos, size_t *count,
+ int isblk, int is_append)
{
struct inode *inode = file->f_mapping->host;
unsigned long limit = rlimit(RLIMIT_FSIZE);
@@ -2270,7 +2271,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
if (!isblk) {
/* FIXME: this is for backwards compatibility with 2.4 */
- if (file->f_flags & O_APPEND)
+ if (is_append)
*pos = i_size_read(inode);
if (limit != RLIM_INFINITY) {
@@ -2333,7 +2334,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
}
return 0;
}
-EXPORT_SYMBOL(generic_write_checks);
+EXPORT_SYMBOL(__generic_write_checks);
int pagecache_write_begin(struct file *file, struct address_space *mapping,
loff_t pos, unsigned len, unsigned flags,
@@ -2565,7 +2566,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
/* We can write back this queue in page reclaim */
current->backing_dev_info = inode_to_bdi(inode);
- err = generic_write_checks(file, &pos, &count, S_ISBLK(inode->i_mode));
+ err = generic_write_checks(iocb, &pos, &count, S_ISBLK(inode->i_mode));
if (err)
goto out;
@@ -2582,7 +2583,7 @@ ssize_t __generic_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
if (err)
goto out;
- if (io_is_direct(file)) {
+ if (is_direct_kiocb(iocb)) {
loff_t endbyte;
written = generic_file_direct_write(iocb, from, pos);
--
1.7.1
next prev parent reply other threads:[~2015-04-04 19:13 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-04 19:13 [PATCH 00/16] fs: fixup racy check file->f_flags for xxx_write_iter Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 01/16] fs: save file->f_flags to kiocb->ki_flags Dmitry Monakhov
2015-04-04 19:13 ` Dmitry Monakhov [this message]
2015-04-04 21:36 ` [PATCH 02/16] vfs: check kiocb->ki_flags instead filp->fl_flags Al Viro
2015-04-05 11:03 ` Dmitry Monakhov
2015-04-05 18:11 ` Al Viro
2015-04-05 21:54 ` Al Viro
2015-04-04 19:13 ` [PATCH 03/16] ext4: use is_xxx_kiocb instead of filp->fl_flags Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 04/16] 9p: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 05/16] btrfs: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 06/16] ceph: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 07/16] cifs: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 08/16] gfs2: " Dmitry Monakhov
2015-04-07 13:11 ` [Cluster-devel] " Steven Whitehouse
2015-04-04 19:13 ` [PATCH 09/16] nfs: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 10/16] ntfs: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 11/16] ocfs2: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 12/16] udf: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 13/16] xfs: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 14/16] fuse: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 15/16] pipe: " Dmitry Monakhov
2015-04-04 19:13 ` [PATCH 16/16] splice: fix race beween splice_write vs fcntl(,F_SETFL,) Dmitry Monakhov
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=1428174805-853-3-git-send-email-dmonakhov@openvz.org \
--to=dmonakhov@openvz.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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).