From patchwork Thu Apr 18 18:41:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hubcap@kernel.org X-Patchwork-Id: 10907879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABFC01515 for ; Thu, 18 Apr 2019 18:43:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 956EF285DB for ; Thu, 18 Apr 2019 18:43:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89CDA28D5D; Thu, 18 Apr 2019 18:43:05 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,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 1FDBE285DB for ; Thu, 18 Apr 2019 18:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390043AbfDRSnE (ORCPT ); Thu, 18 Apr 2019 14:43:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:60884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389995AbfDRSnC (ORCPT ); Thu, 18 Apr 2019 14:43:02 -0400 Received: from localhost.localdomain (unknown [24.213.116.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D187B217D7; Thu, 18 Apr 2019 18:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555612981; bh=m/uiJ+coO1KJva0PmKdo/QviThmPMuQkJJRAhFDcio4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q388sgSKprk9pbosXNAoxFX4NQIvh6+m6XXOUOHNEBUjTqwzutPIoXB9BzfutD9UO mum6ZOqmKkdij5oOtDg7Uin9WgRByvIt4SimZtMEJsCE/UPZcx1OmK06dohGC7ddGt vd7hfGnpk7OjlFBXqxzhFY/18yCuZT81Ue2WDhUY= From: hubcap@kernel.org To: linux-fsdevel@vger.kernel.org, christoph@lameter.com Cc: Mike Marshall , Martin Brandenburg Subject: [PATCH 20/22] orangefs: remember count when reading. Date: Thu, 18 Apr 2019 14:41:12 -0400 Message-Id: <20190418184113.9152-21-hubcap@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190418184113.9152-1-hubcap@kernel.org> References: <20190418184113.9152-1-hubcap@kernel.org> MIME-Version: 1.0 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: Mike Marshall Orangefs wins when it can do IO on large (up to four meg) blocks at a time, and looses when it has to do tiny "small io" reads and writes. Accessing Orangefs through the pagecache with the kernel module helps with small io, both reading and writing, a great deal. Readpage generally tries to fetch a page (four k) at a time. We'll let users use "count" (as in read(2) or pread(2) for example) as a knob to control how much data they get from Orangefs at a time and we'll try to use the data to fill extra pagecache pages when we get to ->readpage, hopefully resulting in fewer calls to readpage and Orangefs userspace. We need a way to remember how they set count so that we can still have it available when we get to ->readpage. - We'll use file->private_data to keep track of "count". We'll wrap generic_file_open with orangefs_file_open and initialize private_data to NULL there. - In ->read_iter we have access to both "count" and file, so we'll kmalloc some space onto file->private_data and store "count" there. - We'll kfree file->private_data each time we visit ->flush and reinitialize it to NULL. Signed-off-by: Mike Marshall Signed-off-by: Martin Brandenburg --- fs/orangefs/file.c | 26 +++++++++++++++++++++++++- fs/orangefs/orangefs-kernel.h | 4 ++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/fs/orangefs/file.c b/fs/orangefs/file.c index faa5b61cdfd6..74292d31d113 100644 --- a/fs/orangefs/file.c +++ b/fs/orangefs/file.c @@ -286,8 +286,23 @@ static ssize_t orangefs_file_read_iter(struct kiocb *iocb, struct iov_iter *iter) { int ret; + struct orangefs_read_options *ro; + orangefs_stats.reads++; + /* + * Remember how they set "count" in read(2) or pread(2) or whatever - + * users can use count as a knob to control orangefs io size and later + * we can try to help them fill as many pages as possible in readpage. + */ + if (!iocb->ki_filp->private_data) { + iocb->ki_filp->private_data = kmalloc(sizeof *ro, GFP_KERNEL); + if (!iocb->ki_filp->private_data) + return(ENOMEM); + ro = iocb->ki_filp->private_data; + ro->blksiz = iter->count; + } + down_read(&file_inode(iocb->ki_filp)->i_rwsem); ret = orangefs_revalidate_mapping(file_inode(iocb->ki_filp)); if (ret) @@ -556,6 +571,12 @@ static int orangefs_lock(struct file *filp, int cmd, struct file_lock *fl) return rc; } +static int orangefs_file_open(struct inode * inode, struct file *file) +{ + file->private_data = NULL; + return generic_file_open(inode, file); +} + static int orangefs_flush(struct file *file, fl_owner_t id) { /* @@ -569,6 +590,9 @@ static int orangefs_flush(struct file *file, fl_owner_t id) struct inode *inode = file->f_mapping->host; int r; + kfree(file->private_data); + file->private_data = NULL; + if (inode->i_state & I_DIRTY_TIME) { spin_lock(&inode->i_lock); inode->i_state &= ~I_DIRTY_TIME; @@ -591,7 +615,7 @@ const struct file_operations orangefs_file_operations = { .lock = orangefs_lock, .unlocked_ioctl = orangefs_ioctl, .mmap = orangefs_file_mmap, - .open = generic_file_open, + .open = orangefs_file_open, .flush = orangefs_flush, .release = orangefs_file_release, .fsync = orangefs_fsync, diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h index 87beab10326a..3ae2f129b9c7 100644 --- a/fs/orangefs/orangefs-kernel.h +++ b/fs/orangefs/orangefs-kernel.h @@ -239,6 +239,10 @@ struct orangefs_write_range { kgid_t gid; }; +struct orangefs_read_options { + ssize_t blksiz; +}; + extern struct orangefs_stats orangefs_stats; /*