Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp3376016rdb; Tue, 6 Feb 2024 16:21:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6QyJus0PruqIjq8tsEqbLT4cs43eQCC6c60DLUg3okoxG/WIyH654qWxYWwdfgl2aPJvS X-Received: by 2002:a05:620a:12cb:b0:783:20c4:663f with SMTP id e11-20020a05620a12cb00b0078320c4663fmr3786966qkl.67.1707265259737; Tue, 06 Feb 2024 16:20:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707265259; cv=pass; d=google.com; s=arc-20160816; b=gTgk/f3Q6Uh9zulef+gv1R02n+N9SuFuIr/zAFZ22PhJWbKDnYpUlSgUm/XJtt8d1q 0YoEgZLmgAzHivAYY8pp6Smwvsq7jn6692qEePbYUZZfpEj3KUOiTbaFpBp2Lj8M0c44 gPSnei2rG/L1w7HgfohWo9I98ukgxx3zOOzbGY+GRSCP33DHotDUvKzJlURyRq3gQ5MV TaWL0dtI4u+SJ/vUY89i3Crss4mJgr45Yj+xO0tId8A4kA/kfMdiGn1IJ73wIcGdQRxR 9X85y4NJ0E9CfJUH7FmjYMHB7VYGYzsrbGs3TFu+quahTCIst/PvwR35ksBraSvcU2Wl rfxg== 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=xurpwFdNldy5a43C8x3u+zLZtuzGTp5D1pD7HBDvZoc=; fh=0XT7zEKw7wpzBId0XkESvMtGo75n7dF7ZK04REyppN0=; b=lg31dDMij5EtignsLEKqDyzgNDRtYj/8995D+VJu5s+2UYJukPEx699XWS5T/RT80J D+0W3dBPhwRxlGClq/eWiHL+IgJbpJOewpSitLzwPpIMU2BtHVbZduB5q4Ib+TSqttDn fuEteW++JEZinKfzgvOehTBEaxazcGSincQanAvQzySRcZ/fyzdhD9GpFt3dp/WC86sl UV81gI5iXAIpRIU936dM1DWnhnZD6bq9rIy6qQcP4ic5hL+MxLDZTxRe+9VUEIzVaswo pzG+a79H0etfZg2r4UZrqeefZsa5417exSDB0lblxrJGV4ioSN0miC4JO/fd+avVTpAp /oeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=owOPz0Ft; arc=pass (i=1 spf=pass spfdomain=fromorbit.com dkim=pass dkdomain=fromorbit-com.20230601.gappssmtp.com dmarc=pass fromdomain=fromorbit.com); spf=pass (google.com: domain of linux-kernel+bounces-55757-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55757-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fromorbit.com X-Forwarded-Encrypted: i=2; AJvYcCW06WjG73Z7PK2GDwqOgRv3G2mL9Q+bvHBBSBBJHSLXFsgrWHMpBOOwDnDXrw5v1MMSU4xfEWEIXwEGXD0uxefBi8oAzUMgunDDTLnA4w== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id vu24-20020a05620a561800b007815c7aa50bsi53028qkn.263.2024.02.06.16.20.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 16:20:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55757-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=owOPz0Ft; arc=pass (i=1 spf=pass spfdomain=fromorbit.com dkim=pass dkdomain=fromorbit-com.20230601.gappssmtp.com dmarc=pass fromdomain=fromorbit.com); spf=pass (google.com: domain of linux-kernel+bounces-55757-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55757-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=fromorbit.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 6FB431C20F6C for ; Wed, 7 Feb 2024 00:20:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 195504A1B; Wed, 7 Feb 2024 00:20:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b="owOPz0Ft" Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9D7C1320E for ; Wed, 7 Feb 2024 00:20:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707265248; cv=none; b=QDhGZ0z+CnNrQb2ybyJLsrH8H7n5VsWPHPykeMjrRIxl5SK0r22b3aOtl4JGx5RuePNcdilisxSrMA04GQ0PmXi+HybEVDjWOVzUuYbVc7XYSFwfTUkrfzSnik+0DKQK96yINxDhmGI8KY1oC3X2jNWHCMmNiKFieWKQDuPr5ms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707265248; c=relaxed/simple; bh=ClMmOPCFmH/6Ksgfa+SOlxvhUma7Q2HOGymy3+SEnec=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CQMR5OCtduviUV0U9TYFPC5fbz8USwhflgDxWy3o+IcA4ty7O5uwA15B9J41XiU9rW6k87DgUMCywxeKXdIp23E/bOFUnqWxWMGS2FgUY3gV5YZsMNPodM/pUkA2VVF1W28DK7nztwQwQLe0S1Cxxj2J/5d8XXxFAsAIqMMnnJo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com; spf=pass smtp.mailfrom=fromorbit.com; dkim=pass (2048-bit key) header.d=fromorbit-com.20230601.gappssmtp.com header.i=@fromorbit-com.20230601.gappssmtp.com header.b=owOPz0Ft; arc=none smtp.client-ip=209.85.215.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=fromorbit.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fromorbit.com Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5ce942efda5so11239a12.2 for ; Tue, 06 Feb 2024 16:20:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1707265246; x=1707870046; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=xurpwFdNldy5a43C8x3u+zLZtuzGTp5D1pD7HBDvZoc=; b=owOPz0FtatUSBKltM/eCgtG+lE3sMC/AYgegW7NkiROgDfRlXOoCcBv+LxDfTyQcXT K1Jpf1zQS8vXcE/T25CVQ1YEkGD4dv0uY7CVBB+UVz7fsqCK800yihCoKosUd8SaSJsX xzOCUy+vf3Ev93P8LOr9cL2RfupL6dzZJHXPueh6ZtJPxIYPKiaHQE2Wc6emyqPBFvkB wMi2st9n8Ps7Cs0Jz0hwkXaHILF8lyHhAEg10uakj69OO4Rlfe9l8kpQyjlTvdZDB+lI V6VZraMQALjTmtyRECa9xkrbLdO+IKovgxerPV3AxnmmcSQK1RKhgIYAnZXjnojLI7qu hoaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707265246; x=1707870046; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=xurpwFdNldy5a43C8x3u+zLZtuzGTp5D1pD7HBDvZoc=; b=lVbqcDNIyBQU+TmlF16ucAXgCRTcAZJobmHLSP9Q4egZ1Xxm/vhleE+ihHWJJ8LW3w jjWSwgbxKadZ7e2MbFJY4SZY3u0Dw+qA0e+p/7rkfeqGv24HbKSb1mCpMJBzCNhymaON dVMZJSeMDPZ2m8KnCirG3U4CL+4YIGgnvoaDFan+i5lyZ7V1P3tuKtzPCu3BvkBu6aif AdNGIRmDWSUid+0XGkPe49xQGYQ8NIxSjLYmSRk3la+PpwVRWdLBQBul6YmIfmhOY67B +l0t/WpquqTGbf/rTHHjJtKjsnKt8qFv3Cs+Q/MU1p6sviqjc/SpscNZ0cnd9XR6bX51 14sQ== X-Gm-Message-State: AOJu0YwJBvlf8+HUCce46frv8DwSv5RaB8nHlOYBgAzdInevKKlBdVxm oCHioIzGauU9ycbt517bQ2nI/QxFUaDTVuM9ta1PYVo4uzgCIiPlIwYYW3XLCEg= X-Received: by 2002:a05:6a21:339d:b0:19c:aba2:69e5 with SMTP id yy29-20020a056a21339d00b0019caba269e5mr3572946pzb.45.1707265245829; Tue, 06 Feb 2024 16:20:45 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCXl4DRRtp4/GlKt7mHd4EOTMTbXwbjSRdRoMPgx4uuppxHN2Apvk65L5wczgD0dn5kGdTTiNp9v0RPYnhtp1/GDmYpD85kJYY26k/+HLsVWUaSM7nyyTMbAA2cJOK0V92wjTeQQjO8ynnygv4seb5bOG8WqY36b2IOTltX56OS0MZL9aE5bDJ6PB91ol3cH++d2YC7FLuoE6I6tKC2Yrbx88I3mdK9c/IwLh05qVN52dbKD0MgNn1jxvYbjoKbguVQCfem4sKI5sHmkWGhMYA== Received: from dread.disaster.area (pa49-181-38-249.pa.nsw.optusnet.com.au. [49.181.38.249]) by smtp.gmail.com with ESMTPSA id hq6-20020a056a00680600b006e03be933cesm89563pfb.96.2024.02.06.16.20.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 16:20:45 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.96) (envelope-from ) id 1rXVgA-0032zx-2J; Wed, 07 Feb 2024 11:20:42 +1100 Date: Wed, 7 Feb 2024 11:20:42 +1100 From: Dave Chinner To: Kent Overstreet Cc: brauner@kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Dave Chinner , "Darrick J. Wong" , Theodore Ts'o , linux-fsdevel@vger.kernel.or Subject: Re: [PATCH v2 3/7] fs: FS_IOC_GETUUID Message-ID: References: <20240206201858.952303-1-kent.overstreet@linux.dev> <20240206201858.952303-4-kent.overstreet@linux.dev> 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=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Feb 06, 2024 at 05:37:22PM -0500, Kent Overstreet wrote: > On Wed, Feb 07, 2024 at 09:01:05AM +1100, Dave Chinner wrote: > > On Tue, Feb 06, 2024 at 03:18:51PM -0500, Kent Overstreet wrote: > > > +static int ioctl_getfsuuid(struct file *file, void __user *argp) > > > +{ > > > + struct super_block *sb = file_inode(file)->i_sb; > > > + > > > + if (!sb->s_uuid_len) > > > + return -ENOIOCTLCMD; > > > + > > > + struct fsuuid2 u = { .len = sb->s_uuid_len, }; > > > + memcpy(&u.uuid[0], &sb->s_uuid, sb->s_uuid_len); > > > + > > > + return copy_to_user(argp, &u, sizeof(u)) ? -EFAULT : 0; > > > +} > > > > Can we please keep the declarations separate from the code? I always > > find this sort of implicit scoping of variables both difficult to > > read (especially in larger functions) and a landmine waiting to be > > tripped over. This could easily just be: > > > > static int ioctl_getfsuuid(struct file *file, void __user *argp) > > { > > struct super_block *sb = file_inode(file)->i_sb; > > struct fsuuid2 u = { .len = sb->s_uuid_len, }; > > > > .... > > > > and then it's consistent with all the rest of the code... > > The way I'm doing it here is actually what I'm transitioning my own code > to - the big reason being that always declaring variables at the tops of > functions leads to separating declaration and initialization, and worse > it leads people to declaring a variable once and reusing it for multiple > things (I've seen that be a source of real bugs too many times). > > But I won't push that in this patch, we can just keep the style > consistent for now. > > > > +/* Returns the external filesystem UUID, the same one blkid returns */ > > > +#define FS_IOC_GETFSUUID _IOR(0x12, 142, struct fsuuid2) > > > + > > > > Can you add a comment somewhere in the file saying that new VFS > > ioctls should use the "0x12" namespace in the range 142-255, and > > mention that BLK ioctls should be kept within the 0x12 {0-141} > > range? > > Well, if we're going to try to keep the BLK_ and FS_IOC_ ioctls in > separate ranges, then FS_IOC_ needs to move to something else becasue > otherwise BLK_ won't have a way to expand. The BLK range can grow downwards towards zero, I think. It starts at 93 and goes to 136, so there's heaps of space for it to grow from 92 to 0.... > So what else - > > ioctl-number.rst has a bunch of other ranges listed for fs.h, but 0x12 > appears to be the only one without conflicts - all the other ranges seem > to have originated with other filesystems. *nod* > So perhaps I will take Darrick's nak (0x15) suggestion after all. That works, too. -Dave. -- Dave Chinner david@fromorbit.com