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 8B904C77B6E for ; Wed, 12 Apr 2023 11:24:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1582B6B0074; Wed, 12 Apr 2023 07:24:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 109326B0075; Wed, 12 Apr 2023 07:24:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F12CF900002; Wed, 12 Apr 2023 07:24:00 -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 DE8816B0074 for ; Wed, 12 Apr 2023 07:24:00 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id A13544005F for ; Wed, 12 Apr 2023 11:24:00 +0000 (UTC) X-FDA: 80672504640.07.7561A35 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf08.hostedemail.com (Postfix) with ESMTP id 7EF6616000A for ; Wed, 12 Apr 2023 11:23:58 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=dbmNll78; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=gvF7go90; spf=pass (imf08.hostedemail.com: domain of jack@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681298638; 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=Xl61cXLhGOLRuAwtEPfNvliak6GSSN+QLJa+pE8BzEc=; b=UhCO/dR6p/7fW7o/1fBxHviRQv3e2X3p7r+c9wz+0ejJIxBkMl3hbB1C0Bl1L2y4gaOcvI 4NGt0aQ6Kc7uj0GebBIp0oeM42vYyLMXnVv/QnnDGn3zmgrfO++6gDHOZ/TjneoG5CRCWp S9S3l+k1ZrJW6tTID4klCP2wj0ZNNQY= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=dbmNll78; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=gvF7go90; spf=pass (imf08.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=1681298638; a=rsa-sha256; cv=none; b=pifOT343THNAYgQzIaJ4oDw1ZQSCw50t9pPOkGHNUwvWPsbvbFudJ1T4k3fH9/WTiX7fDz VA8JmSPj2bmG82emu3GV4BIVyHBthuQIzYZSFrwm6rbCUFMSMfygLDkg7+eUKz6/1pmciD 4Xot4cmfX3I5TuWHgEXUjvCbKrsdkpQ= 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 34E77218FA; Wed, 12 Apr 2023 11:23:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1681298637; 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=Xl61cXLhGOLRuAwtEPfNvliak6GSSN+QLJa+pE8BzEc=; b=dbmNll78Ka6dcrS4wHNA3g4NNST8D6rVbtzy9vXsLn9wKpUtyNpX9svlwy5pe3DtMhoD4f aHb2Sf4zj0sOO0zEVRFpE2sJbBmCJ5i6pHERuHvzLEowSHw2RT7G0TB/i8Xn8GBi8G/1Pf 3HSU/nK33KsWLquLBYXk+clrjSCDwY8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1681298637; 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=Xl61cXLhGOLRuAwtEPfNvliak6GSSN+QLJa+pE8BzEc=; b=gvF7go90Ajv4MjTdHv2pEAe7Qxf/pOGT7crhufgEA9iYBrodDOZo68TCMDu0A7DuUZAghZ UqfJVPf8mTv/f3AA== 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 2527913498; Wed, 12 Apr 2023 11:23:57 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id xkcECc2UNmR+NQAAMHmgww (envelope-from ); Wed, 12 Apr 2023 11:23:57 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id AA78AA0732; Wed, 12 Apr 2023 13:23:56 +0200 (CEST) Date: Wed, 12 Apr 2023 13:23:56 +0200 From: Jan Kara To: Carlos Maiolino Cc: Jan Kara , hughd@google.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, djwong@kernel.org Subject: Re: [PATCH 4/6] shmem: prepare shmem quota infrastructure Message-ID: <20230412112356.gxaw3tbenyd62vb6@quack3> References: <20230403084759.884681-1-cem@kernel.org> <20230403084759.884681-5-cem@kernel.org> <4sn9HjMu80MnoBrnTf2T-G0QFQc9QOwiM7e6ahvv7dZ0N6lpoMY-NTul3DgbNZF08r69V6BuAQI1QcdSzdAFKQ==@protonmail.internalid> <20230404123442.kettrnpmumpzc2da@quack3> <20230404134836.blwy3mfhl3n2bfyj@andromeda> <20230412094432.p5x3sjolu7tbn5g7@andromeda> <_RNo167yxIjXxuLcxRNS79sAk-Hp_67QvILlhEB8sBbXmODJW90YOWDYYU9HHA5MzJ3fFUPxZEfAVbPwlHwfXQ==@protonmail.internalid> <20230412100440.pjgbqc6c44rq5ffj@quack3> <20230412111443.lr5lqq6mchvmesrz@andromeda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230412111443.lr5lqq6mchvmesrz@andromeda> X-Rspamd-Queue-Id: 7EF6616000A X-Stat-Signature: tjbbqwqbzbdd39873gq3j31s1jciccr6 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1681298638-634 X-HE-Meta: U2FsdGVkX19dujQN3i1hxlTClXkJewCM8trBHwnTfn8AlgRmzIZ4ZgAMKbpHqnwehfBhcVz89Ae3M4wqMistjCb72Sv+YAFTUTlLo/XG54HULsK786K/aQGI0OVZF/63wWtu0zQ50UCLHsvSSGMARG6u2iJcJ7h/9gXr0JKeRciKQsMmiDaQks1i0fnDhDnTVvHGiltYLbzrygazhHl1Yvnxh16g4+n7WzSlJ1tjDqgBypNDsKg9t2dZb/iV0lhGmz48hevPsTUCbIp0B0ph6tzkg/t1d+FokKGGZDXe2DFe8Bb3ZirQJWATl0GSwlcOeSs0VaS73zrQK72OP6REYcRvXpfrrYKS7Ko4mkfPbbaMaOgnGPdbakySrfUex3hjGeyr9gu4Dy4nxRiMrAn49xfor21TGtiLpuFOZYyvdvBFuDzK0Mh+aHYdHgGNg9XOqZ6jnr2MuInsNyM6VATeJFaB9ugsSbUyITJjaEgSXzz9XgALhQxSmkpmQRBZOsal7WD6zcfEaPCW4Ez8hJXCM4c9FxiZ1bdWPq5/U9azuTqLCFxbfvD4ZIZjyd74a9WLKJER+LuO3NYThp6GRoCDiV8AleRnjnQkB0ref1drGJ8W325fJu3uiXY97Ha434wmmU9BKOMsNeGIBjAzflNBCmmaD3vDcOrnmyq75lLxHI+BTs/8E9g0OozHWz3B+Mq82YOYr+gcLKrTwt0Us+3sKd6J+STmbL0m7RrCU3UnkzAxS4bhUnL2hwyVhkaDRkWYUd+Awz0Le6Qa2TWdaQg/3lzsb6ncHmF3Gn0qIakJVjg8bVLXXioi2tmHSvXVW9MydNIKeQrh58ZchfO7xrM1XKJQUIICMMMhYWd/GVUKo5gH0w6Shrg+0TfA1ZCF51QqIR5nStVtxoXaTI3hxJYWaVQt8LdUaNGYYNNVFQQurLDeG7OHaDptmdGXimz801CR9yPCMUPED4ELPfV9u46 Y02r5Uyg rSJ2FI/9/nmMEZtbP4qIPA8dz2m/FcYmniCcp6GTMxmRkdaDPqROk57a98jHq81LZgMLnfFRHIvtMZl/NWVI4V0PWEpum7nAZTpR7Ksx+qJT2+EE2t8BCgdfGu3ovqoiaQknYxOdeNV+1ndagR9rULKzsKoew5R+C2rUV8OqDB6dp/kc8GYn3cV0cNAq3kiFe2OsR7JYfQnkh3xc8W4j80ZfqJgi2VqTvRUUWc8yBBuV8afZ9n3flShXPKH9776ILovMDV8V+C6ID8es= 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 Wed 12-04-23 13:14:43, Carlos Maiolino wrote: > On Wed, Apr 12, 2023 at 12:04:40PM +0200, Jan Kara wrote: > > Hi Carlos! > > > > On Wed 12-04-23 11:44:32, Carlos Maiolino wrote: > > > > > > +static int shmem_release_dquot(struct dquot *dquot) > > > > > > +{ > > > > > > + struct mem_dqinfo *info = sb_dqinfo(dquot->dq_sb, dquot->dq_id.type); > > > > > > + struct rb_node *node = ((struct rb_root *)info->dqi_priv)->rb_node; > > > > > > + qid_t id = from_kqid(&init_user_ns, dquot->dq_id); > > > > > > + struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); > > > > > > + struct quota_id *entry = NULL; > > > > > > + > > > > > > + mutex_lock(&dquot->dq_lock); > > > > > > + /* Check whether we are not racing with some other dqget() */ > > > > > > + if (dquot_is_busy(dquot)) > > > > > > + goto out_dqlock; > > > > > > + > > > > > > + down_write(&dqopt->dqio_sem); > > > > > > + while (node) { > > > > > > + entry = rb_entry(node, struct quota_id, node); > > > > > > + > > > > > > + if (id < entry->id) > > > > > > + node = node->rb_left; > > > > > > + else if (id > entry->id) > > > > > > + node = node->rb_right; > > > > > > + else > > > > > > + goto found; > > > > > > + } > > > > > > + > > > > > > + up_write(&dqopt->dqio_sem); > > > > > > + mutex_unlock(&dquot->dq_lock); > > > > > > > > > > We should report some kind of error here, shouldn't we? We do expect to > > > > > have the quota_id allocated from shmem_acquire_dquot() and we will be > > > > > possibly loosing set limits here. > > > > > > > > > > > I've been looking into this today, and I'm not sure if there is any error we > > > should be reporting here, as there isn't anything to really go wrong here. I was > > > comparing it with other filesystems, and most of them uses dquot_release() > > > return value, as a return value for .release_dquot. And on such cases, the error > > > could be other than zero, if something failed while writing the dquot to disk. > > > In the case here, we just write to the RB tree in memory, and it has already > > > been allocated, so, I don't think there is any error we could be returning here. > > > Does it sound right to you? > > > > My point is that it should never happen that we don't find the entry in the > > rbtree in shmem_release_dquot(). So we should rather WARN_ON_ONCE() and > > bail or something like that, rather then silently return success. Not a big > > deal but for initial debugging it might be useful. > > > > I see. Thanks Honza. What you think about something like this: > > while (node) { > entry = rb_entry(node, struct quota_id, node); > > if (id < entry->id) > node = node->rb_left; > else if (id > entry->id) > node = node->rb_right; > else > goto found; > } > > /* We should always find the entry in the rb tree */ > WARN_ONCE(1, "quota id not in rb tree!\n", __func__) > return -ENOENT; > > > I am not sure if -ENOENT is the best error here though. It seems the most > logical one, as -ENOMEM wouldn't make much sense, any suggestions if you don't > agree with ENOENT? Yeah, ENOENT looks good to me. I don't think the error code matters much here as it is in the "should never happen territory". Honza -- Jan Kara SUSE Labs, CR