From patchwork Wed Apr 26 10:20:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos Maiolino X-Patchwork-Id: 13224370 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 358EFC77B78 for ; Wed, 26 Apr 2023 10:20:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 725FE6B00B4; Wed, 26 Apr 2023 06:20:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6D5906B00B6; Wed, 26 Apr 2023 06:20:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 59E516B00B7; Wed, 26 Apr 2023 06:20:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 4851A6B00B4 for ; Wed, 26 Apr 2023 06:20:18 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0E2798018F for ; Wed, 26 Apr 2023 10:20:18 +0000 (UTC) X-FDA: 80723147316.01.B867E3E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 7845E4000E for ; Wed, 26 Apr 2023 10:20:16 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cpWaZKyD; spf=pass (imf12.hostedemail.com: domain of cem@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cem@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1682504416; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=EFplE1ZTV0rZS4ho872cZNjml0GbERpu6BkeRRsymG4=; b=kXgSqvTME1YFS42TSYWrmu0D+dqmiyvJzuJ5zaTcI/SvWksWotdotwEWHlduVt6YdVoNdS f1/5oYduFX94rrZwLplkKKe3T1I3ECp+w7//glMqsMt7poHqlGinuvRkXwNOu5Uw1+Vh97 /VcEibA3BARSDUrAUOapd5K4cw1dSa8= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=cpWaZKyD; spf=pass (imf12.hostedemail.com: domain of cem@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=cem@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1682504416; a=rsa-sha256; cv=none; b=Ufrq3N+c1D1bAv1kk53v6g0frQwHVaBVKfPo+7inrDwETHQZElECU/WS4YVoDvHgh4ZcOX YQtpXWnJ3N53LzYpHs9BcxDGXFWDYw5ZLo2ApcxrcfKexF4GvlZOGWtvySZChAxSyOdtIU QNWMFPAEVZRTLfBdL7MxaQfoZwWFHoE= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 641FE62B5F; Wed, 26 Apr 2023 10:20:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96334C433EF; Wed, 26 Apr 2023 10:20:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682504414; bh=+72scZ7VSrEbFk5AjJyWMk6v7WpaFJZChJ4Unh20ZRU=; h=From:To:Cc:Subject:Date:From; b=cpWaZKyDhYu+aGsuDFlRgHTkyj/dXbXhhtsWcj2SEINC18/G8bosHC1qy77KpSHnR FRecWYiecdRtcFI4xdqImjqLA3ZzOrc9tPB1iA9NiNvuUGBF4IrKp05bf7Zg62oleh SJ+MguHRBqGGCtug8EplmtnGxbeXAtutSKH7wYOz7qpV3vUkWBhBBBjjfNMgwpLHMe el5iuDhiwK9sBNOTkG48WpTz2lTZ/JKXzMA3TRCyi98HBe5W2nuILvm4Vef2cfpaeq r0K5RVZRDmyWujLP5+AN1EvxWv664m4nF1BdbczQ2hjbPAbcOPP5bs/eULAmSLJqFZ JY7eMrCy1GhZQ== From: cem@kernel.org To: hughd@google.com Cc: jack@suse.cz, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, djwong@kernel.org Subject: [PATCH V4 0/6] shmem: Add user and group quota support for tmpfs Date: Wed, 26 Apr 2023 12:20:02 +0200 Message-Id: <20230426102008.2930932-1-cem@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: 3zgqoa15beifjpq1nfzgc83e147oe5kb X-Rspamd-Queue-Id: 7845E4000E X-HE-Tag: 1682504416-151388 X-HE-Meta: U2FsdGVkX18IEBI52aPhiKrqiqDnkLVrrtMf7/hrU6zUIshXHF5musMdyZiINJBBYIvOydbY61yrCMDkqgfiwCBm/03lthFrOihmIB3H9H2jpGg5X60GOA16Z4Wc4vAKaycvqFoVUYXePQQZIbEyyHSsGlZvmJGPJMkOrxOhQ5VA4XABxqtaJ/11SoKZuh4TM32kWftyMgeTEbHrk2FYgU+K2MKK/qAItp+e4gyqIW60RnXi9P043v20OAub/wSRKE8kvJ/EhPNgKtb9ia+97pmv0x+ipYccTJH4sFer/qpQ9Nioz3p51qRKl2/NMCoKZ/yA/GOsrUkqmXQsYYOTyjdUpqKWc728JjShzbvTY0LLN/2/rUd1F/T8pPgxUSXs2HJ7tu7F2bE798uOlaLSMwF6roz1oCPIN8d2ZcO0yFv5ftb0yKd4vv2I+eTzWfOmL/wyxHjcQH5hA2TV1T8sT3fL8DosMEKtpMIgv7Tx+0wawBfcytiqg7AYdN/FBcEsKEyJj35mo279tAwXBuzmGujbUYAxX7A7gDjNv9mp8bbZG1CNy2NhKbyKlKRR9ibFn4F+qEfLkahWxZP8EiHQMRUi3hsDc334nzcQubdTfzBDhjTQdrYobbw0Rixq6dOb7b3yU0iOFl/ly3DifducMns1/NqbjDEOx/BOIiNsnwJ34Bq0j5UsDvjFnpOxuQzFIz+tLK0sfkNX7J8r+pAp6Djh1DYqfpwxFQrBmFUhl0yQp7lK+1JuDDivTtBXZLhJfxMp3shX1AwNZc5FR8CHRi46UxSfLJUFjtVvP/Kd4zbAWAHGlscV4zwMUeMe3aqtOjD7l0bNG/jv8NAvTcsFX2L3YTZ/qZw2vn0kG3ktYEGG+rEmWjdB7U28iXZSzcQwfU9J58kXhd3ZCZPQTfduKm+p7JQypBxc7Kstv85oUftS4R4TbtdOka+Is3kwUzInP41ihHJwW7f/vf/8ly1 47LxcsZh GtllMmv1bLcFom1x9oc7ZRjvdpOclboOvu1i3dsgMg+lTyKgLGUbCjGbo86ihKHNbQuEAnorXu2BmmfDJJUK19bCtEPlZpJHC2du9z9eMUbdMTtbBt4lom5ETPLFkjqWVAiP1p3EKUiycRZ1mKnirh3Er3PhGgePZfOPqmwrWDaLUeC0vI6AkVGoVFAb433RSMTdHvv8fyLqNu8/ip3OiyEMtNT1htVHzC9lZiRTr5hfWNAZeZzGbm7LU3mN1Hcq6ueziDbzx5iDxXOe0NmGHDhb4VZiDIB11tkdNi7HjTAKIqH+ybqopyxFQr2MeqORuP821r9jjRs3GO8GieAn2NYfzzbq0cnd4ZgrQUW2gt5F7inMfa7uJnZubBrolZIbSRm48 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: From: Carlos Maiolino Hello folks. This is the final version of the quota support from tmpfs, with all the issues addressed, and now including RwB tags on all patches, and should be ready for merge. Details are within each patch, and the original cover-letter below. Hi folks. this work has been done originally by Lukas, but he left the company, so I'm taking over his work from where he left it of. This series is virtually done, and he had updated it with comments from the last version, but, I'm initially posting it as a RFC because it's been a while since he posted the last version. Most of what I did here was rebase his last work on top of current Linus's tree. Honza, there is one patch from you in this series, which I believe you had it suggested to Lukas on a previous version. The original cover-letter follows... people have been asking for quota support in tmpfs many times in the past mostly to avoid one malicious user, or misbehaving user/program to consume all of the system memory. This has been partially solved with the size mount option, but some problems still prevail. One of the problems is the fact that /dev/shm is still generally unprotected with this and another is administration overhead of managing multiple tmpfs mounts and lack of more fine grained control. Quota support can solve all these problems in a somewhat standard way people are already familiar with from regular file systems. It can give us more fine grained control over how much memory user/groups can consume. Additionally it can also control number of inodes and with special quota mount options introduced with a second patch we can set global limits allowing us to replace the size mount option with quota entirely. Currently the standard userspace quota tools (quota, xfs_quota) are only using quotactl ioctl which is expecting a block device. I patched quota [1] and xfs_quota [2] to use quotactl_fd in case we want to run the tools on mount point directory to work nicely with tmpfs. The implementation was tested on patched version of xfstests [3]. [1] https://github.com/lczerner/quota/tree/quotactl_fd_support [2] https://github.com/lczerner/xfsprogs/tree/quotactl_fd_support [3] https://github.com/lczerner/xfstests/tree/tmpfs_quota_support Jan Kara (1): quota: Check presence of quota operation structures instead of ->quota_read and ->quota_write callbacks Lukas Czerner (5): shmem: make shmem_inode_acct_block() return error shmem: make shmem_get_inode() return ERR_PTR instead of NULL shmem: prepare shmem quota infrastructure shmem: quota support Add default quota limit mount options Documentation/filesystems/tmpfs.rst | 31 ++ fs/Kconfig | 12 + fs/quota/dquot.c | 2 +- include/linux/shmem_fs.h | 28 ++ include/uapi/linux/quota.h | 1 + mm/Makefile | 2 +- mm/shmem.c | 465 +++++++++++++++++++++------- mm/shmem_quota.c | 350 +++++++++++++++++++++ 8 files changed, 783 insertions(+), 108 deletions(-) create mode 100644 mm/shmem_quota.c Signed-off-by: Carlos Maiolino