Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp2308948rwo; Thu, 3 Aug 2023 07:41:48 -0700 (PDT) X-Google-Smtp-Source: APBJJlFvZ1pNZqNtOiBVWr4q+MtEFUaKlNKL0Tp3uKfWJm1wbOiPy9otEuNpAGy/2D9uDvvvgDTN X-Received: by 2002:a05:6a20:9151:b0:13b:79dc:4538 with SMTP id x17-20020a056a20915100b0013b79dc4538mr19172204pzc.62.1691073707936; Thu, 03 Aug 2023 07:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691073707; cv=none; d=google.com; s=arc-20160816; b=DMtkywoQLtBDmzo2IjZZIfcQ2vv5nL0zi8UKU3Je0bipvyHO0evWnB5XrbDsJRLXqF MRclui/BGqGBUfMNntE578j03YF0B1k7xeGGhz04T44pqOmbGkhOfUHfwxuq+CXflpuB 12zDqQpHnJ7rWvrlCpS3TuBM6zUuXkELhlrB+lgIod4u6j780MbOyreAnFKMvWg3PZlw mU4X7hjwX9awZkrcmau2w9rqofoRrDKpSs7PG2e8DyGLgEmVih2e1huYCbFCwF7bga8F qhchNiV2ntVypk0KilChEH4te1OVcUqBkooGjgNVDGizUP0dh2oI3Tl9PSEu5kaXDsFG 3hWA== 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=StxqveXF5moq9iJU4D0IjENKfN6jaIfCw60woBc2a1E=; fh=Z2mkFIQPI1atT1PXylFFs5aXkUtGzwkgwqJaEftWDsI=; b=IEmaTA2vm4Eft2h4SixNkg+zxgibtNvhtGRi2MqeGSYuVhYAUWVBB9EPR3CJTsLnE2 uvAFNIqblQ1KBKuygQNaa7A2eXuzY0jTr899adCbTOgaIVPicQgxvBT/e5GmgtMHhPph tPH/DWgd85bN4Pk8NTOKT0MduotwEX4lXjZe/u1olqzHn907gvKpAYH4XibgmZKDeD0E aUDVEqSe3Qd1E6FQgaegkEomRQgtZMxw0N/jwZgdGqd/oRF0lD25MWpk0aqjCxzZ7zRl z3Z2VJmZbYCcLazpAIj+7WbQ6wo+krzuCz+D0NAnLA/24jagUSKIUqTWxylXEH0Y56Z9 EJQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=T4cv9Vgy; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j3-20020a056a00174300b00686e4b20b67si4245884pfc.268.2023.08.03.07.41.35; Thu, 03 Aug 2023 07:41:47 -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=T4cv9Vgy; 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 S236536AbjHCOBG (ORCPT + 99 others); Thu, 3 Aug 2023 10:01:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236325AbjHCOAn (ORCPT ); Thu, 3 Aug 2023 10:00:43 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DD69212A for ; Thu, 3 Aug 2023 07:00:20 -0700 (PDT) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.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-1.canonical.com (Postfix) with ESMTPS id 736553F7B7 for ; Thu, 3 Aug 2023 14:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071218; bh=StxqveXF5moq9iJU4D0IjENKfN6jaIfCw60woBc2a1E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=T4cv9VgyoJCSqFrKHBoK3YK5vFZg/TDb4VZdAdn9Jd70cefT3MDGgoPQG0bvTtKK/ vx5j9EFJirL1daNFeUARvNaBe6wVcQKFmhSCkLs1WhL7aBueqiKXp00lUHdsQ5P4l2 +VKp4hYOE/pPmTm6tvwRSJRTxA3w/nAlIvuZUstVlQ3zWqmow3Rfmsi7AfYSBJ1EmV 6Y9xVvZSETbsNwsy1DLumdtfz64y+f8RNGdeqV/LI0sC04lCrQSFiODpHHI9za8lZD wRFHiy81XMA8Q6uQCSCRJUtcivyTdA3dLDSqPHpG5784yVA1jRblmsnhYv3Lk8Cioc reOjsdxNclkgA== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-521da4c99d4so698884a12.1 for ; Thu, 03 Aug 2023 07:00:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071215; x=1691676015; 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=StxqveXF5moq9iJU4D0IjENKfN6jaIfCw60woBc2a1E=; b=JYHHWwpIiCJwBCu0DgP/6RPgVCklh5HK0iNllCLwM5It9x3HisZWB+KmbZN0BborzF ChNq8IvAXahss7KE2nwNZaPRWHF9w7s0IilU/85LQwBKY1u5FgEottzUEkr/PEdb401/ VUhRNUlBfiLwm4Ma8KngHwsnakTbExaRuI1FqlH4YFN3XUyYxtetXUEFX14Q0ExL3crh ZyoyP7uSEKGQNSKgzaz+CsdKEeeFJpjZCSlUUgDmwr/mIDF3KRJL/CPnGmRaDIJBZsR5 4wFTlNzjxDJSm0Qqu+TMnQQ7C1mqE87Ve9nIsvk6Yq5cIuVTypDztXMfhm82v3Wc3XG1 pjvw== X-Gm-Message-State: ABy/qLadBdXuKgoOiLgcN4bwQXSx+v81pFix9UkP8zrR+60ilqa9N49f YAAn9z+mswkjo/8Skic472+gsPpR3CxY3NYaF60vWKg7bbpYG0Ff1aS6CgZlSPNrpcubstk0QRr lVTU6SQ5JWRLZhmnEW+T/yudXiIxhi3GRB+o0IlmGEg== X-Received: by 2002:aa7:de14:0:b0:519:6a6a:7659 with SMTP id h20-20020aa7de14000000b005196a6a7659mr8931901edv.18.1691071214978; Thu, 03 Aug 2023 07:00:14 -0700 (PDT) X-Received: by 2002:aa7:de14:0:b0:519:6a6a:7659 with SMTP id h20-20020aa7de14000000b005196a6a7659mr8931880edv.18.1691071214671; Thu, 03 Aug 2023 07:00:14 -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 bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:14 -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, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 02/12] ceph: stash idmapping in mdsc request Date: Thu, 3 Aug 2023 15:59:45 +0200 Message-Id: <20230803135955.230449-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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 9aae39289b43..8829f55103da 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 */ -- 2.34.1