From patchwork Tue Dec 12 18:34:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Brandenburg X-Patchwork-Id: 10108111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8208E602B3 for ; Tue, 12 Dec 2017 18:38:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7778226E4A for ; Tue, 12 Dec 2017 18:38:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C519292CC; Tue, 12 Dec 2017 18:38:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A2B4426E4A for ; Tue, 12 Dec 2017 18:38:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752710AbdLLSik (ORCPT ); Tue, 12 Dec 2017 13:38:40 -0500 Received: from mail-yb0-f196.google.com ([209.85.213.196]:33935 "EHLO mail-yb0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752380AbdLLSeq (ORCPT ); Tue, 12 Dec 2017 13:34:46 -0500 Received: by mail-yb0-f196.google.com with SMTP id z11so4308978ybm.1 for ; Tue, 12 Dec 2017 10:34:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omnibond-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/S2cKZ9i/ZLRjFXrSciP1cfoV9RbKCyz8gZSWT8vIoM=; b=dX/v46VLvd9isbYTmUgFIpU76xgO5AhRaoTn+fbDIQMLlq5Vv8BunmzPVsWvEi9vfc p5AllvVfnpJLr110k9Voyhmc5khqfMXV8J3qt2NwD/CMCd5mTFglV2S/ewkm/jviM4wo G/flswACkhns0Oh+/svXeVRcW0FcjmEicx1BUS1C2YNBVMqFzHdrdrgOyOqR+r+EzeSz 4RziFjFDqVKYx7XfnwnkUu8xRcEIhkvY0x23MOJrRZzQksC4mWPVZ/VL1s0OyNIDSIOE ZR9zONxShP/WQ+Otrvu7w87Pwcf869g+ShmHANGpyvDvUhpvewSRoLHVzGys2ZvI5/p8 lieg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/S2cKZ9i/ZLRjFXrSciP1cfoV9RbKCyz8gZSWT8vIoM=; b=bhMZq+eDONeIES7NDR0qMT/rV9pH30qS46fqJBFrSE7cujHigCPo+hBTNcMO1I5DHN 4pVgp1tJU3XX3rXzYyH98n+DodR/rII8YsVxz3aukrXi4YnLs6i6UJ88i1Qrdmo1o797 Hv1TuR338TM5tFt8RGihs2/tQXawcCld7MXW7Z56Jp8oRcCqykiiXZ3niTLTvTv8Es0O Z3JkwraMW2a6cuopGPwLcCijLbiltbdUGRUvh9kQ/V7s28ojRpGcI+kruj1Vf+dIDYh8 Dxr2+df3Q3vbyN2IYdGQcwoAn8jKdgIZKnM1GNbti0dmPVsz59a77ejzWtb9vPKRUXpG 07yw== X-Gm-Message-State: AKGB3mLN4siSJa5Oy6mpKtYvWo8qur0s/D6C1JvRpSK8ri3w/8Ek2jfS wvPfAHVzai0KYrvdEpbsUXpy1g== X-Google-Smtp-Source: ACJfBotLS6PqX0RkqE8LkBBYS5Zxt4Xd/d9MkYmpHPx3hPXrH7zykGk5f5ZpmotAs55EwwIhbNxjBQ== X-Received: by 10.129.46.203 with SMTP id u194mr3479203ywu.143.1513103686159; Tue, 12 Dec 2017 10:34:46 -0800 (PST) Received: from omnifs1.omnibond.com ([24.31.12.185]) by smtp.gmail.com with ESMTPSA id i207sm7666353ywe.38.2017.12.12.10.34.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Dec 2017 10:34:45 -0800 (PST) From: Martin Brandenburg X-Google-Original-From: Martin Brandenburg To: hubcap@omnibond.com, devel@lists.orangefs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Martin Brandenburg Subject: [PATCH 06/18] orangefs: move orangefs_address_operations to file.c Date: Tue, 12 Dec 2017 13:34:12 -0500 Message-Id: <20171212183424.26406-7-martin@martinbrandenburg.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20171212183424.26406-1-martin@martinbrandenburg.com> References: <20171212183424.26406-1-martin@martinbrandenburg.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Martin Brandenburg Signed-off-by: Martin Brandenburg --- 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);