From nobody Wed Mar 08 16:40:34 2023 X-Original-To: freebsd-fs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PWyjg4qgqz3wbHC for ; Wed, 8 Mar 2023 16:40:39 +0000 (UTC) (envelope-from se@FreeBSD.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PWyjg2xdDz3n33; Wed, 8 Mar 2023 16:40:39 +0000 (UTC) (envelope-from se@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678293639; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vG+R/8ZFKfP7NP0xfNT6zLujT7b+wcwAO60hofMLV+Y=; b=NXd6/q0LXBhbx5QlP46selLd3uKtLnq9sGccY+J0TjC8Hy8dpd0ghdVmXumQ8uunFz7Ggj glxUfulXOCSB4w23lhV8oJgIENN8rUmyGunR68cG9fEaRl3qptALMrFwaY1mCfdl5Tzcrn EAy9dcRQTCFsGwIuAvF1xUSYFTsBk2TNjBR77cli2A1AoW5JQmfrMx0aXD+PaW/2vsXKy4 x0oFkEh5tmnAeeTICOYKo2vRRXAPc/cI+35Xe62gck2L5PFtp+uRKlCk8cHyEhuseXzwUG Pd/UqnIBw9qrLq2Bs8gBsvaL7O3hQeRvZtsKCG6N7q1CTR43KEW9Yul8mUPTnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678293639; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vG+R/8ZFKfP7NP0xfNT6zLujT7b+wcwAO60hofMLV+Y=; b=tliSThL8GziEa1mtIsd13enGiQ+uya9I0C6gGyRJUkq59rEnObn01J1ypLJq+xggXuLa8b ZTZJpKx5nb2sX5iMcJCuViroGpe6fV6+LrRHi5/W60nJvEeitpzmVkzPeYLWIjBhCA9SCb zK3MNitJoBsPSe0Kh5933O1Bif3qlhsNG6SLanQz1LbkFlO2ks6J9dtRfQ7z2Moce/T7PO 7fwThhcFEVS1RqHVRgGw7/YORhYAIqQOQy3ffPQkIUmFxdW4dV2akKRq16CIxOnWBmA8V9 i8bxT2bJKgrHm+Vp7rU2VvucJLGlXoNRDTgoNKFR1zu5c8m9n+ZmT2LdrCQnng== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678293639; a=rsa-sha256; cv=none; b=bgPnnjPH8d8xmjIH0ZOO+/YIo00nS+FLxcGIwRij5/Rj9z/hTCCl+BwBrGBj35/Jmdnpaq lULk1OhRX8Nd/GZh80LFjDaPRK69YmWNBWpFSmYVZKNTudnxVkVofxzWH4UFuLVT3BHTjN LvKoo5U3YJGROjE3gW3x1TAVmHk2dR5icC9hHZRX19rBPnnD3sRwhd7mjudkcvULIhFA3h PtQRz/OdldwKCRDJc6sE8utrwWasK+POV9Z0dOiMYB2DgbgiHQ8O3lOFsNWzVHWAveiQ/O YfpnoqY8OgG4R0yxhst3y++ucmedMYT00mF1kKWUcDM8d9WM5s4+1324I/8MUQ== Received: from [IPV6:2003:cd:5f1a:a300:d991:f460:ca12:9037] (p200300cd5f1aa300d991f460ca129037.dip0.t-ipconnect.de [IPv6:2003:cd:5f1a:a300:d991:f460:ca12:9037]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: se/mail) by smtp.freebsd.org (Postfix) with ESMTPSA id 4PWyjf5xzjz16MX; Wed, 8 Mar 2023 16:40:38 +0000 (UTC) (envelope-from se@FreeBSD.org) Message-ID: <395b2322-ee4f-876e-cc5e-8efb0595d10a@FreeBSD.org> Date: Wed, 8 Mar 2023 17:40:34 +0100 List-Id: Filesystems List-Archive: https://lists.freebsd.org/archives/freebsd-fs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-fs@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 From: Stefan Esser Subject: Re: FAT32 statfs(2) inode usage To: Ben Woods Cc: freebsd-fs@freebsd.org References: <504ffe37-524a-4218-82e6-93459ef4b528@app.fastmail.com> <09df4665-b43d-9b07-cd4c-def3fd5fdffd@FreeBSD.org> <73441506-5147-4098-abc7-524c9f2791d1@app.fastmail.com> <5ecd7461-7dc7-5fa4-04fc-c76329a072f5@FreeBSD.org> <4a04386f-c58a-45d5-aabd-042d984f27b8@app.fastmail.com> <53c6042f-bac1-479e-b1bd-5af5226d0f35@app.fastmail.com> Content-Language: en-US In-Reply-To: <53c6042f-bac1-479e-b1bd-5af5226d0f35@app.fastmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ThisMailContainsUnwantedMimeParts: N Am 07.03.23 um 15:11 schrieb Ben Woods: > On Tue, 7 Mar 2023, at 6:20 PM, Ben Woods wrote: >> On Tue, 7 Mar 2023, at 6:11 PM, Stefan Esser wrote: >>> >>> I could implement a counter that provides a useful value for f_ffree by >>> counting all file and directory creations and removals from the root >>> directory of a FAT12/FAT16 file system. >> >> If I’m right, the file system could easily be mounted outside of >> FreeBSD on another machine that doesn’t maintain the counter. For >> example, a USB stick shared between machines. Trying to infer state >> from past events is always hard. Instead, how hard would it be to have >> the kernel count the current number of root directory entries at the >> time the statfs request is issued (live)? > > I've noticed the following code is used for enforcing the limit of root directory entities when creating a file or directory on a FAT filesystem. Could msdosfs_statfs use something similar to determine the current count of root directory entities? > > Source file: sys/fs/msdosfs/msdosfs_vnops.c > > Functions: msdosfs_create() and msdosfs_mkdir() > ---------- > /* > * If this is the root directory and there is no space left we > * can't do anything. This is because the root directory can not > * change size. > */ > if (pdep->de_StartCluster == MSDOSFSROOT > && pdep->de_fndoffset >= pdep->de_FileSize) { > error = ENOSPC; > goto bad; > } > ---------- > Hi Ben, I have created a patch that has been tested with both FAT12 and FAT16 and which has passed all my tests with different file system parameters (e.g. number of root directory entries) and all operations (create, rename and delete files and directories with DOS-8.3 or Win95 names). Could you please create a PR that describes the issue you had (wrong report of no free inodes on a FAT16 file system) and assign it to me? I'll reference the PR in the review I'm going to create and hope that this will help get the issue reviewed and the patch set approved ... Best regards, STefan