Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4987104rwb; Mon, 21 Nov 2022 14:58:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf7qpcsIMUaaipEbVYeEBt0dJdkcllI5kDQ/HWccfTPm7yjgHxVAU1FY5K9+/TpK0S+CgtBV X-Received: by 2002:a17:903:289:b0:189:25fb:8e83 with SMTP id j9-20020a170903028900b0018925fb8e83mr3142084plr.20.1669071504460; Mon, 21 Nov 2022 14:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669071504; cv=none; d=google.com; s=arc-20160816; b=0lLDMYOOioohabxxjdjuh88mqUpiD/UJYTtZGrwYAxmyBMkUfAtXY68P1HW81DJtx1 L1v/YhpnByIFk4IL6aE654XJzJQf4TtYDq+k2nnBIFU42gHDYZP4+DHMbgzPFG+aml0k q9mtGZ8lwI06slg64+IHPw5mcmTPV3byf3AgmCmdHqTCtB0lemOH4xBFajWH8QBmo6K9 HSe93dR5pjWtPmI11UGJK4JvGg9kGHursLbXdBEkULFxHIluNqjEVujalft9O4ZfssK0 vWTOCIRzrV4NJy3rC3b7gKDKuvsaxtRerWoeWgeWdmrUTUHyQEvMRQ/I9x4A5CINleB9 rwEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9CSNWtMbUK1u2t8+JxA1M8zd1q6tZY+OyKHvz5BK+Lo=; b=cLxE/Swokqa1ICh+hZwTb9/SU7hq2QychDORFGX3g6jQmkA9wnQgWJbbGFT9tkFdGa T/vmKNhK+YucYaoB5xXw7V7zBSaBgYZluQN/Lr03tbxCbJjmrlLGMj/CPqZnd+IeotKG RmWxGslX2jvJRmwDO1IQL0V5QEMi6qhDRNWhinKAXoMmGRz6R/UfWjM7Ho9fqs5n+1sk GgwfYoalabCY6AhdjgEg90bL7GeInaz/u/Z0Het/7jvKwfwx+bfPgM2qjqyNkYnzMmy9 qbUk82cBxOIeBjp6IqbVsOKxN3f53HFNB/zrx416/HY5wWUIOPDMwryc9iFFPjscFh0K WpSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HIIkyNVd; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c9-20020a17090a8d0900b00218abadb6a3si4825887pjo.65.2022.11.21.14.58.05; Mon, 21 Nov 2022 14:58:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HIIkyNVd; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232112AbiKUWTq (ORCPT + 99 others); Mon, 21 Nov 2022 17:19:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232025AbiKUWTI (ORCPT ); Mon, 21 Nov 2022 17:19:08 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75EAF22B29; Mon, 21 Nov 2022 14:18:49 -0800 (PST) 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 1332A612E4; Mon, 21 Nov 2022 22:18:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C00CC433D7; Mon, 21 Nov 2022 22:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669069128; bh=XaCHFytdWcCHxPKZO9WGONG28k418za/wZBf17odYj0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HIIkyNVd2jZByOV9AyCNR/pVyHKF/QZTyFCaElDyP+fC2/kwZhFaqgqwfNNSnujze 1JAf+bksN/AKoK7fLWSRxvssZ0aqgznjlsxWMw3JP/8ybFrxr+mQzDGrj+UYM6RXwY g7JVmj5hqlhfpDcQd9qMHIh6mKhYEtV2ti5cY9R1BdJq0/K8M7liIjpxs+b3r2lYgy VBUsMdQXE7iE56hxI7KNGbbkjmNSO3Y2VH/LMMH4Zvi6LapI4/5qU0tqERMtCeXFn1 uNPNv9/dTpTTyA9fgZTIFhX/0XmapFQPaC+CxzogQ1fREQu2O267CHvk9m9/h1MwVC Ugw9Ud6eQPQ9g== Date: Mon, 21 Nov 2022 14:18:47 -0800 From: "Darrick J. Wong" To: Dave Chinner Cc: Catherine Hoang , linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org Subject: Re: [PATCH v2 2/2] xfs: add FS_IOC_GETFSUUID ioctl Message-ID: References: <20221118211408.72796-1-catherine.hoang@oracle.com> <20221118211408.72796-3-catherine.hoang@oracle.com> <20221121210223.GJ3600936@dread.disaster.area> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221121210223.GJ3600936@dread.disaster.area> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Nov 22, 2022 at 08:02:23AM +1100, Dave Chinner wrote: > On Fri, Nov 18, 2022 at 01:14:08PM -0800, Catherine Hoang wrote: > > Add a new ioctl to retrieve the UUID of a mounted xfs filesystem. This is a > > precursor to adding the SETFSUUID ioctl. > > > > Signed-off-by: Catherine Hoang > > Reviewed-by: Allison Henderson > > --- > > fs/xfs/xfs_ioctl.c | 36 ++++++++++++++++++++++++++++++++++++ > > 1 file changed, 36 insertions(+) > > > > diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c > > index 1f783e979629..cf77715afe9e 100644 > > --- a/fs/xfs/xfs_ioctl.c > > +++ b/fs/xfs/xfs_ioctl.c > > @@ -1865,6 +1865,39 @@ xfs_fs_eofblocks_from_user( > > return 0; > > } > > > > +static int > > +xfs_ioctl_getuuid( > > + struct xfs_mount *mp, > > + struct fsuuid __user *ufsuuid) > > +{ > > + struct fsuuid fsuuid; > > + __u8 uuid[UUID_SIZE]; > > uuid_t, please, not an open coded uuid_t. > > > + > > + if (copy_from_user(&fsuuid, ufsuuid, sizeof(fsuuid))) > > + return -EFAULT; > > I still think this failing to copy the flex array member and then > having to declare a local uuid buffer is an ugly wart, not just on > the API side of things. > > > + if (fsuuid.fsu_len == 0) { > > + fsuuid.fsu_len = UUID_SIZE; > > XFS uses sizeof(uuid_t) for the size of it's uuids, not UUID_SIZE. > > > + if (copy_to_user(&ufsuuid->fsu_len, &fsuuid.fsu_len, > > + sizeof(fsuuid.fsu_len))) > > + return -EFAULT; > > + return 0; > > + } > > + > > + if (fsuuid.fsu_len < UUID_SIZE || fsuuid.fsu_flags != 0) > > + return -EINVAL; > > + > > + spin_lock(&mp->m_sb_lock); > > + memcpy(uuid, &mp->m_sb.sb_uuid, UUID_SIZE); > > + spin_unlock(&mp->m_sb_lock); > > Hmmmm. Shouldn't we be promoting xfs_fs_get_uuid() to xfs_super.c > (without the pNFS warning!) and calling that here, rather than open > coding another "get the XFS superblock UUID" function here? I disagree that it's worth the effort to create a helper function to wrap four lines of code, particularly since the pnfs code has this extra weird wart of returning the byte offset(?) of the uuid location. > i.e. > if (fsuuid.fsu_flags != 0) > return -EINVAL; > > error = xfs_fs_get_uuid(&mp->m_sb, uuid, &fsuuid.fsu_len, NULL); > if (error) > return -EINVAL; > > Also, uuid_copy()? Why does xfs_fs_get_uuid use memcpy then? Did the compiler reject the u8* -> uuid_t * type conversion? Alternately there's export_uuid(). --D > Cheers, > > Dave. > > -- > Dave Chinner > david@fromorbit.com