From patchwork Wed Jul 26 14:10:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 126404 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp436979vqo; Wed, 26 Jul 2023 07:19:39 -0700 (PDT) X-Google-Smtp-Source: APBJJlF6LWgjhRrHlWhUVVVMszFM2GX4PkxmOXwp38zNYDe1KobgwYzOocSbF2gHLq8IZ5+qJyeQ X-Received: by 2002:aa7:8894:0:b0:663:5624:6fde with SMTP id z20-20020aa78894000000b0066356246fdemr2305783pfe.22.1690381178736; Wed, 26 Jul 2023 07:19:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690381178; cv=none; d=google.com; s=arc-20160816; b=lAEkEnRCqcnEeM5HfPOz2bSwmxfIm9MZc8OSaW/es4UJZEWeCGfPA0sZDof1alXVnV oR9U2FeM4zp6rB0cxFWJuIyeKVgC+0ilKlL0386vm+702y8Fe+vd3gIE1YUKLGVcpaqJ cr2fhFZItlivG5iaHkLbR1SCnzMTeWWX+fdQR++Gq7AES4NQHAg3pEnuYR96F9bThIeD PVE4NA+RJiB5WQlKJICa28w4i0b9wcxRTz4dhupAznK2StogW9GIQnRpyQvQmYhfr9gw lBzysPthRSF9Q1WIOc/BemVIaZEXCQ6GIRRPJ1jAUkASEMK+8YMd+bGEISSqvOtp3zXl 9oRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1S1U/zjZd3rVIX0g7C71Py6TvgiMco2DPzTIrhllhdU=; fh=4TkUEkUtkmMzuUVnw4jjBfLQ2m58OJnBJO1eZJpOGII=; b=Ml9I3qedl2UBDjM1A1TnwItaHku+WQZ6+UZmQFhmt7qwMzHbwXWyU1MOgOW7zw3bfA IeTm/UEDRcv4VePD1wIe9XtwkofTYytqVwIpS2RZhhpmMfLqi8FUKwn2toD9Tdw5ZDvq yJWkP5C0WD7NWS4qKSfqq058c4poZmPswFM8cC6HfwwJDMohyrmsur2y6Qyp41vcM1mJ e7uq/3W++II8wkuEhf2MXHURhq7C0nJZvpd3HQgBQQOwybfxFkICH8F9u+y+Th6HF8rm fXhG2UdENCnZUBi2yyZofTsdk9pdyF26ZRLdndeQNJE7O/myrl1ddztXhn8jxJkzUcSC RGkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b="sTNJYG/c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ea26-20020a056a004c1a00b00672ad8f037esi12761942pfb.231.2023.07.26.07.19.24; Wed, 26 Jul 2023 07:19:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@canonical.com header.s=20210705 header.b="sTNJYG/c"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234024AbjGZOMZ (ORCPT + 99 others); Wed, 26 Jul 2023 10:12:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231912AbjGZOLr (ORCPT ); Wed, 26 Jul 2023 10:11:47 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89DAE46B3 for ; Wed, 26 Jul 2023 07:11:02 -0700 (PDT) Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 5687C420C0 for ; Wed, 26 Jul 2023 14:10:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1690380642; bh=1S1U/zjZd3rVIX0g7C71Py6TvgiMco2DPzTIrhllhdU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sTNJYG/c+U2EAnCreRPNQlYYW+VPs0thnWiiKcndHMFG0YHEQUoJPYOlBji0ED3N4 H9Ch74xpK3TzE2pBMaudFnB9gjPUF3Jp/AU0TA3/c567YcrkRgXGajC83G/ha8JOE7 eWz0gVwxBbBPENY2xavBUQsY6zhGkP1WY52ZRBn9Kw6w5oewhcmQfWsugCBz7gZnIh Z9zJE4IZ5xPfTHDLz9h5U4Z8pPYlMaAjGmzp5CzPsvy/aSMMpemXVQkKiN7y65tl5o GKZHrarDumbrcZPw76mtWvIt3GrhtZmYOfAoiyCmEtvmymdRmQLOISl/QEAeESAKlW 5+Pv0VD1/WNQw== Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-3faabd8fd33so33230545e9.0 for ; Wed, 26 Jul 2023 07:10:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690380639; x=1690985439; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1S1U/zjZd3rVIX0g7C71Py6TvgiMco2DPzTIrhllhdU=; b=PUuHAeIxaX/h1iGItcnf9yZzhzTGBauTNM7/tyx6QDhldjkHBZ1obSUOhy8ezLm54Y /czaRhtqHEa/AcoRnlfXx/nFbf92mCeVdPfEbsgxLTZCEMwrq1vG3NopnJLo7pRg3cND Dq0gIby1xKz9cVXpznm311jBSLkrN5z5yvYBWY56Fb978XlRvwSQYHbwQR6szcSPh9nO jTraRDKNr1y7c0b/X/7qR2JACRHltE9z8+vi7lQ022sxHhPvDRUVqd1GtEECQ7pQXQkk 7umvW/IxVJh3r5z73PxhIhcbk4BnKFBwGdQ2loMYXYDVp6no9ZZW0JIGXYkgIiGjq62L WIww== X-Gm-Message-State: ABy/qLZ0pzNtdS3Zh+muSGKfQ2iLAot0L5qxlURGdMyfs2QJe9nkTV0T DEtq5jTMQ+woTcz3jOxZ9YuMZGyRG8v7MX9jFMGqB5bEODg8sNQuYORaycZ0D1LXaVrYK3zrf4J sj1bGyvvYjfti9D5lkTBKWEVfWoAQMa3785S0A4921Q== X-Received: by 2002:a05:600c:244:b0:3fb:cfe8:8d12 with SMTP id 4-20020a05600c024400b003fbcfe88d12mr1446340wmj.14.1690380639077; Wed, 26 Jul 2023 07:10:39 -0700 (PDT) X-Received: by 2002:a05:600c:244:b0:3fb:cfe8:8d12 with SMTP id 4-20020a05600c024400b003fbcfe88d12mr1446334wmj.14.1690380638896; Wed, 26 Jul 2023 07:10:38 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id k14-20020a7bc30e000000b003fc02219081sm2099714wmj.33.2023.07.26.07.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 07:10:38 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v7 02/11] ceph: stash idmapping in mdsc request Date: Wed, 26 Jul 2023 16:10:17 +0200 Message-Id: <20230726141026.307690-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230726141026.307690-1-aleksandr.mikhalitsyn@canonical.com> References: <20230726141026.307690-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772493134836174730 X-GMAIL-MSGID: 1772493134836174730 From: Christian Brauner When sending a mds request cephfs will send relevant data for the requested operation. For creation requests the caller's fs{g,u}id is used to set the ownership of the newly created filesystem object. For setattr requests the caller can pass in arbitrary {g,u}id values to which the relevant filesystem object is supposed to be changed. If the caller is performing the relevant operation via an idmapped mount cephfs simply needs to take the idmapping into account when it sends the relevant mds request. In order to support idmapped mounts for cephfs we stash the idmapping whenever they are relevant for the operation for the duration of the request. Since mds requests can be queued and performed asynchronously we make sure to keep the idmapping around and release it once the request has finished. In follow-up patches we will use this to send correct ownership information over the wire. This patch just adds the basic infrastructure to keep the idmapping around. The actual conversion patches are all fairly minimal. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- v4: - don't call mnt_idmap_get(..) in __register_request --- fs/ceph/mds_client.c | 5 +++++ fs/ceph/mds_client.h | 1 + 2 files changed, 6 insertions(+) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 191bae3a4ee6..c641ab046e98 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "super.h" #include "crypto.h" @@ -1121,6 +1122,8 @@ void ceph_mdsc_release_request(struct kref *kref) kfree(req->r_path1); kfree(req->r_path2); put_cred(req->r_cred); + if (req->r_mnt_idmap) + mnt_idmap_put(req->r_mnt_idmap); if (req->r_pagelist) ceph_pagelist_release(req->r_pagelist); kfree(req->r_fscrypt_auth); @@ -1180,6 +1183,8 @@ static void __register_request(struct ceph_mds_client *mdsc, insert_request(&mdsc->request_tree, req); req->r_cred = get_current_cred(); + if (!req->r_mnt_idmap) + req->r_mnt_idmap = &nop_mnt_idmap; if (mdsc->oldest_tid == 0 && req->r_op != CEPH_MDS_OP_SETFILELOCK) mdsc->oldest_tid = req->r_tid; diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 717a7399bacb..e3bbf3ba8ee8 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -300,6 +300,7 @@ struct ceph_mds_request { int r_fmode; /* file mode, if expecting cap */ int r_request_release_offset; const struct cred *r_cred; + struct mnt_idmap *r_mnt_idmap; struct timespec64 r_stamp; /* for choosing which mds to send this request to */