Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp892967rdb; Fri, 26 Jan 2024 14:23:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBI4kHso/e8/6xWiON9/RGNfgdr5kMGIAX2VEGV77RmsKBylF6KNUM1oA3FoSDhnjQFzYY X-Received: by 2002:a05:6358:260e:b0:176:3586:d42d with SMTP id l14-20020a056358260e00b001763586d42dmr397719rwc.54.1706307832664; Fri, 26 Jan 2024 14:23:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706307832; cv=pass; d=google.com; s=arc-20160816; b=Bw9TKAH9sL9xOP1vV2DKGqg7mJBJYQUv1Wq6O8pruMDi9QzYO4Ir8KJfoW3PUaPZ1m gbkZtkc93e5n2ApYvHOpaiSuL619P/NMDvYcJehlo3kSliYkaIA6TKbfK1JeOOCPT4RO nXCqOA9gPR6n0u+Av4ZrtGnq9wZrn26YdGHW6Vn/SqF+oEZypUfhVZO2Ns38nSxGFbqB tdAVTY3Y58KnQJjN/OHTFVKNENJqUK2CAZPlOuY+uaU7lgVedguy5KGWjBT0BsNDEhE0 4gA+Qmemj8/B5/eHA7pB6ZIn/MrP8kCrViXtRNQ8x6Bew9hdxthFZJtPT71Dl1VNl3WE kR3g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=QZz0qBQetT+akLfLiEhaucIyE40vy92o9QlsvQ+aURQ=; fh=0JZUWBoGA1xH27IFCmGIBrCO/Bs9Yj3b8PEz3ImOc6g=; b=IanUlsD73Nc6IYcj4ShYJmD2/jqflOgzoQ7Pwe7Hb8aM0YLKCG0/nYpMi57jfuJApL 3eNx6whnvVfpgFm7ZwKe2LIrNgDtbxtzZAyk6YaHnD2qN222O98clO4zsx4BJqhLkRET WkDJ1ENst8oa1XHzL57KS2APRyiPPjYX9I9SiwQMf6TNYcM1YX9pHZc3ZHIewX5i2QyX +NORYPScdLtEBJqMK316syipMLRIyQh7fA033NPJrH1sdYGPdWhCN9IqziSj+i43Oxha TdxPy3bQ/+MG8rcj9Vnywx80BhcZUDyZ4S3BGLxRsoXFhz3c/0wAc7FjxyoPr1nmcj6/ CsYQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=cfkipyRs; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-40734-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40734-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 7-20020a630d47000000b005bdf597ed49si1784407pgn.56.2024.01.26.14.23.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 14:23:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40734-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@efficios.com header.s=smtpout1 header.b=cfkipyRs; arc=pass (i=1 spf=pass spfdomain=efficios.com dkim=pass dkdomain=efficios.com dmarc=pass fromdomain=efficios.com); spf=pass (google.com: domain of linux-kernel+bounces-40734-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40734-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=efficios.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BC088B26806 for ; Fri, 26 Jan 2024 22:15:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DEAE945955; Fri, 26 Jan 2024 22:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b="cfkipyRs" Received: from smtpout.efficios.com (smtpout.efficios.com [167.114.26.122]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0CE9F41C8A; Fri, 26 Jan 2024 22:14:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=167.114.26.122 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706307263; cv=none; b=NSORupO/Gdr+jpP2lyENO5mpVFV9DZo++gyouCyz3ajHwpUP4yzZ8F/O9xv9BYodJmFGYn65MVEQZ8Xm79qU7yrSdCFYdYPbYOMF9hEN2sjSMFqQBUZzBQXJnHFqlGt5c1HiQhvbZqu89kt/WDCRxDU4s3nX5WOMbO5J7GwhTQ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706307263; c=relaxed/simple; bh=Jdm33v2+FbE+eDx5lDB90ydl/s2iNfckbja6xWCLNck=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=QGhXEt/u2qGL0o9TNlwT0PY5is6+3V9Zy4xBbIBqnkEY43Gv8KDIe9qEdeQTW7tOsX8PPQInA5pGK5zAkiintIZLP5faRkpQl0pD1c9sTGRBMRFciguHvB3uG/wC7BlNekAeOOOHYUABs5IwMvHX3ZEBOHt5IQgSPNgG6u/ca0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com; spf=pass smtp.mailfrom=efficios.com; dkim=pass (2048-bit key) header.d=efficios.com header.i=@efficios.com header.b=cfkipyRs; arc=none smtp.client-ip=167.114.26.122 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=efficios.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=efficios.com; s=smtpout1; t=1706307254; bh=Jdm33v2+FbE+eDx5lDB90ydl/s2iNfckbja6xWCLNck=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=cfkipyRsu2VHMJxlmbm3pCANQ19TSTz6YQmuyCbVeZ1qFT0OiAuXMZMHv/kCXDYV5 Sqt5ASfUbdf9yStQP2jZ6RFX4HNh8fxfb3HAtOr5jq8vRQ8Ca1I6RvCUGN66g4Af3h QjCMbYjnwdMK2ZXud8gbIW9J0KEgQDOY8RRPVoaHnpvbHgtbcO1ZVHZn62GCgWS2+0 pQNtpi1wU40f69L+cF/vpnPcRkB/SFSIX/wT6OrP2sIPHDVE/nWEgJ7OCsFERACT32 Tlt9hTxL9LDX/6neQw8PeWympIe3TUM7STM9rFv+t0es/J9Ii2HxUmCzU5DJVg4hSq 5Phhi3/pPJEog== Received: from [172.16.0.134] (192-222-143-198.qc.cable.ebox.net [192.222.143.198]) by smtpout.efficios.com (Postfix) with ESMTPSA id 4TMBn22rgWzVQ4; Fri, 26 Jan 2024 17:14:14 -0500 (EST) Message-ID: <8547159a-0b28-4d75-af02-47fc450785fa@efficios.com> Date: Fri, 26 Jan 2024 17:14:12 -0500 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] eventfs: Have inodes have unique inode numbers Content-Language: en-US To: Linus Torvalds , Steven Rostedt Cc: LKML , Linux Trace Devel , Masami Hiramatsu , Christian Brauner , Ajay Kaher , Geert Uytterhoeven , linux-fsdevel References: <20240126150209.367ff402@gandalf.local.home> <20240126162626.31d90da9@gandalf.local.home> From: Mathieu Desnoyers In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2024-01-26 16:49, Linus Torvalds wrote: > On Fri, 26 Jan 2024 at 13:36, Linus Torvalds > wrote: [...] > So please try to look at things to *fix* and simplify, not at things > to mess around with and make more complicated. Hi Linus, I'm all aboard with making things as simple as possible and making sure no complexity is added for the sake of micro-optimization of slow-paths. I do however have a concern with the approach of using the same inode number for various files on the same filesystem: AFAIU it breaks userspace ABI expectations. See inode(7) for instance: Inode number stat.st_ino; statx.stx_ino Each file in a filesystem has a unique inode number. Inode numbers are guaranteed to be unique only within a filesystem (i.e., the same inode numbers may be used by different filesystems, which is the reason that hard links may not cross filesystem boundaries). This field contains the file's inode number. So user-space expecting inode numbers to be unique within a filesystem is not "legacy" in any way. Userspace is allowed to expect this from the ABI. I think that a safe approach to prevent ABI regressions, and just to prevent adding more ABI-corner cases that userspace will have to work-around, would be to issue unique numbers to files within eventfs, but in the simplest/obviously correct implementation possible. It is, after all, a slow path. The issue with the atomic_add_return without any kinds of checks is the scenarios of a userspace loop that would create/delete directories endlessly, thus causing inode re-use. This approach is simple, but it's unfortunately not obviously correct. Because eventfs allows userspace to do mkdir/rmdir, this is unfortunately possible. It would be OK if only the kernel had control over directory creation/removal, but it's not the case here. I would suggest this straightforward solution to this: a) define a EVENTFS_MAX_INODES (e.g. 4096 * 8), b) keep track of inode allocation in a bitmap (within a single page), c) disallow allocating more than "EVENTFS_MAX_INODES" in eventfs. This way even the mkdir/rmdir loop will work fine, but it will prevent keeping too many inodes alive at any given time. The cost is a single page (4K) per eventfs instance. Thanks, Mathieu -- Mathieu Desnoyers EfficiOS Inc. https://www.efficios.com