From patchwork Sat Jan 6 02:11:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 13512631 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30BD31396 for ; Sat, 6 Jan 2024 02:11:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vQNvKcCN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EF4AC433C9; Sat, 6 Jan 2024 02:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704507072; bh=47TnaR0YpjvB8dI8+cTvzu4LpRGU8CyazbqtphNLNcg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vQNvKcCNTITGQaNsdLcki4SnX0FdRQF0QhP3bdqEHi5vMteqcpWZaZvlPrjsVrD6M 2nBI8HP3Ak2czbqaFGTWxoHGMeJXEWCN3c95uV9QH7NRwNlCfgUdlhG7XBEfUJiIkR pzzJdRGTxLXM3YvS+avZP1To5AxHfpOhvLwXEkuuEN97Ia0kGrvPq+BI0fbpopgndJ ObOL97Xf8nEqa+RLDz5rosPyOkbWzz7H08j+Fgtufttf1/uruSoBPKpR3awrkM23y1 Cg5eT3pQvAA6zzWVKHKcI5wPjCbxpENsB+Z2p+WLa4Q+FicmVGVOulPan0BNe9a/rJ c99J5dsZxE+SA== From: Eric Van Hensbergen Date: Sat, 06 Jan 2024 02:11:08 +0000 Subject: [PATCH 1/9] fs/9p: future-proof qid2ino 32-bit support Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240106-ericvh-fix-cache-dups-v1-1-538c2074f363@kernel.org> References: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> In-Reply-To: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> To: v9fs@lists.linux.dev Cc: Eric Van Hensbergen , linux_oss@crudebyte.com, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1385; i=ericvh@kernel.org; h=from:subject:message-id; bh=47TnaR0YpjvB8dI8+cTvzu4LpRGU8CyazbqtphNLNcg=; b=owEBbQKS/ZANAwAKAYj/1ftKX/+YAcsmYgBlmLa+B+Pd7mu8rSkk+R7wVWqTra6cE0ZAxRrY7 wBnnVP8RcyJAjMEAAEKAB0WIQSWlvDRlqWQmKTK0VGI/9X7Sl//mAUCZZi2vgAKCRCI/9X7Sl// mLJlD/4xO8NZp/8pCEhBQBa7+6brr5Z2tQCrqHybc4nmKp1twU0psbPD6cEYP5HKa2jZQpfB3Or lzmpS8QDw1fhfQvraQhSY1xcmfj+DAqaTas3C7GbH7/TkbKvj3+3DZVOONkUhSafWcwU1uIWr90 10IkmM5zjOW+4AE1b6gCL6KXIZmFVfCI0njd0hnmZxT39jc7K4PqHgil2LvkjxTYev/mOBto+rB 3cmYJTERy9WeHMWSv76CpninZw7Exq4Z2O313ESFm0KzcUaBX/0MKKCpk8o6Twdz/lOsj1w5X7A NL67Wpbn43OVsJQ1RHxlqi8sIf9k7NuwDcgQSBBCuh566baKuJoI8fgfKcjhCzq/5inw3ryqX7l RL9zkQZyuAzZYCBGn4LR4ohTnZ6EZs39u37sH222XGwii2wdlHzHAspBZaBv42nR50upOBLXRfH uubh5f8qc5qAvq0s5fPcCnw4yN7sWC0AWFTHCYsOI3choK/pv3eXCKb4RIT6vdjdCVA3+NO4dR4 mPuyNKWuAMXyOMPkTaTGXfGgFttwAgH+3hJLHi57icUGRvGho0G7Zrlr6/hhpDLm/hZF7To3TXe cLEFk9BJiVyUk5Hjx1GpvKOOBK+tPdckv0mgY0l1NkVhLJCUqUYrQp9YkyPc9QII7e6/69dG/+q RhgjjY6meQtx1OQ== X-Developer-Key: i=ericvh@kernel.org; a=openpgp; fpr=9696F0D196A59098A4CAD15188FFD5FB4A5FFF98 The qid2ino code had a check to allow a reduced precision qid to inode number mapping, but it only checked if the sizes were equal. Change to check if the ino_t is smaller than qid->path before using the reduced precision version. Signed-off-by: Eric Van Hensbergen --- fs/9p/vfs_inode.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index b845ee18a80b..6d149ba12bc0 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -1192,18 +1192,25 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, * v9fs_qid2ino - convert qid into inode number * @qid: qid to hash * - * BUG: potential for inode number collisions? + * We add 2 to qid->path to keep reserved inode + * numbers reserved. + * + * Its possible in the future we will make qid->path + * just a hash to lookup inodes, but this breaks too + * much right now. + * */ ino_t v9fs_qid2ino(struct p9_qid *qid) { - u64 path = qid->path + 2; ino_t i = 0; - if (sizeof(ino_t) == sizeof(path)) - memcpy(&i, &path, sizeof(ino_t)); + WARN_ON((qid->path+2)==0); + + if (sizeof(ino_t) < sizeof(qid->path)) + i = (ino_t) ((qid->path+2) ^ (qid->path >> 32)); else - i = (ino_t) (path ^ (path >> 32)); + i = (ino_t) qid->path; return i; } From patchwork Sat Jan 6 02:11:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 13512632 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 071E715A8 for ; Sat, 6 Jan 2024 02:11:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PmUX8mlQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id ECD8DC433C8; Sat, 6 Jan 2024 02:11:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704507073; bh=FzqC8vGfSQKqsymfIdQBKBTvSoDcKJkKyoEMFGNr5Uk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PmUX8mlQqPM1Mz4Wz0JHkmAqAsUItLMY+Rn7Th4masyrIug+mHuihPlsDxAEtmY+8 CHsVLgm8+7qrMm+XK++DhxUzLctE9NsGFIGmdEYQ/BEUxrmDhLn23w+JVwD06dAj+U zld1P1pVl7GhkXn4rjwDZSBywRCIhc6mEyW0ev2EjQmceapczrRncn81iGx+kTIF5I StaQqf7rMLSW50pWJa0q+JMnCSrxcM7ZDewwLuTC3KKzNOWtXKOft5VFEDxTAvr/kj cJtaZ/70HUj/GGDthaSdEdu8vCb02J9icMG/1HAmmEuPVo6FDOkGl5TVGXwBBBuRQD 6UnmRtm0e0mQQ== From: Eric Van Hensbergen Date: Sat, 06 Jan 2024 02:11:09 +0000 Subject: [PATCH 2/9] fs/9p: switch vfsmount to use v9fs_get_new_inode Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240106-ericvh-fix-cache-dups-v1-2-538c2074f363@kernel.org> References: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> In-Reply-To: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> To: v9fs@lists.linux.dev Cc: Eric Van Hensbergen , linux_oss@crudebyte.com, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1973; i=ericvh@kernel.org; h=from:subject:message-id; bh=FzqC8vGfSQKqsymfIdQBKBTvSoDcKJkKyoEMFGNr5Uk=; b=owEBbQKS/ZANAwAKAYj/1ftKX/+YAcsmYgBlmLa+bYyjavEwQ/+ZukjEm+V7H+sf6ybM2KmRg ZW3yZAynGOJAjMEAAEKAB0WIQSWlvDRlqWQmKTK0VGI/9X7Sl//mAUCZZi2vgAKCRCI/9X7Sl// mOgDD/9kX9/H8C7vvNzApOIw6IUrlYymcTdsD/OJCaoK7ibzy5m15Jl8kSdsw2sO3QveAU3FJtz fRzuBLO4jiuwBa706HbjonN9Kd7LE24FbQ5YNlA36RJsTFzsiQjyHmXLh7xsai1tejfLOlDostY AebXgXuAkAiPDCoIAD3t5Gzk5nDg7g/g8+BNPsTSdJvR4kk3R1Lerh9Prwgkl65l9ywgzb1xU7P o2lsxAhPWnASohM648wPdpqsJqs3kUKLbu8L5MuKDGLX3A6qqz/LyTTWJuqc9kFD0/tOQkCtYpO gS9qaywrTDcOGtouA8WHjfSgdnS70skO9+Gw2Hw2iZmoVjYn8XV79fk3Qy5CUGV3qc3E+0NWiAK K9pvrlDbP8lWvzUFq5hhoo0YzbGC2AaW4sQPTqkneCUUOlUjCVIqbQLzEccYHBtXZhNRSDk+t6A FjhdGy1V6wT7v5/JaJk10Sh1OzC9lY5TfVkSRQ+PwI9bWPxEUhK7lIY9G9UHKWQvuvRg4tUsacr FDhYq3YJV927nEb3MwWZthdi8OT6wSSg20nuXYF/QYttExTnS9yZpElbs5s+s1WNmhUHoQnTB+R N6/B2PFNp/rxUYgqoJxxAOj62KwhUPw4nwVCpEWLyT2GbaaBtqV09HWr4bE8ImA9M5odMgqSYGa a8zAOsC/xllX3kg== X-Developer-Key: i=ericvh@kernel.org; a=openpgp; fpr=9696F0D196A59098A4CAD15188FFD5FB4A5FFF98 In the process of cleaning up inode number allocation, I noticed several functions which didn't use the standard helper allocators. This patch fixes the allocation in the mount entrypoint. Signed-off-by: Eric Van Hensbergen --- fs/9p/vfs_super.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 73db55c050bf..8d14cc0b3916 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -110,7 +110,6 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags, struct inode *inode = NULL; struct dentry *root = NULL; struct v9fs_session_info *v9ses = NULL; - umode_t mode = 0777 | S_ISVTX; struct p9_fid *fid; int retval = 0; @@ -140,7 +139,7 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags, else sb->s_d_op = &v9fs_dentry_operations; - inode = v9fs_get_inode(sb, S_IFDIR | mode, 0); + inode = v9fs_get_new_inode_from_fid(v9ses, fid, sb); if (IS_ERR(inode)) { retval = PTR_ERR(inode); goto release_sb; @@ -152,32 +151,6 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags, goto release_sb; } sb->s_root = root; - if (v9fs_proto_dotl(v9ses)) { - struct p9_stat_dotl *st = NULL; - - st = p9_client_getattr_dotl(fid, P9_STATS_BASIC); - if (IS_ERR(st)) { - retval = PTR_ERR(st); - goto release_sb; - } - d_inode(root)->i_ino = v9fs_qid2ino(&st->qid); - v9fs_stat2inode_dotl(st, d_inode(root), 0); - kfree(st); - } else { - struct p9_wstat *st = NULL; - - st = p9_client_stat(fid); - if (IS_ERR(st)) { - retval = PTR_ERR(st); - goto release_sb; - } - - d_inode(root)->i_ino = v9fs_qid2ino(&st->qid); - v9fs_stat2inode(st, d_inode(root), sb, 0); - - p9stat_free(st); - kfree(st); - } retval = v9fs_get_acl(inode, fid); if (retval) goto release_sb; From patchwork Sat Jan 6 02:11:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 13512633 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC52C15AB for ; Sat, 6 Jan 2024 02:11:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pFFW3m8r" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD58AC433C7; Sat, 6 Jan 2024 02:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704507074; bh=6J7EZJj9VWIpSwcWubGlaBSfbZNbY5oiwi0szyHJl2k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pFFW3m8rQOi++GbL0FBo12fKix9MUwtwQNuEZgODI3esjivPQREnyPDNgZHg45I7N L5MQaHrfUpKO1m+XqsxtFBOqwOCAdhgiTibJsy3BqNrJ88scrG4jsIF04PqwdkjCUd oABU+Bgw+gd7lhq+P+sJLFvKlGibdkWALwjIJsJ6Dy/egr9b57c6qDPkHtARQfgRud btnEq+6UD+89MDfSwgniN1EuaXxzktc/jys2/PKkSPi3r3VLJXgR65FpGcS+iPBo76 RQnwlepaBBQ3HFLZUxmPTN6LnvR7daEhnAVWVSq2TFlkq2ogvge/NpAJmQAOS5TBLA CySdVVmFIbbHA== From: Eric Van Hensbergen Date: Sat, 06 Jan 2024 02:11:10 +0000 Subject: [PATCH 3/9] fs/9p: convert mkdir to use get_new_inode Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240106-ericvh-fix-cache-dups-v1-3-538c2074f363@kernel.org> References: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> In-Reply-To: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> To: v9fs@lists.linux.dev Cc: Eric Van Hensbergen , linux_oss@crudebyte.com, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1893; i=ericvh@kernel.org; h=from:subject:message-id; bh=6J7EZJj9VWIpSwcWubGlaBSfbZNbY5oiwi0szyHJl2k=; b=owEBbQKS/ZANAwAKAYj/1ftKX/+YAcsmYgBlmLa+yTHWqJB9C3xBalia4vpyb7nOFLHx/qiEp KYMpjFmgM+JAjMEAAEKAB0WIQSWlvDRlqWQmKTK0VGI/9X7Sl//mAUCZZi2vgAKCRCI/9X7Sl// mOLKD/9ucY0+lTqzhCgWYZ1aHAqQPDyxjbBK925EZEJfCBoEgbEAkyzA9JudcQGpm1oK01OLltU BfATyXh6WtypxRQrkOVKOV3RGdaOMer5vhC3wNxFm2KJ6Hf86oAatm3mymDDcZMh0S5Qt5x+aBK xp0MYMzhizAUQM1XxnqjmVp1S1wByQEn3IZ+/IsZlm5c3dm0JL37+PXTzEsNdUpvlUztNVzZNJ9 6xVPR7IhciWW9Fzii4y2JdFHCkwioFXqm0sESmni/SsUHCL0bCCuqj1lTBUp/AuoC55DD02uqud lcORCuoTWKmExffLN64R3OtxWPIvgFCeBNwCVknNIdcuScAyi6vdspzOsKedb5IwBI1NDQy2Agg eZKWIyOUWKDto8A1ENxpM0gTu/X4vr5VvXU8lCMQrCR6YlK28Yt1gSsX1g8fqCjJgkuhnfWrxSz NKm+l/degcppPiHWF3PYn76eRZR5OFAIdgi3u54AHunZieH3swj9EmBd66/YwtKYZjVaEU02L9v BnHg9Imb+JNweF+Ti5NUZ6l0oJI4/a+FOzR2577ugziTtRG1TugS4pTsGVZSkriEoAF2GUphYdm soVeYzTX5bQYMcqQS0x+002bTwHp1N4dHxRaQwjEENe+oLVWjFIiUD9GYcGF8sZSiL4H2U1Ui3L xGOSWmco9uPYCJQ== X-Developer-Key: i=ericvh@kernel.org; a=openpgp; fpr=9696F0D196A59098A4CAD15188FFD5FB4A5FFF98 mkdir had different code paths for inode creation, cache used the get_new_inode_from_fid helper, but non-cached used v9fs_get_inode. Collapsed into a single implementation across both as there should be no difference. Signed-off-by: Eric Van Hensbergen --- fs/9p/vfs_inode_dotl.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index c7319af2f471..981278d0788e 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -401,32 +401,17 @@ static int v9fs_vfs_mkdir_dotl(struct mnt_idmap *idmap, } /* instantiate inode and assign the unopened fid to the dentry */ - if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) { - inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); - if (IS_ERR(inode)) { - err = PTR_ERR(inode); - p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", - err); - goto error; - } - v9fs_fid_add(dentry, &fid); - v9fs_set_create_acl(inode, fid, dacl, pacl); - d_instantiate(dentry, inode); - err = 0; - } else { - /* - * Not in cached mode. No need to populate - * inode with stat. We need to get an inode - * so that we can set the acl with dentry - */ - inode = v9fs_get_inode(dir->i_sb, mode, 0); - if (IS_ERR(inode)) { - err = PTR_ERR(inode); - goto error; - } - v9fs_set_create_acl(inode, fid, dacl, pacl); - d_instantiate(dentry, inode); + inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); + if (IS_ERR(inode)) { + err = PTR_ERR(inode); + p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", + err); + goto error; } + v9fs_fid_add(dentry, &fid); + v9fs_set_create_acl(inode, fid, dacl, pacl); + d_instantiate(dentry, inode); + err = 0; inc_nlink(dir); v9fs_invalidate_inode_attr(dir); error: From patchwork Sat Jan 6 02:11:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 13512634 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 780FD1381 for ; Sat, 6 Jan 2024 02:11:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XaQbVMU9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE744C433CA; Sat, 6 Jan 2024 02:11:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704507075; bh=T5xc0bJrXcRdQKa0K3R9OxUailnaVit69f7Vx3zsyzU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XaQbVMU9FwAqm2VGzMTGIzCmqhQpasXjaMIzjDwwwqLVbb5FVovzsa1/CP+x7OaXz Tm5zBd1s6CaM0L4sX8F1S4H0g4tDQGYcI/H4lgBA7zZmmNq4Y71hugJxtWglZEBaQr AQSe2wqSK7IlilLYCFuIv476ajNBktlKd3D3ez+kPJLcOxUDcVQfX2fKB11im8n1q3 jAttEc1IAuEx/NzEMD79FIK/rhIngiV5M/PbWBpc8qF962ojhHrK7C7l+ha3D/QisA vH5dPulMBzuLInfvX9gX/1gV7ewFPXSwNO8KawT5L1mCunbvOHwxNcsCJ7Mb7DX8fU jTJyBhYaC09lA== From: Eric Van Hensbergen Date: Sat, 06 Jan 2024 02:11:11 +0000 Subject: [PATCH 4/9] fs/9p: remove walk and inode allocation from symlink Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240106-ericvh-fix-cache-dups-v1-4-538c2074f363@kernel.org> References: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> In-Reply-To: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> To: v9fs@lists.linux.dev Cc: Eric Van Hensbergen , linux_oss@crudebyte.com, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1969; i=ericvh@kernel.org; h=from:subject:message-id; bh=T5xc0bJrXcRdQKa0K3R9OxUailnaVit69f7Vx3zsyzU=; b=owEBbQKS/ZANAwAKAYj/1ftKX/+YAcsmYgBlmLa+Lp07SLiGq/GDLs5ljQv9/YcSNi8PCWkZQ IhmIk/TwfuJAjMEAAEKAB0WIQSWlvDRlqWQmKTK0VGI/9X7Sl//mAUCZZi2vgAKCRCI/9X7Sl// mGJzEAC8FioHQcZhFzN0pJtM35MiXT3BWMOMf3uKcAeVfPWxU+oDcqDde66VphmlLuYrIwRDsth VEafIWMpojfaHVC08hv476ylvxHayfiS8kHaMBB5R51F9rFoxohMZFTiFAWhWGpEFxK5Ft6nH1l clesBGuQfvAi9uXZm/iUkO1md+vxYLHu9+QZlVPxENdvoQMSIocxVG3e6D31rQm/4fzgTZaEIJV kebBsM0KVCpO4QkEiBD9JCJK5XQLVbsmcrF6gi7PeX9maveQffmGVgX6GYMWM0hvFA3uvNMoYNb Kcy/F3RE186uh95VU8rFESRhooPcJj6GgctUK6i9JZ/Wjt1kN7bXYXTLhbzFWE2g7YL8NK12hNB Hq1gvVwYsWivsXdiTKUY9hqSS+ns2mXMXpMxBuvYATEWBMfcQBf8rs7lSnViT9o0niTJ8/waJR4 /awKMaUV2XDEosS0NaOEBNN3ZFJl5Utke4LwgrUopYYTpFQHxb+xdYfxnn3pyDK4m3bjuQAR243 4oS1HBAwlnN+SIVyTx3anOyjUsf0CcnnZ0CPcvY5ZkGY89ImZ7NuNWmjnCPcieMf42jOC29YE4o LMlRqqHHPtvmDWWwGlt1kqY4J91PxB9aHd/Ox1WUl/ftjFuH4x7kNiL4MOrTQPup0eDPoXDs2Ml omF+huHdvZZ6kwg== X-Developer-Key: i=ericvh@kernel.org; a=openpgp; fpr=9696F0D196A59098A4CAD15188FFD5FB4A5FFF98 Symlink had a bunch of extra operations which essentially end up discarded. It was walking the fid to the new file and creating an inode for it, but those semantics are part of tsymlink. This did prepopulate the cache, but that also seems potentially unnecessary and frought with peril. Signed-off-by: Eric Van Hensbergen --- fs/9p/vfs_inode_dotl.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 981278d0788e..c435952f6355 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -690,7 +690,6 @@ v9fs_vfs_symlink_dotl(struct mnt_idmap *idmap, struct inode *dir, kgid_t gid; const unsigned char *name; struct p9_qid qid; - struct inode *inode; struct p9_fid *dfid; struct p9_fid *fid = NULL; struct v9fs_session_info *v9ses; @@ -717,36 +716,6 @@ v9fs_vfs_symlink_dotl(struct mnt_idmap *idmap, struct inode *dir, } v9fs_invalidate_inode_attr(dir); - if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) { - /* Now walk from the parent so we can get an unopened fid. */ - fid = p9_client_walk(dfid, 1, &name, 1); - if (IS_ERR(fid)) { - err = PTR_ERR(fid); - p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", - err); - goto error; - } - - /* instantiate inode and assign the unopened fid to dentry */ - inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); - if (IS_ERR(inode)) { - err = PTR_ERR(inode); - p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", - err); - goto error; - } - v9fs_fid_add(dentry, &fid); - d_instantiate(dentry, inode); - err = 0; - } else { - /* Not in cached mode. No need to populate inode with stat */ - inode = v9fs_get_inode(dir->i_sb, S_IFLNK, 0); - if (IS_ERR(inode)) { - err = PTR_ERR(inode); - goto error; - } - d_instantiate(dentry, inode); - } error: p9_fid_put(fid); From patchwork Sat Jan 6 02:11:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 13512635 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DADFC15A8 for ; Sat, 6 Jan 2024 02:11:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="R8ymtrpJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CD40C433C7; Sat, 6 Jan 2024 02:11:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704507076; bh=WcsBUkpy1F6mKEDfTEDSif8hiGN+jyga9xdAs/K/iAk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=R8ymtrpJI84+lHIxBZXpm1CYtsuHB8cnY87Gq7slkBTR3uf4yNdMztashh37Aw2kH Gc5fFbKLafapA0+LD2bCzBkGOuxpPSDwFVWSpBM+dF3d6yq4OEbbESmg5p/nDH//dX JXvd5y+YjUEE1nGobXO+Xi4B7cyOqHn6u+xkuTmyT3ExNhxo/jNniF/dmk/InToOUj 3DAuKJ/Mx5CnI/GAXFkAKguXY4fmZ5fucS+M4BSuKLQaVRnfEkdujW3CVhh9ekIktk VDfoI31fvuy/DHw/yATPYjwWDj7fu6AIv2SA3cog0a3mjI7inWqNlVWnyuot3IQBJ7 3Mq1PMCCLZXQA== From: Eric Van Hensbergen Date: Sat, 06 Jan 2024 02:11:12 +0000 Subject: [PATCH 5/9] fs/9p: Eliminate redundant non-cache path in mknod Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240106-ericvh-fix-cache-dups-v1-5-538c2074f363@kernel.org> References: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> In-Reply-To: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> To: v9fs@lists.linux.dev Cc: Eric Van Hensbergen , linux_oss@crudebyte.com, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1817; i=ericvh@kernel.org; h=from:subject:message-id; bh=WcsBUkpy1F6mKEDfTEDSif8hiGN+jyga9xdAs/K/iAk=; b=owEBbQKS/ZANAwAKAYj/1ftKX/+YAcsmYgBlmLa+8BGcl1uMVYPJFJdC7DornzpLzqOdRQXZJ ELD5DAOvTmJAjMEAAEKAB0WIQSWlvDRlqWQmKTK0VGI/9X7Sl//mAUCZZi2vgAKCRCI/9X7Sl// mDCJD/4rMjkVo2GqVPA5jqoPE1tLO9OVIfWtsPqb2jY3qJjUNbQihPbKdI8lFARpN5glFmnI8vv N/H/b4eFNHrswnFuJPU+PWTfBoAsJ5B0whyATMkc0F7X9rdvg7OZSuuGK6ZaXpCyeOPw65xm6PA WLgOAXxeW6f+gCeOD793l7Mp1qQwauyKnbJ0DY5JendolSsu2rFbJXYqf4NT9vv0RpahjJLXS/T YknmFrW5NmDoYPqGLhkTSqyMEj6wl773CRKfjPQ/Pd72FJ5Okb6ViVaxMsS2uEg/O6YhLhUGB7M f9k9/4d0EB40LI77JMbbpTw5vn1EzHHUrZmEcpwmX4N5Mqzo0d8KAiimJTEcjZzYsjPPKiAN69m Pgo/7MPX/sh3fP9Co2tPPObnbiI2oIjL8tg/VEikQOYisqf3fzKjoaQTmM1bliwqBpEH9wAZv2B l53KFM+wGMRHgj/Cyske2l/FZab/EXxDa9HXlxGcvHpB7XN2t4Dt8Q2hUksntbx/ZMZs7ZW5s+x iUGOJFFczh/2ywy2VW6IKm76SCzX8Y6r166xEPNCzxT9Xxppliryfb4s1w2yH+1Lk8dQCxZajGm jzZOxwhtgVS1o8wyPwSod2SW/v3EElyfc3vZGuyGw7RO4mv31rhDRMCwb16KBHOUParJcQcPVgo yj2VSeNW1Z4UW/A== X-Developer-Key: i=ericvh@kernel.org; a=openpgp; fpr=9696F0D196A59098A4CAD15188FFD5FB4A5FFF98 Like symlink, mknod had a seperate path with different inode allocation -- but this seems unnecessary, so eliminating this path. Signed-off-by: Eric Van Hensbergen --- fs/9p/vfs_inode_dotl.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index c435952f6355..8eee13bae887 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -838,33 +838,17 @@ v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir, err); goto error; } - - /* instantiate inode and assign the unopened fid to the dentry */ - if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) { - inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); - if (IS_ERR(inode)) { - err = PTR_ERR(inode); - p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", - err); - goto error; - } - v9fs_set_create_acl(inode, fid, dacl, pacl); - v9fs_fid_add(dentry, &fid); - d_instantiate(dentry, inode); - err = 0; - } else { - /* - * Not in cached mode. No need to populate inode with stat. - * socket syscall returns a fd, so we need instantiate - */ - inode = v9fs_get_inode(dir->i_sb, mode, rdev); - if (IS_ERR(inode)) { - err = PTR_ERR(inode); - goto error; - } - v9fs_set_create_acl(inode, fid, dacl, pacl); - d_instantiate(dentry, inode); + inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); + if (IS_ERR(inode)) { + err = PTR_ERR(inode); + p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", + err); + goto error; } + v9fs_set_create_acl(inode, fid, dacl, pacl); + v9fs_fid_add(dentry, &fid); + d_instantiate(dentry, inode); + err = 0; error: p9_fid_put(fid); v9fs_put_acl(dacl, pacl); From patchwork Sat Jan 6 02:11:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 13512636 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 202A9136F for ; Sat, 6 Jan 2024 02:11:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QVsXVT3S" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E1F8C433CA; Sat, 6 Jan 2024 02:11:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704507077; bh=pl4xa9j0jvzdsgU27tdeu2QMqyC853DqIweh9gwWM/A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QVsXVT3SWG01KLTBRzDCb8N7B0X1m+kTYVe63TCgtUdd0/amDf//EYA5v1rqAhWPK 3I4/N7tZsgoL8FZCVogwkCEA5dGnd3bh+UCDqShCjXhfvqSCII78Mxifj99V/DlJHj SOI0twJbsmJb87ig3Q1zaCVDUor+UrwiiF142WhwD3AZLxA1zzBDCaLkCr9ifrqPuT 0dkLH0AJBIrI9FoBSDRbLDrDWKO9OqbtrcwZYY0Ywi6EE4umBvbBxCvTr+g7h/CHl8 p5JmIoO9fVpYrW1HTiDHy9Y9WcrNWDt93MGg5hu2PDTszO/376zWtTvYLk6CAvWpcA aJa4ak1xkNubA== From: Eric Van Hensbergen Date: Sat, 06 Jan 2024 02:11:13 +0000 Subject: [PATCH 6/9] fs/9p: Eliminate now unused v9fs_get_inode Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240106-ericvh-fix-cache-dups-v1-6-538c2074f363@kernel.org> References: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> In-Reply-To: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> To: v9fs@lists.linux.dev Cc: Eric Van Hensbergen , linux_oss@crudebyte.com, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1950; i=ericvh@kernel.org; h=from:subject:message-id; bh=pl4xa9j0jvzdsgU27tdeu2QMqyC853DqIweh9gwWM/A=; b=owEBbQKS/ZANAwAKAYj/1ftKX/+YAcsmYgBlmLa+a/4Wfh9PfHfUMoBfeBHQp4c+UTjJldgFY jXrkmp6lE+JAjMEAAEKAB0WIQSWlvDRlqWQmKTK0VGI/9X7Sl//mAUCZZi2vgAKCRCI/9X7Sl// mMETD/4hEmvfMxf2Qx1IaFnJWctFLlYRcZhT1lzeazVTlAPi6kjJz7xe+OUQ2xlVEn6KXb/f3wi TZs0neZ3X+B/kfljWmpKH500+lWoJH9SnNf09bbpLqCiPCeSeJ5E9I1CLU07NF0+H7fOYASWygU cUbEe7C0mb4sX4XYt5RbiKlm1CHUcuIDGjv0msgO7VlqQdohiTe0oSAPnicnVheyPevBJ9PQdvO raUnvQ6xun+zq3wQtSKGP0EUx+o8FVaeWmXv1k6N1DnLRc5jLJM2xZ+uZSFqKtENteVqciGJH/B 3K8zW2tAQa5Pn+Vt7mQHG6tnQjFHGe+Z4RJlUnv/VW0gluFlwthLc54RHPebnLR53d5XLM1LL3i FqcrlNosHTURBJnEIIpglMsAQ1+U1cvYNb2YyUpgL/LJ14IJNYiQZv4xh1dlBpuhi49LK0UvjBg rUSvqgMxMxjbi/i6XKAqVxUnIrnhHKgb8gLBsJZq40mWrjPN42jOXoQsvw0MT+PCEwXDiiAXLuc KTq4d56dV+/EflPvPoGDi/IyAGAxD/IErWrzopbRPKUQPwWzWH0cxiO1R7+lYMIeqjn8x8QXP3x 412r2GV+fnDOCC0Fu/jJOm52x9452ZFpWPdDEQFYpKazU+UYHysj0jnWhI1I9KwfuAY/m9EeP2u QJolgIK9W688JdQ== X-Developer-Key: i=ericvh@kernel.org; a=openpgp; fpr=9696F0D196A59098A4CAD15188FFD5FB4A5FFF98 Now with all inode allocation going through get_from_fid functions we can remove v9fs_get_inode and reduce us down to a single inode allocation path. Signed-off-by: Eric Van Hensbergen --- fs/9p/v9fs_vfs.h | 2 -- fs/9p/vfs_inode.c | 29 ----------------------------- 2 files changed, 31 deletions(-) diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index 731e3d14b67d..ad0310deb6c8 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h @@ -40,8 +40,6 @@ extern struct kmem_cache *v9fs_inode_cache; struct inode *v9fs_alloc_inode(struct super_block *sb); void v9fs_free_inode(struct inode *inode); -struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, - dev_t rdev); int v9fs_init_inode(struct v9fs_session_info *v9ses, struct inode *inode, umode_t mode, dev_t rdev); void v9fs_evict_inode(struct inode *inode); diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 6d149ba12bc0..02761009946b 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -333,35 +333,6 @@ int v9fs_init_inode(struct v9fs_session_info *v9ses, } -/** - * v9fs_get_inode - helper function to setup an inode - * @sb: superblock - * @mode: mode to setup inode with - * @rdev: The device numbers to set - */ - -struct inode *v9fs_get_inode(struct super_block *sb, umode_t mode, dev_t rdev) -{ - int err; - struct inode *inode; - struct v9fs_session_info *v9ses = sb->s_fs_info; - - p9_debug(P9_DEBUG_VFS, "super block: %p mode: %ho\n", sb, mode); - - inode = new_inode(sb); - if (!inode) { - pr_warn("%s (%d): Problem allocating inode\n", - __func__, task_pid_nr(current)); - return ERR_PTR(-ENOMEM); - } - err = v9fs_init_inode(v9ses, inode, mode, rdev); - if (err) { - iput(inode); - return ERR_PTR(err); - } - return inode; -} - /** * v9fs_evict_inode - Remove an inode from the inode cache * @inode: inode to release From patchwork Sat Jan 6 02:11:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 13512637 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45ABC15A8 for ; Sat, 6 Jan 2024 02:11:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fZGWYQiE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37778C433C7; Sat, 6 Jan 2024 02:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704507077; bh=kot4iF/QDarHM9VhmDTaiToyFbsFqA6zYYgEX2GnOSA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fZGWYQiEPviuNuvmo7LVpC5/WcadIVgEpfdSmiNOWYC6ij7OQQoQq9aNQh1eRyele D/Cjfuc0/+6C//jCJisNrpQ3UQ/npL61GHTdOoxWjH0U3G0OJAynNlsW4CGikbZT7O mrcTLSWjqqciorXdaSCWTFYNfjnwWfYPxj4NKMcHHeGDpiXzS9SDLKIAA5M147FsgW dxAOVdnSebW6bqjRZPac4GnPF5HjoFfqOpeqJCXif4vM0lTLvJJOTrIyhFrf4eyLIe fDzqE5wQ3YLJFv4lYGwNZqUrq6k8xbvX1GzwEg1ZLKAbJt9ZR44tyG2RFrz2yw2NZX z++Uf9klyNjcg== From: Eric Van Hensbergen Date: Sat, 06 Jan 2024 02:11:14 +0000 Subject: [PATCH 7/9] fs/9p: rework qid2ino logic Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240106-ericvh-fix-cache-dups-v1-7-538c2074f363@kernel.org> References: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> In-Reply-To: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> To: v9fs@lists.linux.dev Cc: Eric Van Hensbergen , linux_oss@crudebyte.com, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4959; i=ericvh@kernel.org; h=from:subject:message-id; bh=kot4iF/QDarHM9VhmDTaiToyFbsFqA6zYYgEX2GnOSA=; b=owEBbQKS/ZANAwAKAYj/1ftKX/+YAcsmYgBlmLa+s76PNA8hnOn4SFC1XN/QC0yHtb7lOgw8a QvYIP5gMQmJAjMEAAEKAB0WIQSWlvDRlqWQmKTK0VGI/9X7Sl//mAUCZZi2vgAKCRCI/9X7Sl// mNmDD/9Ritvzq6Mrn66zZGFyaVSM3OrvYnKr6PRjcRrbfkXhaSGQBbvKY+PPCUyC8kdDSj77s8z ww3tKwZ/edGkwC+X+rF5rS2GJI2A2yetHByyiHOT3QNgwLPvu0iQeE1qp7EzwgKlJX5fweicZFv X5NeKIknyJJU810vyoZdIyeJlLMgar9e8DCxv8rkegPxm7B+0ZDuOU1XN1Fdd/yo3NfhVmEyY6T MyUx1EIX5/gS5ePuUuvpiz/3MwIY8W5I0ORuMtSFqop0AuLVp3epd1O1pW72u2NoUmKzl5BfNHB 8ilqkQakPEXFinJYML8t9xUmP5qBuRTiAOCIo2KacYWyO6/OLmNi+yDhDlVepNytqdAbKDpkjeC 8XqOvhnNf5p3L94dJyQIjqBukFj+UKbHX/Z4LJItNqcD8UNV4xr0yj/j0JpZCbfGghEWRDdz1R8 hSXP9/oaFmoSyfDejc17ks92fgSWLdcSAVEUAIg9fB+DaADMdQKnBugGYbsYpsAHJivMuD3+HnE CSeGoy36Iy3kwxQ/oPPBbXP+jCkFU4qLFd5H3zVp/Ef8diBkGgAqNKijtHkpMtpLo+QM59kopO7 eYtJq9nA3A1/9RoiHXbkR4GvbV8rFJSvLk5rdFIYxfYbn2sOKolanyi3WIpJvYXwj0NWW2GDW0n NmnxwrhVoRhl+JQ== X-Developer-Key: i=ericvh@kernel.org; a=openpgp; fpr=9696F0D196A59098A4CAD15188FFD5FB4A5FFF98 This changes from a function to a macro because we can figure out if we are 32 or 64 bit at compile time. Signed-off-by: Eric Van Hensbergen --- fs/9p/v9fs_vfs.h | 7 ++++++- fs/9p/vfs_dir.c | 6 +++--- fs/9p/vfs_inode.c | 31 +------------------------------ fs/9p/vfs_inode_dotl.c | 6 ++---- 4 files changed, 12 insertions(+), 38 deletions(-) diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index ad0310deb6c8..789e1188d5dc 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h @@ -43,7 +43,12 @@ void v9fs_free_inode(struct inode *inode); int v9fs_init_inode(struct v9fs_session_info *v9ses, struct inode *inode, umode_t mode, dev_t rdev); void v9fs_evict_inode(struct inode *inode); -ino_t v9fs_qid2ino(struct p9_qid *qid); +#if (ULONG_MAX == 0xffffffffUL) +#define QID2INO(q) (ino_t) (((q)->path+2) ^ (((q)->path) >> 32)) +#else +#define QID2INO(q) (ino_t) ((q)->path+2) +#endif + void v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, struct super_block *sb, unsigned int flags); void v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode, diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index 4102759a5cb5..13a53da75ec8 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c @@ -125,9 +125,9 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx) p9_debug(P9_DEBUG_VFS, "returned %d\n", err); return -EIO; } - + over = !dir_emit(ctx, st.name, strlen(st.name), - v9fs_qid2ino(&st.qid), dt_type(&st)); + QID2INO(&st.qid), dt_type(&st)); p9stat_free(&st); if (over) return 0; @@ -184,7 +184,7 @@ static int v9fs_dir_readdir_dotl(struct file *file, struct dir_context *ctx) if (!dir_emit(ctx, curdirent.d_name, strlen(curdirent.d_name), - v9fs_qid2ino(&curdirent.qid), + QID2INO(&curdirent.qid), curdirent.d_type)) return 0; diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 02761009946b..fe8cbcdf4b5f 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -407,7 +407,6 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, dev_t rdev; int retval; umode_t umode; - unsigned long i_ino; struct inode *inode; struct v9fs_session_info *v9ses = sb->s_fs_info; int (*test)(struct inode *inode, void *data); @@ -417,8 +416,7 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, else test = v9fs_test_inode; - i_ino = v9fs_qid2ino(qid); - inode = iget5_locked(sb, i_ino, test, v9fs_set_inode, st); + inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode, st); if (!inode) return ERR_PTR(-ENOMEM); if (!(inode->i_state & I_NEW)) @@ -428,7 +426,6 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, * FIXME!! we may need support for stale inodes * later. */ - inode->i_ino = i_ino; umode = p9mode2unixmode(v9ses, st, &rdev); retval = v9fs_init_inode(v9ses, inode, umode, rdev); if (retval) @@ -1159,32 +1156,6 @@ v9fs_stat2inode(struct p9_wstat *stat, struct inode *inode, v9inode->cache_validity &= ~V9FS_INO_INVALID_ATTR; } -/** - * v9fs_qid2ino - convert qid into inode number - * @qid: qid to hash - * - * We add 2 to qid->path to keep reserved inode - * numbers reserved. - * - * Its possible in the future we will make qid->path - * just a hash to lookup inodes, but this breaks too - * much right now. - * - */ - -ino_t v9fs_qid2ino(struct p9_qid *qid) -{ - ino_t i = 0; - - WARN_ON((qid->path+2)==0); - - if (sizeof(ino_t) < sizeof(qid->path)) - i = (ino_t) ((qid->path+2) ^ (qid->path >> 32)); - else - i = (ino_t) qid->path; - - return i; -} /** * v9fs_vfs_get_link - follow a symlink path diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 8eee13bae887..2699d7b3b8e8 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -100,7 +100,6 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, int new) { int retval; - unsigned long i_ino; struct inode *inode; struct v9fs_session_info *v9ses = sb->s_fs_info; int (*test)(struct inode *inode, void *data); @@ -110,8 +109,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, else test = v9fs_test_inode_dotl; - i_ino = v9fs_qid2ino(qid); - inode = iget5_locked(sb, i_ino, test, v9fs_set_inode_dotl, st); + inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode_dotl, st); if (!inode) return ERR_PTR(-ENOMEM); if (!(inode->i_state & I_NEW)) @@ -121,7 +119,7 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, * FIXME!! we may need support for stale inodes * later. */ - inode->i_ino = i_ino; + inode->i_ino = QID2INO(qid); retval = v9fs_init_inode(v9ses, inode, st->st_mode, new_decode_dev(st->st_rdev)); if (retval) From patchwork Sat Jan 6 02:11:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 13512638 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0F71515AB for ; Sat, 6 Jan 2024 02:11:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="V/N6gf3A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C52CC433C9; Sat, 6 Jan 2024 02:11:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704507078; bh=2ilIaYqvoK/mkCBgHWHH98EX4M0yVCJ+u5eYGKqTQl0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=V/N6gf3AGxRPO1WlDUF4zrPkV1GVqwq5+m0P0wnfK9UB9vWtjFDSubsIPtxRlBApZ 9+YG0ggEXxhw5QNWnh7HUXHgLIp9tvtZggpykYyJr3s/Jbx23XBiaPzHpRzSRXXYIP j0mQpENLNGgQRCTUv2zDl3qclccuJ7+EO1RMjOMNvT7rOC8BK1Mf6TD8gfqJPPVEOk n+e7lq+ckDstVLriqhG8sdMfEhsAMUsLXGYeHP4h0eIl9/04ej4QuDFWo+hnF7Czh7 K3ZeqxMN4kseJP0dVKY7TpWAl3ID69TpXr2cYYBnds8hNxbKovWbyrZ0KOZP5Uoptt U/jGjholnVcVQ== From: Eric Van Hensbergen Date: Sat, 06 Jan 2024 02:11:15 +0000 Subject: [PATCH 8/9] fs/9p: simplify iget path to remove unnecessary paths Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240106-ericvh-fix-cache-dups-v1-8-538c2074f363@kernel.org> References: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> In-Reply-To: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> To: v9fs@lists.linux.dev Cc: Eric Van Hensbergen , linux_oss@crudebyte.com, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7048; i=ericvh@kernel.org; h=from:subject:message-id; bh=2ilIaYqvoK/mkCBgHWHH98EX4M0yVCJ+u5eYGKqTQl0=; b=owEBbQKS/ZANAwAKAYj/1ftKX/+YAcsmYgBlmLa+SX8BZNa7ItTLF9b/EwzrhZnPQI+4Tg/J/ h1Ve05H6ROJAjMEAAEKAB0WIQSWlvDRlqWQmKTK0VGI/9X7Sl//mAUCZZi2vgAKCRCI/9X7Sl// mPEaD/9G4EKChdSUz+kcorjbYR4+taa3UWXSWpeud6RAu/dWIoyI7i4MH0A8fnmIsxhdVhrIf69 wB4Fb4ZzUE98UKe1lVGee0W4bE8DMzVK1bb6C1EYzRLEm4X5gzR9XPZPp6NwyNv5ZY9jbMfBXsi /MNun++2WDqfB/r6Y9fPg5LE13EZf8cGkZnSo3ck7XClY144S9p4nwa4O41QOceBezO6KEhQSTN bLMyLyUpdNix6hg2xbjg4ftuQAhiQ3blm/fjGFCSHRWIkPAZQKfp4eSpfOoRhzUx90NPXvkE4zG uilalsu1APGEuhcDZr01qPiJzxh7VTpHOzw0ErQoR6wK24atnN7UeHj9193IXv9mdEfjOoMzScs yMHorlmy5kjByRtiE35sCOnpaddJMEZQtLY9SUfygAvagEKbJXdcokZWT+KVlIl2QVcVdVjkYpA 5p2Wtrg6vN/x6i50FIkPD/fHSG4Q2eAORjw4hLw4tdFEF5eU37KkaWlrSGrA9pyEloeVlvJVt/S n0qhBz/I/ANF0ZeOtX7v4WUrW3MUVCQLdiv65hz4GDenmxvD6N9RNd2FnKVjLZhg6eJH2cO6FPU Jawo5I02zFMzpZrudx8aUxlDDc7jzjFWkjNgEW5WVcJMjPOdRXP5BWkyTakZ0TvaALddxXL28zA cFDypYPuP5Kx/Jw== X-Developer-Key: i=ericvh@kernel.org; a=openpgp; fpr=9696F0D196A59098A4CAD15188FFD5FB4A5FFF98 Remove the additional comparison operators and switch to simply lookup by inode number (aka qid.path). Signed-off-by: Eric Van Hensbergen --- fs/9p/v9fs_vfs.h | 2 +- fs/9p/vfs_inode.c | 67 +++++++++++--------------------------------------- fs/9p/vfs_inode_dotl.c | 67 +++++++++----------------------------------------- 3 files changed, 27 insertions(+), 109 deletions(-) diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h index 789e1188d5dc..791231b31b95 100644 --- a/fs/9p/v9fs_vfs.h +++ b/fs/9p/v9fs_vfs.h @@ -41,7 +41,7 @@ extern struct kmem_cache *v9fs_inode_cache; struct inode *v9fs_alloc_inode(struct super_block *sb); void v9fs_free_inode(struct inode *inode); int v9fs_init_inode(struct v9fs_session_info *v9ses, - struct inode *inode, umode_t mode, dev_t rdev); + struct inode *inode, struct p9_qid *qid, umode_t mode, dev_t rdev); void v9fs_evict_inode(struct inode *inode); #if (ULONG_MAX == 0xffffffffUL) #define QID2INO(q) (ino_t) (((q)->path+2) ^ (((q)->path) >> 32)) diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index fe8cbcdf4b5f..766496579b28 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -253,9 +253,12 @@ static void v9fs_set_netfs_context(struct inode *inode) } int v9fs_init_inode(struct v9fs_session_info *v9ses, - struct inode *inode, umode_t mode, dev_t rdev) + struct inode *inode, struct p9_qid *qid, umode_t mode, dev_t rdev) { int err = 0; + struct v9fs_inode *v9inode = V9FS_I(inode); + + memcpy(&v9inode->qid, qid, sizeof(struct p9_qid)); inode_init_owner(&nop_mnt_idmap, inode, NULL, mode); inode->i_blocks = 0; @@ -359,75 +362,33 @@ void v9fs_evict_inode(struct inode *inode) #endif } -static int v9fs_test_inode(struct inode *inode, void *data) -{ - int umode; - dev_t rdev; - struct v9fs_inode *v9inode = V9FS_I(inode); - struct p9_wstat *st = (struct p9_wstat *)data; - struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); - - umode = p9mode2unixmode(v9ses, st, &rdev); - /* don't match inode of different type */ - if (inode_wrong_type(inode, umode)) - return 0; - - /* compare qid details */ - if (memcmp(&v9inode->qid.version, - &st->qid.version, sizeof(v9inode->qid.version))) - return 0; - - if (v9inode->qid.type != st->qid.type) - return 0; - - if (v9inode->qid.path != st->qid.path) - return 0; - return 1; -} - -static int v9fs_test_new_inode(struct inode *inode, void *data) -{ - return 0; -} - -static int v9fs_set_inode(struct inode *inode, void *data) -{ - struct v9fs_inode *v9inode = V9FS_I(inode); - struct p9_wstat *st = (struct p9_wstat *)data; - - memcpy(&v9inode->qid, &st->qid, sizeof(st->qid)); - return 0; -} - static struct inode *v9fs_qid_iget(struct super_block *sb, struct p9_qid *qid, - struct p9_wstat *st, - int new) + struct p9_wstat *st) { dev_t rdev; int retval; umode_t umode; struct inode *inode; struct v9fs_session_info *v9ses = sb->s_fs_info; - int (*test)(struct inode *inode, void *data); - if (new) - test = v9fs_test_new_inode; - else - test = v9fs_test_inode; - - inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode, st); - if (!inode) + inode = iget_locked(sb, QID2INO(qid)); + if (unlikely(!inode)) return ERR_PTR(-ENOMEM); if (!(inode->i_state & I_NEW)) return inode; + if (unlikely(st == NULL)) { + retval = -EINVAL; + goto error; + } + /* * initialize the inode with the stat info * FIXME!! we may need support for stale inodes * later. */ umode = p9mode2unixmode(v9ses, st, &rdev); - retval = v9fs_init_inode(v9ses, inode, umode, rdev); + retval = v9fs_init_inode(v9ses, inode, qid, umode, rdev); if (retval) goto error; @@ -452,7 +413,7 @@ v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, if (IS_ERR(st)) return ERR_CAST(st); - inode = v9fs_qid_iget(sb, &st->qid, st, new); + inode = v9fs_qid_iget(sb, &st->qid, st); p9stat_free(st); kfree(st); return inode; diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 2699d7b3b8e8..2200c5f77d58 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -52,75 +52,31 @@ static kgid_t v9fs_get_fsgid_for_create(struct inode *dir_inode) return current_fsgid(); } -static int v9fs_test_inode_dotl(struct inode *inode, void *data) -{ - struct v9fs_inode *v9inode = V9FS_I(inode); - struct p9_stat_dotl *st = (struct p9_stat_dotl *)data; - - /* don't match inode of different type */ - if (inode_wrong_type(inode, st->st_mode)) - return 0; - - if (inode->i_generation != st->st_gen) - return 0; - - /* compare qid details */ - if (memcmp(&v9inode->qid.version, - &st->qid.version, sizeof(v9inode->qid.version))) - return 0; - - if (v9inode->qid.type != st->qid.type) - return 0; - - if (v9inode->qid.path != st->qid.path) - return 0; - return 1; -} - -/* Always get a new inode */ -static int v9fs_test_new_inode_dotl(struct inode *inode, void *data) -{ - return 0; -} - -static int v9fs_set_inode_dotl(struct inode *inode, void *data) -{ - struct v9fs_inode *v9inode = V9FS_I(inode); - struct p9_stat_dotl *st = (struct p9_stat_dotl *)data; - - memcpy(&v9inode->qid, &st->qid, sizeof(st->qid)); - inode->i_generation = st->st_gen; - return 0; -} - static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, struct p9_qid *qid, struct p9_fid *fid, - struct p9_stat_dotl *st, - int new) + struct p9_stat_dotl *st) { int retval; struct inode *inode; struct v9fs_session_info *v9ses = sb->s_fs_info; - int (*test)(struct inode *inode, void *data); - - if (new) - test = v9fs_test_new_inode_dotl; - else - test = v9fs_test_inode_dotl; - inode = iget5_locked(sb, QID2INO(qid), test, v9fs_set_inode_dotl, st); - if (!inode) + inode = iget_locked(sb, QID2INO(qid)); + if (unlikely(!inode)) return ERR_PTR(-ENOMEM); if (!(inode->i_state & I_NEW)) return inode; + if (unlikely(st == NULL)) { + retval = -EINVAL; + goto error; + } + /* * initialize the inode with the stat info * FIXME!! we may need support for stale inodes * later. */ - inode->i_ino = QID2INO(qid); - retval = v9fs_init_inode(v9ses, inode, + retval = v9fs_init_inode(v9ses, inode, qid, st->st_mode, new_decode_dev(st->st_rdev)); if (retval) goto error; @@ -143,14 +99,15 @@ struct inode * v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid, struct super_block *sb, int new) { - struct p9_stat_dotl *st; + struct p9_stat_dotl *st = NULL; struct inode *inode = NULL; st = p9_client_getattr_dotl(fid, P9_STATS_BASIC | P9_STATS_GEN); if (IS_ERR(st)) return ERR_CAST(st); - inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st, new); + inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st); + kfree(st); return inode; } From patchwork Sat Jan 6 02:11:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Van Hensbergen X-Patchwork-Id: 13512639 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 035631381 for ; Sat, 6 Jan 2024 02:11:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CYw8Z4v8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEA21C433C8; Sat, 6 Jan 2024 02:11:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704507079; bh=QmhmTJ9+CP7sGiwWpHsE25lzjIh2Wbnu23GArt9Mmgk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=CYw8Z4v8sACHE7SUMAmKv+Ir1M6R19wpwB2vTaGrvAb6w1taUviooRBgpx/XdpVig f0rVyKYjdKbIHnWlqXg9Vsvdag+Z5LuxwFwyVzNqwd8rEun7yuidIt9mXb6YRmRpeT HNJoZJMEIaCCGf1pXd8LM3fXpWxXra25fewctah/Uj8WgSwr8Y9vbCWxEzyid4g/4s 5PFUP8s/dFE16CmBZjRpLGmodLaq9BDANaqVi95jKMKjtqOVfLRPjt+qFXikbdbzV4 lObNNLYWSaHnRCrLeH7xm+Al7pVlHg6Ya7wKOZ7rGuhdm1szuFGqUbb9Hg99+DvERy 4EAydE17zdr5A== From: Eric Van Hensbergen Date: Sat, 06 Jan 2024 02:11:16 +0000 Subject: [PATCH 9/9] fs/9p: Further simplify inode lookup Precedence: bulk X-Mailing-List: v9fs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240106-ericvh-fix-cache-dups-v1-9-538c2074f363@kernel.org> References: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> In-Reply-To: <20240106-ericvh-fix-cache-dups-v1-0-538c2074f363@kernel.org> To: v9fs@lists.linux.dev Cc: Eric Van Hensbergen , linux_oss@crudebyte.com, asmadeus@codewreck.org, rminnich@gmail.com, lucho@ionkov.net X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=9308; i=ericvh@kernel.org; h=from:subject:message-id; bh=QmhmTJ9+CP7sGiwWpHsE25lzjIh2Wbnu23GArt9Mmgk=; b=owEBbQKS/ZANAwAKAYj/1ftKX/+YAcsmYgBlmLa+ASFeAdN2ZVHu/sb2bvdrNopi168GyCrlE NryDa45Wn6JAjMEAAEKAB0WIQSWlvDRlqWQmKTK0VGI/9X7Sl//mAUCZZi2vgAKCRCI/9X7Sl// mIoWD/0dXYAjW4uKL+R3RiBVRTk1byYBR1CCvNN0x7dxMC77Cu/eKpO1AyJ5VPMU6pnhWXab1JA 2yffHxn65KFITZJHFRDnk7yBkguQ72SjVHgxQS4OLOpQJf8EklHog/wc/Vu5d0BOSh/xatOPNwE nZJenIwohYvIblEvT4lMuyxwZLUmNikWEdXbf5QxcdCmWE4lHQjYdlcNjfaj3zJQvW3rA5CHM2+ zXkSCmgVZL7P0jUzQWE5phFqL7XyQnACEMvC3j6Zrm2/zZuHeSC0U6TT6EvPsbgXeGOgyM8S0Zf db7Cy0lX5eTRWc8r1H6JHjntr+gZY+OSaL+Lrhud26gOMsl2FRAmc753AAc2LHunL/4Av2+FDOX GbXfdc/qXwVFKpkQUaex5CbvGZZ8hODPcfJaLficWziNEzw0oYj9c27QHKGzzowj1ZhL/HKKEY5 PGi6Gm0ijTN3XwxH9oEkBoJjpN6ASDPhMRxIjPE/e5YL5MYehsJCYZWyUxzX+vJ+/8tkBJGd6zX VBwbqjSa4KCQKCLvIPxDvOrSeDWV8IgC0L+nQ0FIwYs4kEOIJx58xZCOiQ4mkrGaDNG8yvZTTST uT1ygYGiYkzroxQOdBFF2mfukz409OU7wT/l/xfsDZ+psZ15g1DF9FDl6R1zmYlUoVDBE2NdgHf xK2xxRCD/BSiqig== X-Developer-Key: i=ericvh@kernel.org; a=openpgp; fpr=9696F0D196A59098A4CAD15188FFD5FB4A5FFF98 Collapse function call chain and shortcut helper functions where they are no longer necessary. Move stat/getattr code into the iget functions so that it only gets called when the inode doesn't exist yet. Signed-off-by: Eric Van Hensbergen --- fs/9p/v9fs.h | 31 +++++-------------------------- fs/9p/vfs_inode.c | 46 +++++++++++++++------------------------------- fs/9p/vfs_inode_dotl.c | 47 ++++++++++++++++------------------------------- fs/9p/vfs_super.c | 2 +- 4 files changed, 37 insertions(+), 89 deletions(-) diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h index 698c43dd5dc8..9defa12208f9 100644 --- a/fs/9p/v9fs.h +++ b/fs/9p/v9fs.h @@ -179,16 +179,13 @@ extern int v9fs_vfs_rename(struct mnt_idmap *idmap, struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, unsigned int flags); -extern struct inode *v9fs_inode_from_fid(struct v9fs_session_info *v9ses, - struct p9_fid *fid, - struct super_block *sb, int new); +extern struct inode *v9fs_fid_iget(struct super_block *sb, struct p9_fid *fid); extern const struct inode_operations v9fs_dir_inode_operations_dotl; extern const struct inode_operations v9fs_file_inode_operations_dotl; extern const struct inode_operations v9fs_symlink_inode_operations_dotl; extern const struct netfs_request_ops v9fs_req_ops; -extern struct inode *v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, - struct p9_fid *fid, - struct super_block *sb, int new); +extern struct inode *v9fs_fid_iget_dotl(struct super_block *sb, + struct p9_fid *fid); /* other default globals */ #define V9FS_PORT 564 @@ -230,27 +227,9 @@ v9fs_get_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, struct super_block *sb) { if (v9fs_proto_dotl(v9ses)) - return v9fs_inode_from_fid_dotl(v9ses, fid, sb, 0); + return v9fs_fid_iget_dotl(sb, fid); else - return v9fs_inode_from_fid(v9ses, fid, sb, 0); -} - -/** - * v9fs_get_new_inode_from_fid - Helper routine to populate an inode by - * issuing a attribute request - * @v9ses: session information - * @fid: fid to issue attribute request for - * @sb: superblock on which to create inode - * - */ -static inline struct inode * -v9fs_get_new_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, - struct super_block *sb) -{ - if (v9fs_proto_dotl(v9ses)) - return v9fs_inode_from_fid_dotl(v9ses, fid, sb, 1); - else - return v9fs_inode_from_fid(v9ses, fid, sb, 1); + return v9fs_fid_iget(sb, fid); } #endif diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index 766496579b28..76e40c057c56 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c @@ -362,37 +362,40 @@ void v9fs_evict_inode(struct inode *inode) #endif } -static struct inode *v9fs_qid_iget(struct super_block *sb, - struct p9_qid *qid, - struct p9_wstat *st) +struct inode *v9fs_fid_iget(struct super_block *sb, struct p9_fid *fid) { dev_t rdev; int retval; umode_t umode; struct inode *inode; + struct p9_wstat *st; struct v9fs_session_info *v9ses = sb->s_fs_info; - inode = iget_locked(sb, QID2INO(qid)); + inode = iget_locked(sb, QID2INO(&fid->qid)); if (unlikely(!inode)) return ERR_PTR(-ENOMEM); if (!(inode->i_state & I_NEW)) return inode; - if (unlikely(st == NULL)) { - retval = -EINVAL; - goto error; - } /* * initialize the inode with the stat info * FIXME!! we may need support for stale inodes * later. */ + st = p9_client_stat(fid); + if (IS_ERR(st)) { + retval= PTR_ERR(st); + goto error; + } + umode = p9mode2unixmode(v9ses, st, &rdev); - retval = v9fs_init_inode(v9ses, inode, qid, umode, rdev); + retval = v9fs_init_inode(v9ses, inode, &fid->qid, umode, rdev); + v9fs_stat2inode(st, inode, sb, 0); + p9stat_free(st); + kfree(st); if (retval) goto error; - v9fs_stat2inode(st, inode, sb, 0); v9fs_cache_inode_get_cookie(inode); unlock_new_inode(inode); return inode; @@ -402,23 +405,6 @@ static struct inode *v9fs_qid_iget(struct super_block *sb, } -struct inode * -v9fs_inode_from_fid(struct v9fs_session_info *v9ses, struct p9_fid *fid, - struct super_block *sb, int new) -{ - struct p9_wstat *st; - struct inode *inode = NULL; - - st = p9_client_stat(fid); - if (IS_ERR(st)) - return ERR_CAST(st); - - inode = v9fs_qid_iget(sb, &st->qid, st); - p9stat_free(st); - kfree(st); - return inode; -} - /** * v9fs_at_to_dotl_flags- convert Linux specific AT flags to * plan 9 AT flag. @@ -565,7 +551,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir, /* * instantiate inode and assign the unopened fid to the dentry */ - inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); + inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); if (IS_ERR(inode)) { err = PTR_ERR(inode); p9_debug(P9_DEBUG_VFS, @@ -693,10 +679,8 @@ struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, inode = NULL; else if (IS_ERR(fid)) inode = ERR_CAST(fid); - else if (v9ses->cache & (CACHE_META|CACHE_LOOSE)) + else inode = v9fs_get_inode_from_fid(v9ses, fid, dir->i_sb); - else - inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); /* * If we had a rename on the server and a parallel lookup * for the new name, then make sure we instantiate with diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c index 2200c5f77d58..6f8cdbcef444 100644 --- a/fs/9p/vfs_inode_dotl.c +++ b/fs/9p/vfs_inode_dotl.c @@ -52,32 +52,33 @@ static kgid_t v9fs_get_fsgid_for_create(struct inode *dir_inode) return current_fsgid(); } -static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, - struct p9_qid *qid, - struct p9_fid *fid, - struct p9_stat_dotl *st) +struct inode *v9fs_fid_iget_dotl(struct super_block *sb, struct p9_fid *fid) { int retval; struct inode *inode; + struct p9_stat_dotl *st; struct v9fs_session_info *v9ses = sb->s_fs_info; - inode = iget_locked(sb, QID2INO(qid)); + inode = iget_locked(sb, QID2INO(&fid->qid)); if (unlikely(!inode)) return ERR_PTR(-ENOMEM); if (!(inode->i_state & I_NEW)) return inode; - if (unlikely(st == NULL)) { - retval = -EINVAL; - goto error; - } /* * initialize the inode with the stat info * FIXME!! we may need support for stale inodes * later. */ - retval = v9fs_init_inode(v9ses, inode, qid, + st = p9_client_getattr_dotl(fid, P9_STATS_BASIC | P9_STATS_GEN); + if (IS_ERR(st)) { + retval = PTR_ERR(st); + goto error; + } + + retval = v9fs_init_inode(v9ses, inode, &fid->qid, st->st_mode, new_decode_dev(st->st_rdev)); + kfree(st); if (retval) goto error; @@ -87,7 +88,8 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, if (retval) goto error; - unlock_new_inode(inode); + unlock_new_inode(inode); + return inode; error: iget_failed(inode); @@ -95,23 +97,6 @@ static struct inode *v9fs_qid_iget_dotl(struct super_block *sb, } -struct inode * -v9fs_inode_from_fid_dotl(struct v9fs_session_info *v9ses, struct p9_fid *fid, - struct super_block *sb, int new) -{ - struct p9_stat_dotl *st = NULL; - struct inode *inode = NULL; - - st = p9_client_getattr_dotl(fid, P9_STATS_BASIC | P9_STATS_GEN); - if (IS_ERR(st)) - return ERR_CAST(st); - - inode = v9fs_qid_iget_dotl(sb, &st->qid, fid, st); - - kfree(st); - return inode; -} - struct dotl_openflag_map { int open_flag; int dotl_flag; @@ -261,7 +246,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry, p9_debug(P9_DEBUG_VFS, "p9_client_walk failed %d\n", err); goto out; } - inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); + inode = v9fs_fid_iget_dotl(dir->i_sb, fid); if (IS_ERR(inode)) { err = PTR_ERR(inode); p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", err); @@ -356,7 +341,7 @@ static int v9fs_vfs_mkdir_dotl(struct mnt_idmap *idmap, } /* instantiate inode and assign the unopened fid to the dentry */ - inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); + inode = v9fs_fid_iget_dotl(dir->i_sb, fid); if (IS_ERR(inode)) { err = PTR_ERR(inode); p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", @@ -793,7 +778,7 @@ v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir, err); goto error; } - inode = v9fs_get_new_inode_from_fid(v9ses, fid, dir->i_sb); + inode = v9fs_fid_iget_dotl(dir->i_sb, fid); if (IS_ERR(inode)) { err = PTR_ERR(inode); p9_debug(P9_DEBUG_VFS, "inode creation failed %d\n", diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 8d14cc0b3916..6d9a98c57185 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c @@ -139,7 +139,7 @@ static struct dentry *v9fs_mount(struct file_system_type *fs_type, int flags, else sb->s_d_op = &v9fs_dentry_operations; - inode = v9fs_get_new_inode_from_fid(v9ses, fid, sb); + inode = v9fs_get_inode_from_fid(v9ses, fid, sb); if (IS_ERR(inode)) { retval = PTR_ERR(inode); goto release_sb;