From: Martin Brandenburg <mar...@omnibond.com> Signed-off-by: Martin Brandenburg <mar...@omnibond.com> --- fs/orangefs/file.c | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++ fs/orangefs/inode.c | 132 ---------------------------------------------------- 2 files changed, 132 insertions(+), 132 deletions(-)
diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index 70909ee27323..f9c1dc5aaf78 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c @@ -718,3 +718,135 @@ const struct file_operations orangefs_file_operations = { .release = orangefs_file_release, .fsync = orangefs_fsync, }; + +static int read_one_page(struct page *page) +{ + int ret; + int max_block; + ssize_t bytes_read = 0; + struct inode *inode = page->mapping->host; + const __u32 blocksize = PAGE_SIZE; /* inode->i_blksize */ + const __u32 blockbits = PAGE_SHIFT; /* inode->i_blkbits */ + struct iov_iter to; + struct bio_vec bv = {.bv_page = page, .bv_len = PAGE_SIZE}; + + iov_iter_bvec(&to, ITER_BVEC | READ, &bv, 1, PAGE_SIZE); + + gossip_debug(GOSSIP_INODE_DEBUG, + "orangefs_readpage called with page %p\n", + page); + + max_block = ((inode->i_size / blocksize) + 1); + + 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 */ + iov_iter_zero(~0U, &to); + /* takes care of potential aliasing */ + flush_dcache_page(page); + if (bytes_read < 0) { + ret = bytes_read; + SetPageError(page); + } else { + SetPageUptodate(page); + if (PageError(page)) + ClearPageError(page); + ret = 0; + } + /* unlock the page after the ->readpage() routine completes */ + unlock_page(page); + return ret; +} + +static int orangefs_readpage(struct file *file, struct page *page) +{ + return read_one_page(page); +} + +static int orangefs_readpages(struct file *file, + struct address_space *mapping, + struct list_head *pages, + unsigned nr_pages) +{ + int page_idx; + int ret; + + gossip_debug(GOSSIP_INODE_DEBUG, "orangefs_readpages called\n"); + + for (page_idx = 0; page_idx < nr_pages; page_idx++) { + struct page *page; + + page = list_entry(pages->prev, struct page, lru); + list_del(&page->lru); + if (!add_to_page_cache(page, + mapping, + page->index, + readahead_gfp_mask(mapping))) { + ret = read_one_page(page); + gossip_debug(GOSSIP_INODE_DEBUG, + "failure adding page to cache, read_one_page returned: %d\n", + ret); + } else { + put_page(page); + } + } + BUG_ON(!list_empty(pages)); + return 0; +} + +static void orangefs_invalidatepage(struct page *page, + unsigned int offset, + unsigned int length) +{ + gossip_debug(GOSSIP_INODE_DEBUG, + "orangefs_invalidatepage called on page %p " + "(offset is %u)\n", + page, + offset); + + ClearPageUptodate(page); + ClearPageMappedToDisk(page); + return; + +} + +static int orangefs_releasepage(struct page *page, gfp_t foo) +{ + gossip_debug(GOSSIP_INODE_DEBUG, + "orangefs_releasepage called on page %p\n", + page); + 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, + struct iov_iter *iter) +{ + gossip_debug(GOSSIP_INODE_DEBUG, + "orangefs_direct_IO: %pD\n", + iocb->ki_filp); + + return -EINVAL; +} + +/** ORANGEFS2 implementation of address space operations */ +const struct address_space_operations orangefs_address_operations = { + .readpage = orangefs_readpage, + .readpages = orangefs_readpages, + .invalidatepage = orangefs_invalidatepage, + .releasepage = orangefs_releasepage, + .direct_IO = orangefs_direct_IO, +}; diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index ff0c799f09e2..5c451e245cf7 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -14,138 +14,6 @@ #include "orangefs-kernel.h" #include "orangefs-bufmap.h" -static int read_one_page(struct page *page) -{ - int ret; - int max_block; - ssize_t bytes_read = 0; - struct inode *inode = page->mapping->host; - const __u32 blocksize = PAGE_SIZE; /* inode->i_blksize */ - const __u32 blockbits = PAGE_SHIFT; /* inode->i_blkbits */ - struct iov_iter to; - struct bio_vec bv = {.bv_page = page, .bv_len = PAGE_SIZE}; - - iov_iter_bvec(&to, ITER_BVEC | READ, &bv, 1, PAGE_SIZE); - - gossip_debug(GOSSIP_INODE_DEBUG, - "orangefs_readpage called with page %p\n", - page); - - max_block = ((inode->i_size / blocksize) + 1); - - 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 */ - iov_iter_zero(~0U, &to); - /* takes care of potential aliasing */ - flush_dcache_page(page); - if (bytes_read < 0) { - ret = bytes_read; - SetPageError(page); - } else { - SetPageUptodate(page); - if (PageError(page)) - ClearPageError(page); - ret = 0; - } - /* unlock the page after the ->readpage() routine completes */ - unlock_page(page); - return ret; -} - -static int orangefs_readpage(struct file *file, struct page *page) -{ - return read_one_page(page); -} - -static int orangefs_readpages(struct file *file, - struct address_space *mapping, - struct list_head *pages, - unsigned nr_pages) -{ - int page_idx; - int ret; - - gossip_debug(GOSSIP_INODE_DEBUG, "orangefs_readpages called\n"); - - for (page_idx = 0; page_idx < nr_pages; page_idx++) { - struct page *page; - - page = list_entry(pages->prev, struct page, lru); - list_del(&page->lru); - if (!add_to_page_cache(page, - mapping, - page->index, - readahead_gfp_mask(mapping))) { - ret = read_one_page(page); - gossip_debug(GOSSIP_INODE_DEBUG, - "failure adding page to cache, read_one_page returned: %d\n", - ret); - } else { - put_page(page); - } - } - BUG_ON(!list_empty(pages)); - return 0; -} - -static void orangefs_invalidatepage(struct page *page, - unsigned int offset, - unsigned int length) -{ - gossip_debug(GOSSIP_INODE_DEBUG, - "orangefs_invalidatepage called on page %p " - "(offset is %u)\n", - page, - offset); - - ClearPageUptodate(page); - ClearPageMappedToDisk(page); - return; - -} - -static int orangefs_releasepage(struct page *page, gfp_t foo) -{ - gossip_debug(GOSSIP_INODE_DEBUG, - "orangefs_releasepage called on page %p\n", - page); - 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, - struct iov_iter *iter) -{ - gossip_debug(GOSSIP_INODE_DEBUG, - "orangefs_direct_IO: %pD\n", - iocb->ki_filp); - - return -EINVAL; -} - -/** ORANGEFS2 implementation of address space operations */ -const struct address_space_operations orangefs_address_operations = { - .readpage = orangefs_readpage, - .readpages = orangefs_readpages, - .invalidatepage = orangefs_invalidatepage, - .releasepage = orangefs_releasepage, - .direct_IO = orangefs_direct_IO, -}; - static int orangefs_setattr_size(struct inode *inode, struct iattr *iattr) { struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); -- 2.15.1