Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp580599pxv; Wed, 30 Jun 2021 12:24:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyurWj18hiSq+9mbCsbkmt0ujWCg0cggLQ465qXvst8mcVAS4kJLjlh3YRBe8zFewrDlwWg X-Received: by 2002:a92:7d08:: with SMTP id y8mr25129422ilc.43.1625081088832; Wed, 30 Jun 2021 12:24:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625081088; cv=none; d=google.com; s=arc-20160816; b=mRKm/ohH8NCqfbFrAKxSADH2ppK9LQg95BPK/bJKX4xAd7xOnwpTpuMjcop4tpZH6O yM5yVMj6g+nIS+FKfSWo51WH+N4qyzF9BcWqyihaAC4EZmuxvUF9c6MiaxcXAqF0xI2N 7pzGScyOKQyLCm0upqyH/EGJbyFoVN1y5TXy5K+jDB+kWciu+D/bGoKFmesK1oBaeS5r ZA4/J6DDmxbETdknzMtwlpuckRzaqkXQj2tOeVv25iUezmir0Nk75qR5iHUf5Qwn9rZd lQAuE0nNz6gw3Fledwtz4BLFb0x+ZxcrdXW5rxueFHZrPXPfgar7LXCM2e7A1WgOJu/B +l/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter; bh=9q09zb/a9pi+v9zGtqPXj4ZX8NE3dbNc6C0rG4tPJVQ=; b=SB2t85RsESJ0vbUJo/K87jD55js1npCpX2BgYidMUJKRHXlzpZDD9kNMUgqsUTYz95 lKfwzY6reNkP0dPAu66VpjkfvgD/lfWkSSrnmYeYiGx/0fv/A/c4qfrf47V/pN92li7V Xfg2CTr4Yy52rZZEAw9sCfWDKMVlTST4QYoKnzTct4VqbG3bm+v2c5QQRg8m4uMViYjB /etUodcP1S6qCgGUr0SM9g6xx14S0sBKCJVlgjlDqwlBupUnAzAqTGMKYQpce7nt/OS2 Ijm9sSJwCOTOhgm2vw87Zig5FnN17LELdg6A4rVULEh+sMaJnQokEl/dJnNTiXDznpmz yAog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=jhJSCGU8; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 d25si23257399iop.15.2021.06.30.12.24.35; Wed, 30 Jun 2021 12:24:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fieldses.org header.s=default header.b=jhJSCGU8; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233583AbhF3T1C (ORCPT + 99 others); Wed, 30 Jun 2021 15:27:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233536AbhF3T07 (ORCPT ); Wed, 30 Jun 2021 15:26:59 -0400 Received: from fieldses.org (fieldses.org [IPv6:2600:3c00:e000:2f7::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B976AC061756 for ; Wed, 30 Jun 2021 12:24:30 -0700 (PDT) Received: by fieldses.org (Postfix, from userid 2815) id C746A64B9; Wed, 30 Jun 2021 15:24:29 -0400 (EDT) DKIM-Filter: OpenDKIM Filter v2.11.0 fieldses.org C746A64B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fieldses.org; s=default; t=1625081069; bh=9q09zb/a9pi+v9zGtqPXj4ZX8NE3dbNc6C0rG4tPJVQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jhJSCGU8sY0vY/2R/JGgdPAd2Y77F95e1TDNK+0y2pRxA8hSWAApx4KN8VDEODVqH cBF5py6H0xienElZWC1ZrGnU1aZ4czUrf6YPUlaakH3cX7M+0iNSljDQEs2XClysOA g0RURsvsMOMuME1wPF9UtqBqm+4BA5BquVdmuTEs= Date: Wed, 30 Jun 2021 15:24:29 -0400 From: "J. Bruce Fields" To: dai.ngo@oracle.com Cc: chuck.lever@oracle.com, linux-nfs@vger.kernel.org Subject: Re: [PATCH RFC 1/1] nfsd: Initial implementation of NFSv4 Courteous Server Message-ID: <20210630192429.GH20229@fieldses.org> References: <20210603181438.109851-1-dai.ngo@oracle.com> <20210628202331.GC6776@fieldses.org> <9628be9d-2bfd-d036-2308-847cb4f1a14d@oracle.com> <20210630180527.GE20229@fieldses.org> <08caefcd-5271-8d44-326d-395399ff465c@oracle.com> <20210630185519.GG20229@fieldses.org> <08884534-931b-d828-0340-33c396674dd5@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <08884534-931b-d828-0340-33c396674dd5@oracle.com> User-Agent: Mutt/1.5.21 (2010-09-15) Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Jun 30, 2021 at 12:13:35PM -0700, dai.ngo@oracle.com wrote: > > On 6/30/21 11:55 AM, J. Bruce Fields wrote: > >On Wed, Jun 30, 2021 at 11:49:18AM -0700, dai.ngo@oracle.com wrote: > >>On 6/30/21 11:05 AM, J. Bruce Fields wrote: > >>>On Wed, Jun 30, 2021 at 10:51:27AM -0700, dai.ngo@oracle.com wrote: > >>>>>On 6/28/21 1:23 PM, J. Bruce Fields wrote: > >>>>>>where ->fl_expire_lock is a new lock callback with second > >>>>>>argument "check" > >>>>>>where: > >>>>>> > >>>>>>     check = 1 means: just check whether this lock could be freed > >>>>Why do we need this, is there a use case for it? can we just always try > >>>>to expire the lock and return success/fail? > >>>We can't expire the client while holding the flc_lock. And once we drop > >>>that lock we need to restart the loop. Clearly we can't do that every > >>>time. > >>> > >>>(So, my code was wrong, it should have been: > >>> > >>> > >>> if (fl->fl_lops->fl_expire_lock(fl, 1)) { > >>> spin_unlock(&ct->flc_lock); > >>> fl->fl_lops->fl_expire_locks(fl, 0); > >>> goto retry; > >>> } > >>> > >>>) > >>This is what I currently have: > >> > >>retry: > >> list_for_each_entry(fl, &ctx->flc_posix, fl_list) { > >> if (!posix_locks_conflict(request, fl)) > >> continue; > >> > >> if (fl->fl_lmops && fl->fl_lmops->lm_expire_lock) { > >> spin_unlock(&ctx->flc_lock); > >> ret = fl->fl_lmops->lm_expire_lock(fl, 0); > >> spin_lock(&ctx->flc_lock); > >> if (ret) > >> goto retry; > >We have to retry regardless of the return value. Once we've dropped > >flc_lock, it's not safe to continue trying to iterate through the list. > > Yes, thanks! > > > > >> } > >> > >> if (conflock) > >> locks_copy_conflock(conflock, fl); > >> > >>>But the 1 and 0 cases are starting to look pretty different; maybe they > >>>should be two different callbacks. > >>why the case of 1 (test only) is needed, who would use this call? > >We need to avoid dropping the spinlock in the case there are no clients > >to expire, otherwise we'll make no forward progress. > > I think we can remember the last checked file_lock and skip it: I doubt that works in the case there are multiple locks with lm_expire_lock set. If you really don't want another callback here, maybe you could set some kind of flag on the lock. At the time a client expires, you're going to have to walk all of its locks to see if anyone's waiting for them. At the same time maybe you could set an FL_EXPIRABLE flag on all those locks, and test for that here. If the network partition heals and the client comes back, you'd have to remember to clear that flag again. --b. > retry: > list_for_each_entry(fl, &ctx->flc_posix, fl_list) { > if (!posix_locks_conflict(request, fl)) > continue; > > if (checked_fl != fl && fl->fl_lmops && > fl->fl_lmops->lm_expire_lock) { > checked_fl = fl; > spin_unlock(&ctx->flc_lock); > fl->fl_lmops->lm_expire_lock(fl); > spin_lock(&ctx->flc_lock); > goto retry; > } > > if (conflock) > locks_copy_conflock(conflock, fl); > > -Dai > > > > >--b.