Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4315678pxf; Tue, 16 Mar 2021 10:24:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHcpyRfHts/vKiVEUEgDxV/qwDaB4Qx8+v+Upm0xl0U1/FLqXIyAGTyPs2S+TKcyN+jLhe X-Received: by 2002:aa7:de8b:: with SMTP id j11mr37420754edv.363.1615915440163; Tue, 16 Mar 2021 10:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615915440; cv=none; d=google.com; s=arc-20160816; b=mSyarEOVqKSWDmZ7I2TR3wIG7Lns4jg9wiTNktxccAjMvnGNExQUL1LRj/FQwbMBNe LHxUosSrtEvcXpnQ9ArAPUxXfzMDNqYo29KSEp19ntFiOdS+V+m48IWjeW7e4w6s1gFe sa6N20xCFllSd3f2WsxIPERvSH3BfU9k/e3uN0RiRq6axDxqesQcwKsC48h4cPXHu2me hM9rfWJaNhaCy7PjLQPjpXvE7RksHKXgHQUVbmN01ko4UzC6/V+37jpy2ncwG6dItcpQ dEPby6xivtF8KvnLnhwZnFumuaYPs4AZxvvQ+bk0c8ul3qn7H0KncqQIAqbLYn37q6jj h1cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=H6EDtxe5nSx1FEf7+D7mTFSV9sfzqRIO7jXz1AlG9ik=; b=xlv5Jq1zy7vaPNc2//FBeddxDi6SROhUaCOkeenPfJVohpYE9C1NlHrxitloOHWGOm mfH23BTze19kiEejFieuYmKUS32cKvYmb0ETfG3piBfC89oNbPeKIsSVcRn35rFdTzp9 WFM2H4oPEOcsSy2pd+O+dGfXVuxgWbC7vUbJ8+tbXss5HfWI2UMOU8+3a0ZYEtkjO9Ph qs+c5ZreTpaXnTEaIhuAZj2qV26kFlF7i69Pnf16Y7S9/s8McuWmEsFiqrAB84ajFOFz YBde4mZ7bN4y2tR7Pco6cGARIJsI/cVvHKsBSKLKG7HFGYvgfo91qwOjChlyDbYOqts4 UfJA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-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 f16si14263844eds.608.2021.03.16.10.23.35; Tue, 16 Mar 2021 10:24:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235180AbhCPRO6 (ORCPT + 99 others); Tue, 16 Mar 2021 13:14:58 -0400 Received: from mx2.suse.de ([195.135.220.15]:42968 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239090AbhCPROa (ORCPT ); Tue, 16 Mar 2021 13:14:30 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 4F0E1AC24; Tue, 16 Mar 2021 17:14:29 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 1945B1F2C4C; Tue, 16 Mar 2021 18:14:29 +0100 (CET) Date: Tue, 16 Mar 2021 18:14:29 +0100 From: Jan Kara To: Alexander Lochmann Cc: Theodore Ts'o , Horst Schirmeier , Jan Kara , Jan Kara , linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [RFC] inode.i_opflags - Usage of two different locking schemes Message-ID: <20210316171429.GA22701@quack2.suse.cz> References: <667b3ec3-a522-05a9-31e8-87d8bfaa7adb@tu-dortmund.de> <0f387f5b-a516-af45-856d-f38d1adfadf5@tu-dortmund.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0f387f5b-a516-af45-856d-f38d1adfadf5@tu-dortmund.de> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Mon 08-03-21 15:05:33, Alexander Lochmann wrote: > On 05.03.21 17:04, Theodore Ts'o wrote: > > On Fri, Mar 05, 2021 at 04:35:47PM +0100, Alexander Lochmann wrote: > > > > > > > > > On 05.03.21 16:18, Theodore Ts'o wrote: > > > > 1) I don't see where i_opflags is being read in ipc/mqueue.c at all, > > > > either with or without i_rwsem. > > > > > > > It is read in fs/dcache.c > > > > So why is this unique to the mqueue inode then? It might be helpful > > to have explicit call stacks in the e-mail, in text form, when you > > resend to LKML. > It is unique to mqeue inode, because the control flow goes through > ipc/mqueue.c where almost always the i_rwsem is taken. > Hence, we see more memory accesses to an mqueue inode with the i_rwsem. > The i_lock is less often hold compared to the i_rwsem. > We conclude the i_rwsem is needed. So it might not be a contradiction at > all. It rather could be a flaw in our approach. :-/ > > Besides from our current discussion: > Does the i_lock protect i_opflags for both reading and writing? So i_lock is supposed to protect i_opflags for writing AFAICT. For reading we don't seem to bother in some cases and I agree that is potentially problematic. It is *mostly* OK because we initialize i_opflags when loading inode into memory / adding it to dcache. But sometimes we also update them while the inode is alive. Now this is fine for the particular flag we update but in theory, if the compiler wants to screw us and stores temporarily some nonsensical value in i_opflags we'd have a problem. This is mostly a theoretical issue but eventually we probably want to fix this. Honza -- Jan Kara SUSE Labs, CR