From patchwork Mon Apr 18 21:37:10 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: 12817128 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 58790C433F5 for ; Mon, 18 Apr 2022 21:37:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D42C8D0021; Mon, 18 Apr 2022 17:37:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 485458D001A; Mon, 18 Apr 2022 17:37:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 34C0F8D0021; Mon, 18 Apr 2022 17:37:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0049.hostedemail.com [216.40.44.49]) by kanga.kvack.org (Postfix) with ESMTP id 2232D8D001A for ; Mon, 18 Apr 2022 17:37:22 -0400 (EDT) Received: from smtpin27.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A94CD1833A4AD for ; Mon, 18 Apr 2022 21:37:21 +0000 (UTC) X-FDA: 79371311082.27.A891D6E Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by imf29.hostedemail.com (Postfix) with ESMTP id E7D1E120008 for ; Mon, 18 Apr 2022 21:37:20 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 39A381F41BE3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1650317839; bh=aqZ/sq+j8QUOgvzBXdkd5NE7N/6Wr11NqMESsYe11pM=; h=From:To:Cc:Subject:Date:From; b=oW4ApWcimHnbFor0ZjzfIAqT4tqJUslwxI7DlzXP76/APzx4x1IyJM7UZFIbNB6/a PC0O9+uw6SxAjkQuVtAz0HDpGfAYP2DW7XOT8h/5kMGNAtUUtZYe0kepM72B484EWP adgfMzUKL8+ys/SPG6d000grmj1Rcz+5tzQ7wWgeseafC06TI2JbfCr9sLUZ7JBz8D VC1RKPQ/PtNkLao47K8oXJ7YTSUYBnecV5k7CglssmkHCzlJ9cLBBM6VNC22V1hKW7 JAGJFA3qhkHgCO+CVdjYszp5XwVwK4VArLdXwnd2DMw0AtbV0FzoWR9nlAiYlAaS7r 12MhIlSwM0OSw== From: Gabriel Krisman Bertazi To: hughd@google.com, akpm@linux-foundation.org, amir73il@gmail.com Cc: viro@zeniv.linux.org.uk, Gabriel Krisman Bertazi , kernel@collabora.com, Khazhismel Kumykov , Linux MM , linux-fsdevel Subject: [PATCH v3 0/3] shmem: Allow userspace monitoring of tmpfs for lack of space. Date: Mon, 18 Apr 2022 17:37:10 -0400 Message-Id: <20220418213713.273050-1-krisman@collabora.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: E7D1E120008 X-Stat-Signature: 5zooyqonecgimpqzwkhxz5so4sbttpra Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=oW4ApWci; spf=pass (imf29.hostedemail.com: domain of krisman@collabora.com designates 46.235.227.227 as permitted sender) smtp.mailfrom=krisman@collabora.com; dmarc=pass (policy=none) header.from=collabora.com X-Rspamd-Server: rspam01 X-HE-Tag: 1650317840-148685 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 v2 is applying Viro's coment on how the life of the sbinfo should now be tied to the kobject. I hope it is correct the way i did it. Tested by mount/umount while holding a reference. * v2 cover: 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 | 5 ++ mm/shmem.c | 76 ++++++++++++++++++++++-- 3 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-fs-tmpfs Signed-off-by: Gabriel Krisman Bertazi