Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2754930ybl; Thu, 29 Aug 2019 12:24:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwe6EIwe3Xat8PKYYexcCod/SZ5O80uyn9tvtmVnDenCoaklAlFQpBWfoGoga6xQGpuGHm0 X-Received: by 2002:a17:90a:32a3:: with SMTP id l32mr11974580pjb.14.1567106697819; Thu, 29 Aug 2019 12:24:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567106697; cv=none; d=google.com; s=arc-20160816; b=qKP8UwykR2eVUNNgcrhoAm0OqrwpgCw+pxhSMZQ2yGoSg3EX1l8o92wVw3hR1kS3j2 Dy90zyvjHxEu/z9j65bhDEG/o5KM8XRBvNTz8tlBmpa4hDAbK3K5h0aNA5nDe1o1OS3A cA6qSokCPMaH76VWmQ6K9J+GL8z+vJ1Zdtp6WQdQA7cbGecs/hgiUokLZP6DI269rvtG Xf9oYbGxhxnE8xkA9R7fXeATzaAjfPZUtNx9utiBNepq0izI0B8nLNDxnXUD8pyFKDnN B+rhxx7ur8p1SUYgQ4nb/9PvpnFpRet6PxYuQ+ELimtzSdodDDPWzSzEelfl8tu7Wxx9 6MwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=TX7nZAwHLhviw3X+bn/byWo3/tYGyaYnRaK2qp7/2fk=; b=iHI30JGqWHZv6WeLwDFOL9eoLQ2OxP5/86xvYRY6fKI89Pq4P7PAs2/RdcxyTmGJNd 9yRAJVJYSUpNaRbftS2nlL/KZbUpwIAoHP0pwO0BL+KaxUnWSGN5FbwegQ2MqJYTv40w ZOmlYI/IKXQFSct9LuOXw3zjVp18QOL1hn0ajaX5LVrOg+EcD5Vmuj/veIc7Ikzaj1e1 GgPkav8wKjCT+SzFF1hnvx2xITzOdhvbk/h5Tbf41QpKSjONTvVkirnIvF55C2SXMr7c wmTScQB9xy5Lw0Je55h985r78ZNreCQ8G9SUhf81jOVqQYzbXkU0BOgsPwCE7Z9M0RKd lVKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KFmONNT1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c130si3540881pfc.103.2019.08.29.12.24.31; Thu, 29 Aug 2019 12:24:57 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KFmONNT1; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728143AbfH2TXz (ORCPT + 99 others); Thu, 29 Aug 2019 15:23:55 -0400 Received: from mail-vs1-f65.google.com ([209.85.217.65]:40334 "EHLO mail-vs1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727525AbfH2TXz (ORCPT ); Thu, 29 Aug 2019 15:23:55 -0400 Received: by mail-vs1-f65.google.com with SMTP id i128so3189621vsc.7 for ; Thu, 29 Aug 2019 12:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TX7nZAwHLhviw3X+bn/byWo3/tYGyaYnRaK2qp7/2fk=; b=KFmONNT1pLqKJPKkk2/8g1QaCduL/jNaAWWekJYRRkuNZpGg1jCbU4YvmwaQQIMWIs UzkgeAFYgOGpPtgEXZKy3M+05noxWGKDOe+qxe5nKTK25qYz3TzxRbArOYqt7Mm7GUUS qTz+tmoSE6ZxGXTGtt1VoevkubJVIBVL6wtm34vmQ+//3J1Ye5MucT422UgOAQvd8uNy EorER+DW+dyf5j1F8cbZdeGe/FRVCHZYViIcYRvu9pToNM8iekHd3Yw0E1tXBK9QKZok oL6kLsjchIRbWYX/BfBiCluA6FhkCXxj6A2fe8BwPDTc63pz28gvDMj7W30IA+0jijR2 tVNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TX7nZAwHLhviw3X+bn/byWo3/tYGyaYnRaK2qp7/2fk=; b=UN5edtMfbYDoDQN4vsUC/cr5/eW78aGfQhruMJ+KmNXsBl78apdPvjSO9BPJb2WM9+ daKz2ipv62cGiu603GLtWBPimSa/65HOgib1VeQp5j0QEAPBV6jyil1uNd4NESmoF4/G M34J9OwXJXX7J7Q2GqOwPFM+P0ZqgN903tcgA0kxM7uq4Ytce6nQCsH5fOfHXbobTi4Y FW3BEfM9aFlADNSKqs5Rw9a8OCPQGlYiBE2EnkxW4dV8dE7TMy/Juq2MhaF+NjV8rERo sq2x+0GQEXcZDC/3+FqdncFDEAPg/6LlIVKS7ejUCkU1VL00zlfYmj0cbq1GiPe0GBMp bahQ== X-Gm-Message-State: APjAAAWxZCWd7wxaxd5cHnO9hcjy7U+VLmEwfqOng5af6vDSisXnnw2d 2UP32qCrk+XiPhJTUDYvWKnAvHFtPzpMLzR+OD0= X-Received: by 2002:a67:10c6:: with SMTP id 189mr6512496vsq.194.1567106634205; Thu, 29 Aug 2019 12:23:54 -0700 (PDT) MIME-Version: 1.0 References: <20190808201848.36640-1-olga.kornievskaia@gmail.com> <20190808201848.36640-6-olga.kornievskaia@gmail.com> <20190812200019.GB29812@parsley.fieldses.org> In-Reply-To: From: Olga Kornievskaia Date: Thu, 29 Aug 2019 15:23:43 -0400 Message-ID: Subject: Re: [PATCH v5 5/9] NFSD add COPY_NOTIFY operation To: "J. Bruce Fields" Cc: linux-nfs Content-Type: text/plain; charset="UTF-8" Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Aug 14, 2019 at 11:05 AM Olga Kornievskaia wrote: > > On Tue, Aug 13, 2019 at 1:57 PM Olga Kornievskaia > wrote: > > > > On Mon, Aug 12, 2019 at 4:00 PM J. Bruce Fields wrote: > > > > > > On Mon, Aug 12, 2019 at 03:16:47PM -0400, Olga Kornievskaia wrote: > > > > On Mon, Aug 12, 2019 at 12:19 PM Olga Kornievskaia > > > > wrote: > > > > > While this passes my testing, in theory this allows for the race that > > > > > we get the copy notify size but then offload_cancel arrive and change > > > > > the value. Then refcount_sub_and test_check would have an incorrect > > > > > value (can subtract larger than an actual reference count). I have no > > > > > solution for that as there is no refcount_sub_and_lock() that will > > > > > allow to decrement by a multiple under a lock. Thoughts? > > > > > > > > I tried not to use the client's cl_lock but instead use a specific > > > > lock to protect the copy notifies stateid on the stateid list. But > > > > since stateid's reference counter (sc_count) is protected by it, I > > > > think by getting rid of the special lock and using cl_lock will solve > > > > the problem of coordinating access between the sc_count and the > > > > copy_notify stateid list. Are the any problems with using such a big > > > > lock? > > > > > > Probably not. But it can be confusing when a single lock is used for > > > several different things. A comment explaining why you need it might > > > help. > > > > While holding the client's cl_lock to manipulate the list of copy > > notify stateids solves the refcount problem. It generates a different > > problem for the laundromat thread. There, client list is traversed > > already holding the cl_lock, so I can't call routines to free > > copy_notify stateid because in turn it calls nfs4_put_stid() which > > wants to take the cl_lock. Putting the copy_notify stateid on the > > reaplist and then I lose a pointer to the client structure that I need > > to take the lock. Then it seems the nfs4_cpntf_state structure would > > need to keep a pointer to the client structure but then I get a > > problem of making sure the nfs4_client structure isn't going away and > > because it even a bigger mess. > > > > I think I need to remove the code in the laundromat that looks for the > > not referenced copy_notifies stateid and just rely on cleaning on the > > removal of the stateid (basically what I originally had). Or I need to > > rely on the client to always send FREE_STATEID. I don't see other > > options, do you? > > Ignore this Bruce. Trond gave me a good idea and gets me unstuck. Hi Bruce, I'm stuck again. The idea that Trond gave me is to instead of storing the pointer to the stateid, (copy) store the stateid_t structure itself and then use it to look it up the appropriate nfs4_stid. The problem with that is when nfsd4_lookup_stateid() is called it takes is a compound state (cstate) which has a client pointer and during the lookup it's verified that the client looking up the stateid is the same that generate the stateid which is not the case with copy offload. I tried also saving a cl_clientid and using that to lookup the nfs4_client that's needed for the stateid lookup but I'm not sure that's possible. lookup_clientid() calls find_client_in_id_table() and always passes "false" for sessions args. Original client has minor version 2 and then the check if (clp->minor_versions != sessions) fails. I don't understand what this logic is suppose to check. Should I be writing special version of the lookup_clientid that ignores that check (when called in the path of the copy_notify verification)? Or any other ideas of how to get passed this would be appreciated it. Thank you. > > > > > > > > > --b.