Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp1570389rdb; Sun, 8 Oct 2023 14:21:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGBCegLMeHL7ER0rTnlSivqhhUmjuPLceg9s7iPX/kzRpaU/JLblg2WA2smrg05Hyvm3A00 X-Received: by 2002:a17:90a:ce92:b0:268:2523:652c with SMTP id g18-20020a17090ace9200b002682523652cmr12941511pju.31.1696800117293; Sun, 08 Oct 2023 14:21:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696800117; cv=none; d=google.com; s=arc-20160816; b=ADMKD+ju78lidRhQ2INLysbfdKLmJ//u1bZOJsNciZkniYZWBxRTF0TPfYAsn6Mc1e hGhYL2uUet5kAodGLLP+PDgofzaZsV4qrzbIiJSk/OVP7W9BKG5TSS/FgA0fTAMo9tTJ cFXyrzQ/OyVY4CyLf1D4Lf+cgQXLS6CQGTr3Gl6DQIyZdKi0ZOrKYQaOCIzsrfpFfnU6 nyWaLRk3Y4ODF28jdNe6wWQBrbOmZZUW9jWy5vHx0RoGJ89iK1yw80BpsnYuzcXcjZcd 4jYVCRUFHE/htqTjs0WTQZcujKR6F+F49ZdynJsLuKRfVJbNRZnXnqn8rd/0LDpowJsC Gb+w== 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:references :in-reply-to:mime-version:dkim-signature; bh=7tFkgfW4cZbNG3g5YvrO+dBVaVKzGdwwIuQTmQTY0jc=; fh=7uiAS/uYSiar9RpaGp+P674uHHo91jgQfPDxZ4AIkGQ=; b=wqRIepdWF+IDsU9yUMSaFgPvKtpzz0XEPr9d1Bdru76yBWoAFaS8KzgNQuOyZHY6HJ 30mrcj8c6pOCnLHuCOHBn3Mxm7CTCpodOtz+mObQ29JvmPTg2jH1Hz1M7u9HiXtY73N9 W1ma5Z5a9KGr1EMxA3+o5fpM/mQaUxG/yfq1Tjh4I6RkU+A/z51qGNKapbzWuvMI42XD xu9wyh1jxoNzk7bwQ6wEX2NYkRWCUfaLC/jEdHqXnZiCh2jGjbIQ4qBeXSH/NGu46btc NJnuN6F9oFYz2fooN+KhH6YrBFLg57rLzt7N+2yZzo20BDkIkcyQuED+41VU3DZ766US ShHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=J2T6ECoZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id d63-20020a17090a6f4500b00278182c3af6si8330969pjk.64.2023.10.08.14.21.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Oct 2023 14:21:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=J2T6ECoZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 127FF80681EB; Sun, 8 Oct 2023 14:21:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229845AbjJHVVi (ORCPT + 99 others); Sun, 8 Oct 2023 17:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbjJHVVh (ORCPT ); Sun, 8 Oct 2023 17:21:37 -0400 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [IPv6:2607:f8b0:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5771AC; Sun, 8 Oct 2023 14:21:35 -0700 (PDT) Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6c63117a659so2205272a34.0; Sun, 08 Oct 2023 14:21:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696800095; x=1697404895; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=7tFkgfW4cZbNG3g5YvrO+dBVaVKzGdwwIuQTmQTY0jc=; b=J2T6ECoZ2NQ6jQK317KDWj5GB1bRHagjHXju3Uj80aoxQ08+3krVPYJzsZFRDdKhgH brYhhqc2WkItqIha8tre4HCmBJo1LxFGvXpv8Ge9A5AkQ4gnbah8TbLX7MFMH0Nd/0fg 0ucF7qCpbqZrQw3F/Z1pxfNaGnjWDFDeDzYfrgcFgVG9w5/ZvS9EAssP9hDYiEr3aSmD b6Cb8Bv3uMTULzBBXoowJyrlftVRdvQDWvGIajZ00xTjdoOyKPRayTKZ/njjW1UjIVIn XaL9M9xZxz12Mx8cexXc5XpeRm05Fbf8aEQgnpJbGH2DcDEec8EvxhDyTUkQ5ENlLPDw gOZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696800095; x=1697404895; h=cc:to:subject:message-id:date:from:references:in-reply-to :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=7tFkgfW4cZbNG3g5YvrO+dBVaVKzGdwwIuQTmQTY0jc=; b=GHFJCMhnhaveJrU479uVF93+QnRC8BAbHmPNwhdgrMVp1U9DTl1gX6OoQDR8PTWmkU V6RPNbCg3Ybb0hzaFlLHoaK6xVN/V7USZMEH87n0fXIcoKAm7n3POxJ4vPClmjgthynn 47AegXE+duNJf62P+Hv0k5ouLmUJvkWO+3dccLhiXpEDR/n533zppl3zHsgZPwSF3o9p dGgyR9baANU1nYau4X08GemM0c201Xy2pAIy78j3QHpVSUfNBqEX7GGb4sLobRWppbsB cwHLpjK1W3LI6Blzb31JLzp7Ks7Sz9kZ2mMnP6+qEbQNDhfDgnNXOxWh8g29P8nx/hIr 4NrQ== X-Gm-Message-State: AOJu0YwhYshEUex9WpuZfY4KCGV3HCIbyAdceqWiemrJhAAFwOYHuJtv 2tnTtqhEiBsrfXArlHPLwSQioW2mxOl4QJzkl44= X-Received: by 2002:a9d:6d0d:0:b0:6c4:6aef:cd58 with SMTP id o13-20020a9d6d0d000000b006c46aefcd58mr12438764otp.8.1696800095162; Sun, 08 Oct 2023 14:21:35 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:ac9:5786:0:b0:4f0:1250:dd51 with HTTP; Sun, 8 Oct 2023 14:21:34 -0700 (PDT) In-Reply-To: References: <20231007203543.1377452-1-willy@infradead.org> <20231007203543.1377452-6-willy@infradead.org> From: Mateusz Guzik Date: Sun, 8 Oct 2023 23:21:34 +0200 Message-ID: Subject: Re: [PATCH v2 5/5] fs: Add inode_assert_locked() and inode_assert_locked_excl() To: Matthew Wilcox Cc: Peter Zijlstra , Ingo Molnar , Will Deacon , Waiman Long , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Chandan Babu R , "Darrick J . Wong" , linux-xfs , linux-fsdevel , Christian Brauner Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_SBL_CSS, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 08 Oct 2023 14:21:55 -0700 (PDT) X-Spam-Level: ** On 10/8/23, Matthew Wilcox wrote: > On Sun, Oct 08, 2023 at 10:26:40PM +0200, Mateusz Guzik wrote: >> On 10/7/23, Matthew Wilcox (Oracle) wrote: >> > +static inline void inode_assert_locked_excl(const struct inode *inode) >> > +{ >> > + rwsem_assert_held_write(&inode->i_rwsem); >> > +} >> > + >> > static inline void inode_lock_nested(struct inode *inode, unsigned >> > subclass) >> > { >> > down_write_nested(&inode->i_rwsem, subclass); >> >> Why "excl" instead of "write"? Apart from looking weird, it is >> inconsistent with "prior art" in the file: i_mmap_assert_write_locked. > > Yes, but that pairs with i_mmap_lock_write() / i_mmap_lock_read(). > > The problem is that we have inode_lock() / inode_lock_shared() > inode_assert_locked_read/write doesn't make sense with them. But > inode_assert_locked() doesn't make sense as the assertion for > inode_lock() because you'd expect it to assert whether the inode lock > is held at all. So I went with inode_assert_locked_excl(). > > I wouldn't mind if we converted all the inode_lock()/shared to > inode_lock_read() / inode_lock_write(), and then added > inode_assert_read_locked() / inode_assert_write_locked(). That's > a bit of a bigger job than I want to take on today. > I agree it is rather messy and I'm not going to spend time arguing as it is not my call anyway. Speaking of that, I just noticed the vfs folk are not CC'ed, which I'm rectifying with this e-mail. -- Mateusz Guzik