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 B1046C77B71 for ; Wed, 12 Apr 2023 11:16:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 440C3900002; Wed, 12 Apr 2023 07:16:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3F16E6B0075; Wed, 12 Apr 2023 07:16:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B8E8900002; Wed, 12 Apr 2023 07:16:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 195766B0074 for ; Wed, 12 Apr 2023 07:16:36 -0400 (EDT) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D843A8047E for ; Wed, 12 Apr 2023 11:14:51 +0000 (UTC) X-FDA: 80672481582.09.09663CD Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id 224FB14000A for ; Wed, 12 Apr 2023 11:14:49 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DH0uPm4w; spf=pass (imf26.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=1681298090; 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=dtgWl3yQCwE54++4n0ZvVgBPKpvg8KjBk3I457hyvUk=; b=GTmDUQZ/8YvgHnkh9/18eZvwo+X9CXq54sFaBlSzgEblNqzFhURZ91f/EZKiB4sD094nUw CADQRciqr8KY/27dIGxiB4sz8Jk5kdxqITKJsFXgE5udEg+9CpZ+O/MHKxvjvUKMJP4oc7 62gnl79xyGbF8GxWjp0RAXNbiZoarNE= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=DH0uPm4w; spf=pass (imf26.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=1681298090; a=rsa-sha256; cv=none; b=5exJzqdY6qG6nVUVnaYqERQUIYc/+QcUFejMvGKFXxaI+m09usONPOmmX6LU5jPWcIOsji bsBtwabX1P47ZdDKPCXjFV5UuP3mgk4DK8zR9YLNQKaIArbBYtomEZeqZjciLJ4EQpcJiD FqYky8vxlRjCgtmynB1p+0+/aHamn2s= 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 0A313628B9; Wed, 12 Apr 2023 11:14:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DF7DC433D2; Wed, 12 Apr 2023 11:14:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1681298088; bh=rHUZtGRkV4yBcmlzGakf5qYn8rNrtTmQ84uzuS2ngHE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=DH0uPm4wPDUhJDbgf2LQzIFtR3ZOn8KE/hWpH3jcXliklLlbZEIfPrKNivl7Kecof MLaJDgg10hv97qefFDfX0DDw/AB39d4XiShyfPXYEFaNW3hnEls3TO5uLXWSW2SQ08 dbsBCrnzq+AQvBAyCFjUPsVGp+wbzo4peJAkoEtvNvPvZpmtYLnA5vSgLHEe0C0CPk zq5DTRT0lZbB8AoHEo0DzwX6I1may44r9mGY4w1ErnE+YnZa6H8w6VtkHm9cgfwBp3 EmGReuHipsWpSB5WMgSrtpkXtZW/zrTuLMBx4ellM3hF2tA+jbaj5W5lplyiJOaHVr B4KJBhMWu+Nwg== Date: Wed, 12 Apr 2023 13:14:43 +0200 From: Carlos Maiolino To: Jan Kara Cc: 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: <20230412111443.lr5lqq6mchvmesrz@andromeda> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230412100440.pjgbqc6c44rq5ffj@quack3> X-Rspamd-Queue-Id: 224FB14000A X-Stat-Signature: rjo9dirrzya7a7einuw1ytotuzu88jz4 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1681298089-419914 X-HE-Meta: U2FsdGVkX18ih/+M0MEmSQsJhxV/Zueh/t4Uf/Vph/bltfuRsMnL0x/cSryMuTzPZxXGSXUqRabXB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zezNW8lr1ONTavF/boZSlUMYkvdVG8+t7xBJ2k+j3lTy7520Z+udbkoOts8lVCSThdd+1Xq2jaaz+EiPe8t7cwOF5yjasL5l5lDGb1LOWiqRcfQrvOB+cCu4rmC56AMSZk7l+jp9elql80G2laEG9HQpRnKtwce/WCbTOWLZ+FIrVYLORACKxXwFiF85B0Lpnn5XRIy6QmjZpM= 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, 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? > Honza > -- > Jan Kara > SUSE Labs, CR -- Carlos Maiolino