diff options
author | Martin Brandenburg <martin@omnibond.com> | 2018-02-16 23:51:24 +0300 |
---|---|---|
committer | Mike Marshall <hubcap@omnibond.com> | 2019-05-03 21:32:38 +0300 |
commit | c453dcfc79815760071bd9a7805d4b809fec05cf (patch) | |
tree | 69caa47318f5e229f894c4c0bd62665552b754ee /fs/orangefs/file.c | |
parent | 0dcac0f7812b2c09ed018a5eba91448a37f1b71b (diff) | |
download | linux-c453dcfc79815760071bd9a7805d4b809fec05cf.tar.xz |
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: Martin Brandenburg <martin@omnibond.com>
Signed-off-by: Mike Marshall <hubcap@omnibond.com>
Diffstat (limited to 'fs/orangefs/file.c')
-rw-r--r-- | fs/orangefs/file.c | 66 |
1 files changed, 7 insertions, 59 deletions
diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index a9e69c56d2fb..934f102ce9e1 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c @@ -44,7 +44,7 @@ static int flush_racache(struct inode *inode) /* * 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, size_t total_size, loff_t readahead_size) { @@ -240,7 +240,7 @@ out: * augmented/extended metadata attached to the file. * 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) { struct inode *inode = file->f_mapping->host; @@ -341,65 +341,11 @@ out: return ret; } -/* - * Read data from a specified offset in a file (referenced by inode). - * 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) +static ssize_t orangefs_file_read_iter(struct kiocb *iocb, + struct iov_iter *iter) { - 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++; - - 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; + return generic_file_read_iter(iocb, 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 loff_t pos; ssize_t rc; + truncate_inode_pages(file->f_mapping, 0); + gossip_debug(GOSSIP_FILE_DEBUG, "orangefs_file_write_iter\n"); inode_lock(file->f_mapping->host); |