Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp191855lfo; Tue, 17 May 2022 21:54:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWVPQ0H6QzGmJ1jdAHh7XpHjDmYGLGu+Oi8v/bQ99+s/AGWkiqmJKvtfwd++EM5DGYAXUE X-Received: by 2002:a17:902:e94e:b0:15b:22a7:f593 with SMTP id b14-20020a170902e94e00b0015b22a7f593mr25373765pll.148.1652849656923; Tue, 17 May 2022 21:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652849656; cv=none; d=google.com; s=arc-20160816; b=Nib8BXQr9TOSyQ10j2sbzzgl4hrDHTqkdZCz9UZDQ1snP+bHtRsX1zouXeTO4ZjXFr Fr4QJDu1HF46i/roncNdix3enKS73MZ9CNRiUQDaqFqFmIBO3l9mdO408uQgU5kD7IO9 TsIDU4bzTo/Wm0icAREQTya3BsVEVgTpQQBl6NeoJZXEh+2AEdL764j3/3NUEMci5zlL NI4ju5mf1pPuMmToBw6zLOayEoEjpk2AmNhwrp/UYEQpjaLTEyC/P5tPLA8uqcz+aFeO dtf6x1FR4Yc7DDqd3IgLrSb7/z3S4aRvMNb7GQvR+fdRBC3aHIKd7nQiacTstz4Ffrjp YLNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CZekkTwrC4S+/YZo062E5YXgbQ0lRlxuhi1puw/bt/M=; b=NmqK+dnnpZX4SGUYTmJsYpfq+FlVcFyFuPSGEaVbTcrjbPs/7Vbuwr3f+HWkceHPLi iZ7G7y/hdhqGWGtyftpkr/xHMaMVGv01s7lyVJWxliRp6aNi6wgJYgpjNU7wRQZf9a/G 0tqMbMon76+j1ytBOVnhEDIHgQODhk6OFMelxBTWGplYEBiWDgBnnaMEKcfeMQVqaHEi KBv/g2t7vs/Mzs9sJzuygcppLU2B3/CiThxvktR19CLgZfutE44XibE9mAmsgZfpel2Z TQr8fxWRRjhlL86CerME6kfSjCpawlMgsG8SRBaDy50mtSPtATvYma/+rMH8xIPAKmcV SsVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uTu+DhNs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k5-20020a654345000000b003ab19fb15f1si1213287pgq.382.2022.05.17.21.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uTu+DhNs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 11CD613FD70; Tue, 17 May 2022 21:03:55 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349140AbiEQOgs (ORCPT + 99 others); Tue, 17 May 2022 10:36:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349131AbiEQOgp (ORCPT ); Tue, 17 May 2022 10:36:45 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72AC04FC7E; Tue, 17 May 2022 07:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CZekkTwrC4S+/YZo062E5YXgbQ0lRlxuhi1puw/bt/M=; b=uTu+DhNslWz8qWcmVmfH54N8KF wBUcjSpcSJ2nJHiPkW7OMlvxTG/p7GEThEEHmIvejja/Th7nfN9SgZs00QOlQM9lj+Afr/XBUlo9R NrTdcBD6HaKEn4+/erscw4J7/nD/1qbABGbfPcXEEHrYgWpC05pJYW4yylOjsTLWa0bEYrIzJQo0j VUNXn4UnOlD/Q6uzKfMD5D0zfW6v/HOp6ZKwl4bfC1jArn8OIVR7L/zd15dOZ8Xp32hfTMdhGXBVc eqd2lhtWc8OhEElbhDSM0FafInhFphzZrN3tEQldNOPtBzY0xKcDd66gODXEYjQfYUyYdLqn8zXDV q6Wf+5IQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nqyJ9-00Ave3-IJ; Tue, 17 May 2022 14:36:19 +0000 Date: Tue, 17 May 2022 15:36:19 +0100 From: Matthew Wilcox To: Xiubo Li Cc: jlayton@kernel.org, viro@zeniv.linux.org.uk, idryomov@gmail.com, vshankar@redhat.com, ceph-devel@vger.kernel.org, dchinner@redhat.com, hch@lst.de, arnd@arndb.de, mcgrof@kernel.org, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot Subject: Re: [PATCH v3 2/2] ceph: wait the first reply of inflight async unlink Message-ID: References: <20220517125549.148429-1-xiubli@redhat.com> <20220517125549.148429-3-xiubli@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220517125549.148429-3-xiubli@redhat.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,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, May 17, 2022 at 08:55:49PM +0800, Xiubo Li wrote: > +int ceph_wait_on_conflict_unlink(struct dentry *dentry) > +{ > + struct ceph_fs_client *fsc = ceph_sb_to_client(dentry->d_sb); > + struct dentry *pdentry = dentry->d_parent; > + struct dentry *udentry, *found = NULL; > + struct ceph_dentry_info *di; > + struct qstr dname; > + u32 hash = dentry->d_name.hash; > + int err; > + > + dname.name = dentry->d_name.name; > + dname.len = dentry->d_name.len; > + > + rcu_read_lock(); > + hash_for_each_possible_rcu(fsc->async_unlink_conflict, di, > + hnode, hash) { > + udentry = di->dentry; > + > + spin_lock(&udentry->d_lock); > + if (udentry->d_name.hash != hash) > + goto next; > + if (unlikely(udentry->d_parent != pdentry)) > + goto next; > + if (!hash_hashed(&di->hnode)) > + goto next; > + > + if (!test_bit(CEPH_DENTRY_ASYNC_UNLINK_BIT, &di->flags)) > + pr_warn("%s dentry %p:%pd async unlink bit is not set\n", > + __func__, dentry, dentry); > + > + if (d_compare(pdentry, udentry, &dname)) > + goto next; > + > + spin_unlock(&udentry->d_lock); > + found = dget(udentry); > + break; > +next: > + spin_unlock(&udentry->d_lock); > + } > + rcu_read_unlock(); > + > + if (likely(!found)) > + return 0; > + > + dout("%s dentry %p:%pd conflict with old %p:%pd\n", __func__, > + dentry, dentry, found, found); > + > + err = wait_on_bit(&di->flags, CEPH_DENTRY_ASYNC_UNLINK_BIT, > + TASK_INTERRUPTIBLE); Do you really want to use TASK_INTERRUPTIBLE here? If the window is resized and you get a SIGWINCH, or a timer goes off and you get a SIGALRM, you want to return -EINTR? I would suggest that TASK_KILLABLE is probably the semantics that you want.