Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2395685ioo; Sat, 28 May 2022 12:17:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxoI59ZH+YCNpg9L4Kh9+PHq+9CTqxJVFiRI5/Dq4I4NkOkdnHjheK9YC0bc/xA0CGkXIxz X-Received: by 2002:a65:63d9:0:b0:374:6b38:c6b3 with SMTP id n25-20020a6563d9000000b003746b38c6b3mr42599513pgv.195.1653765443423; Sat, 28 May 2022 12:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653765443; cv=none; d=google.com; s=arc-20160816; b=P/SVe5EPl5Z7T3NS5j3QfovrbyvC5oGu9IxSjj4Dpudmf9yHXuqJSkAsZN/Kzm+Q5x mEbX4IeX+hbKc6quKd3hgMiGvzuXv7nG5IJqyJglGZJDqDU8vNgtzByv2m2pzmNePuNN VziPn2C7sRSUWxfLJZl5Y1xJ/qVDjfm8A8AHhVJgnGIB7v9yV1aQPCukSfiPqKk6yCBZ ndg11/WqQSTtgPXTUjd2UrXCKWGvov/ZEXmYba/gQmzuf9ElOdcKER0RWYvZKCeMVrTF e3nWGuE9CHm4ci9H4PveUgJbjhc/bZTkiDZL+JIPktKkzzzKCri9d0Qr7LF3taNDUhUQ jcbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=8pdt9j0YTn4gITTYumjXbqE/LEAOIMIl+jNZOjh5y9Q=; b=p0uFxX4kCJsM59JqezeYolUZ1f+ePMSQsqovQqnv7a1B7b9Idz6ySoXDSYxvVaOaTe pqGUMNRosz1LSHtlfgu7De1wD3stKHEvxYQ0zpf0or8fZUFojJRSz7K+wd3xmUhHD+nL h2gweJoDIWVi6/D6n9ZVYnDg8UgTDswh95PW0giOujyx9ZCQylaRSWfgGpJqpgRkwl3R dB9lQ/i4gJIfrAey9PieKa4Ibsgo9uNtT/GalAsEDjqwpUHL3H5vArhAmYt4Iw3YPvQi J8rrgKlW46SFOGtsmJQZj3p3raqhwYRBdGefMEVDzV68E6UpZ2ziYA/SLEaRiWXjvcJh q55w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=bqM8ydfp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bk11-20020a056a02028b00b003fbb0cb276fsi7359404pgb.369.2022.05.28.12.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 12:17:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=bqM8ydfp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 30E1224BFE; Sat, 28 May 2022 11:51:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348358AbiE0AAg (ORCPT + 99 others); Thu, 26 May 2022 20:00:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231754AbiE0AAa (ORCPT ); Thu, 26 May 2022 20:00:30 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 046AAFD0F for ; Thu, 26 May 2022 17:00:30 -0700 (PDT) Received: from sequoia.corp.microsoft.com (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id 41E3B20B87F6; Thu, 26 May 2022 17:00:29 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 41E3B20B87F6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1653609629; bh=8pdt9j0YTn4gITTYumjXbqE/LEAOIMIl+jNZOjh5y9Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bqM8ydfpKp1R2Kwm8m7OBlevH7IJIMHPMoCSE1CaHbLVz/LOzrTju7Ar16s7Emix5 RmZSiXqKjPUnhD8RzfRF61Lt1SR6UQGJ7+C1F9+hczFIgvYrUEckMTPDL0y2chY7Fg AW331OC6buNm2EunSqeYeI0BDWQle8Sp9C9XhHSY= From: Tyler Hicks To: Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet Cc: Christian Schoenebeck , Jianyong Wu , v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/5] 9p: Track the root fid with its own variable during lookups Date: Thu, 26 May 2022 19:00:00 -0500 Message-Id: <20220527000003.355812-3-tyhicks@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220527000003.355812-1-tyhicks@linux.microsoft.com> References: <20220527000003.355812-1-tyhicks@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Improve readability by using a new variable when dealing with the root fid. The root fid requires special handling in comparison to other fids used during fid lookup. Signed-off-by: Tyler Hicks --- fs/9p/fid.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/fs/9p/fid.c b/fs/9p/fid.c index 5a469b79c1ee..dae276ca7f7a 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c @@ -152,7 +152,7 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, const unsigned char **wnames, *uname; int i, n, l, clone, access; struct v9fs_session_info *v9ses; - struct p9_fid *fid, *old_fid; + struct p9_fid *fid, *root_fid, *old_fid; v9ses = v9fs_dentry2v9ses(dentry); access = v9ses->flags & V9FS_ACCESS_MASK; @@ -178,8 +178,8 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, up_read(&v9ses->rename_sem); /* start from the root and try to do a lookup */ - fid = v9fs_fid_find(dentry->d_sb->s_root, uid, any); - if (!fid) { + root_fid = v9fs_fid_find(dentry->d_sb->s_root, uid, any); + if (!root_fid) { /* the user is not attached to the fs yet */ if (access == V9FS_ACCESS_SINGLE) return ERR_PTR(-EPERM); @@ -189,17 +189,18 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, else uname = v9ses->uname; - fid = p9_client_attach(v9ses->clnt, NULL, uname, uid, - v9ses->aname); - if (IS_ERR(fid)) - return fid; + root_fid = p9_client_attach(v9ses->clnt, NULL, uname, uid, + v9ses->aname); + if (IS_ERR(root_fid)) + return root_fid; - refcount_inc(&fid->count); - v9fs_fid_add(dentry->d_sb->s_root, fid); + refcount_inc(&root_fid->count); + v9fs_fid_add(dentry->d_sb->s_root, root_fid); } /* If we are root ourself just return that */ if (dentry->d_sb->s_root == dentry) - return fid; + return root_fid; + /* * Do a multipath walk with attached root. * When walking parent we need to make sure we @@ -211,7 +212,8 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, fid = ERR_PTR(n); goto err_out; } - old_fid = fid; + fid = root_fid; + old_fid = root_fid; clone = 1; i = 0; while (i < n) { @@ -220,7 +222,7 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry, * We need to hold rename lock when doing a multipath * walk to ensure none of the patch component change */ - fid = p9_client_walk(fid, l, &wnames[i], clone); + fid = p9_client_walk(old_fid, l, &wnames[i], clone); p9_client_clunk(old_fid); if (IS_ERR(fid)) { kfree(wnames); -- 2.25.1