Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1132828pxj; Sat, 8 May 2021 08:31:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxp9ofkCt66yKjBUnGEuT/NrEubpnzMZKDe+7QLqLL/JKTZXurjwlHGB995A0K0Cn1yKx/M X-Received: by 2002:a6b:b28f:: with SMTP id b137mr11716522iof.194.1620487905432; Sat, 08 May 2021 08:31:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620487905; cv=none; d=google.com; s=arc-20160816; b=i8SLcZT7p/8f0RY+Sg/KT9gTlaT/8//+BMB04Ir2K7K9c+vshQXmcr67RVuLUXuvKe PE22/PCVrbgnU+idIruEC8QJBPg50WtDxxTbPEHasVoTCUlUA0b7zB5uKwlDrepiOZ6p zElRRX/o9e755H4nnyULoOutx/kJDCcOwt1hUO3CHaYFD21JElQNidq4VugIW3D1xWCq N+fBvw8omXKluUwda3640fxcaoX4xYshT2vH4Hb/4ORYCUY6KxsB6AvY534RBsCeq8sx gVjDZTTuOjDQbklLnhlMOAvlt9vCiLio6rfuz4uCK51b4UyxTaey2k/vo85YS+Ug1/PC RBjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=T80RW0N0f2bW+RbqzRU+sONErcUEsqlqhrSCovQJd4U=; b=Vt0cclAJu0aRvXUJf5E7L5Oel9R9jQOwdbt/8icE/5g/6CVIvhoN+mrrNPTfZEn2Mj Z50fihANbtnzsMi7xZDKwqCfBxOdjZYw/jMG76Sh4+M+yCZvhz820L/+lDFpC4r41Dah TAghLHO+0zSuYq2fzLbG36dDbBQmrj1GQoyc7Q4lDPOSUiHzXxUOV0H5AJc5V9wvJP2M pI96yfkDEixQ/nh+V7bqZdDO7s3HdFLJSMORcqnYKVehvzfz/TFf2iMc7TpPGFe+p0Pt BuPvw/q/swdMNcgdd3xda9xcO7NSM4OPoYH+NqIih1wS43mgW+09j10lSYJolnxo5KOn iGcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=J06BUQYI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 n8si9033310jam.34.2021.05.08.08.31.32; Sat, 08 May 2021 08:31:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linux-foundation.org header.s=google header.b=J06BUQYI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbhEHPcF (ORCPT + 99 others); Sat, 8 May 2021 11:32:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229500AbhEHPcF (ORCPT ); Sat, 8 May 2021 11:32:05 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84D02C061574 for ; Sat, 8 May 2021 08:31:03 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id w4so15336417ljw.9 for ; Sat, 08 May 2021 08:31:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=T80RW0N0f2bW+RbqzRU+sONErcUEsqlqhrSCovQJd4U=; b=J06BUQYI0u+DnqsTFDFBW9BAol4dCToP14yYTvqrpw03eRMBn6wqgvdBIcmTmtUa4A 5W0K6bMRkpOlnT6CwcVWRYVNjl9UHUiTVQt8AyjTba2fa2urqSpsnng7MZQLkZqrRfpu j85e+lD83jQdKI1jb6V7KdAg91qs6OZW5Fam0= 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=T80RW0N0f2bW+RbqzRU+sONErcUEsqlqhrSCovQJd4U=; b=kZyT+Psq/S6quU71doE8ukWvg9BAdzTEypycj1e8orsjKALxWm4Z82K8r/8uxUGuvi SwBVZay9p684/2NVKma0CkPWKu3BAXoWzTuPL+frMFZIcK7eyO5srXIWrUYODoH0oOkq EpS/OKTaJZu24vhWM790KC2sLAM2w43mVhjELLQ3tkgp/k9B78sQpMoK/WVK2zKSlRsj 97G1bPIFNazsZ6Az30kU7CVZrZhB1NJ81lFm/8DM25UGwpFt4wkKjI+Rv1cbrDArnCxP S7CxNNwUM0Mulg9QYM0jVZqQMIK/Nx23c/naHtPymv9CHeKfZpcq70LmQElQv2hYxBdf dqiw== X-Gm-Message-State: AOAM532u8MIveAe9wcd8Hy1amnc9dTMX5aj3IFMesziy3a4ibUtRCEgB Rd6hus3quEd7IlglXCM/KXM0Y6bykC7+Zqqi X-Received: by 2002:a2e:b0e5:: with SMTP id h5mr9734005ljl.453.1620487861655; Sat, 08 May 2021 08:31:01 -0700 (PDT) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com. [209.85.208.179]) by smtp.gmail.com with ESMTPSA id a17sm1648407lfl.228.2021.05.08.08.30.59 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 08 May 2021 08:31:00 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id b21so15313358ljf.11 for ; Sat, 08 May 2021 08:30:59 -0700 (PDT) X-Received: by 2002:a05:651c:1311:: with SMTP id u17mr12053441lja.48.1620487859712; Sat, 08 May 2021 08:30:59 -0700 (PDT) MIME-Version: 1.0 References: <20210508122530.1971-1-justin.he@arm.com> <20210508122530.1971-2-justin.he@arm.com> In-Reply-To: <20210508122530.1971-2-justin.he@arm.com> From: Linus Torvalds Date: Sat, 8 May 2021 08:30:43 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH RFC 1/3] fs: introduce helper d_path_fast() To: Jia He Cc: Petr Mladek , Steven Rostedt , Sergey Senozhatsky , Andy Shevchenko , Rasmus Villemoes , Jonathan Corbet , Alexander Viro , Al Viro , Heiko Carstens , Vasily Gorbik , Christian Borntraeger , "Eric W . Biederman" , "Darrick J. Wong" , "Peter Zijlstra (Intel)" , Ira Weiny , Eric Biggers , "Ahmed S. Darwish" , "open list:DOCUMENTATION" , Linux Kernel Mailing List , linux-s390 , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 8, 2021 at 5:29 AM Jia He wrote: > > This helper is similar to d_path except for not taking seqlock/spinlock. I see why you did it that way, but conditional locking is something we really really try to avoid in the kernel. It basically makes a lot of static tools unable to follow the locking rules, and it makes it hard for people to se what's going on too. So instead of passing a "bool need_lock" thing down, the way to do these things is generally to extract the code inside the locked region into a helper function of its own, and then you have __unlocked_version(...) { .. do the actual work } locked_version(..) { take_lock(..) retval = __unlocked_version(..); release_lock(..); return retval; } this prepend_path() case is a bit more complicated because there's two layers of locking, but I think the pattern should still work fine. In fact, I think it would clean up prepend_path() and make it more legible to have the two layers of mount_lock / rename_lock be done in callers with the restarting being done as a loop in the caller rather than as "goto restart_*". Linus