Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2609407pxb; Sun, 30 Jan 2022 23:26:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwFwYfk4CyHI+l6rP3+krEMFPUNfLhoA65bRYUmQmZoOktRyO6ygGr0M+MC5NMUaurndeCY X-Received: by 2002:a63:141f:: with SMTP id u31mr15987191pgl.614.1643613982900; Sun, 30 Jan 2022 23:26:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643613982; cv=none; d=google.com; s=arc-20160816; b=MS07O0NLWmhiBuuxaN3KEppC7e7ChA74DvqVJRcehKIHHHmxMZMEL+u0KPiVvIwt9o iCSw5zpxbklRgUIOCUc0sQEz5DNlBAm7LsJMR4lhKjPFFlOy5TywAybVacN56E5Z0tCa ILxTARgZnh6S3go1S+lorYjhx9tYBHDhW+RboDdycNogUs0mi9jtLmIISQTOu5ciVIyt XQ8FTjRqOFeT8iBw83eeOVz6S8w/9dJWrInr+uko4Dp/bEo1U1szvRj254FJKLaocQzQ GDKnGY3fD2rgVziG7//5joC3HrbAKza7endk341K4qu0GBw9oQwuSTs9CmP6jwq/U/X7 mFtg== 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=wDt4jv4w3YC6Q40GetvSo+cqdaAT0L68ivf9sPs/K8Q=; b=EqXcYCeQwNTJAbx/zlK4qE9O4aKnRcqtRiLeuTEuG9biIEwIPO1NG8J5kuA6ELxWcp HB0zCXy9DA46IzIBBrvDhT80ta6sFbQUdZFWoeGbxLOVWJ0nczK9N0XGmHmTpQZKBFp9 E0Y45A7oIDquL9msczqeAzB+UDOIvoCAn1sGPiKsEh4e8aq/Pq7+4QggsrE1YBUgKo6E 9fTOM0O8pwscfXA4FQfMsHk042iaXC2Kdy/w7Tqs34X7/wS7DazqMjVD9DqvNXCw4CcX bUFHxWG1wDY+nVacoKtJk+1FEA6UZ2sEgrLpthLvcOw1feI+hSz+GwFDnt26zjoWD2CQ UUiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=EJ4fNl8j; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w24si12798114pgj.52.2022.01.30.23.26.12; Sun, 30 Jan 2022 23:26:22 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=EJ4fNl8j; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348022AbiA1LJm (ORCPT + 99 others); Fri, 28 Jan 2022 06:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52224 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348074AbiA1LJ0 (ORCPT ); Fri, 28 Jan 2022 06:09:26 -0500 Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A1BDC061749; Fri, 28 Jan 2022 03:09:26 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id e8so5034631ilm.13; Fri, 28 Jan 2022 03:09:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=wDt4jv4w3YC6Q40GetvSo+cqdaAT0L68ivf9sPs/K8Q=; b=EJ4fNl8jGpwOF+l7mYmqwnMdwQaU7ijAZyfJ0sMP9w1lOujGb+aadfBn078cU/LVXQ CIjZFd2s8/1wcIz/IAfucniv59I5ug6C1Wdfc4DmVqaGXWPlVnXX7KfoI2I8zkuY9qlP slYslrq1aeQhKYeGIWKYTvFuoORRrgA2yZSefrae4Ke3pluEiuMI7Dxy/N72sYXzYXx7 Fr+7EpWiyElnfqtE0K2vQhHIsB3XjL8vEbzhId/UQ5TsdvG+J8gcQUD25CwxTorFlFOy 5OjZ4v7itBoShKaf4qwlumgWCxZW6/wuL1AbNbZbaJQHo00QFfeTgUAUvJl5/SQ3uTFN KTLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=wDt4jv4w3YC6Q40GetvSo+cqdaAT0L68ivf9sPs/K8Q=; b=44c7AKpxFYlPu29UIm0/tkLWMYAjRyJ4G8rq2VJWNmb2CaT6jbAlRl5J23zQOmUvik kk+y83cmxZ1hRutFHauwT0XMinHFhvxGlnFy/SgLOJORtwx6GeiWl14FE9wIJUrNes/L oatT/wMpXx7sB+5EsxV8TqLKu8aJ5mkPu5+k8rveHY5CUjXxzb+PxCkAC5nrQfy7ZU8I +1Lb/E1TUsMxcvLV+uJt/za6OzKlnJdjPvpgabcvk3DELUjp7mjYS7nDuKXz9fbd9VM1 +dqVp8b8OCMXAVfyh/eF98rsFRnQv5/IjZUIttaLN0+9Q3ypkxi+5u7KwfCU7aB4BISl bq8A== X-Gm-Message-State: AOAM531PhPQTIN9u1Ug4SaaqecSDVMfFfDKZ3Gm+FUL8UPJnk+obnnna m3tzF/liMSCZzQXT6MFl2k4Zj1IewVIM9GSGdmQ= X-Received: by 2002:a92:c567:: with SMTP id b7mr5367192ilj.24.1643368165717; Fri, 28 Jan 2022 03:09:25 -0800 (PST) MIME-Version: 1.0 References: <20220128074731.1623738-1-hch@lst.de> <918225.1643364739@warthog.procyon.org.uk> In-Reply-To: <918225.1643364739@warthog.procyon.org.uk> From: Amir Goldstein Date: Fri, 28 Jan 2022 13:09:14 +0200 Message-ID: Subject: Re: [PATCH v2] fs: rename S_KERNEL_FILE To: David Howells Cc: Christoph Hellwig , Linus Torvalds , Al Viro , linux-fsdevel , linux-kernel , Chaitanya Kulkarni , Miklos Szeredi Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 28, 2022 at 12:12 PM David Howells wrote: > > Christoph Hellwig wrote: > > > S_KERNEL_FILE is grossly misnamed. We have plenty of files hold > > "held". > > > open by the kernel kernel using filp_open. > > You said "kernel" twice. > > And so what? Cachefiles holds files open by filp_open - but it can only do so > temporarily otherwise EMFILE/ENFILE and OOMs start to become a serious problem > because it could end up holding thousands of files open (one or two of the > xfstests cause this to happen). > > Further, holding the file open *doesn't* prevent cachefilesd from trying to > cull the file to make space whilst it's "in use". > > Yet further, I'm not holding the directories that form the cache layout open > with filp_open at all - I'm not reading them, so that would just be a waste of > resources - but I really don't want cachefilesd culling them because it sees > they're empty but cachefiles is holding them ready. > > > This flag OTOH signals the inode as being a special snowflake that > > cachefiles holds onto that can't be unlinked because of ..., erm, pixie > > dust. > > Really? I presume you read the explanation I gave of the races that are a > consequence of splitting the driver between the kernel and userspace? I could > avoid them - or at least mitigate them - by keeping my own list of all the > inodes in use by cachefiles so that cachefilesd can query it. I did, in fact, > use to have such a list, but the core kernel already has such lists and the > facilities to translate pathnames into internal objects, so my stuff ought to > be redundant - all I need is one inode flag. > > Further, that inode flag can be shared with anyone else who wants to do > something similar. It's just an "I'm using this" lock. There's no particular > reason to limit its use to cachefiles. In fact, it is better if it is then > shared so that in the unlikely event that two drivers try to use the same > file, an error will occur. > Good idea, but then the helpers to set the flag should not be internal to cachefiles and the locking semantics should be clear. FYI, overlayfs already takes an "exclusive lock" on upper/work dir among all ovl instances. How do you feel about hoisting ovl_inuse_* helpers to fs.h and rename s/I_OVL_INUSE/I_EXCL_INUSE? Whether deny rmdir should have its own flag or not I don't know, but from ovl POV I *think* it should not be a problem to deny rmdir for the ovl upper/work dirs as long as ovl is mounted(?). From our experience, adding the exclusive lock caused regressions in setups with container runtimes that had mount leaks bugs. I am hoping that all those mount leaks bugs were fixed, but one never knows what sort of regressions deny rmdir of upper/work may cause. Another problem with generic deny of rmdir is that users getting EBUSY have no way to figure out the reason. At least for a specific subsystem (i.e. cachefiles) users should be able to check if the denied dir is in the subsystem's inventory(?) Thanks, Amir.