Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1836362rwd; Fri, 9 Jun 2023 02:59:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zgXbd1r5xiCEqob6wwmEz5datMY3dYBS0uIAYFCfe78mKMIbPp4zUBy9dw3ra0fNpJ7RS X-Received: by 2002:a05:6a20:4291:b0:10c:37ed:3e94 with SMTP id o17-20020a056a20429100b0010c37ed3e94mr5142112pzj.28.1686304749385; Fri, 09 Jun 2023 02:59:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686304749; cv=none; d=google.com; s=arc-20160816; b=KGzCG5tbcO4jmdqacP+Lq8LzqRdO42dlm+UkU8paq3CLfT91INMzjMHwSvLriZF5m0 d/nR1gU1as0j7aCBmvXCcWxDB4JW6Jpcr1zLdAryZkvs2/z1asNzlpkBS58/aNk6vufH ji/RoEdrWznroJEObH1rYUOZ0CojhDA5f/lGMg7NWEKP0w2bS7M0WMy6UGq1/gnsGZJB 5pZYz7xY5bgqIPYdCyC4B223nOf4q87ARHTERiQ8AHC9568/URDMn0i7r0Tfzg/Pct1Q Mft7kVL+0pwZ4hgbthIF8Ct08GbUpbHM5/5PMQQEDx7vKiDwDC/XqWhBypgaHAub/Vj6 nVbQ== 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=Qh/WJ81ZpXRyl0gQ4ukcXvtFhi/qxOmZnI5fUrSNycI=; b=l/OuVBtqoBhSW3cod20VsXOeC7+PAunIThAR3KEogdIZct8/2AWgWJMhACDBdPsuY/ Y5NeMLvoodnuuSCbio7uaZBFJ1d173SqOrFU0t77WjdXBsmcjc5AFAHl4OOBOiRZeN/D 4pPfL26BSxiNh21L9Bjq1t+AGUhv0x/xVsNEiZP1tD8IC8bmIcxbNg2GiLO7CSmg3uG4 PnWqjAUEo2ljjMpoqS4oeXfNFoWMMc7hKJt9qYhnXfcFBGyRPpEMwNhqWN1zepIPKApb s8gTV5C37XJ16aOzCn2+gBDIshK6wPmBcgK3LxRZPp4ON6bbogXAtwSq++ZPgSNlAvH8 QOnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=janVrMAL; 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 c20-20020a6566d4000000b00543a6ba4a98si2532059pgw.228.2023.06.09.02.58.57; Fri, 09 Jun 2023 02:59:09 -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=janVrMAL; 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 S241708AbjFIJjL (ORCPT + 99 others); Fri, 9 Jun 2023 05:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241771AbjFIJiw (ORCPT ); Fri, 9 Jun 2023 05:38:52 -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 64FE63C2A for ; Fri, 9 Jun 2023 02:33:28 -0700 (PDT) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (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 4201E3F36B for ; Fri, 9 Jun 2023 09:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303157; bh=Qh/WJ81ZpXRyl0gQ4ukcXvtFhi/qxOmZnI5fUrSNycI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=janVrMALn5r213g/rDnEkl1i3iMgdLxMc2L25qsX4ZuKCHX+wqow7EUfftZiks9mX iO9f0xKxWXD8HLgoWtQulAzDvGv34CgzQWQkNg9yezNgDcVAJHLip/5FXAo6qxUaTX XlVU/LIE9U+tN28eFS0aIl4ybQrR2b1unlShM1105f9yXYXtV0IKABMJJzDQ1O4m9l E1w4EJJXiw0TwKr0by3g+UEk74AbPJjwkt8FgSCZLm/gIopm1fPC6nVDTssrJ4I3QJ 0eAdySVG0gwPpZSQqiFUdm0cliXKfyP76eWKRLYcoqPmdX0hYw8guQyCTZdYOfqqKh J5KEGbB/KwW0A== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-977c8170b52so184104766b.0 for ; Fri, 09 Jun 2023 02:32:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303157; x=1688895157; 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=Qh/WJ81ZpXRyl0gQ4ukcXvtFhi/qxOmZnI5fUrSNycI=; b=F8BdO6BYB0oNuH0K+PgV0ZvxRg1B5EAlZ2YtnbZeL7sopPd77Nk+xZynIJmQ7KiSpu tt0OCF/o4tqG4QbLQtjGRbQUiX5OlS7BnT6o3MoCu/xU4qyyLlkUxk6AbCmmMe+dRwZV TpXCDmRQoUV0zTpBouYq7YePw6l2S+HpJ8B0XPAXdTueUgWIlOgmLKGAeIRYxXmSL0mu Jzai9yrq9t4m4n/jMWFOOS/9RnYfFzfnySmAdK8o96/MUwxgorBb+52o0Z7Pov8i5h2A iNkowt6Au66yIzea6WB2v82CdAvEoiHj1ydvxZhfX0hqIRPZJxccdyG3MIKL8U26+Xbb nm/A== X-Gm-Message-State: AC+VfDwFFkYP8MUvxlGEhELpfIvF2P+KavIkNX+BQ64f1Jsx+Nq59gma Zz4GUIzxsw3sPDJnHQBqhAiYW2lCwtjkbIut03oWqhkvtTkmJ/90o5pYn5gDshQLJoAL7chgrsF oTMLGLrGBiph6sGEFj403FfNA46gicOXHe7I+aY0RJQ== X-Received: by 2002:a17:906:ee83:b0:974:5480:171e with SMTP id wt3-20020a170906ee8300b009745480171emr1462446ejb.32.1686303156918; Fri, 09 Jun 2023 02:32:36 -0700 (PDT) X-Received: by 2002:a17:906:ee83:b0:974:5480:171e with SMTP id wt3-20020a170906ee8300b009745480171emr1462432ejb.32.1686303156625; Fri, 09 Jun 2023 02:32:36 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:36 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 02/15] ceph: stash idmapping in mdsc request Date: Fri, 9 Jun 2023 11:31:13 +0200 Message-Id: <20230609093125.252186-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 c808270a2f5d..083d0329f62d 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" @@ -1115,6 +1116,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); @@ -1173,6 +1176,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 351d92f7fc4f..89799becec90 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -298,6 +298,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