Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5663285ybh; Wed, 7 Aug 2019 09:23:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRJRjoVGuRHDVT+2HDKKU/MYBXX7cmHES469VoE4hkoZVWX68fU21wpEXYfAlYw1U33brg X-Received: by 2002:a17:902:9a04:: with SMTP id v4mr8628976plp.95.1565194993803; Wed, 07 Aug 2019 09:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565194993; cv=none; d=google.com; s=arc-20160816; b=g3MOgSS3JuSQ7Q0C1fLTZ65vb0AuARPW+lTyeEZhaT5lEQz8wQKnS8IefREj+5Ta25 T7w6qMWPp/3mzvyBbkpHwdFBZVhkhB9h4u0H79whw9mOdDuTPOs/UGJwLLMRl9djrJW4 GLUvrCJf3mPue9cGqIAf/yPMOU7Hcnc2ZfjTIJiha0v+h0y+9brZRr8YEWYjovQrCqwv hfgEw2BnCF+O9OVcNoQV2bDY2klYXy759jWTBENGQbGJPgW8K4t1t8PWl3okoklkn4LC K+1yetDv0GobXZaDrRe/GBMYL37q2Gjpl7qSoWzSFuV+qOo0NWnZiAZbC9OzjXjBkjH4 6VEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=etQlopmAXXFT6P3n85R01TP+gcZ4GAGMJbeHijBoSUI=; b=EBKWRYhl94m/d2Hz8m456uWC0OWC3WOXHFetPkYwnIBFokuYIepoYfuKQyk/ymKWSh A1OQJRNIus91MRvRL18TTZHfOxxldITywAQRTN2ddVdBFeDjX7EZmsyoWgNyTJBKx87A X217GbXUwlRDjCzXUCTfd0WKARCtnTcolA/bODb3RUpNgw4CKFf0KW9v7DPbR7XO9uJD LZLCF7oQEhqki7MlpRQ06hU18r29ZsmUTmUhu8p/c2e7fycvWgKUJFOAf5KFkGJYtCAl Hm7cRLAba5lAK4pVbf/tug2jiBQ9ef2Z/znq782riNvu5TrwHU4ICD9f3Fu5qlM7qvSX TO1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si36244985pgh.434.2019.08.07.09.22.58; Wed, 07 Aug 2019 09:23:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388929AbfHGQIo (ORCPT + 99 others); Wed, 7 Aug 2019 12:08:44 -0400 Received: from fieldses.org ([173.255.197.46]:51756 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727213AbfHGQIo (ORCPT ); Wed, 7 Aug 2019 12:08:44 -0400 Received: by fieldses.org (Postfix, from userid 2815) id 427683F5; Wed, 7 Aug 2019 12:08:43 -0400 (EDT) Date: Wed, 7 Aug 2019 12:08:43 -0400 From: "J. Bruce Fields" To: Olga Kornievskaia Cc: "J. Bruce Fields" , linux-nfs Subject: Re: [PATCH v4 5/8] NFSD check stateids against copy stateids Message-ID: <20190807160843.GD24728@fieldses.org> References: <20190731215118.GA13311@parsley.fieldses.org> <20190801151239.GC17654@fieldses.org> <20190801181158.GC19461@fieldses.org> <20190801193654.GA12211@parsley.fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Aug 07, 2019 at 12:02:40PM -0400, Olga Kornievskaia wrote: > On Thu, Aug 1, 2019 at 3:36 PM J. Bruce Fields wrote: > > > > On Thu, Aug 01, 2019 at 02:24:04PM -0400, Olga Kornievskaia wrote: > > > i was just looking at close_lru and delegation_lru but I guess that's > > > not a list of delegation or open stateids but rather some complex of > > > not deleting the stateid right away but moving it to nfs4_ol_stateid > > > and the list on the nfsd_net. Are you looking for something similar > > > for the copy_notify state or can I just keep a global list of the > > > nfs4_client and add and delete of that (not move to the delete later)? > > > > A global list seems like it should work if the locking's OK. > > I'm having issues taking a reference on a parent stateid and being > able to clean it. Let me try to explain. With other stateid parent relationships I believe what we do is: instead of the child taking a reference on the parent, we ensure that the child is destroyed, and that nobody can be holding a pointer to it, before we destroy the parent. --b. > Since I take a reference on the stateid, then during what would have > been the last put (due to say a close operation), stateid isn't > released. Now that stateid is sticking around. I personally would have > liked on what would have been a close and release of the stateid to > release the copy notify state(s) (which was being done before but > having a reference makes it hard? i want to count number of copy > notify states and if then somehow if the num_copies-1 is going to make > it 0, then decrement by num_copies (and the normal -1) but if it's not > the last reference then it shouldn't be decremented. > > Now say no fancy logic happens on close so we have these stateids left > over . What to do on unmount? It will error with err_client_busy since > there are non-zero copy notify states and only after a lease period it > will release the resources (when the close of the file should have > removed any copy notify state)? > > Question: would it be acceptable to do something like this on freeing > of the parent stateid? > > @@ -896,8 +931,12 @@ static void block_delegations(struct knfsd_fh *fh) > might_lock(&clp->cl_lock); > > if (!refcount_dec_and_lock(&s->sc_count, &clp->cl_lock)) { > - wake_up_all(&close_wq); > - return; > + if (!refcount_sub_and_test_checked(s->sc_cp_list_size, > + &s->sc_count)) { > + refcount_add_checked(s->sc_cp_list_size, &s->sc_count); > + wake_up_all(&close_wq); > + return; > + } > } > idr_remove(&clp->cl_stateids, s->sc_stateid.si_opaque.so_id); > spin_unlock(&clp->cl_lock); > > then free the copy notify stateids associated with stateid. > > Laundromat would still be checking the copy_notify stateids for > anything that's been not active for a while (but not closed). > > > > > > > > > --b.