Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2356469pxb; Sun, 30 Jan 2022 13:26:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJz89Z7IrHAjJ06Qng2RtP/3Jqj20REbnL0Q1heVGoRRNh27MrAWJaaPdHAVimYhJjKI1zka X-Received: by 2002:a17:90a:be15:: with SMTP id a21mr21201310pjs.36.1643577974584; Sun, 30 Jan 2022 13:26:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643577974; cv=none; d=google.com; s=arc-20160816; b=yQy4ksz5H4UcoifhvBmIrviEmbh5ND1fHvhnsbwwdyiXPuBtWJE9xckpX3E7zFxD06 r/IEeAOxNjP4TZbdC/a1uxly8cy3rKfBV1rj7hVE1ISGZGRHzYc7zjX/dUoi1dqARptt rbIKfddKabdMlo8n4+T9xy3KcYdlv9CFjiNKBPec5mAEPbkdnCR2lMN3F6Wbs4wQ/0/J WNKS9qTkBliRIM54v6RAdwglWlvrVfMBX1muzQXvRHJNT3ZmYHMLWbFZwl6f7NR1JiQH +h8c3zNoX/UTOTEfSk3/1Oy1locTEODA27+xMc7GICpc2MIXgw31djgsMWvu4ePQdFY1 QhSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=vrB8wKd/YuQDRzVLBwG4KgSFnRULjzQXEtQgJ4S5oNc=; b=NE37Ugk/VNoh7PtxsJdeWiwwV2FcZcRiLWujNVyd9MV1is5uxwHMG1sXOonG/51Uhl WYXoTb/4+6DWd7KtkmIGmT+3UjvQ1N89Z5TECiFlBRv4DyZtZLLovOnaKMvKOfPiyg/x e9gpC2wvc+s+V1HnWXlAMa7gJ2aQt+PalOhvZ0yrBiLjHsFDOv3BbczcMd6H9Q40sJ7U 3xhzrsD6PHGKElXZfED9PVjinsi/FGBxQh/wsd1K5Ft1gF/HA4PQdlMd3ouuVmYxBlQr DS/On71X2y9OReYCMwmnVGtO8wFT3sUSr3CKMqaHwaIQzOhBqhc3hs2FXXiLe4LBieM/ KkCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=I0SqErYo; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si10819199plo.58.2022.01.30.13.26.02; Sun, 30 Jan 2022 13:26:14 -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=@redhat.com header.s=mimecast20190719 header.b=I0SqErYo; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244011AbiA1KMd (ORCPT + 99 others); Fri, 28 Jan 2022 05:12:33 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36314 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243748AbiA1KM3 (ORCPT ); Fri, 28 Jan 2022 05:12:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643364749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vrB8wKd/YuQDRzVLBwG4KgSFnRULjzQXEtQgJ4S5oNc=; b=I0SqErYooRrn5ZBOHjHEs3SmIxrzzELlo3jWXNvrVQgSxqqE1TWZDSBSDRE9NtHCjsbZ++ 5bRB2q5WwynoZBNaaG+y7uTstdSL4mWrTdNuLMZjWTBaeHjaeToBUelQajXoetempl1+ux 4Vg3FjNqJOL6pdRIsH5rMaNJ7hCwloA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-339-O80TzOU3MMC2GBxfNuzNFA-1; Fri, 28 Jan 2022 05:12:24 -0500 X-MC-Unique: O80TzOU3MMC2GBxfNuzNFA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 84E102F45; Fri, 28 Jan 2022 10:12:22 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id DBEC260C41; Fri, 28 Jan 2022 10:12:20 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: <20220128074731.1623738-1-hch@lst.de> References: <20220128074731.1623738-1-hch@lst.de> To: Christoph Hellwig Cc: dhowells@redhat.com, torvalds@linux-foundation.org, viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Amir Goldstein , Chaitanya Kulkarni Subject: Re: [PATCH v2] fs: rename S_KERNEL_FILE MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <918224.1643364739.1@warthog.procyon.org.uk> Date: Fri, 28 Jan 2022 10:12:19 +0000 Message-ID: <918225.1643364739@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. I do use it to defend cachefiles against itself also. In the event that there's a bug or a race and it tries to reuse its own cache - particularly with something like NFS that can have multiple superblocks for the same source, just with different I/O parameters, for example - this can lead to data corruption. I try to defend against it in fscache also, but there can be delayed effects due to object finalisation being done in the background after fscache has returned to the netfs. Now, I do think there's an argument to be made for splitting the flag into two, as I advanced in a proposed patch. One piece would just be an "I'm using this", the other would be a "don't delete this" flag. Both are of potential use to other drivers. I take it you'd prefer this to be done a different way? David