Commit c453dcfc authored by Martin Brandenburg's avatar Martin Brandenburg Committed by Mike Marshall

orangefs: migrate to generic_file_read_iter

Remove orangefs_inode_read.  It was used by readpage.  Calling
wait_for_direct_io directly serves the purpose just as well.  There is
now no check of the bufmap size in the readpage path.  There are already
other places the bufmap size is assumed to be greater than PAGE_SIZE.

Important to call truncate_inode_pages now in the write path so a
subsequent read sees the new data.
Signed-off-by: default avatarMartin Brandenburg <martin@omnibond.com>
Signed-off-by: default avatarMike Marshall <hubcap@omnibond.com>
parent 0dcac0f7
...@@ -44,7 +44,7 @@ static int flush_racache(struct inode *inode) ...@@ -44,7 +44,7 @@ static int flush_racache(struct inode *inode)
/* /*
* Post and wait for the I/O upcall to finish * Post and wait for the I/O upcall to finish
*/ */
static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode, ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inode,
loff_t *offset, struct iov_iter *iter, loff_t *offset, struct iov_iter *iter,
size_t total_size, loff_t readahead_size) size_t total_size, loff_t readahead_size)
{ {
...@@ -240,7 +240,7 @@ static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inod ...@@ -240,7 +240,7 @@ static ssize_t wait_for_direct_io(enum ORANGEFS_io_type type, struct inode *inod
* augmented/extended metadata attached to the file. * augmented/extended metadata attached to the file.
* Note: File extended attributes override any mount options. * Note: File extended attributes override any mount options.
*/ */
static ssize_t do_readv_writev(enum ORANGEFS_io_type type, struct file *file, ssize_t do_readv_writev(enum ORANGEFS_io_type type, struct file *file,
loff_t *offset, struct iov_iter *iter) loff_t *offset, struct iov_iter *iter)
{ {
struct inode *inode = file->f_mapping->host; struct inode *inode = file->f_mapping->host;
...@@ -341,65 +341,11 @@ static ssize_t do_readv_writev(enum ORANGEFS_io_type type, struct file *file, ...@@ -341,65 +341,11 @@ static ssize_t do_readv_writev(enum ORANGEFS_io_type type, struct file *file,
return ret; return ret;
} }
/* static ssize_t orangefs_file_read_iter(struct kiocb *iocb,
* Read data from a specified offset in a file (referenced by inode). struct iov_iter *iter)
* Data may be placed either in a user or kernel buffer.
*/
ssize_t orangefs_inode_read(struct inode *inode,
struct iov_iter *iter,
loff_t *offset,
loff_t readahead_size)
{ {
struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode);
size_t count = iov_iter_count(iter);
size_t bufmap_size;
ssize_t ret = -EINVAL;
orangefs_stats.reads++; orangefs_stats.reads++;
return generic_file_read_iter(iocb, iter);
bufmap_size = orangefs_bufmap_size_query();
if (count > bufmap_size) {
gossip_debug(GOSSIP_FILE_DEBUG,
"%s: count is too large (%zd/%zd)!\n",
__func__, count, bufmap_size);
return -EINVAL;
}
gossip_debug(GOSSIP_FILE_DEBUG,
"%s(%pU) %zd@%llu\n",
__func__,
&orangefs_inode->refn.khandle,
count,
llu(*offset));
ret = wait_for_direct_io(ORANGEFS_IO_READ, inode, offset, iter,
count, readahead_size);
if (ret > 0)
*offset += ret;
gossip_debug(GOSSIP_FILE_DEBUG,
"%s(%pU): Value(%zd) returned.\n",
__func__,
&orangefs_inode->refn.khandle,
ret);
return ret;
}
static ssize_t orangefs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter)
{
struct file *file = iocb->ki_filp;
loff_t pos = iocb->ki_pos;
ssize_t rc = 0;
gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_read_iter\n");
orangefs_stats.reads++;
rc = do_readv_writev(ORANGEFS_IO_READ, file, &pos, iter);
iocb->ki_pos = pos;
return rc;
} }
static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *iter) static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *iter)
...@@ -408,6 +354,8 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite ...@@ -408,6 +354,8 @@ static ssize_t orangefs_file_write_iter(struct kiocb *iocb, struct iov_iter *ite
loff_t pos; loff_t pos;
ssize_t rc; ssize_t rc;
truncate_inode_pages(file->f_mapping, 0);
gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_write_iter\n"); gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_write_iter\n");
inode_lock(file->f_mapping->host); inode_lock(file->f_mapping->host);
......
...@@ -17,37 +17,25 @@ ...@@ -17,37 +17,25 @@
static int orangefs_readpage(struct file *file, struct page *page) static int orangefs_readpage(struct file *file, struct page *page)
{ {
int ret;
int max_block;
ssize_t bytes_read = 0;
struct inode *inode = page->mapping->host; struct inode *inode = page->mapping->host;
const __u32 blocksize = PAGE_SIZE; struct iov_iter iter;
const __u32 blockbits = PAGE_SHIFT; struct bio_vec bv;
struct iov_iter to; ssize_t ret;
struct bio_vec bv = {.bv_page = page, .bv_len = PAGE_SIZE}; loff_t off;
iov_iter_bvec(&to, READ, &bv, 1, PAGE_SIZE); off = page_offset(page);
bv.bv_page = page;
gossip_debug(GOSSIP_INODE_DEBUG, bv.bv_len = PAGE_SIZE;
"orangefs_readpage called with page %p\n", bv.bv_offset = 0;
page); iov_iter_bvec(&iter, READ, &bv, 1, PAGE_SIZE);
max_block = ((inode->i_size / blocksize) + 1); ret = wait_for_direct_io(ORANGEFS_IO_READ, inode, &off, &iter,
PAGE_SIZE, inode->i_size);
if (page->index < max_block) {
loff_t blockptr_offset = (((loff_t) page->index) << blockbits);
bytes_read = orangefs_inode_read(inode,
&to,
&blockptr_offset,
inode->i_size);
}
/* this will only zero remaining unread portions of the page data */ /* this will only zero remaining unread portions of the page data */
iov_iter_zero(~0U, &to); iov_iter_zero(~0U, &iter);
/* takes care of potential aliasing */ /* takes care of potential aliasing */
flush_dcache_page(page); flush_dcache_page(page);
if (bytes_read < 0) { if (ret < 0) {
ret = bytes_read;
SetPageError(page); SetPageError(page);
} else { } else {
SetPageUptodate(page); SetPageUptodate(page);
...@@ -84,22 +72,17 @@ static int orangefs_releasepage(struct page *page, gfp_t foo) ...@@ -84,22 +72,17 @@ static int orangefs_releasepage(struct page *page, gfp_t foo)
return 0; return 0;
} }
/*
* Having a direct_IO entry point in the address_space_operations
* struct causes the kernel to allows us to use O_DIRECT on
* open. Nothing will ever call this thing, but in the future we
* will need to be able to use O_DIRECT on open in order to support
* AIO. Modeled after NFS, they do this too.
*/
static ssize_t orangefs_direct_IO(struct kiocb *iocb, static ssize_t orangefs_direct_IO(struct kiocb *iocb,
struct iov_iter *iter) struct iov_iter *iter)
{ {
gossip_debug(GOSSIP_INODE_DEBUG, struct file *file = iocb->ki_filp;
"orangefs_direct_IO: %pD\n", loff_t pos = *(&iocb->ki_pos);
iocb->ki_filp); /*
* This cannot happen until write_iter becomes
return -EINVAL; * generic_file_write_iter.
*/
BUG_ON(iov_iter_rw(iter) != READ);
return do_readv_writev(ORANGEFS_IO_READ, file, &pos, iter);
} }
/** ORANGEFS2 implementation of address space operations */ /** ORANGEFS2 implementation of address space operations */
......
...@@ -369,11 +369,6 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size); ...@@ -369,11 +369,6 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size);
struct inode *orangefs_iget(struct super_block *sb, struct inode *orangefs_iget(struct super_block *sb,
struct orangefs_object_kref *ref); struct orangefs_object_kref *ref);
ssize_t orangefs_inode_read(struct inode *inode,
struct iov_iter *iter,
loff_t *offset,
loff_t readahead_size);
/* /*
* defined in devorangefs-req.c * defined in devorangefs-req.c
*/ */
...@@ -384,6 +379,14 @@ void orangefs_dev_cleanup(void); ...@@ -384,6 +379,14 @@ void orangefs_dev_cleanup(void);
int is_daemon_in_service(void); int is_daemon_in_service(void);
bool __is_daemon_in_service(void); bool __is_daemon_in_service(void);
/*
* defined in file.c
*/
ssize_t wait_for_direct_io(enum ORANGEFS_io_type, struct inode *, loff_t *,
struct iov_iter *, size_t, loff_t);
ssize_t do_readv_writev(enum ORANGEFS_io_type, struct file *, loff_t *,
struct iov_iter *);
/* /*
* defined in orangefs-utils.c * defined in orangefs-utils.c
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment