Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1397310ybh; Sun, 19 Jul 2020 18:50:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxH6WLiX42OLKdMsClAOF94j3YSZgEmu73fJknk5xL4lc3B9ggnCCqLe08l94PqAparDCw9 X-Received: by 2002:a17:906:1111:: with SMTP id h17mr18236685eja.203.1595209837338; Sun, 19 Jul 2020 18:50:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595209837; cv=none; d=google.com; s=arc-20160816; b=YfQCE71lzSJEt7vxP3xLTreHgP/xzdGV3ZPtxcvCYb16ooKYywxmaiRCKSNuYbcu8n 7efIhVMjxryN6s+gP3/lBYGJqtkGMztkMxKe+71KAAxvjxt6lwn0u1q8tPIMGwzbSEfu 3kwrAOweRg+JWmalWbH29SI7uK0FLayekDYSR/9Hz7MRmF8Njxynu7tyXuRZveF+1bp0 6HS7qpqwhygOn/2YvftwIFPQaX5jD0EErfnHMEeU69/lFLjiW98sb97gV28LG9dyYWbP 3+s2dfGbPkZ6+3pwpYb/Pz8CRiyrNTDT7SC0V4edKnnIup3umSs6o6cFkbe2SBPmPKiF fcRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=z+pjDMkVsr1GSxEmSht1t62uZ1Ls+LDRfVe39NOHfdI=; b=USann7APvBiXq6sM1IWhLGaGe24B5R62EwPnfkbDdkOMCsRshnr+n2tbB/l51Qfohr nX1InUewtowEfI7801ODQOOjD0+0fEBsta6ydy8iuWvVzfBVpxYk7aWU0y2YEa/zuQLy Yd/Di62/yWA3QkD1X14rXGqs6DxWic1Q7l7LScquBk141Jc62PxXdKONFaAp5Vzk3frU yNKmKc3YgYT2WKeXhnE2epu81aHqO6wdDIZDhUuA6fbVOKn/1pXFM1u5neuO80qNnO2L oxFjFXHd54A117mvTZs1VnT2qNTzoeLi6+n8rYXMqCGHdbZYbuOJ85l5qJ4DEF3YZL2d zIzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y8si10844218edw.59.2020.07.19.18.50.14; Sun, 19 Jul 2020 18:50:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727025AbgGTBqm (ORCPT + 99 others); Sun, 19 Jul 2020 21:46:42 -0400 Received: from foss.arm.com ([217.140.110.172]:40834 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726312AbgGTBqm (ORCPT ); Sun, 19 Jul 2020 21:46:42 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BADAE143B; Sun, 19 Jul 2020 18:46:41 -0700 (PDT) Received: from entos-d05.shanghai.arm.com (entos-d05.shanghai.arm.com [10.169.212.212]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 6307A3F66E; Sun, 19 Jul 2020 18:46:38 -0700 (PDT) From: Jianyong Wu To: ericvh@gmail.com, hch@lst.de, dhowells@redhat.com, lucho@ionkov.net, asmadeus@codewreck.org Cc: v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Kaly.Xin@arm.com, justin.he@arm.com, jianyong.wu@arm.com, wei.chen@arm.com Subject: [RFC PATCH 2/2] 9p: retrieve fid from file if it exists when getattr. Date: Mon, 20 Jul 2020 09:46:22 +0800 Message-Id: <20200720014622.37364-3-jianyong.wu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200720014622.37364-1-jianyong.wu@arm.com> References: <20200720014622.37364-1-jianyong.wu@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org fid should be retrieved from file when it is not NULL in getattr. it denotes that getattr is called by fdstat from userspace when file is exist, which means we should get info from file context not dentry to avoid the failure when the dentry has gone. Signed-off-by: Jianyong Wu --- fs/9p/vfs_inode.c | 9 +++++++-- fs/9p/vfs_inode_dotl.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index c9255d399917..f562f5710eae 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1054,7 +1054,7 @@ v9fs_vfs_getattr(const struct path *path, struct kstat *stat, { struct dentry *dentry = path->dentry; struct v9fs_session_info *v9ses; - struct p9_fid *fid; + struct p9_fid *fid = NULL; struct p9_wstat *st; p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); @@ -1063,7 +1063,12 @@ v9fs_vfs_getattr(const struct path *path, struct kstat *stat, generic_fillattr(d_inode(dentry), stat); return 0; } - fid = v9fs_fid_lookup(dentry); + if (stat->filp) { + fid = stat->filp->private_data; + WARN_ON(!fid); + } + if (!fid) + fid = v9fs_fid_lookup(dentry); if (IS_ERR(fid)) return PTR_ERR(fid); diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 60328b21c5fb..6b7cbe74b0bb 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -460,7 +460,7 @@ v9fs_vfs_getattr_dotl(const struct path *path, struct kstat *stat, { struct dentry *dentry = path->dentry; struct v9fs_session_info *v9ses; - struct p9_fid *fid; + struct p9_fid *fid = NULL; struct p9_stat_dotl *st; p9_debug(P9_DEBUG_VFS, "dentry: %p\n", dentry); @@ -469,7 +469,12 @@ v9fs_vfs_getattr_dotl(const struct path *path, struct kstat *stat, generic_fillattr(d_inode(dentry), stat); return 0; } - fid = v9fs_fid_lookup(dentry); + if (stat->filp) { + fid = stat->filp->private_data; + WARN_ON(!fid); + } + if (!fid) + fid = v9fs_fid_lookup(dentry); if (IS_ERR(fid)) return PTR_ERR(fid); -- 2.17.1