From patchwork Tue Jul 5 19:13:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Brandenburg X-Patchwork-Id: 9215125 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 00FC760752 for ; Tue, 5 Jul 2016 19:14:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E61FD28333 for ; Tue, 5 Jul 2016 19:14:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB29928336; Tue, 5 Jul 2016 19:14:01 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 B050428333 for ; Tue, 5 Jul 2016 19:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753228AbcGETN7 (ORCPT ); Tue, 5 Jul 2016 15:13:59 -0400 Received: from mail-yw0-f179.google.com ([209.85.161.179]:36773 "EHLO mail-yw0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753192AbcGETN5 (ORCPT ); Tue, 5 Jul 2016 15:13:57 -0400 Received: by mail-yw0-f179.google.com with SMTP id b72so70026593ywa.3 for ; Tue, 05 Jul 2016 12:13:56 -0700 (PDT) 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=v+IFSF+SLsUfvQcWfoBslvpYTRZ+hcYlWPMd5gpwzPQ=; b=ofzrnzbGGCvNMPe04Ti5Ihkrdcf9mxy7/Oatmdvnya5BbrGNQlYuTniMPcq4+xEqTf dfSRQPGBNlsXy2w7JG15gY/L2ZGQlvRN7716qBBrPIF5pOXJKzST34ErUVaNYMpnamnu jDqgoq6ZKf6ApvVTAfLXKFt2OhEnNET5k7Uo8yaGpr1ywS8Vcmnf3Q4gXQPx+Ye1nzZM WaHXqZDJ3iNhJ9yfxafP3+XAFlVpDFcOEM5f7HZ9GA1Esc0EzmBSgDqTgl/lhgMlPwIp C2VubkgFdm8Nnfzws/KEnKgMyagZnqeJJ+i8rgvBdIjfcoFEeOTfN3etKUMmswpFR5NZ ycag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=v+IFSF+SLsUfvQcWfoBslvpYTRZ+hcYlWPMd5gpwzPQ=; b=I6aJvxooV+9gPn3Fs0lDVzMEYDw2X5nQkVOuvZ4Q1aSe7AQzbJHOhAR5xW0dzyiEKc +2E3DCUncPE1HZZ5+hpxkW3DG8Oinz+GaBg34GNQ8CrdwnyZJJTxUjABRq96S7J/CXmW vS8zU09geVhIb/BN0VneSa8sj7/TuC9lPkpDAJPeSI91vXPCZZuhnRn/efuUSorHFp3v IagdixFT/9YzznRzxp+PkEKlIHaL2TZBtV+KqIIs9Cm60EwAzLEBFbrQi3N+woX30hy2 97FlCfQA7CGOswMLzqQtuYZQ8fypsA+aI7Bvju6vLFQYwcqUVgRGbg2bx8ky4GuiTFvR st4g== X-Gm-Message-State: ALyK8tI0U/ctmTl3FGQfWAvzGCi0QxCtekMXoy7KC6hDNYqI/pN5xTgQEkRbgGpKPu5ANw== X-Received: by 10.129.109.147 with SMTP id i141mr12928343ywc.220.1467746035974; Tue, 05 Jul 2016 12:13:55 -0700 (PDT) Received: from localhost.clemson.edu ([2620:103:a003:102:3fd8:8d9f:eb2c:e31f]) by smtp.gmail.com with ESMTPSA id p198sm10167106ywg.12.2016.07.05.12.13.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Jul 2016 12:13:55 -0700 (PDT) From: Martin Brandenburg X-Google-Original-From: Martin Brandenburg To: linux-fsdevel@vger.kernel.org Cc: Martin Brandenburg Subject: [PATCH 2/2] orangefs: Cache getattr results. Date: Tue, 5 Jul 2016 15:13:49 -0400 Message-Id: <1467746029-4199-3-git-send-email-mkb@localhost.localdomain> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1467746029-4199-1-git-send-email-mkb@localhost.localdomain> References: <1467746029-4199-1-git-send-email-mkb@localhost.localdomain> 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 The userspace component attempts to do this, but this will prevent us from even needing to go into userspace to satisfy certain getattr requests. Signed-off-by: Martin Brandenburg --- fs/orangefs/inode.c | 6 +++--- fs/orangefs/namei.c | 7 +++++++ fs/orangefs/orangefs-kernel.h | 4 +++- fs/orangefs/orangefs-utils.c | 38 +++++++++++++++++++++----------------- fs/orangefs/protocol.h | 8 -------- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index 85640e9..6bf7a19 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -265,7 +265,7 @@ int orangefs_getattr(struct vfsmount *mnt, "orangefs_getattr: called on %s\n", dentry->d_name.name); - ret = orangefs_inode_getattr(inode, 0, 1); + ret = orangefs_inode_getattr(inode, 0, 0); if (ret == 0) { generic_fillattr(inode, kstat); @@ -387,7 +387,7 @@ struct inode *orangefs_iget(struct super_block *sb, struct orangefs_object_kref if (!inode || !(inode->i_state & I_NEW)) return inode; - error = orangefs_inode_getattr(inode, 1, 0); + error = orangefs_inode_getattr(inode, 1, 1); if (error) { iget_failed(inode); return ERR_PTR(error); @@ -432,7 +432,7 @@ struct inode *orangefs_new_inode(struct super_block *sb, struct inode *dir, orangefs_set_inode(inode, ref); inode->i_ino = hash; /* needed for stat etc */ - error = orangefs_inode_getattr(inode, 1, 0); + error = orangefs_inode_getattr(inode, 1, 1); if (error) goto out_iput; diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c index 5e32e0e..ffe6377 100644 --- a/fs/orangefs/namei.c +++ b/fs/orangefs/namei.c @@ -73,6 +73,7 @@ static int orangefs_create(struct inode *dir, d_instantiate(dentry, inode); unlock_new_inode(inode); dentry->d_time = jiffies + HZ; + ORANGEFS_I(inode)->getattr_time = 0; gossip_debug(GOSSIP_NAME_DEBUG, "%s: dentry instantiated for %s\n", @@ -192,6 +193,8 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry, goto out; } + ORANGEFS_I(inode)->getattr_time = 0; + gossip_debug(GOSSIP_NAME_DEBUG, "%s:%s:%d " "Found good inode [%lu] with count [%d]\n", @@ -320,6 +323,7 @@ static int orangefs_symlink(struct inode *dir, d_instantiate(dentry, inode); unlock_new_inode(inode); dentry->d_time = jiffies + HZ; + ORANGEFS_I(inode)->getattr_time = 0; gossip_debug(GOSSIP_NAME_DEBUG, "Inode (Symlink) %pU -> %s\n", @@ -383,6 +387,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode d_instantiate(dentry, inode); unlock_new_inode(inode); dentry->d_time = jiffies + HZ; + ORANGEFS_I(inode)->getattr_time = 0; gossip_debug(GOSSIP_NAME_DEBUG, "Inode (Directory) %pU -> %s\n", @@ -417,6 +422,8 @@ static int orangefs_rename(struct inode *old_dir, new_dentry->d_name.name, d_count(new_dentry)); + ORANGEFS_I(new_dentry->d_parent->d_inode)->getattr_time = 0; + new_op = op_alloc(ORANGEFS_VFS_OP_RENAME); if (!new_op) return -EINVAL; diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h index a9925e2..f6f58b7 100644 --- a/fs/orangefs/orangefs-kernel.h +++ b/fs/orangefs/orangefs-kernel.h @@ -257,6 +257,8 @@ struct orangefs_inode_s { * with this object */ unsigned long pinode_flags; + + unsigned long getattr_time; }; #define P_ATIME_FLAG 0 @@ -540,7 +542,7 @@ int orangefs_inode_setxattr(struct inode *inode, size_t size, int flags); -int orangefs_inode_getattr(struct inode *inode, int new, int size); +int orangefs_inode_getattr(struct inode *inode, int new, int bypass); int orangefs_inode_check_changed(struct inode *inode); diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c index 2d129b5..1eccc0c 100644 --- a/fs/orangefs/orangefs-utils.c +++ b/fs/orangefs/orangefs-utils.c @@ -251,7 +251,7 @@ static int orangefs_inode_is_stale(struct inode *inode, int new, return 0; } -int orangefs_inode_getattr(struct inode *inode, int new, int size) +int orangefs_inode_getattr(struct inode *inode, int new, int bypass) { struct orangefs_inode_s *orangefs_inode = ORANGEFS_I(inode); struct orangefs_kernel_op_s *new_op; @@ -261,12 +261,16 @@ int orangefs_inode_getattr(struct inode *inode, int new, int size) gossip_debug(GOSSIP_UTILS_DEBUG, "%s: called on inode %pU\n", __func__, get_khandle_from_ino(inode)); + if (!new && !bypass) { + if (orangefs_inode->getattr_time > jiffies) + return 0; + } + new_op = op_alloc(ORANGEFS_VFS_OP_GETATTR); if (!new_op) return -ENOMEM; new_op->upcall.req.getattr.refn = orangefs_inode->refn; - new_op->upcall.req.getattr.mask = size ? - ORANGEFS_ATTR_SYS_ALL_NOHINT : ORANGEFS_ATTR_SYS_ALL_NOHINT_NOSIZE; + new_op->upcall.req.getattr.mask = ORANGEFS_ATTR_SYS_ALL_NOHINT; ret = service_operation(new_op, __func__, get_interruptible_flag(inode)); @@ -287,20 +291,18 @@ int orangefs_inode_getattr(struct inode *inode, int new, int size) case S_IFREG: inode->i_flags = orangefs_inode_flags(&new_op-> downcall.resp.getattr.attributes); - if (size) { - inode_size = (loff_t)new_op-> - downcall.resp.getattr.attributes.size; - rounded_up_size = - (inode_size + (4096 - (inode_size % 4096))); - inode->i_size = inode_size; - orangefs_inode->blksize = - new_op->downcall.resp.getattr.attributes.blksize; - spin_lock(&inode->i_lock); - inode->i_bytes = inode_size; - inode->i_blocks = - (unsigned long)(rounded_up_size / 512); - spin_unlock(&inode->i_lock); - } + inode_size = (loff_t)new_op-> + downcall.resp.getattr.attributes.size; + rounded_up_size = + (inode_size + (4096 - (inode_size % 4096))); + inode->i_size = inode_size; + orangefs_inode->blksize = + new_op->downcall.resp.getattr.attributes.blksize; + spin_lock(&inode->i_lock); + inode->i_bytes = inode_size; + inode->i_blocks = + (unsigned long)(rounded_up_size / 512); + spin_unlock(&inode->i_lock); break; case S_IFDIR: inode->i_size = PAGE_SIZE; @@ -345,6 +347,7 @@ int orangefs_inode_getattr(struct inode *inode, int new, int size) inode->i_mode = type | (is_root_handle(inode) ? S_ISVTX : 0) | orangefs_inode_perms(&new_op->downcall.resp.getattr.attributes); + orangefs_inode->getattr_time = jiffies + HZ; ret = 0; out: op_release(new_op); @@ -418,6 +421,7 @@ int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr) ClearMtimeFlag(orangefs_inode); ClearCtimeFlag(orangefs_inode); ClearModeFlag(orangefs_inode); + orangefs_inode->getattr_time = 0; } return ret; diff --git a/fs/orangefs/protocol.h b/fs/orangefs/protocol.h index 1efc6f8..3d7418c 100644 --- a/fs/orangefs/protocol.h +++ b/fs/orangefs/protocol.h @@ -207,14 +207,6 @@ typedef __s64 ORANGEFS_offset; ORANGEFS_ATTR_SYS_DIRENT_COUNT | \ ORANGEFS_ATTR_SYS_BLKSIZE) -#define ORANGEFS_ATTR_SYS_ALL_NOHINT_NOSIZE \ - (ORANGEFS_ATTR_SYS_COMMON_ALL | \ - ORANGEFS_ATTR_SYS_LNK_TARGET | \ - ORANGEFS_ATTR_SYS_DFILE_COUNT | \ - ORANGEFS_ATTR_SYS_MIRROR_COPIES_COUNT | \ - ORANGEFS_ATTR_SYS_DIRENT_COUNT | \ - ORANGEFS_ATTR_SYS_BLKSIZE) - #define ORANGEFS_XATTR_REPLACE 0x2 #define ORANGEFS_XATTR_CREATE 0x1 #define ORANGEFS_MAX_SERVER_ADDR_LEN 256