From mboxrd@z Thu Jan 1 00:00:00 1970 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 ED16CC4332F for ; Tue, 8 Nov 2022 17:43:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43EB46B0072; Tue, 8 Nov 2022 12:43:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EF2C8E0002; Tue, 8 Nov 2022 12:43:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B6F78E0001; Tue, 8 Nov 2022 12:43:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 180F86B0072 for ; Tue, 8 Nov 2022 12:43:30 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id E064A16076E for ; Tue, 8 Nov 2022 17:43:29 +0000 (UTC) X-FDA: 80110996938.18.1644620 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf23.hostedemail.com (Postfix) with ESMTP id 2D670140005 for ; Tue, 8 Nov 2022 17:43:28 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 49C922236D; Tue, 8 Nov 2022 17:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1667929407; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fFpkVndgvsqEYK2160brGpLwx/3cfx9Kks2Ym2V5INA=; b=yQSb5T9exB819XSZWj2WAnbZUNPhsysI7Dd2vjTrMHp4wh8olPc4YimZW+G0gwV0hJl3lR +IErioO/JXoxSgU0mxwL4hEgfNXTXqzM3YNZ2a3cxCp4Kg9RIXHL3avuGSbAsl9wNhRqe6 Eim9/vkMPNEIR5/VKYatYLkjPrcN2UI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1667929407; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=fFpkVndgvsqEYK2160brGpLwx/3cfx9Kks2Ym2V5INA=; b=mgqxeWLbFKd6+QX7VyrqRDxOELY+pefRk9DVekG9CkBT86h0GeGVbs8OdaJ8eyoQk6NP8S OQt1IKwbI8h9FqCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3C313139F1; Tue, 8 Nov 2022 17:43:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eRmsDj+VamNZJAAAMHmgww (envelope-from ); Tue, 08 Nov 2022 17:43:27 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 9D874A0704; Tue, 8 Nov 2022 18:43:26 +0100 (CET) Date: Tue, 8 Nov 2022 18:43:26 +0100 From: Jan Kara To: Lukas Czerner Cc: Hugh Dickins , Jan Kara , Eric Sandeen , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH 0/2] [RFC] shmem: user and group quota support for tmpfs Message-ID: <20221108174326.hkgtrt72rpkmelyq@quack3> References: <20221108133010.75226-1-lczerner@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221108133010.75226-1-lczerner@redhat.com> ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=yQSb5T9e; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mgqxeWLb; spf=pass (imf23.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667929409; a=rsa-sha256; cv=none; b=flnjum80TRGbpVg90UT0gc21A3zB2hHOYH+ry97nS4bFEPdCo5m8mGK+CY9lw581XKNDCj EWzYgEk88AHbGBKPCZBhq3rKwWch72MjR0G+SkGTbfnI5sYg+iWhwIwfkehq+h0cu1Bpt8 WAK9nc2k5fb1KCE3EoDxxF9odAuBPx4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667929409; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fFpkVndgvsqEYK2160brGpLwx/3cfx9Kks2Ym2V5INA=; b=60Y31imsYpDcKz26GrlRY8wgjCbhftGrURUC8oC65g+FtFF1cWvtYUSoYJFVhh5Wb1BovR F6CYHMDAJsQjdREGFRooYck1YtTYPO8fLDCJ1tz2Ayz4zuAws6ygom99juIaxNIiMJWZj8 t+EhTga/1GTrj9gdbjp1d4ltC7HQkjo= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2D670140005 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=yQSb5T9e; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mgqxeWLb; spf=pass (imf23.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none X-Stat-Signature: 6s53yc7c9nhau9ntz6x18x68wyomcz1m X-Rspam-User: X-HE-Tag: 1667929408-988081 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: On Tue 08-11-22 14:30:08, Lukas Czerner wrote: > 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]. > > Thoughts? Thanks for the work Lukas! I have one general note regarding this quota support: IMO it is pointless to try to retrofit how quota files work on block-based filesystems to tmpfs. All the bothering with converting between on-disk and in-mem representation, formatting of btree nodes is just pointless waste of CPU and code. I think much simpler approach would be to keep some internal rbtree with quota structures carrying struct mem_dqblk and id. Then your .acquire_dquot handler will fill in quota information from the structure and .release_dquot will copy new data into the structure. So basically all operations you'd need to provide in your implementation are .acquire_dquot, .release_dquot, and .get_next_id. And then you'll probably need to define new quota format with .read_file_info callback filling in some limits of the format (and some other stub callbacks doing nothing). If there's too much boilerplate code doing nothing, we can have a look into making quota core more clever to make life simpler for in-memory filesystems (hidden behind something like DQUOT_QUOTA_IN_MEMORY flag in struct quota_info) but currently I don't think it will be too bad. Honza > [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 SUSE Labs, CR