Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp3521979pxb; Mon, 4 Apr 2022 19:46:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNaaGoykP0V3S7TEbRTTW5wzKOgIHY1TYlYwopZpWisenQf4Ls3ymL9JkQayn3ZlPjGafz X-Received: by 2002:a17:90a:cc0d:b0:1ca:c47f:a8f6 with SMTP id b13-20020a17090acc0d00b001cac47fa8f6mr1463183pju.1.1649126800108; Mon, 04 Apr 2022 19:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649126800; cv=none; d=google.com; s=arc-20160816; b=khpMesvGy+FusMe1Bto2VVxZUgoQKqliH8vr+90OaeX397siyxAGZulYmXMM02qiGK t5/cvMWZufuDiZDfirL+kOGAiMIHC1x5OBk87drWwyOYqtZSiKObvYhKrjHO9akVZXS2 +bmMfE6nBEbybkn0iVR5sr/ZQrmdMyyWY0nllclTF81GpmjXJgebd8/2p/AOPDBp0PdV r2Z8zqGm6ZVZjLTI5VWLDuR/HbmhUUkbzyfwhrbuwmIgDGFJDQI9qcU4mCpLR2LnxflC JvoBAjZp/oUrej1XAsoWX3NUnmuZSAiTzx/+P6oXEOW11elgPzEYIeEM8aHU/iZoB80Y MxzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=SetFAKutclE/yyKTkciHTa9dxUVAQelXK5rEur9ld6Y=; b=PCZ8BG1qKdh70PmntGpCSSSpTcnHWeFHTK8TelY+7cuL98EzPcAN8gtJllKMDj4lQz w7paC7Vmh0tgFq3CvVt+ixoI0XRMGAy1jP6mvfUHNpggSXg1osbxGM1mNRx3CcMm/Xk2 IE7HbszWZAEg4X8eF+0yqBKCOeh1QwwRQxtSSCxFTpMS5QhNMmFhNHOU41oEdusLchfw fVWwNEO03wcPXs3tvtRigYnqNAVgZTB/0WLlnmi0lRmoyb48MKZOLsqnRvFD2AEqZz5y tlsoY1GfvM/MZ6C7z3VxaPeIIDjmLv5C8ML0pMBjy9zVkMXGWBc9A/eCw5mh7a4HdlS8 GeGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=4LpuhqYg; dkim=pass header.i=@codewreck.org header.s=2 header.b=y7AyGgdz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id y16-20020a1709027c9000b001569aeb7516si5580824pll.543.2022.04.04.19.46.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Apr 2022 19:46:40 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@codewreck.org header.s=2 header.b=4LpuhqYg; dkim=pass header.i=@codewreck.org header.s=2 header.b=y7AyGgdz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=codewreck.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DF6C13EC8AD; Mon, 4 Apr 2022 18:09:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235504AbiDAXNW (ORCPT + 99 others); Fri, 1 Apr 2022 19:13:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235008AbiDAXNV (ORCPT ); Fri, 1 Apr 2022 19:13:21 -0400 Received: from nautica.notk.org (nautica.notk.org [91.121.71.147]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E9861AE231; Fri, 1 Apr 2022 16:11:29 -0700 (PDT) Received: by nautica.notk.org (Postfix, from userid 108) id 3061BC01E; Sat, 2 Apr 2022 01:11:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1648854688; bh=SetFAKutclE/yyKTkciHTa9dxUVAQelXK5rEur9ld6Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=4LpuhqYg0JYGNwwdEcsJuxwlpKU9TfWtt6EuaItp0DiPKVZpLdyYG36HeVYeMDloj oBmuzUQX2VaLiVTfvIwa2tfJqNSwlxchSagqicC+xD9O9MovXh/F5xE1P9/prGYH/U /XstkEwVo3tcYdHurSeDePxxienJ4IktVZJG8JRn9V1T0hxWHBBFdELSuj+wQqB8EH zwT35Y82CaWe9fSkn27sp4jhs+kZ5uKrdHZUm4JisQh5F6v0Uh9i3+j50djyNE0Swu nyFthwX3L4XCUXamyindjatuucN99GMcDSLWVea4UpbAw3bCXyrg0nQZptx+xC5ZB3 +W+TFuNI/Fmsg== X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-2.0 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 autolearn=no autolearn_force=no version=3.4.6 Received: from odin.codewreck.org (localhost [127.0.0.1]) by nautica.notk.org (Postfix) with ESMTPS id E5B28C009; Sat, 2 Apr 2022 01:11:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=codewreck.org; s=2; t=1648854687; bh=SetFAKutclE/yyKTkciHTa9dxUVAQelXK5rEur9ld6Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=y7AyGgdzV9RIYAvdo+e71CeyXyd7OjgbOu+6jy5903aPxwQKeWDMwygxuze4Cj0JY rLgHWupoCxT2rLOccNXi4WipK9q1vufgQDHoZi307pgRgfiFnwyOdqMhdB0xoOyp8M ueZo/74TsW7C4T8WxuSoU1JOqVi9sOVf4htDVSoIMHRiyXjkpY5pauKCrgdC+pUV2i KBtGZhbhG/GOdyI0OIfTQx7NCZCMoLE0HWQWa/aVDSSr9OAgmIQ99D6zL+5qJ5VMsp ZVpqvC777v6leVvOz8bYs/5t2Jo9G00MpfMFstxfuRMSd5tW7wjuyvl+yAAm/JP6tt StnW9X+XJLe9A== Received: from localhost (odin.codewreck.org [local]) by odin.codewreck.org (OpenSMTPD) with ESMTPA id ad70e3e6; Fri, 1 Apr 2022 23:11:19 +0000 (UTC) Date: Sat, 2 Apr 2022 08:11:04 +0900 From: asmadeus@codewreck.org To: Christian Schoenebeck Cc: David Kahurani , davem@davemloft.net, ericvh@gmail.com, kuba@kernel.org, linux-kernel@vger.kernel.org, lucho@ionkov.net, netdev@vger.kernel.org, v9fs-developer@lists.sourceforge.net, David Howells , Greg Kurz Subject: Re: 9p fs-cache tests/benchmark (was: 9p fscache Duplicate cookie detected) Message-ID: References: <3791738.ukkqOL8KQD@silver> <1866935.Y7JIjT2MHT@silver> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1866935.Y7JIjT2MHT@silver> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christian Schoenebeck wrote on Fri, Apr 01, 2022 at 04:19:20PM +0200: > 4. v9fs_qid_iget_dotl [fs/9p/vfs_inode_dotl.c, 133]: > > v9fs_cache_inode_get_cookie(inode); > ^--- Called independent of function argument "new"'s value here > https://github.com/torvalds/linux/blob/e8b767f5e04097aaedcd6e06e2270f9fe5282696/fs/9p/vfs_inode_dotl.c#L133 uh, I'd have assumed either this call or the function to check v9ses->cache, but it doesn't look like either do... There's a nice compile-time static inline empty definition if FSCACHE is not compiled in, but that should -also- be a check at runtime based on the session struct. For your remark vs. the 'new' argument, it does depend on it: - new determines which check is used for iget5_locked. In the 'new' case, v9fs_test_new_inode_dotl always returns 0 so we always get a new inode. - if iget5_locked found an existing inode (i_state & I_NEW false) we return it. - at this point we're allocating a new inode, so we should initialize its cookie if it's on a fscache-enabled mount So that part looks OK to me. What isn't correct with qemu setting qid version is the non-new case's v9fs_test_inode_dotl, it'll consider the inode to be new if version changed so it would recreate new, different inodes with same inode number/cookie and I was sure that was the problem, but it looks like there's more to it from your reply below :( >> Well, at least that one is an easy fix: we just don't need this. >> It's the easiest way to reproduce but there are also harder to fix >> collisions, file systems only guarantee unicity for (fsid,inode >> number,version) which is usually bigger than 128 bits (although version >> is often 0), but version isn't exposed to userspace easily... >> What we'd want for unicity is handle from e.g. name_to_handle_at but >> that'd add overhead, wouldn't fit in qid path and not all fs are capable >> of providing one... The 9p protocol just doesn't want bigger handles >> than qid path. > > No bigger qid.path on 9p protocol level in future? Why? I have no idea about the "9p protocol" as a standard, nor who decides how that evolves -- I guess if we wanted to we could probably make a 9p2022.L without concerting much around, but I have no plan to do that... But if we do, I can probably add quite a few things to the list of things that might need to change :) That being said, this particular change of qid format is rather annoying. 9p2000.L basically just added new message types, so dissectors such as wireshark could barge in the middle of the tcp flow and more or less understand; modifying a basic type like this would require to either catch the TVERSION message or make new message types for everything that deals wth qids (auth/attach, walk, lopen, lcreate, mknod, getattr, readdir, mkdir... that's quite a few) So I think we're better off with the status quo here. >> And, err, looking at the qemu code >> >> qidp->version = stbuf->st_mtime ^ (stbuf->st_size << 8); >> >> so the qid is treated as "data version", >> but on kernel side we've treated it as inode version (i_version, see >> include/linux/iversion.h) >> >> (v9fs_test_inode_dotl checks the version is the same when comparing two >> inodes) so it will incorrectly identify two identical inodes as >> different. >> That will cause problems... >> Since you'll be faster than me could you try keeping it at 0 there? > > I tried with your suggested change on QEMU side: > > diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c > index a6d6b3f835..5d9be87758 100644 > --- a/hw/9pfs/9p.c > +++ b/hw/9pfs/9p.c > @@ -981,7 +981,7 @@ static int stat_to_qid(V9fsPDU *pdu, const struct stat *stbuf, V9fsQID *qidp) > memcpy(&qidp->path, &stbuf->st_ino, size); > } > > - qidp->version = stbuf->st_mtime ^ (stbuf->st_size << 8); > + qidp->version = 0; > qidp->type = 0; > if (S_ISDIR(stbuf->st_mode)) { > qidp->type |= P9_QID_TYPE_DIR; > > Unfortunately it did not make any difference for these 2 Linux kernel fs-cache > issues at least; still same errors, and same suboptimal performance. Thanks, I'll give it a try today or tomorrow, adding some trace when we create inodes might give a clue... -- Dominique