Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4881025ybi; Tue, 30 Jul 2019 09:44:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqweeihGCn8qZ8cnfp5yGf9j65ouq0O+WGa99OKAM0HmylDlgPmor+mN1Sinc2FN+mYClLMC X-Received: by 2002:a17:902:7894:: with SMTP id q20mr111945041pll.339.1564505073430; Tue, 30 Jul 2019 09:44:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564505073; cv=none; d=google.com; s=arc-20160816; b=r/0rhP+vGjo7XCvh4hbW/OthBveKEwRvRUW3yKc11BSc/XoKz95ecELldn11DpExGR r+MqxR21xLuOXl9l/bFSohq+tE6qEWOV1z4vNIOsCrXz6UVCpJUy+QgpJR91bYbkJGRV LW+2N4alRGC9if6B/FYOuCh5oFg80ZqHXs1mRJyHIU0hF90WAaZfY1Ab/cpMLUf5i1UO 8AK0G4WEOY9DuVXhkroyyRuWuhBqUSIsiqMZUiFbgqmWgrjzYyriU7SJ50sAPthtqbDF int4CqTdjZbomc0Uu2pRmxiF6aGulW+Dj2ZBse4dTJt8YPo4/ECJYzmQW/Hac5nR08Cj Bqgg== 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=pGsAEdIBa8dM1n5FtBHp/gcWSa/wDZg9ZBjzT/B9xUU=; b=h2RM8IwLmhlAEmhtSHS6PMVPz1fQ0P6ahYzvOD2W9mRIE+2i8DwFD+P8yTxGuq/j/5 ri6usAOigLgcVV4Q3Iwa+iN6U8I1PfAniZTBgLZI5lD5vg4BHFwo7sm6NoAPuiUXCz4W UZNTnPS9BfrEGgIymtpnrHKgZDlA2k5sxwAFZL/R0U7n9wG9KOWJ7tHhKTNBYCSsulDV FlqFRGL8g+a26FHK5CrDgWTzs3MJOZngyKxtZojCEq7uTL21JXlFht4UKPe46uxH2NLF tNrcCwfALYoT3zGZwh0pS8y/Mq83CEaIOXHd5z0chIr76aOIatrLAwAGJxdimtzIClEA p+NQ== 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 q14si30319228pgm.325.2019.07.30.09.44.19; Tue, 30 Jul 2019 09:44:33 -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 S1726840AbfG3Pz3 (ORCPT + 99 others); Tue, 30 Jul 2019 11:55:29 -0400 Received: from fieldses.org ([173.255.197.46]:41514 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726501AbfG3Pz3 (ORCPT ); Tue, 30 Jul 2019 11:55:29 -0400 Received: by fieldses.org (Postfix, from userid 2815) id B4A7BC56; Tue, 30 Jul 2019 11:55:28 -0400 (EDT) Date: Tue, 30 Jul 2019 11:55:28 -0400 From: "J. Bruce Fields" To: Olga Kornievskaia Cc: "J. Bruce Fields" , linux-nfs Subject: Re: [PATCH v4 4/8] NFSD add COPY_NOTIFY operation Message-ID: <20190730155528.GE31707@fieldses.org> References: <20190708192352.12614-1-olga.kornievskaia@gmail.com> <20190708192352.12614-5-olga.kornievskaia@gmail.com> <20190717230726.GA26801@fieldses.org> <20190723204537.GA19559@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 Tue, Jul 30, 2019 at 11:48:27AM -0400, Olga Kornievskaia wrote: > On Tue, Jul 23, 2019 at 4:46 PM J. Bruce Fields wrote: > > > > On Mon, Jul 22, 2019 at 04:17:44PM -0400, Olga Kornievskaia wrote: > > > Let me see if I understand your suspicion and ask for guidance how to > > > resolve it as perhaps I'm misusing the function. idr_alloc_cyclic() > > > keeps track of the structure of the 2nd arguments with a value it > > > returns. How do I initiate the structure with the value of the > > > function without knowing the value which can only be returned when I > > > call the function to add it to the list? what you are suggesting is to > > > somehow get the value for the new_id but not associate anything then > > > update the copy structure with that value and then call > > > idr_alloc_cyclic() (or something else) to create that association of > > > the new_id and the structure? I don't know how to do that. > > > > You could move the initialization under the s2s_cp_lock. But there's > > additional initialization that's done in the caller. > > I still don't understand what you are looking for here and why. I'm > following what the normal stid allocation does. There is no extra code > there to see if it initiated or not. nfs4_alloc_stid() calls > idr_alloc_cyclic() creates an association between the stid pointer and > at the time uninitialized nfs4_stid structure which is then filled in > with the return of the idr_alloc_cyclic(). That's exactly what the new > code is doing (well accept that i'll change it to store the > stateid_t). Yes, I'm a little worried about normal stid allocation too. It's got one extra safeguard because of the check for 0 sc_type in the lookup, I haven't yet convinced myself that's enough. The race I'm worried about is: one task does the idr allocation and drops locks. Before it has the chance to finish initializing the object, a second task looks it up in the idr and does something with it. It sees the not-yet-initialized fields. --b.