From patchwork Mon Mar 28 02:04:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gabriel Krisman Bertazi X-Patchwork-Id: 12793091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD68BC433F5 for ; Mon, 28 Mar 2022 02:05:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3195F8D0002; Sun, 27 Mar 2022 22:05:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C67D8D0001; Sun, 27 Mar 2022 22:05:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 18E9E8D0002; Sun, 27 Mar 2022 22:05:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 0ADF48D0001 for ; Sun, 27 Mar 2022 22:05:06 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C2B92208C5 for ; Mon, 28 Mar 2022 02:05:05 +0000 (UTC) X-FDA: 79292152170.01.4680CC2 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by imf26.hostedemail.com (Postfix) with ESMTP id 0A43A140037 for ; Mon, 28 Mar 2022 02:05:03 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 2D2AA1F42F39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1648433103; bh=YQwmxHNUIjUbR7VNXES3Vf/IfbnrF5LgkehmOk77BNw=; h=From:To:Cc:Subject:Date:From; b=XhZLDmm+cTd0qtlAuDdCkwpaKlPZwypMWs0SaSjBctTfSPtfVwK/h9eP+1KEkG+DB VOyVxi/7K8E/nd+vAT9TxSR+yz0XXbdqEf9nxO2krVxa8TkRekCt7hNiTtWo+XYV4p aOfu7sNYe+cNiE3C/0AL58BBQNLOwKzuI0Hn7DpcKNK0pbLoZxF3O3Eo8T1Na7uNOd MZiU5dtMOLtYVA7wZJ/dxl5Vb5sqKj9WvhrEFRRpphpetAd4ebQbudQ9HXpgXSCuOI sn0TlGi8KzCzPlKUZ9jEa6dHl3CwNpIScSCcqY2LGxFvGkl5nav1A9wqTP2yGCyczU H4ZAjbEaztEZw== From: Gabriel Krisman Bertazi To: Hugh Dickins , Andrew Morton , Amir Goldstein Cc: Gabriel Krisman Bertazi , kernel@collabora.com, Khazhismel Kumykov , Linux MM , linux-fsdevel Subject: [PATCH v2 0/3] shmem: Allow userspace monitoring of tmpfs for lack of space. Date: Sun, 27 Mar 2022 22:04:40 -0400 Message-Id: <20220328020443.820797-1-krisman@collabora.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Stat-Signature: 1z4q6fur3d8qkrqyedmhcjo633itd8op Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=XhZLDmm+; dmarc=pass (policy=none) header.from=collabora.com; spf=pass (imf26.hostedemail.com: domain of krisman@collabora.com designates 46.235.227.227 as permitted sender) smtp.mailfrom=krisman@collabora.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 0A43A140037 X-HE-Tag: 1648433103-19037 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: the only difference from v1 is addressing Amir's comment about generating the directory in sysfs using the minor number. * Original cover letter When provisioning containerized applications, multiple very small tmpfs are used, for which one cannot always predict the proper file system size ahead of time. We want to be able to reliably monitor filesystems for ENOSPC errors, without depending on the application being executed reporting the ENOSPC after a failure. It is also not enough to watch statfs since that information might be ephemeral (say the application recovers by deleting data, the issue can get lost). For this use case, it is also interesting to differentiate IO errors caused by lack of virtual memory from lack of FS space. This patch exposes two counters on sysfs that log the two conditions that are interesting to observe for container provisioning. They are recorded per tmpfs superblock, and can be polled by a monitoring application. I proposed a more general approach [1] using fsnotify, but considering the specificity of this use-case, people agreed it seems that a simpler solution in sysfs is more than enough. [1] https://lore.kernel.org/linux-mm/20211116220742.584975-3-krisman@collabora.com/T/#mee338d25b0e1e07cbe0861f9a5ca8cc439b3edb8 To: Hugh Dickins To: Andrew Morton To: Amir Goldstein Cc: Khazhismel Kumykov Cc: Linux MM Cc: linux-fsdevel Gabriel Krisman Bertazi (3): shmem: Keep track of out-of-memory and out-of-space errors shmem: Introduce /sys/fs/tmpfs support shmem: Expose space and accounting error count Documentation/ABI/testing/sysfs-fs-tmpfs | 13 +++ include/linux/shmem_fs.h | 7 ++ mm/shmem.c | 102 ++++++++++++++++++++++- 3 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-fs-tmpfs