From patchwork Tue Mar 22 22:27:35 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: 12789326 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 B835EC433EF for ; Tue, 22 Mar 2022 22:27:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 468B06B007B; Tue, 22 Mar 2022 18:27:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 418576B007D; Tue, 22 Mar 2022 18:27:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2DFA16B0085; Tue, 22 Mar 2022 18:27:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0159.hostedemail.com [216.40.44.159]) by kanga.kvack.org (Postfix) with ESMTP id 1E2126B007B for ; Tue, 22 Mar 2022 18:27:50 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id CF4271828D803 for ; Tue, 22 Mar 2022 22:27:49 +0000 (UTC) X-FDA: 79273460658.18.99B59E3 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by imf24.hostedemail.com (Postfix) with ESMTP id 2E611180038 for ; Tue, 22 Mar 2022 22:27:49 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 9B93D1F442B1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1647988067; bh=4/FepsizIsWm4GoSaRjR4ETqQfuFUzAfsgJVjpf5yOU=; h=From:To:Cc:Subject:Date:From; b=NSIrJ8nCY/OShm3Z1pg2H71KGLRaJtr6V4vokxZKjQWmfbYRzs5x6VfmMGpfhkmUi pWy3gYhzNAGCUT4/TSTrBWcognVvtiXwUYkFFkIzxgkM9htv08qEg8Hx+d1z7G+1bk s6btXVzjwHMxbu9y7irasxEKbZ3rdZUiyektXP4vp0CN0Vz0qdFyCDVJW3ShEfIK6R dIBnqs3xOFsgnsMEXfGihTtLnuUKQ+InBNKylXfsABKilPU/1Vghu4TqC+aLApYakS vCufnFF5r0CYMfBs7bCaWFQUHxuSq7aFIrOrd0w0w2pA6U7LVxFfvJZSZE6LADgMve LS8LXcYbI+L5Q== From: Gabriel Krisman Bertazi To: hughd@google.com, akpm@linux-foundation.org, amir73il@gmail.com Cc: khazhy@google.com, linux-mm@kvack.org, Gabriel Krisman Bertazi , kernel@collabora.com Subject: [PATCH 0/3] shmem: Allow userspace monitoring of tmpfs for lack of space. Date: Tue, 22 Mar 2022 18:27:35 -0400 Message-Id: <20220322222738.182974-1-krisman@collabora.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: j74ma5sypjw7fsrees117mgo4taq7emy Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=NSIrJ8nC; spf=pass (imf24.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-Rspamd-Queue-Id: 2E611180038 X-HE-Tag: 1647988069-884536 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000830, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 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 | 103 ++++++++++++++++++++++- 3 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-fs-tmpfs