Message ID | 161340390150.1303470.509630287091953754.stgit@warthog.procyon.org.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Network fs helper library & fscache kiocb API [ver #3] | expand |
On Mon, Feb 15, 2021 at 03:45:01PM +0000, David Howells wrote: > Export rw_verify_area() for so that cachefiles can use it before issuing > call_read_iter() and call_write_iter() to effect async DIO operations > against the cache. This is analogous to aio_read() and aio_write(). I don't think this is the right thing to do. Instead of calling into ->read_iter / ->write_iter directly this should be using helpers. What prevents you from using vfs_iocb_iter_read and vfs_iocb_iter_write which seem the right level of abstraction for this?
Christoph Hellwig <hch@lst.de> wrote: > > Export rw_verify_area() for so that cachefiles can use it before issuing > > call_read_iter() and call_write_iter() to effect async DIO operations > > against the cache. This is analogous to aio_read() and aio_write(). > > I don't think this is the right thing to do. Instead of calling > into ->read_iter / ->write_iter directly this should be using helpers. > > What prevents you from using vfs_iocb_iter_read and > vfs_iocb_iter_write which seem the right level of abstraction for this? I don't think they existed when I wrote this code. Should aio use that too, btw? I modelled my code on aio_read() and aio_write(). But I can certainly switch to using vfs_iocb_iter_read/write, though the trivial checks are redundant. The fsnotify call, I guess I'm missing though (and is that missing in aio_read/write() also?). David
diff --git a/fs/internal.h b/fs/internal.h index 77c50befbfbe..92e686249c40 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -164,11 +164,6 @@ extern char *simple_dname(struct dentry *, char *, int); extern void dput_to_list(struct dentry *, struct list_head *); extern void shrink_dentry_list(struct list_head *); -/* - * read_write.c - */ -extern int rw_verify_area(int, struct file *, const loff_t *, size_t); - /* * pipe.c */ diff --git a/fs/read_write.c b/fs/read_write.c index 75f764b43418..fe84e11245bd 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -400,6 +400,7 @@ int rw_verify_area(int read_write, struct file *file, const loff_t *ppos, size_t return security_file_permission(file, read_write == READ ? MAY_READ : MAY_WRITE); } +EXPORT_SYMBOL(rw_verify_area); static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, loff_t *ppos) { diff --git a/include/linux/fs.h b/include/linux/fs.h index fd47deea7c17..493804856ab3 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2760,6 +2760,7 @@ extern int notify_change(struct dentry *, struct iattr *, struct inode **); extern int inode_permission(struct inode *, int); extern int generic_permission(struct inode *, int); extern int __check_sticky(struct inode *dir, struct inode *inode); +extern int rw_verify_area(int, struct file *, const loff_t *, size_t); static inline bool execute_ok(struct inode *inode) {
Export rw_verify_area() for so that cachefiles can use it before issuing call_read_iter() and call_write_iter() to effect async DIO operations against the cache. This is analogous to aio_read() and aio_write(). Signed-off-by: David Howells <dhowells@redhat.com> cc: Alexander Viro <viro@zeniv.linux.org.uk> cc: Christoph Hellwig <hch@lst.de> cc: Matthew Wilcox <willy@infradead.org> cc: linux-mm@kvack.org cc: linux-cachefs@redhat.com cc: linux-afs@lists.infradead.org cc: linux-nfs@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: ceph-devel@vger.kernel.org cc: v9fs-developer@lists.sourceforge.net cc: linux-fsdevel@vger.kernel.org --- fs/internal.h | 5 ----- fs/read_write.c | 1 + include/linux/fs.h | 1 + 3 files changed, 2 insertions(+), 5 deletions(-)