Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2103086iob; Fri, 20 May 2022 01:58:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxPck/t4eoVOXiv2gykw8Bl8RJI4fGSMpeU41Tb/c0qLiXlSHkIMBqyNk3tyfevoNDr1j7P X-Received: by 2002:a05:6402:e99:b0:41d:11f2:85e0 with SMTP id h25-20020a0564020e9900b0041d11f285e0mr9520376eda.339.1653037105538; Fri, 20 May 2022 01:58:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653037105; cv=none; d=google.com; s=arc-20160816; b=OJ24RtCS/QUxgAtyu24/LxzpZnLICUKoZ5qW269KJlSNwl3AYJt8hO5OB+x0/Yh+Jk sPY0AwngiRne0CZFoKUDEac65m9Th122m1q0UoAjn+ZTKM48iN7At72adg2eDybeJ4V1 FO4PVhHK6AUheviGjLDUeOrT0woyOM1ucF/gRsK7kHiuyG/uJvQl5Y80jP3gtCyzmZ+C SzUNRd2X7kGatBqCB407js2FwnwptYjOY/t1DKX2xosLsnYYU9ArsznV+hs6/s8rh+GD cqiqPSsNq0XiAWpDFUWEJLY/9WDMBVu7Nfd2CHSdmMFiwn7m2o8c54pOEvt1JlDMt9NW zEHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=tfUqL2hAQiwlZtQZKTSFdFDIUiwxRK4bfglUJckElMI=; b=MsxJEsMg60RTlZ5TeM0LEMh07sRerWZyH4huKCOvY6bLgR4zhwINQDR74BwC38Zpku GWQ4j99nnBKQVYVPGg8MqTonHdruvb8xwge+iKEXecF0p/ihHLIFOzpHgjffEndupHVC U3MZcl0ECuYHs01vhD5BRRZz4H1GWfrlfxnqIolTp7c5GewIv461qcLzYlQ0kS/e1PbT FvfUBTKhuquZirIsy9xOmaD238R5g7lgWfhC/RW5j/l+bKP907Qj161YzxYq4I6cmwBs GBEbRp1Ozmy81HEgqa9JEEBmsES3wP+IufBhxArAM5nxfEiFWx9rKng0B2MOwh614XGC ECtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=BLtxyBSi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w17-20020a056402269100b0042ab724c55esi9267982edd.83.2022.05.20.01.57.58; Fri, 20 May 2022 01:58:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=BLtxyBSi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236152AbiESJjT (ORCPT + 99 others); Thu, 19 May 2022 05:39:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236119AbiESJjR (ORCPT ); Thu, 19 May 2022 05:39:17 -0400 Received: from mail-ej1-x62d.google.com (mail-ej1-x62d.google.com [IPv6:2a00:1450:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF972793B6 for ; Thu, 19 May 2022 02:39:14 -0700 (PDT) Received: by mail-ej1-x62d.google.com with SMTP id i19so8755474eja.11 for ; Thu, 19 May 2022 02:39:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=tfUqL2hAQiwlZtQZKTSFdFDIUiwxRK4bfglUJckElMI=; b=BLtxyBSiFUiwliLEOyyyxg5U0ZrvialfgDzdK2PCV0do10BmtrOaky25bKhouRiohT TmNQPmcSduvNchV8buKxviiu2y3q8C7ic7/goOQtJbz95Lgi9+vh30wJC9oAR0rdKngr aZMhCLcsqf9f1H5aINm542hl6S+Ed9B1/DN7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=tfUqL2hAQiwlZtQZKTSFdFDIUiwxRK4bfglUJckElMI=; b=H7X998aQUJZ+aebWDirDV7aUZ2BnK3NiuWNO53Jqi/Z9N+rNpIQqXkKf1Zivpfx5Lr Ss+3oB3tlFl7+om+io0kDyq8AKDWyJgAXA0WrpGxrsqekDCGAOETj7wIh1sarJCn0reu 41H14+yYQCcVGl+HhHJGcf6f2ZHdt9Hw3LPlkcjalJURoBF4V993Sm6X4jV1x6qh0HZy 9H7n1CiZXEBEaDBMT5EKSrY8dYRE6+le+bj/QOOUrQOQc3FsMaFRyCixHK9m01MOiwnO k0r1NxCmUd2CF/J1L2qaEfrRvLqP8MSKCMs98I0fB9n4PRFUfcdOUsn0TDMe5wHro5DT 72OQ== X-Gm-Message-State: AOAM5318QPO9SENRJYsYU4sOJ11WcF8TNB4DdwL7pmoCFZA4YaRr+QTR w2ZlrZuvoP3b3GdqrYhmDmd1tur1LCCMyH8e6AkVv1uJziBerDy3 X-Received: by 2002:a17:907:6e0f:b0:6fe:382a:6657 with SMTP id sd15-20020a1709076e0f00b006fe382a6657mr3345940ejc.192.1652953153454; Thu, 19 May 2022 02:39:13 -0700 (PDT) MIME-Version: 1.0 References: <20220517100744.26849-1-dharamhans87@gmail.com> In-Reply-To: <20220517100744.26849-1-dharamhans87@gmail.com> From: Miklos Szeredi Date: Thu, 19 May 2022 11:39:01 +0200 Message-ID: Subject: Re: [PATCH v5 0/3] FUSE: Implement atomic lookup + open/create To: Dharmendra Singh Cc: Vivek Goyal , linux-fsdevel@vger.kernel.org, fuse-devel , linux-kernel@vger.kernel.org, Bernd Schubert Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 On Tue, 17 May 2022 at 12:08, Dharmendra Singh wrote: > > In FUSE, as of now, uncached lookups are expensive over the wire. > E.g additional latencies and stressing (meta data) servers from > thousands of clients. These lookup calls possibly can be avoided > in some cases. Incoming three patches address this issue. > > > Fist patch handles the case where we are creating a file with O_CREAT. > Before we go for file creation, we do a lookup on the file which is most > likely non-existent. After this lookup is done, we again go into libfuse > to create file. Such lookups where file is most likely non-existent, can > be avoided. I'd really like to see a bit wider picture... We have several cases, first of all let's look at plain O_CREAT without O_EXCL (assume that there were no changes since the last lookup for simplicity): [not cached, negative] ->atomic_open() LOOKUP CREATE [not cached, positive] ->atomic_open() LOOKUP ->open() OPEN [cached, negative, validity timeout not expired] ->d_revalidate() return 1 ->atomic_open() CREATE [cached, negative, validity timeout expired] ->d_revalidate() return 0 ->atomic_open() LOOKUP CREATE [cached, positive, validity timeout not expired] ->d_revalidate() return 1 ->open() OPEN [cached, positive, validity timeout expired] ->d_revalidate() LOOKUP return 1 ->open() OPEN (Caveat emptor: I'm just looking at the code and haven't actually tested what happens.) Apparently in all of these cases we are doing at least one request, so it would make sense to make them uniform: [not cached] ->atomic_open() CREATE_EXT [cached] ->d_revalidate() return 0 ->atomic_open() CREATE_EXT Similarly we can look at the current O_CREAT | O_EXCL cases: [not cached, negative] ->atomic_open() LOOKUP CREATE [not cached, positive] ->atomic_open() LOOKUP return -EEXIST [cached, negative] ->d_revalidate() return 0 (see LOOKUP_EXCL check) ->atomic_open() LOOKUP CREATE [cached, positive] ->d_revalidate() LOOKUP return 1 return -EEXIST Again we are doing at least one request, so we can unconditionally replace them with CREATE_EXT like the non-O_EXCL case. > > Second patch handles the case where we open first time a file/dir > but do a lookup first on it. After lookup is performed we make another > call into libfuse to open the file. Now these two separate calls into > libfuse can be combined and performed as a single call into libfuse. And here's my analysis: [not cached, negative] ->lookup() LOOKUP return -ENOENT [not cached, positive] ->lookup() LOOKUP ->open() OPEN [cached, negative, validity timeout not expired] ->d_revalidate() return 1 return -ENOENT [cached, negative, validity timeout expired] ->d_revalidate() return 0 ->atomic_open() LOOKUP return -ENOENT [cached, positive, validity timeout not expired] ->d_revalidate() return 1 ->open() OPEN [cached, positive, validity timeout expired] ->d_revalidate() LOOKUP return 1 ->open() OPEN There's one case were no request is sent: a valid cached negative dentry. Possibly we can also make this uniform, e.g.: [not cached] ->atomic_open() OPEN_ATOMIC [cached, negative, validity timeout not expired] ->d_revalidate() return 1 return -ENOENT [cached, negative, validity timeout expired] ->d_revalidate() return 0 ->atomic_open() OPEN_ATOMIC [cached, positive] ->d_revalidate() return 0 ->atomic_open() OPEN_ATOMIC It may even make the code simpler to clearly separate the cases where the atomic variants are supported and when not. I'd also consider merging CREATE_EXT into OPEN_ATOMIC, since a filesystem implementing one will highly likely want to implement the other as well. Thanks, Miklos