Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp688606pxb; Wed, 18 Aug 2021 11:38:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8MXvFy2j+xDwPPnyZ7KlU/g2a+p6ras9DYDn+4AYm8lcAV77GGef9/wtFBmCebCoMe6rU X-Received: by 2002:a05:6402:1601:: with SMTP id f1mr11635023edv.388.1629311881939; Wed, 18 Aug 2021 11:38:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629311881; cv=none; d=google.com; s=arc-20160816; b=LuihmBGI39bABKgzImBnL39KO2NEiNtyZLO/Uxx1FApR3QGi3Lqqh8E0Q8APHfuFrZ BGSs7jeXejhpFcL2aA/K+PS32hJxvacgMw+syZF+Udzu4jAUBWM9QRyIMQCKppNawvwK bIN/BLOY4R2HIL3pnXagnsD+aFByAReBhOC/yLb5jgQNGIzOiFRRiZtgofPZkT5SSGUu AbWE3FDQokZReJsuxh8tzofoJsxNCM7isD+61xNmnrwxBmovJmCp4CU2grNlaqKnkzkC +Nsl6SChdG/Ipq0Vrlc6ZMkMCld+mp4U1tyC8g0EiH5OqDEXytzYkqTx4Ik76tQaYnUn P3gg== 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=9FPUr4CdEhH6rDlKsFJKVG6weGYB4goKDrrriPqlf4c=; b=JHAeNfN5DuEeRVJEO7yMpRmpoIlf9xXoXiWyTcKXdA+/tLYtm4hmyqR1hXrqC4/v/+ 4WdMKu0OI9X+4lY7WhCiaP/PsbyTpqtd5DOkKYsaGtE/vDqKv//rkep8t8h5P60ytj/O 6M+WlkoUHSIvCzOUQXpAoPDD7W+BBLIUC9qy2150cfweWzD2xPqU3tyff0O7VOosmk7k KfNdOq0sEX2mfR9uexeDmNLqKb1Sk/SLjeJk5qoeCOGgrf1NW0wUPfN0CqRC9fcrLX9I Qou1kexbcMwR9oF8g9NN2MOvF9/rIlAzKSOruuYdbyHrG3q3xj0i71wY6lWMSSFOsyyk ATuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=UsJzOywq; 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 y23si679540ejw.88.2021.08.18.11.37.38; Wed, 18 Aug 2021 11:38:01 -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=UsJzOywq; 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 S232401AbhHRSfZ (ORCPT + 99 others); Wed, 18 Aug 2021 14:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229965AbhHRSfZ (ORCPT ); Wed, 18 Aug 2021 14:35:25 -0400 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1066CC0613CF for ; Wed, 18 Aug 2021 11:34:50 -0700 (PDT) Received: by mail-lj1-x22e.google.com with SMTP id c12so6806579ljr.5 for ; Wed, 18 Aug 2021 11:34:49 -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=9FPUr4CdEhH6rDlKsFJKVG6weGYB4goKDrrriPqlf4c=; b=UsJzOywq2ROkYLqA5CcdCp3s5r6bZjUJracBOkcBXm8YR8CmgShinAl0dyjPNTwbbT pLDb2UCOiSdPY/cvSTX1YknA8EFSxroQjJnPWKbt2h+fImZ4nOwlqkbqm72M2M6EuU9i yzeg9mXqlr6a1MUg4Os42/IodELJ+RDIOnnH8= 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=9FPUr4CdEhH6rDlKsFJKVG6weGYB4goKDrrriPqlf4c=; b=B9imQ6M5rDdEy7rzZq87hsk/kQCBC9lLyhTFvGKuj5ueuwd8v4ECRGzW3ydo1LdTqD kzERBKZD4kSbda8Xh/DVqxfhuC/nm9auCRY10rAIs80x/Fjm0Jj90wlAdim7uRg7B5Eu zPuB/iqkBwtfICPm0gDbv3I0sVemhB4qasY/UbplQb4K2v46zIVkrJcjrHZQMDzUJDPk 1h80Mf3SkRoBgSGYdLKzKKLSDQDPtlW3m/0HxvFgoT+GAKygO4oncrDZNe10u8C1HYlU DUf7h9Oyh1hzOMST6mCeVnldDIJyCSTyleGQVoDcTJNOAnE/MlHgUGJ1v39+PrAP9b9p IC9w== X-Gm-Message-State: AOAM533OJQFCbG99MMQYJteVmkp0Jod96aEFQIddBZjNHrEjHUu+PBNg Ye7F4h5n+ikkG2gNtBUPhL2Qd19Jll3drXPr X-Received: by 2002:a2e:870f:: with SMTP id m15mr9055634lji.169.1629311688144; Wed, 18 Aug 2021 11:34:48 -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 y10sm67940ljj.10.2021.08.18.11.34.47 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Aug 2021 11:34:47 -0700 (PDT) Received: by mail-lj1-f179.google.com with SMTP id n7so6893296ljq.0 for ; Wed, 18 Aug 2021 11:34:47 -0700 (PDT) X-Received: by 2002:a2e:944c:: with SMTP id o12mr8897833ljh.411.1629311686896; Wed, 18 Aug 2021 11:34:46 -0700 (PDT) MIME-Version: 1.0 References: <20210818133400.830078-1-mszeredi@redhat.com> <20210818133400.830078-3-mszeredi@redhat.com> In-Reply-To: <20210818133400.830078-3-mszeredi@redhat.com> From: Linus Torvalds Date: Wed, 18 Aug 2021 11:34:31 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 2/2] ovl: enable RCU'd ->get_acl() To: Miklos Szeredi Cc: Al Viro , linux-unionfs@vger.kernel.org, linux-fsdevel , Linux Kernel Mailing List , Andreas Gruenbacher , garyhuang Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 18, 2021 at 6:34 AM Miklos Szeredi wrote: > > struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type) > { > - return rcu_dereference(*acl_by_type(inode, type)); > + struct posix_acl *acl = rcu_dereference(*acl_by_type(inode, type)); > + > + if (acl == ACL_DONT_CACHE) > + acl = inode->i_op->get_acl(inode, type, LOOKUP_RCU); > + > + return acl; > } What? No. You just made get_cached_acl_rcu() return ERR_PTR(-EINVAL) for most filesystems. So now you've changed the behavior of get_cached_acl_rcu() ENTIRELY. It used to return either (a) the ACL (b) NULL (c) ACL_DONT_CACHE/ACL_NOT_CACHED but now you've changed that (c) case to "ACL_NOT_CACHED or random error value". You can't just mix these kinds of entirely different return values like that. So no, this is not at all acceptable. I would suggest: (a) make the first patch actually test explicitly for LOOKUP_RCU, so that it's clear to the filesystems what is going on. So instead of that pattern of if (flags) return ERR_PTR(-EINVAL); I'd suggest using if (flags & LOOKUP_RCU) return ERR_PTR(-ECHILD); so that it actually matches what lookup does for the "I can't do this under RCU", and so that any reader of the code understands what "flags" is all about. And then (b) make the get_cached_acl_rcu() case handle errors _properly_ instead of mixing the special ACL cache markers with error returns. So instead of if (acl == ACL_DONT_CACHE) acl = inode->i_op->get_acl(inode, type, LOOKUP_RCU); maybe something more along the lines of if (acl == ACL_DONT_CACHE) { struct posix_acl *lookup_acl; lookup_acl = inode->i_op->get_acl(inode, type, LOOKUP_RCU); if (!IS_ERR(lookup_acl)) acl = lookup_acl; } or whatever. I disagree with Al that a "bool" would be better. I think LOOKUP_RCU is good documentation, and consistent with lookup, but it really needs to be *consistent*. Thus that if (flags & LOOKUP_RCU) return ERR_PTR(-ECHILD); pattern, not some "test underscibed flags, return -EINVAL" pattern that looks entirely nonsensical. Linus