Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA72CC388F7 for ; Tue, 10 Nov 2020 13:34:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 68CEB206B2 for ; Tue, 10 Nov 2020 13:34:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="awmffSie" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730672AbgKJNew (ORCPT ); Tue, 10 Nov 2020 08:34:52 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:59350 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730418AbgKJNev (ORCPT ); Tue, 10 Nov 2020 08:34:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605015290; 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: in-reply-to:in-reply-to:references:references; bh=Ef4XMKxyjsP61fvlbl6gamniFO7GK9pZarg2o+N1cAE=; b=awmffSieTeZdA0GOb/6hQ+tUIc0cwL+bl6UqZCXfGezV/OXnB3Elh3+qRGYB/Qih/9sZ98 IPcXkAihlx+DG4a4QSGbKX6+spUgWK+n/dob6uWoiE5/63hfzUTyc1QFJdlrL/ne1quivz ehNPz9xVpObeGOAwjfvC2ryrSHFCarA= 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-216-P0bV52n5OBOYSc4uEV5BRw-1; Tue, 10 Nov 2020 08:34:48 -0500 X-MC-Unique: P0bV52n5OBOYSc4uEV5BRw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5ADD6101F7AC; Tue, 10 Nov 2020 13:34:47 +0000 (UTC) Received: from [10.72.12.102] (ovpn-12-102.pek2.redhat.com [10.72.12.102]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C3F0C5DA33; Tue, 10 Nov 2020 13:34:44 +0000 (UTC) Subject: Re: [PATCH v2 2/2] ceph: add CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS ioctl cmd support To: Jeff Layton , idryomov@gmail.com Cc: zyan@redhat.com, pdonnell@redhat.com, ceph-devel@vger.kernel.org References: <20201110105755.340315-1-xiubli@redhat.com> <20201110105755.340315-3-xiubli@redhat.com> <4e7ca1cec2ad6bc78423fc77ac9295c8740a8601.camel@kernel.org> <8ed29213-aac8-7395-9331-fa7ce1d53280@redhat.com> <9ee0df520ac58ff1726dbb6527910ab87dc771d1.camel@kernel.org> From: Xiubo Li Message-ID: <976fd2c8-1a5c-ff67-7a79-1346493b3ef0@redhat.com> Date: Tue, 10 Nov 2020 21:34:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <9ee0df520ac58ff1726dbb6527910ab87dc771d1.camel@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org On 2020/11/10 21:32, Jeff Layton wrote: > On Tue, 2020-11-10 at 21:25 +0800, Xiubo Li wrote: >> On 2020/11/10 20:24, Jeff Layton wrote: >>> On Tue, 2020-11-10 at 18:57 +0800, xiubli@redhat.com wrote: >>>> From: Xiubo Li >>>> >>>> This ioctl will return the cluster and client ids back to userspace. >>>> With this we can easily know which mountpoint the file belongs to and >>>> also they can help locate the debugfs path quickly. >>>> >>>> URL: https://tracker.ceph.com/issues/48124 >>>> Signed-off-by: Xiubo Li >>>> --- >>>>   fs/ceph/ioctl.c | 23 +++++++++++++++++++++++ >>>>   fs/ceph/ioctl.h | 15 +++++++++++++++ >>>>   2 files changed, 38 insertions(+) >>>> >>> I know I opened this bug and suggested an ioctl for this, but I think >>> that this may be better presented as new vxattrs. Driving ioctls from >>> scripts is difficult (in particular). An xattr is easier for them to >>> deal with. Maybe: >>> >>>      ceph.clusterid >>>      ceph.clientid >> How about : >> >> [root@lxbceph1 kcephfs]# getfattr -n ceph.local.clusterid file >> # file: file >> ceph.local.clusterid="6ff21dc9-36b0-45a9-bec2-75aeaf0414cf" >> >> [root@lxbceph1 kcephfs]# getfattr -n ceph.local.clientid file >> # file: file >> ceph.local.clientid="client4360" >> >> ?? >> > What does "local" signify in these names? Which means only existing in local client side. If this make no sense I will remove them. Thanks BRs >> >>> ...or you could even make one that gives you the same format as the >>> dirnames in /sys/kernel/debug/ceph. >>> >>>> diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c >>>> index 6e061bf62ad4..a4b69c1026ce 100644 >>>> --- a/fs/ceph/ioctl.c >>>> +++ b/fs/ceph/ioctl.c >>>> @@ -268,6 +268,27 @@ static long ceph_ioctl_syncio(struct file *file) >>>>    return 0; >>>>   } >>>> >>>> >>>> >>>> >>>> +/* >>>> + * Return the cluster and client ids >>>> + */ >>>> +static long ceph_ioctl_get_fs_ids(struct file *file, void __user *arg) >>>> +{ >>>> + struct inode *inode = file_inode(file); >>>> + struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb); >>>> + struct cluster_client_ids ids; >>>> + >>>> + snprintf(ids.cluster_id, sizeof(ids.cluster_id), "%pU", >>>> + &fsc->client->fsid); >>>> + snprintf(ids.client_id, sizeof(ids.client_id), "client%lld", >>>> + ceph_client_gid(fsc->client)); >>>> + >>>> + /* send result back to user */ >>>> + if (copy_to_user(arg, &ids, sizeof(ids))) >>>> + return -EFAULT; >>>> + >>>> + return 0; >>>> +} >>>> + >>>>   long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg) >>>>   { >>>>    dout("ioctl file %p cmd %u arg %lu\n", file, cmd, arg); >>>> @@ -289,6 +310,8 @@ long ceph_ioctl(struct file *file, unsigned int cmd, unsigned long arg) >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>>    case CEPH_IOC_SYNCIO: >>>>    return ceph_ioctl_syncio(file); >>>> + case CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS: >>>> + return ceph_ioctl_get_fs_ids(file, (void __user *)arg); >>>>    } >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>>    return -ENOTTY; >>>> diff --git a/fs/ceph/ioctl.h b/fs/ceph/ioctl.h >>>> index 51f7f1d39a94..9879d58854fb 100644 >>>> --- a/fs/ceph/ioctl.h >>>> +++ b/fs/ceph/ioctl.h >>>> @@ -98,4 +98,19 @@ struct ceph_ioctl_dataloc { >>>>    */ >>>>   #define CEPH_IOC_SYNCIO _IO(CEPH_IOCTL_MAGIC, 5) >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> +/* >>>> + * CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS - get the cluster and client ids >>>> + * >>>> + * This ioctl will return the cluster and client ids back to user space. >>>> + * With this we can easily know which mountpoint the file belongs to and >>>> + * also they can help locate the debugfs path quickly. >>>> + */ >>>> + >>>> +struct cluster_client_ids { >>>> + char cluster_id[40]; >>>> + char client_id[24]; >>>> +}; >>>> +#define CEPH_IOC_GET_CLUSTER_AND_CLIENT_IDS _IOR(CEPH_IOCTL_MAGIC, 6, \ >>>> + struct cluster_client_ids) >>>> + >>>>   #endif >>