Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4181846ybz; Tue, 28 Apr 2020 07:06:47 -0700 (PDT) X-Google-Smtp-Source: APiQypL8OBw1rNQB0hXgkZZTrg9uNHBqE+Ht0TBEV/IcWDcFEo23B5HpYV4tp6n0bF+VSOB2c7IY X-Received: by 2002:a17:906:adb:: with SMTP id z27mr25105645ejf.263.1588082807493; Tue, 28 Apr 2020 07:06:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588082807; cv=none; d=google.com; s=arc-20160816; b=teHSVjZO+zg/W1IKEGkAyrLvuxXD9zbxaylKPxERt41apUgV1WCznBoDpYFyVGQ2pQ q8DJB53DlAxCCG7JO876p+4JyZTbDM/+hJpFQ9maIgAFudh0DukQXrtQyMeOq8wz7wJh NJWOen6Ym8Br2N8OGn19MRW7HMxtBIXHMUb1scmBA+jJZNmp77rsN86BVHCOP7rBZiBV gK3BDvaGsCONQEI3qasA+gcScnBCb366IdC7xJKXTZbeqkUxEw0whFzqo6bmTddn49NV +9MVwo/TYB2ZLvPBea8dMJ3Pgr767NEysl6je7luvssUepF6auio6vswe0TPH2zHA7e2 6l+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:from:organization :dkim-signature; bh=4zvqBCg098ovR8dFjmTUuCU9Nkp7zOhIutaHG4wiHTc=; b=A2OPapjw2X2gTMtJKc8TRVvfSSBmq1+RpXg/CnlA3n8RQJCIUgYBzAaK0GonW848s6 ovo3YLS/y4L9HUh+GU5hecblISok+GzqSgksdZ4Oh+xIJ0+v8nBvTJe0M1dKc6yCwiJh +hHmhk91p7ZVo5TQ3ZC+XTchhBVt04Na/ptM3crSqs/ew1kMETb6ci69feb4H9SZZ9Ej ZWtlRt/qMyvC6h6eMGHb06cNMsbZq8qx8EG3zz8udQmpLr7LNRHZmysUDfAmRYBoQhmk uGjFugPT7aek2bPz4OhVSt6s840O2/5ayZ1mP84P8CSwXSdCEN+Rojl4WbEwU+Tv8leY INqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V4pYBcZA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si1868219ejv.473.2020.04.28.07.05.58; Tue, 28 Apr 2020 07:06:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=V4pYBcZA; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727934AbgD1OEu (ORCPT + 99 others); Tue, 28 Apr 2020 10:04:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:42149 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727933AbgD1OEu (ORCPT ); Tue, 28 Apr 2020 10:04:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588082688; h=from:from: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:content-transfer-encoding; bh=4zvqBCg098ovR8dFjmTUuCU9Nkp7zOhIutaHG4wiHTc=; b=V4pYBcZAJOPSWDV6hUGNw4n6TnlIskTCjNfkXzHtmiCmOkz1Zt3KvsTSy895o0zO/53/VF WpB3Fo1ZiysPwnlxu/u1dfY0YifoEUogs9QAFYYAjZnzxeWP+WbNrJjjkW50iAInQ/wRad ag96L0yhncEosoYvROineLWze3a+1lA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-288-jJvNShcYOhG0_Q-JhooAFg-1; Tue, 28 Apr 2020 10:04:44 -0400 X-MC-Unique: jJvNShcYOhG0_Q-JhooAFg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EDACD800685; Tue, 28 Apr 2020 14:04:43 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-113-129.rdu2.redhat.com [10.10.113.129]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6B995D715; Tue, 28 Apr 2020 14:04:42 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: lczerner@redhat.com cc: dhowells@redhat.com, viro@zeniv.linux.org.uk, linux-ext4@vger.kernel.org Subject: Notes on ext4 mount API parsing stuff MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1020557.1588082682.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Tue, 28 Apr 2020 15:04:42 +0100 Message-ID: <1020558.1588082682@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Hi Lukas, Here are some notes on your ext4 mount API parsing stuff. >static int note_qf_name(struct fs_context *fc, int qtype, > struct fs_parameter *param) >{ >... > qname =3D kmemdup_nul(param->string, param->size, GFP_KERNEL); No need to do this. You're allowed to steal param->string. Just NULL it = out afterwards. It's guaranteed to be NUL-terminated. ctx->s_qf_names[qtype] =3D param->string; param->string =3D NULL; >... >} > ... >static int ext4_parse_param(struct fs_context *fc, struct fs_parameter *p= aram) >{ > struct ext4_fs_context *ctx =3D fc->fs_private; > const struct mount_opts *m; > struct fs_parse_result result; > kuid_t uid; > kgid_t gid; > int token; > > token =3D fs_parse(fc, ext4_param_specs, param, &result); > if (token < 0) > return token; > >#ifdef CONFIG_QUOTA > if (token =3D=3D Opt_usrjquota) { > if (!*param->string) > return unnote_qf_name(fc, USRQUOTA); > else > return note_qf_name(fc, USRQUOTA, param); > } else if (token =3D=3D Opt_grpjquota) { > if (!*param->string) > return unnote_qf_name(fc, GRPQUOTA); > else > return note_qf_name(fc, GRPQUOTA, param); > } >#endif Merge this into the switch-statement below? > switch (token) { > case Opt_noacl: > case Opt_nouser_xattr: > ext4_msg(NULL, KERN_WARNING, deprecated_msg, param->key, "3.5"); > break; > case Opt_removed: > ext4_msg(NULL, KERN_WARNING, "Ignoring removed %s option", > param->key); > return 0; > case Opt_abort: > set_mount_flags(ctx, EXT4_MF_FS_ABORTED); > return 0; > case Opt_i_version: > set_flags(ctx, SB_I_VERSION); > return 0; > case Opt_lazytime: > set_flags(ctx, SB_LAZYTIME); > return 0; > case Opt_nolazytime: > clear_flags(ctx, SB_LAZYTIME); > return 0; > case Opt_errors: > case Opt_data: > case Opt_data_err: > case Opt_jqfmt: > token =3D result.uint_32; > } Missing break directive? > for (m =3D ext4_mount_opts; m->token !=3D Opt_err; m++) > if (token =3D=3D m->token) > break; I guess this can't be turned into a direct array lookup given what else ext4_mount_opts[] is used for. > ctx->opt_flags |=3D m->flags; > > if (m->token =3D=3D Opt_err) { > ext4_msg(NULL, KERN_ERR, "Unrecognized mount option \"%s\" " > "or missing value", param->key); > return -EINVAL; > } > > if (m->flags & MOPT_EXPLICIT) { > if (m->mount_opt & EXT4_MOUNT_DELALLOC) { > set_mount_opt2(ctx, EXT4_MOUNT2_EXPLICIT_DELALLOC); > } else if (m->mount_opt & EXT4_MOUNT_JOURNAL_CHECKSUM) { > set_mount_opt2(ctx, > EXT4_MOUNT2_EXPLICIT_JOURNAL_CHECKSUM); > } else > return -EINVAL; > } > if (m->flags & MOPT_CLEAR_ERR) > clear_mount_opt(ctx, EXT4_MOUNT_ERRORS_MASK); > > if (m->flags & MOPT_NOSUPPORT) { > ext4_msg(NULL, KERN_ERR, "%s option not supported", > param->key); > } else if (token =3D=3D Opt_commit) { > if (result.uint_32 =3D=3D 0) > ctx->s_commit_interval =3D JBD2_DEFAULT_MAX_COMMIT_AGE; > else if (result.uint_32 > INT_MAX / HZ) { > ext4_msg(NULL, KERN_ERR, > "Invalid commit interval %d, " > "must be smaller than %d", > result.uint_32, INT_MAX / HZ); > return -EINVAL; You're doing this a lot. It might be worth making a macro something like: #define ext4_inval(fmt, ...) \ ({ ext4_msg(NULL, KERN_ERR, ## __VA_LIST__), -EINVAL }) then you can just do: return ext4_inval("Invalid commit interval %d, must be smaller than %d", result.uint_32, INT_MAX / HZ); > } > ctx->s_commit_interval =3D HZ * result.uint_32; > ctx->spec |=3D EXT4_SPEC_s_commit_interval; > } else if (token =3D=3D Opt_debug_want_extra_isize) { This whole thing looks like it might be better as a switch-statement. > } > return 0; >} > >static int parse_options(struct fs_context *fc, char *options) >{ >} I wonder if this could be replaced with a call to generic_parse_monolithic= () - though that calls security_sb_eat_lsm_opts() which you might not want. David