Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp441745lqc; Fri, 8 Mar 2024 01:53:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVJhHAIIWb4S5W6/vKzAmullEm0MJbWPA1qWPSgKiWWavCZOitrolYEj25kKxCif+U7WgDYnvcoPpii+e8S+l/z1pXSBP5FkGAZSfTcqQ== X-Google-Smtp-Source: AGHT+IEO3C3UUc4xMCNV5KwUbgJfxkcjqjz8T8qW2W73ldVF12GJ3XU0s00g9oqO5swdukNyRQz7 X-Received: by 2002:a17:906:589:b0:a45:163a:c08e with SMTP id 9-20020a170906058900b00a45163ac08emr2786996ejn.0.1709891624826; Fri, 08 Mar 2024 01:53:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709891624; cv=pass; d=google.com; s=arc-20160816; b=WVrUQt0oLPsnxurWeJm4V/WKtPQS9OdFgLkcjIQb5sEjc9b/7TUgIOf03KQAxTtzUn HKcG1Uo4LP4xJ2lNc7lRy/QW38lTxGd1BV0+HugK4AJdWK3Oc/aNg11UMKcv3J2EPHEC w5VfdBUQlyFSkOJlFOvbAwAmrc5CaZZt0lHSqxBuOOqoxyPCHNpL/mnETQzkKaCriEvQ xPTEZEzrO3qtCuYlq6uIK63SeNNh07rLPrnHxf7Lq3qCX4RNNijT3Em/ovm35whEio0V RMqwrf+EkO7scMbzyn8900ffsF8HH5Y+xJ+o/eFlVL9g0oo+Sdb/lNDqG0Z9vqH5lv/Q a0eg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=++mC9pDkD/hOMHYzJw3R7PxJ91EMbU3KtoFbVL+oReY=; fh=0eTAKV20nj/fdrcR/0g+fj6ex8aYFOrCNCMqIsb2meQ=; b=u7oBoz0HIUY9WJXSm+bAsroc7cpqz5kzlmWSyA056oJ1zMqzG78i1s3WNTOOJduiuy jA+UIPUBVO3KQ1eNDVeC/l+rWTXRiPlow1YB6f1axGY7Sm2f51F1rmD8BMqIrUaKejNM SXj4oVjMMIuDwvefHIrVfHZ+4z40ZIz68SunWt42z9ZLU+Sczpajp/wSRm9W4JG//zPr 0+buSE3CaAychFZjAtxz4y3RB7uNuJvMnoAYe1ThREKYaSQa+5KSTT6GRxekTi++nNNV pclg5v7Do030xa/gnN+1+dD2UnId4bEVIUApGjNkHCRsd2qEDoa4ZNrCh48Ob0iZWcN7 FDLA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XtH6iBRE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-96776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id n4-20020a170906118400b00a4519d5358dsi5009304eja.243.2024.03.08.01.53.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Mar 2024 01:53:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XtH6iBRE; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-96776-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96776-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8BFDF1F218AB for ; Fri, 8 Mar 2024 09:53:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6FA45380B; Fri, 8 Mar 2024 09:53:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XtH6iBRE" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D21F3535BC; Fri, 8 Mar 2024 09:53:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709891611; cv=none; b=PySgpcBlh6DCNMHyzvpl974gTy4VHGU9N2NTDBUxgn4hUl3TyD5QD5hWAfvFCoRSrYM2B4vjBLthLGPeobnGuRwIjXLmoT393YjiO+4Xu2Ne80ywSJKAJoN4dn4SENP1q2F1k8+5nR5WBVMdW1xZQki1d9sr2HwcXmCzCgSEFi0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709891611; c=relaxed/simple; bh=QmRLKVLKdt30yVzpTeSE0AYS+PV/cT94dyjGByHQZGI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=rkG5ZmLzU7dlBOOFMZNfXgKaXHZLC2fISJRJS9z4sGZLzxMfBt8hvvRNl2JqEmugwYIVAnxoVqczBGT9CJEuGXRbPm5PiVktKuzMzOMp2MjPqg8MMhqiDu22Zsj9ImYWVBFqFJcs+8Dl8yIszRjlkSpATb03MN86bNdspdDnoL8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XtH6iBRE; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4F71FC43399; Fri, 8 Mar 2024 09:53:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709891611; bh=QmRLKVLKdt30yVzpTeSE0AYS+PV/cT94dyjGByHQZGI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=XtH6iBREN3fVVbo0N98tpdhelBvJwfta1zM+gE/yvF18IO5iE87HFY4lXF56SGXBC kfA/twpwFNN6zkz9o5kHiYAIigkaQWNx1W625GlLF0ECkUajoYcHp+5D7ex0cpOEUd sEYKQ3DkTH72v7llSvb3nIRzJsR/IxsWbzs/xRevqAVtCc30bIc8TcGQUFjcwuWW27 OHAKUnSrl2Vq3SBUSQXLvr2Op7avFBjDWLafKD56EP9l5GOtlMwkAs3Cz/C/qTaV7A iXKRr01hwuLcx5zDqGxrCDLJoW9eIw/4OwGCpqHmra+EUNn0rnVAQduOepaSxxcbHI SuzZNHn2+YKkA== Date: Fri, 8 Mar 2024 10:53:25 +0100 From: Christian Brauner To: Jan Kara Cc: Luis Henriques , Theodore Ts'o , Andreas Dilger , Alexander Viro , Miklos Szeredi , Amir Goldstein , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] fs_parser: handle parameters that can be empty and don't have a value Message-ID: <20240308-fahrdienst-torten-eae8f3eed3b4@brauner> References: <20240229163011.16248-1-lhenriques@suse.de> <20240229163011.16248-2-lhenriques@suse.de> <20240301-gegossen-seestern-683681ea75d1@brauner> <87il269crs.fsf@suse.de> <20240307151356.ishrtxrsge2i5mjn@quack3> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240307151356.ishrtxrsge2i5mjn@quack3> On Thu, Mar 07, 2024 at 04:13:56PM +0100, Jan Kara wrote: > On Fri 01-03-24 15:45:27, Luis Henriques wrote: > > Christian Brauner writes: > > > > > On Thu, Feb 29, 2024 at 04:30:08PM +0000, Luis Henriques wrote: > > >> Currently, only parameters that have the fs_parameter_spec 'type' set to > > >> NULL are handled as 'flag' types. However, parameters that have the > > >> 'fs_param_can_be_empty' flag set and their value is NULL should also be > > >> handled as 'flag' type, as their type is set to 'fs_value_is_flag'. > > >> > > >> Signed-off-by: Luis Henriques > > >> --- > > >> fs/fs_parser.c | 3 ++- > > >> 1 file changed, 2 insertions(+), 1 deletion(-) > > >> > > >> diff --git a/fs/fs_parser.c b/fs/fs_parser.c > > >> index edb3712dcfa5..53f6cb98a3e0 100644 > > >> --- a/fs/fs_parser.c > > >> +++ b/fs/fs_parser.c > > >> @@ -119,7 +119,8 @@ int __fs_parse(struct p_log *log, > > >> /* Try to turn the type we were given into the type desired by the > > >> * parameter and give an error if we can't. > > >> */ > > >> - if (is_flag(p)) { > > >> + if (is_flag(p) || > > >> + (!param->string && (p->flags & fs_param_can_be_empty))) { > > >> if (param->type != fs_value_is_flag) > > >> return inval_plog(log, "Unexpected value for '%s'", > > >> param->key); > > > > > > If the parameter was derived from FSCONFIG_SET_STRING in fsconfig() then > > > param->string is guaranteed to not be NULL. So really this is only > > > about: > > > > > > FSCONFIG_SET_FD > > > FSCONFIG_SET_BINARY > > > FSCONFIG_SET_PATH > > > FSCONFIG_SET_PATH_EMPTY > > > > > > and those values being used without a value. What filesystem does this? > > > I don't see any. > > > > > > The tempting thing to do here is to to just remove fs_param_can_be_empty > > > from every helper that isn't fs_param_is_string() until we actually have > > > a filesystem that wants to use any of the above as flags. Will lose a > > > lot of code that isn't currently used. > > > > Right, I find it quite confusing and I may be fixing the issue in the > > wrong place. What I'm seeing with ext4 when I mount a filesystem using > > the option '-o usrjquota' is that fs_parse() will get: > > > > * p->type is set to fs_param_is_string > > ('p' is a struct fs_parameter_spec, ->type is a function) > > * param->type is set to fs_value_is_flag > > ('param' is a struct fs_parameter, ->type is an enum) > > > > This is because ext4 will use the __fsparam macro to set define a > > fs_param_spec as a fs_param_is_string but will also set the > > fs_param_can_be_empty; and the fsconfig() syscall will get that parameter > > as a flag. That's why param->string will be NULL in this case. > > So I'm a bit confused here. Valid variants of these quota options are like > "usrjquota=" (to set quota file name) or "usrjquota=" (to clear > quota file name). The variant "usrjquota" should ideally be rejected > because it doesn't make a good sense and only adds to confusion. Now as far > as I'm reading fs/ext4/super.c: parse_options() (and as far as my testing > shows) this is what is happening so what is exactly the problem you're > trying to fix? mount(8) has no way of easily knowing that for something like mount -o usrjquota /dev/sda1 /mnt that "usrjquota" is supposed to be set as an empty string via FSCONFIG_SET_STRING. For mount(8) it is indistinguishable from a flag because it's specified without an argument. So mount(8) passes FSCONFIG_SET_FLAG and it seems strange that we should require mount(8) to know what mount options are strings or no. I've ran into this issue before myself when using the mount api programatically.