From patchwork Wed May 24 15:33:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48B39C77B73 for ; Wed, 24 May 2023 15:35:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236132AbjEXPfA (ORCPT ); Wed, 24 May 2023 11:35:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235342AbjEXPej (ORCPT ); Wed, 24 May 2023 11:34:39 -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 63928E4D for ; Wed, 24 May 2023 08:34:20 -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-0.canonical.com (Postfix) with ESMTPS id 95BE83F13F for ; Wed, 24 May 2023 15:33:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942433; bh=tSdP/T4XpDdXngtRP7H8sm4qPchKBIP/6AL5g4/r8eE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YybhPqr1t+uFMEwWnQHkE2Y0XP0zHprPUUttrIMDqGLEJe5FrnKrvQZZKA/XlBqoJ wM2f0lDc2U8gdxXVwqMkCQBkxDgoVpH+B4tifpHkLXb0FkqgenPxpiPNZYbHbkdbYv +hSpp9CMoY1mts96gwhCzWlax81ERcuFAUXL0WXQ2OBUvx08feYmflbq3ojrj6dDZj FesDPKnbfpD2hsKXQELFQpQoW2viB+RnCwTz53MiNPCsOvUmWBCslRVl7lVXy9p1le xfH9DfGsBRR0V1yGy91vhFldykfSV2dQkLJc9iGpTsYHvuG0XQsMZIzq8Rzk3sTrOL VL4vXhatFimVA== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-96fd3757c1dso121003066b.1 for ; Wed, 24 May 2023 08:33:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942431; x=1687534431; 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=tSdP/T4XpDdXngtRP7H8sm4qPchKBIP/6AL5g4/r8eE=; b=k6i07f2fPBga2VYN6pfgutQ7aYRuXpcFXDsAR/lu0s5GzBRtWyoY63LNFvw8wdBSya poCUbXj1ht7yB5SiWrMtq1U6P4NwYze6LfQnR8BRnQrU3FwfmoezSCQs9pxLhORiTKjV 9D8za5BYx/DXu3/TsgNjU+PQ0e8Hi03wEiFgT842QBPdbcM/+DDkmJ8Q0NMsX4TP1RzC 16vMgVmRRqzHd3S/ZmFSKgia7gzH9wXxFjpZi+ZwsRm1R15e/m7yuqPfpNOeF0wRbec9 dsw9RNkcX58x/6sbyrUX06U63TAfe6ukHmahK9O4GZmUa5oDCIezLd1m1ea+wpPEXUPQ vdeg== X-Gm-Message-State: AC+VfDwvHKLHl7zP89b6gc/l/XG9pev/b0C9CttMH2HllDhXwI1JSUfR A/dcBORQRTwJyNzb/tBG/JTXcS9e6loGEX1bzXNhR03vUv8QnA3MDsiPK+GnvNSmiUKu/ojJ6LL o1BW4plaTauqWcoQCldPzuk9DzdZIPx04gtVwDg8= X-Received: by 2002:a17:907:1606:b0:96f:d154:54f7 with SMTP id hb6-20020a170907160600b0096fd15454f7mr12266661ejc.42.1684942431692; Wed, 24 May 2023 08:33:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5owA1z5kBY01k6fQMnJ+aOqpvSenWRt3xIxcA2Af18CPctBSVmxRFbXwpWIr+T1mt2M3MY8w== X-Received: by 2002:a17:907:1606:b0:96f:d154:54f7 with SMTP id hb6-20020a170907160600b0096fd15454f7mr12266633ejc.42.1684942431448; Wed, 24 May 2023 08:33:51 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.33.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:33:50 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Alexander Mikhalitsyn , Ilya Dryomov , Jeff Layton , Alexander Viro , Seth Forshee , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 01/13] fs: export mnt_idmap_get/mnt_idmap_put Date: Wed, 24 May 2023 17:33:03 +0200 Message-Id: <20230524153316.476973-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org These helpers are required to support idmapped mounts in the Cephfs. Signed-off-by: Alexander Mikhalitsyn Reviewed-by: Christian Brauner --- fs/mnt_idmapping.c | 2 ++ include/linux/mnt_idmapping.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c index 4905665c47d0..5a579e809bcf 100644 --- a/fs/mnt_idmapping.c +++ b/fs/mnt_idmapping.c @@ -256,6 +256,7 @@ struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap) return idmap; } +EXPORT_SYMBOL(mnt_idmap_get); /** * mnt_idmap_put - put a reference to an idmapping @@ -271,3 +272,4 @@ void mnt_idmap_put(struct mnt_idmap *idmap) kfree(idmap); } } +EXPORT_SYMBOL(mnt_idmap_put); diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h index 057c89867aa2..b8da2db4ecd2 100644 --- a/include/linux/mnt_idmapping.h +++ b/include/linux/mnt_idmapping.h @@ -115,6 +115,9 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid) int vfsgid_in_group_p(vfsgid_t vfsgid); +struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap); +void mnt_idmap_put(struct mnt_idmap *idmap); + vfsuid_t make_vfsuid(struct mnt_idmap *idmap, struct user_namespace *fs_userns, kuid_t kuid); From patchwork Wed May 24 15:33:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254241 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BDFB3C77B7A for ; Wed, 24 May 2023 15:35:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236619AbjEXPfJ (ORCPT ); Wed, 24 May 2023 11:35:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236308AbjEXPfB (ORCPT ); Wed, 24 May 2023 11:35:01 -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 1680FE43 for ; Wed, 24 May 2023 08:34:43 -0700 (PDT) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (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 F116D3F235 for ; Wed, 24 May 2023 15:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942435; bh=XgKnpq4bIvhR7eBTR7Q+NdjpFwn1XJ2nSq/DTgjo3dY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZTpzhbY38OV8QVISl9OcxFMQ7ML1kqinI9MnsOr1aJ07v1DqQAdstoYAEnv988FWa ZFrTA0XOYOCQQsYbcIYs+ld1iA2vx4DkTa69yj7wawcVyHU5IvcWh21Jpz4ISSt6gr g5Wy3vSBoGbWolsYr7s0CCEwgsF1iVxh5zQ54PvLSzRR0uuqwXOD079YYEMIgDWh9c jlAI5GyyL4szARH2NxEGIZ0S1K6iLGPnnJA54ou6sKthqSLapBLh8To4OzVTX/cMt5 KewaViTs4smF/J6FGTZy+xJtA1a2/oGHNM0Cd1+yo/+bSp5B5tx83X9mI3kwlNfnfE 68rjMxpguRWbA== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-96fae2a13a5so103817866b.2 for ; Wed, 24 May 2023 08:33:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942434; x=1687534434; 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=XgKnpq4bIvhR7eBTR7Q+NdjpFwn1XJ2nSq/DTgjo3dY=; b=R5E8GuNZ590WVsw8F9pxD3b0PQ9n3sAePYRk1/za4jZpuvbGNlRuEiUf7RzBpEDXcZ OACLaruwggc0Gj7vbHiOVDU7Z1OpK9cWQRPNBbSANv6LN90Im1GyiMT0a0E73zjvm2Oz 6WYTnfsUXhRleZVdOOYEv8J8lh+sGDOyWmX+QUNyjfzQWGJkuNHWF+tuOl5TKpn4lood qIbAGTzROgFzcdNBSY0vECIzo6tLBoelPob3IRWnGWiR0pmP8QTMZzt3oXFHh/lz3t8P pR404hI4qDHtGL5Er9OFgs5rgke5Wed/pdiJrECfdfUQ2VS3CwsN0q++wFn0zDSPQ8++ 7TcA== X-Gm-Message-State: AC+VfDxNgoWCRBgQ5jyOSULAys6rq4g6u3BB6361Y+ZkTECWTM/KRIrf DmFCBBwkyvrgi3AE+OgY4RqvVqyiwwfGAt/wUcOLDmiItftN/Zb2wd6Q1IsdCu8wRTagI2pZ0PZ DLX9hYfQV8JQ43+b2ZTwlxE5EZyUMBQDBAASUIas= X-Received: by 2002:a17:907:7f8c:b0:96a:5e38:ba49 with SMTP id qk12-20020a1709077f8c00b0096a5e38ba49mr19196158ejc.2.1684942434314; Wed, 24 May 2023 08:33:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Mffvochh5YQEn/DHlzCnAsBqpPKJ0HvpBj7yTSc8OSsGh1dOxxL29MY1dSL/HnDP8qeW35A== X-Received: by 2002:a17:907:7f8c:b0:96a:5e38:ba49 with SMTP id qk12-20020a1709077f8c00b0096a5e38ba49mr19196142ejc.2.1684942434005; Wed, 24 May 2023 08:33:54 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.33.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:33:53 -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 v2 02/13] ceph: stash idmapping in mdsc request Date: Wed, 24 May 2023 17:33:04 +0200 Message-Id: <20230524153316.476973-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@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: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- v2: - added "r_" prefix to the field name to make it consistent with others --- fs/ceph/mds_client.c | 7 +++++++ fs/ceph/mds_client.h | 1 + 2 files changed, 8 insertions(+) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 4c0f22acf53d..810c3db2e369 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 "mds_client.h" @@ -962,6 +963,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 != &nop_mnt_idmap) + mnt_idmap_put(req->r_mnt_idmap); if (req->r_pagelist) ceph_pagelist_release(req->r_pagelist); put_request_session(req); @@ -1018,6 +1021,10 @@ 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; + else + mnt_idmap_get(req->r_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 724307ff89cd..32001ade1ea7 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -280,6 +280,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 */ From patchwork Wed May 24 15:33:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254239 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 774B0C77B7A for ; Wed, 24 May 2023 15:35:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236315AbjEXPfC (ORCPT ); Wed, 24 May 2023 11:35:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236208AbjEXPem (ORCPT ); Wed, 24 May 2023 11:34:42 -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 9B6BAE52 for ; Wed, 24 May 2023 08:34:23 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.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 C645E41BAE for ; Wed, 24 May 2023 15:33:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942437; bh=7MPRaaS/wfFyMaJukilLcDQaABE/d326C6SUb3pM724=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZlixQUAyDH4K8g8S8h8nxQZWVG6nDfqWv2AX2FmnKjDHUda3Gc2nGsS4+N09/HbgU +zC+rmdQZTyON6HFuG5ZxhbLHCOUSV9ZzPIZvclBfKevkwbE9KgTKtk3O8Xq511UOU kMoSnhzzmuk9ylyWO3REVic27wshhdOObuI3xZIo6p/35vALcyGOO5un06yPyW/x8G AM5rXEgrlM7E7+5yczVblLnOM8iWgLqpj0o4yAoS2cyejfeCC8qU/Ka/5scD+PghNY 9G+5i1scJFN6dHQKbnHyz2NG/wnE5bsO2xRuoyhCZN2V9qm7zxHwHUkvArWJ+Seid3 Qdjoc5+1EY1mQ== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-97005627685so120369066b.2 for ; Wed, 24 May 2023 08:33:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942437; x=1687534437; 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=7MPRaaS/wfFyMaJukilLcDQaABE/d326C6SUb3pM724=; b=ig7qSpeEROCw2ZP79cwt5NGXGf3pxR0BeJRDVzPgyAKkIB5FFB9L4qudyJyKrodrlW 3dyVWsonbpclC+ZXuvDRo0y0k2zTGuaN/fORRKQDig3zeqMjdukWo5oUTFDIDuju9rpV x4fg8brRA9FF5dZ6v//ZxIpRbGAk0HTqdNH3SmETlAyVHiZCEnd6rxsDaB14BtzSUtfL nHod78pGrA+Ag/sarP8DtDnxO2fKbuxcSyT25upJp8vVciHX+d9HPA7EDcnQVveOij2O HNKzPtHXO05AOEEI7izetlXE6uqDtnHCSXcp20+SRr2swF8r0Do/xpjgQcVICEUUNZKZ SGDw== X-Gm-Message-State: AC+VfDzNXNGtmnkht90OMX43wFTnS9QuZMC1byC4rGgQQ2NVKrQ7OpKi voOOt2pAK0WKceWEnd5WnWU3oMFvwwl2EqRBO7N+vwJ6E2AHUPC0yqMjz4lmuDtVZbNF+Jo/mhl PjqEVmRzDNGKQxbEA+Fz3T3v2HqRMI5wAcnAUtFc= X-Received: by 2002:a17:907:6d0a:b0:94e:afa6:299f with SMTP id sa10-20020a1709076d0a00b0094eafa6299fmr16453139ejc.22.1684942437537; Wed, 24 May 2023 08:33:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ75DBcDr80x3nJRZUtCnJIz0VU1HD43GtaQtz8dKn2NTdPmSfiM3FsRTA9p2vEEfIPqJc7rNg== X-Received: by 2002:a17:907:6d0a:b0:94e:afa6:299f with SMTP id sa10-20020a1709076d0a00b0094eafa6299fmr16453103ejc.22.1684942437096; Wed, 24 May 2023 08:33:57 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:33:56 -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 v2 03/13] ceph: handle idmapped mounts in create_request_message() Date: Wed, 24 May 2023 17:33:05 +0200 Message-Id: <20230524153316.476973-4-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Inode operations that create a new filesystem object such as ->mknod, ->create, ->mkdir() and others don't take a {g,u}id argument explicitly. Instead the caller's fs{g,u}id is used for the {g,u}id of the new filesystem object. Cephfs mds creation request argument structures mirror this filesystem behavior. They don't encode a {g,u}id explicitly. Instead the caller's fs{g,u}id that is always sent as part of any mds request is used by the servers to set the {g,u}id of the new filesystem object. In order to ensure that the correct {g,u}id is used map the caller's fs{g,u}id for creation requests. This doesn't require complex changes. It suffices to pass in the relevant idmapping recorded in the request message. If this request message was triggered from an inode operation that creates filesystem objects it will have passed down the relevant idmaping. If this is a request message that was triggered from an inode operation that doens't need to take idmappings into account the initial idmapping is passed down which is an identity mapping and thus is guaranteed to leave the caller's fs{g,u}id unchanged.,u}id is sent. The last few weeks before Christmas 2021 I have spent time not just reading and poking the cephfs kernel code but also took a look at the ceph mds server userspace to ensure I didn't miss some subtlety. This made me aware of one complication to solve. All requests send the caller's fs{g,u}id over the wire. The caller's fs{g,u}id matters for the server in exactly two cases: 1. to set the ownership for creation requests 2. to determine whether this client is allowed access on this server Case 1. we already covered and explained. Case 2. is only relevant for servers where an explicit uid access restriction has been set. That is to say the mds server restricts access to requests coming from a specific uid. Servers without uid restrictions will grant access to requests from any uid by setting MDS_AUTH_UID_ANY. Case 2. introduces the complication because the caller's fs{g,u}id is not just used to record ownership but also serves as the {g,u}id used when checking access to the server. Consider a user mounting a cephfs client and creating an idmapped mount from it that maps files owned by uid 1000 to be owned uid 0: mount -t cephfs -o [...] /unmapped mount-idmapped --map-mount 1000:0:1 /idmapped That is to say if the mounted cephfs filesystem contains a file "file1" which is owned by uid 1000: - looking at it via /unmapped/file1 will report it as owned by uid 1000 (One can think of this as the on-disk value.) - looking at it via /idmapped/file1 will report it as owned by uid 0 Now, consider creating new files via the idmapped mount at /idmapped. When a caller with fs{g,u}id 1000 creates a file "file2" by going through the idmapped mount mounted at /idmapped it will create a file that is owned by uid 1000 on-disk, i.e.: - looking at it via /unmapped/file2 will report it as owned by uid 1000 - looking at it via /idmapped/file2 will report it as owned by uid 0 Now consider an mds server that has a uid access restriction set and only grants access to requests from uid 0. If the client sends a creation request for a file e.g. /idmapped/file2 it will send the caller's fs{g,u}id idmapped according to the idmapped mount. So if the caller has fs{g,u}id 1000 it will be mapped to {g,u}id 0 in the idmapped mount and will be sent over the wire allowing the caller access to the mds server. However, if the caller is not issuing a creation request the caller's fs{g,u}id will be send without the mount's idmapping applied. So if the caller that just successfully created a new file on the restricted mds server sends a request as fs{g,u}id 1000 access will be refused. This however is inconsistent. From my perspective the root of the problem lies in the fact that creation requests implicitly infer the ownership from the {g,u}id that gets sent along with every mds request. I have thought of multiple ways of addressing this problem but the one I prefer is to give all mds requests that create a filesystem object a proper, separate {g,u}id field entry in the argument struct. This is, for example how ->setattr mds requests work. This way the caller's fs{g,u}id can be used consistenly for server access checks and is separated from the ownership for new filesystem objects. Servers could then be updated to refuse creation requests whenever the {g,u}id used for access checking doesn't match the {g,u}id used for creating the filesystem object just as is done for setattr requests on a uid restricted server. But I am, of course, open to other suggestions. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/mds_client.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 810c3db2e369..e4265843b838 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2583,6 +2583,8 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, void *p, *end; int ret; bool legacy = !(session->s_con.peer_features & CEPH_FEATURE_FS_BTIME); + kuid_t caller_fsuid; + kgid_t caller_fsgid; ret = set_request_path_attr(req->r_inode, req->r_dentry, req->r_parent, req->r_path1, req->r_ino1.ino, @@ -2651,10 +2653,22 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, head->mdsmap_epoch = cpu_to_le32(mdsc->mdsmap->m_epoch); head->op = cpu_to_le32(req->r_op); - head->caller_uid = cpu_to_le32(from_kuid(&init_user_ns, - req->r_cred->fsuid)); - head->caller_gid = cpu_to_le32(from_kgid(&init_user_ns, - req->r_cred->fsgid)); + /* + * Inode operations that create filesystem objects based on the + * caller's fs{g,u}id like ->mknod(), ->create(), ->mkdir() etc. don't + * have separate {g,u}id fields in their respective structs in the + * ceph_mds_request_args union. Instead the caller_{g,u}id field is + * used to set ownership of the newly created inode by the mds server. + * For these inode operations we need to send the mapped fs{g,u}id over + * the wire. For other cases we simple set req->r_mnt_idmap to the + * initial idmapping meaning the unmapped fs{g,u}id is sent. + */ + caller_fsuid = from_vfsuid(req->r_mnt_idmap, &init_user_ns, + VFSUIDT_INIT(req->r_cred->fsuid)); + caller_fsgid = from_vfsgid(req->r_mnt_idmap, &init_user_ns, + VFSGIDT_INIT(req->r_cred->fsgid)); + head->caller_uid = cpu_to_le32(from_kuid(&init_user_ns, caller_fsuid)); + head->caller_gid = cpu_to_le32(from_kgid(&init_user_ns, caller_fsgid)); head->ino = cpu_to_le64(req->r_deleg_ino); head->args = req->r_args; From patchwork Wed May 24 15:33:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254243 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08585C77B73 for ; Wed, 24 May 2023 15:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236504AbjEXPff (ORCPT ); Wed, 24 May 2023 11:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236396AbjEXPfG (ORCPT ); Wed, 24 May 2023 11:35:06 -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 D071AE6F for ; Wed, 24 May 2023 08:34:44 -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 91CC341BEC for ; Wed, 24 May 2023 15:34:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942445; bh=xxg/uwnVyZOP2Ay/FSpDiOkYB17FXWwEBwZ7vkk162A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=khqWo8ws38zr/fIJG4SWcocwBKdPExV2Ls7ICyCZ6uaSDV9Qjudpq3hoMb7GZYMvQ 8kR09cKQJ4WXrCdD59WEkptUGGMQRXkt0dngXpQu2XlZU+kjxJL60iJElDXfivCdrD vcLa2AZNR2e4c0+Cj6OcYD/jrr7qPtCkN9Hmb+qhYAsQR7fzmGQ+2rYbckFeSdSRR1 PNwBV6lEfGN9PLWjOCRfIihWp9GGvvFiNnCFdENyTAbwugEvH4FBr1vog/hfVl0zlC tGIKonQ3MqZdjoo+1+0INNytlEICZ/7mXioFcRNImk3mG7phRPzM29b9kgM13v3V7C Rv/bA3KKtKBcw== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-511b509b55bso1532709a12.0 for ; Wed, 24 May 2023 08:34:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942441; x=1687534441; 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=xxg/uwnVyZOP2Ay/FSpDiOkYB17FXWwEBwZ7vkk162A=; b=OwupnAWqV8PjhvT/5Z+jzEW8g5AtMFboIXOXx3hMigN2g30fQ+OWuZYexUbt79yX9Q NH/VFee5KnO2jLUnzu4+JDEk22nPDQJK6YWiO1O10ZLuGECZZGskedDCKaz0IC/89HG4 hGSeBd+ZewS4bmn+S6vOcl9UZ7oFpt7E40Pm66DauhljCWrIhEsgPy/fQv478XIeaPiK K8aGe0Uq1VMUkNOXhOhsU0KmMU6lUoWuPBhqNAVtzfdY4ttLNKBu9UjsHt+yOyJuU/Iy YiNb9JF7rwYJthnB0eJm76s/T6U3Xs9knsMCIlUDNxZhcWTGUZUYBynYNjjepJoGZlJZ p2mw== X-Gm-Message-State: AC+VfDxtm1Z6Cc2QhZy8AcLwZAYlCAFV5rXfsUhLprQhLWSARsTNqn8e Vuxr8uqHfalozt0PbtLAON45kEFcKy1e3G31R1D0a476cXI3r3l2VP2CMgLN4ytAkCWea0TDpGi 5gTooSQO34W0SFn3ToxVE9gDruzH5Xawj5zWHDHc= X-Received: by 2002:a17:907:728c:b0:96f:f6a6:58cc with SMTP id dt12-20020a170907728c00b0096ff6a658ccmr9115844ejc.15.1684942441742; Wed, 24 May 2023 08:34:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Q7Lsu20tS8hE/7FwlwR1NjZ7p+guAstMYuytSVHgRos67j/I/Z+zrmEJ9DtP+ZasFoivgRg== X-Received: by 2002:a17:907:728c:b0:96f:f6a6:58cc with SMTP id dt12-20020a170907728c00b0096ff6a658ccmr9115823ejc.15.1684942441514; Wed, 24 May 2023 08:34:01 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:01 -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 v2 04/13] ceph: allow idmapped mknod inode op Date: Wed, 24 May 2023 17:33:06 +0200 Message-Id: <20230524153316.476973-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_mknod() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index cb67ac821f0e..8d3fedb3629b 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -884,6 +884,7 @@ static int ceph_mknod(struct mnt_idmap *idmap, struct inode *dir, req->r_parent = dir; ihold(dir); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); + req->r_mnt_idmap = idmap; req->r_args.mknod.mode = cpu_to_le32(mode); req->r_args.mknod.rdev = cpu_to_le32(rdev); req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; From patchwork Wed May 24 15:33:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254242 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 229BFC77B73 for ; Wed, 24 May 2023 15:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236707AbjEXPfO (ORCPT ); Wed, 24 May 2023 11:35:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236332AbjEXPfD (ORCPT ); Wed, 24 May 2023 11:35:03 -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 CF4C1E5A for ; Wed, 24 May 2023 08:34:43 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.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 E2B483F438 for ; Wed, 24 May 2023 15:34:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942444; bh=VOsvDeo72Li4A+MGz8y/FXCiDvmbWTjb5uUMq09Z+GE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gWZurhxT3fpyDMIpY77JZvx4PwqkyY55Hc00DdcdOYztydiLIGYoifVtCs4mY8MIa ZcsHOyJkkF4TImSP8JTVQ3o6LuOPpT0l/y/hlaf2s6QXPAF8bYWqmKwHHGkR9hBBrL JR6JDvFZ0j4k16Kq91Cdd1QRvMd8AkU+++VHZYxiz7PphVXcvGAeUk6s5gz7ZKO95E MZjGao1DtzPoAPe/70t/3FmgTniZj6iDRtIIa5gkSpOrdewvRvZFvhEcR0sGwe6GXC OvbqVUp0s9LIjXIjkFb1hlcl+6PnYJ3DK/lKKIpsqy8ze78clGszML8MEKIdxJeMn3 TG10RXmVv5ceQ== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-96fd3757bd1so132721066b.1 for ; Wed, 24 May 2023 08:34:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942444; x=1687534444; 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=VOsvDeo72Li4A+MGz8y/FXCiDvmbWTjb5uUMq09Z+GE=; b=STpHw/+J/2869zUVZJulPxftIQwVY/RnvNGrf71TY7qT6vgBZq6ZDyDmv0qR+mN4JN 6sR4hNB+Ym+X2uT03F4h20pKWzEOAou5w2pTvNvCQTUus2ijuD/CLeXi88bOBAb3cU99 jO0SNHTULgk6WAtQbEioD1iQRgcw2rSPnE7SavsDYmsfAVLjeR+KxXl4SY/k6CzGh4tX BCgA50C93Cte0yn/LNVOfw2R1l45zPdGGf9V30P+rVpKhCuMostoWQOFVu3a+CYL99yq 55GG5OWB4rMtkUyrYYXxl8wJDcuAkHqX2KXilPw8xb2gEJzfh291HclvwFE9XJBF/88I V/Qg== X-Gm-Message-State: AC+VfDwKD8XXjd6j9c0tn3r3w774EVLu0G8YsbVhKSe11y/Y9tPMruYN Zu0HlnkX6Lh4CdrAvkmyfoc86X73QpzkT7Cs74p2LChmtTdT+q3CEI52DEXhToobTHM5Q2LK/pZ VgtWNzaMXUJa8B0nM809vBM92awEg4hgKjGfpDMI= X-Received: by 2002:a17:906:5044:b0:96a:63d4:24c5 with SMTP id e4-20020a170906504400b0096a63d424c5mr16834952ejk.77.1684942444422; Wed, 24 May 2023 08:34:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7gBpqHitu+lLhIckipr6Iw+ZMNPeoZej+/zA1KHtSCkxGa9OwcqI2J/tv0ifrYtmEPsQMuyg== X-Received: by 2002:a17:906:5044:b0:96a:63d4:24c5 with SMTP id e4-20020a170906504400b0096a63d424c5mr16834933ejk.77.1684942444258; Wed, 24 May 2023 08:34:04 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:03 -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 v2 05/13] ceph: allow idmapped symlink inode op Date: Wed, 24 May 2023 17:33:07 +0200 Message-Id: <20230524153316.476973-6-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_symlink() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 8d3fedb3629b..3996572060da 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -956,6 +956,7 @@ static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir, req->r_num_caps = 2; req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; + req->r_mnt_idmap = idmap; if (as_ctx.pagelist) { req->r_pagelist = as_ctx.pagelist; as_ctx.pagelist = NULL; From patchwork Wed May 24 15:33:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254245 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5AD2C77B7A for ; Wed, 24 May 2023 15:35:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236876AbjEXPfy (ORCPT ); Wed, 24 May 2023 11:35:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236458AbjEXPfG (ORCPT ); Wed, 24 May 2023 11:35:06 -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 4F4F0E78 for ; Wed, 24 May 2023 08:34:45 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.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 17B3D41B3C for ; Wed, 24 May 2023 15:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942452; bh=H9xVyVFm2J6DXYIa+xt6L2ldHLbh9SntsfJpFosG5pA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Zawuf/mUkmxlmKjHvIo8YkQSISYNN+oWu6UQULQ9n9gWrJqpLjKOh5JPYWyQ8geoG Hw7AmdLSei0NlWx2u1LIA9JJ5i+JSzekz6o3DUvHrAEOBFAMXnMVvFIhT4Q0WT+ULk UqIm3MoOZsifKN/Dla0l5bq/Z5CQ08NVPkWUV0LwN+W8+lFqQAszr/AI+sXEKMZh1T hbSXjiyAGZPmlr81YS4w6n3dIBi2vLLR7IRGlVyI1MqdWgbAhZPHS4X3T4wS7O8kuA 7XfJv2cu8ORgf/J6FtoI8L+QicvwLh9z7QREZz6NNcG2PPkL/iY+wHFwbmHQlmQjQH Ahyge8wYY8zzg== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-970e0152da7so132635666b.2 for ; Wed, 24 May 2023 08:34:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942446; x=1687534446; 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=H9xVyVFm2J6DXYIa+xt6L2ldHLbh9SntsfJpFosG5pA=; b=BAju4ydI9NAryBorcircmPxLZJvPNJTOLBei4tEGYG4Zx5i1tPgQxKyXDrTj4ypVCA PUaGigFbNsP1XEg8EZxF6NBgV/Bc5BxEUZP8pjBCmdTOiSZJOLDAsxV/OVZ7UmJ/ItYX WlxSrmIOkFU2sRNBN2Fd8RVN7xhGwdfAkNcm/EG/mLGcaHmxV/4kbNI0W/mpGciyhgP1 jiXoLy1BpdB0upFy6whBw/f3CWfHIZlmIsOeShtiYQ430fBkN/OH7AoAP1qij7HGpZXf EXQ00hzj1zxVSa5GZFmPQpMQEf60qnwGxD0fFZ6+gBx+OQSKg7ybvVV0lkhlgv/sA9+A 5zwA== X-Gm-Message-State: AC+VfDxlzzYAHpKqcaj+040exS4cgTUhELUCbFvqAwGzMNnQQqSyRCLT 1Nn06KDERZ3P2mvpSrUsEYZ79OtkvI4vRitv+Ie11n2AVPwwzL675MJ0cY1pATeJ6y8MFhB0r1g 8TvoWJJQSkuxavcy2SlVriKkXXDXxDTjqC7pVb8g= X-Received: by 2002:a17:907:c07:b0:96a:c661:fa1 with SMTP id ga7-20020a1709070c0700b0096ac6610fa1mr20640400ejc.46.1684942446758; Wed, 24 May 2023 08:34:06 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4XpCjIcxhdoliupK6KKdEUY8jcq27fFWoCooizfqJ+xFZsiS/Txtj9EH8UgEqevhz9hzz8ew== X-Received: by 2002:a17:907:c07:b0:96a:c661:fa1 with SMTP id ga7-20020a1709070c0700b0096ac6610fa1mr20640376ejc.46.1684942446551; Wed, 24 May 2023 08:34:06 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:06 -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 v2 06/13] ceph: allow idmapped mkdir inode op Date: Wed, 24 May 2023 17:33:08 +0200 Message-Id: <20230524153316.476973-7-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_mkdir() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 3996572060da..a4b1ee5ce6b6 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1024,6 +1024,7 @@ static int ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, ihold(dir); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); req->r_args.mkdir.mode = cpu_to_le32(mode); + req->r_mnt_idmap = idmap; req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; if (as_ctx.pagelist) { From patchwork Wed May 24 15:33:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254244 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFA7CC77B7A for ; Wed, 24 May 2023 15:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236808AbjEXPfw (ORCPT ); Wed, 24 May 2023 11:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236423AbjEXPfG (ORCPT ); Wed, 24 May 2023 11:35:06 -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 4CE9AE77 for ; Wed, 24 May 2023 08:34:45 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.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 4F0F241D47 for ; Wed, 24 May 2023 15:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942452; bh=lZbP4iiEH03HfqTDqSU+Hv1fOneGFOzGKwUObj1rpGo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GR+CUNIAtExfmj/W35+rrFjTPXtQU0Z0On/VaNbDxGI3p3TG6LH2U1KPb63+7u02E 44FpxYzOdcrCd+SmcxFX3gmrNa85laQJvg6gAEglzJkNm9BrMpGVi07LhnEzaV91Rl Ozwc88FuuGX4mt4nMsNOYa7rRuYnd7IPShYi0x/3yt1/5SNIdRzFuhVI5XPGK7Ce+4 Y/ndYwwtxMV5koaKnmzOuEyuHBwXkgxYMsX5xx6npiO70ljCPjl58oHdnnYdHUqqwf 2KDLhV+zRx94lLtuUcyTph9WBx0qcgwcwWOB9Sgh/higlH0ZZ8gJuDPDoPkGQ9pkv2 8AzHCY3TAzcYg== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-96fb396ee3dso106869466b.1 for ; Wed, 24 May 2023 08:34:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942449; x=1687534449; 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=lZbP4iiEH03HfqTDqSU+Hv1fOneGFOzGKwUObj1rpGo=; b=Z97Q7mIoTpDR/eXbeA/9Sct4ZlXyJLkGOtUJZFFMvh/SrlgvZoZZ0Gf+JVwbdxyPk3 R0VLDLM1pql6s6ZLEowStB7Wg0Ba0SWd9TRs4gdm65oHJvzCM2R2nrsijgu6rY7hu6kZ ccasmz0JkvM3V+S8ic6dO3gYdkr9kEJ65UMI0DS8BWcpmH8bVzpGLUb+bl0YLiZ5r8JJ h7IxkySBQ+UFdbQmGEw6c2rvNCyrxX/iQAIG8sEQHhE7pZafQDLFilXHWgUiosq/85Kx ZmecxR4MpEfIzi0ySSFDzNvm4uQCdSRaTilG7s+xr7jpISI6liZqiysHVaCIhyPGn/14 g3dw== X-Gm-Message-State: AC+VfDzee2lHI5AXfJSjmC/RS4+zJgTrPCFI/iF5lLb0cX6WhxZ1DGr3 /cPJ+xLdDMOYwnvzW/KQmhfBLID+yzgsOtsPE01mCdQbyWElA1IF/Ka767Vq/MgEvz95T1K8fGH CVRuFZQRIo+J+eD7HCIPVgxxeR8ovNQXRt8GcJPg= X-Received: by 2002:a17:907:26c6:b0:969:f677:11b4 with SMTP id bp6-20020a17090726c600b00969f67711b4mr16979968ejc.37.1684942448867; Wed, 24 May 2023 08:34:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6GkqD2mx9edhZF+fiZhPW/iOs1zLB2TI7gEZMH8nbEv37OBHOLISYOfgzS57PLOIkRd9L02g== X-Received: by 2002:a17:907:26c6:b0:969:f677:11b4 with SMTP id bp6-20020a17090726c600b00969f67711b4mr16979950ejc.37.1684942448627; Wed, 24 May 2023 08:34:08 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:08 -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 v2 07/13] ceph: allow idmapped rename inode op Date: Wed, 24 May 2023 17:33:09 +0200 Message-Id: <20230524153316.476973-8-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_rename() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index a4b1ee5ce6b6..7ae02a690464 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -1327,6 +1327,7 @@ static int ceph_rename(struct mnt_idmap *idmap, struct inode *old_dir, req->r_old_dentry_unless = CEPH_CAP_FILE_EXCL; req->r_dentry_drop = CEPH_CAP_FILE_SHARED; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; + req->r_mnt_idmap = idmap; /* release LINK_RDCACHE on source inode (mds will lock it) */ req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; if (d_really_is_positive(new_dentry)) { From patchwork Wed May 24 15:33:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254246 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CC48C77B73 for ; Wed, 24 May 2023 15:36:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237010AbjEXPgE (ORCPT ); Wed, 24 May 2023 11:36:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235582AbjEXPfK (ORCPT ); Wed, 24 May 2023 11:35:10 -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 CDCD210D8 for ; Wed, 24 May 2023 08:34:47 -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-0.canonical.com (Postfix) with ESMTPS id 8C0F74226F for ; Wed, 24 May 2023 15:34:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942451; bh=nUbgNVx3j+EjvX/3B5psKLPL9iW2vvt56NMjhT4BQS4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GEBmMagOvm4ju2xmzpQo8tW0sIDyZ57B04n09xDWXQO2Ne1ZXe714tPPuS64bPN8+ FnQe90V5SrnvNXtTiCtHEo9YbNjhJP6dD4bKzbSI4WLt6q5kPVDPoQybailo4MD543 tu1PrXJg6XCJjKc72NF28kH2fcX1WHulwh97jj6cjxAnyd7Lg54/merqix66wm6/CZ QrdJ0kyXg/MFMZ0nJVUhola4xpl54sict/R+Aj73sZsc/mVV5FA78tnDbYBX8fCPn/ 0Pr6H7mbFvSz9NK601XyqB1rbbQ7eUeQoNN3R8f6iSHNQlj2eB42g7Wo2Dy3wcg1ky DwI4Uw4fUvmvA== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-513e9c14adbso1217801a12.3 for ; Wed, 24 May 2023 08:34:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942451; x=1687534451; 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=nUbgNVx3j+EjvX/3B5psKLPL9iW2vvt56NMjhT4BQS4=; b=TiGcGarltu81EU2SSF/aF0kFkiIkE+DvOiEI7EnVmjbzJd9m/5YYmsFhlY5hujGaJa HS/Eu6QvA1vzMQnmNeMxyorpde5U1LlNObO/ufKvnYiGW3trihnJcues7BetGdcJvqGi ybd6KmycqN2h+2laGtVFDp8TifVTVMBxfMiYqtjwOLOB89MdfSrI8Nbcxt8yQdl3s7qq tPQReEu1ARwTsG9xbu62VmhsVohQT03pWEr35AUmKxUL+fXsCGcDlanm6WJeT6oLByw5 31s83gawZx2ufScNW9yodZlFsoyyRs0dQlhSnqyFWsZgK4JPH+yTwOWjxb9A5/d+K4ra Kqdg== X-Gm-Message-State: AC+VfDyHJJ0B4XPlBvY+TzeSvhruNTMe3+jtwtP1Jl4hpfcoST1u/KNr x43xpHpNusy9ut5Ef9yd7HJQMpJJ0OOt4GP/3xN8ZjIQvVd+zwIJhQLL+VGUzVIcEvkzHSIIEWK SkHMce2h4W6PjUU8mhuQtXXyjO6kW3NR8tmj89mo= X-Received: by 2002:a17:907:2cc7:b0:959:18b2:454a with SMTP id hg7-20020a1709072cc700b0095918b2454amr16847501ejc.76.1684942451058; Wed, 24 May 2023 08:34:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4agyA0tH+R6Uc7Qz229nwHWOixIWfcCKeLBdwkSFRUhR2KeRm98taylnAcoCXZTrZXUluskw== X-Received: by 2002:a17:907:2cc7:b0:959:18b2:454a with SMTP id hg7-20020a1709072cc700b0095918b2454amr16847484ejc.76.1684942450831; Wed, 24 May 2023 08:34:10 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:10 -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 v2 08/13] ceph: allow idmapped getattr inode op Date: Wed, 24 May 2023 17:33:10 +0200 Message-Id: <20230524153316.476973-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_getattr() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 8e5f41d45283..2e988612ed6c 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2465,7 +2465,7 @@ int ceph_getattr(struct mnt_idmap *idmap, const struct path *path, return err; } - generic_fillattr(&nop_mnt_idmap, inode, stat); + generic_fillattr(idmap, inode, stat); stat->ino = ceph_present_inode(inode); /* From patchwork Wed May 24 15:33:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 196C0C77B7C for ; Wed, 24 May 2023 15:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237090AbjEXPhF (ORCPT ); Wed, 24 May 2023 11:37:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237097AbjEXPgM (ORCPT ); Wed, 24 May 2023 11:36:12 -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 6EDAD10E3 for ; Wed, 24 May 2023 08:35:11 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.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 1BEB8423A7 for ; Wed, 24 May 2023 15:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942453; bh=nR9/+ewIyyw/jy6drOGZEF0QPlfa9Zf5mm9/nFwa0HI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lLSZB1MLefikaTBugXnexNAbwJsg3wzvKCqyR0eF/6I9SfCTH2bvwl+ygZV4Hm5yr bsiQHIbOoKVZbNyOn/In4C8hn8SdqJjsauXQX/b84H4nc99TmHwXzi4I1o0c3NTrRS HAw0wNH04XnVeA2ngKLCczOLhoEPKgpVkexlD7H4X5ONAbqspIegejn4K3B38MCtfV Ft7/moXeSsB6qyXWBwXahJrwlC4a2FRgEXIsjdLxoSUsZvvzYnFhE/usO7ij14l3xZ xSESqEW8LD36xA/z38ECMjWoQ6UTPSRnsuQzi7jj+cHP1fXFyuBlSpoKfjIUYlp0c8 tDBK1sg6uPuZg== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-96fd3757bd1so132743166b.1 for ; Wed, 24 May 2023 08:34:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942453; x=1687534453; 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=nR9/+ewIyyw/jy6drOGZEF0QPlfa9Zf5mm9/nFwa0HI=; b=MaOFute/7MvmrZU/jZei60GH4vXUM/rcdbPlLCqhqbgQh4a2dqQnCPoqnI/Z6K76uT lSSADvr0b4FkcHk7tj7lGdn/ObwKO+gCgRcoEX4Iw9Vg/uzPbXQb1iKDlPDN1YsVAET4 Uah5zS0iRXm+02azXP40L4Oh1yfqjgQcUzw5c9c9PRa0t6lNq8CmFwjNMwAteUxmBjTk 1smeeawmL6mt2u6ikfz1803NkFdvva8cqtbf7mupfJ5hlRZOmGfkB57IV1cac34Sn2AU 8J3cVwOu1mGMX6kjp2FNOiSNinCAJ8QPVHMUb8/wKqL0r1ufOLlueRus5s8C3Y3YipwT +9wg== X-Gm-Message-State: AC+VfDwxCMSUdGd4LF4rqum03gC1F2EGL9dvn+P/heSVVTij9304mcTl 41yc84YotQhMOlUyz2uETAyYpa0KHfCD0xUzHTY8GK46nV1kCoxSfVye9OEcFdmcyhha5ZL9uHL ByKVPmDcoZvBnWII+IfT9QSIoRh3IVPXJ+vCvKQ8= X-Received: by 2002:a17:907:928c:b0:94a:7da2:d339 with SMTP id bw12-20020a170907928c00b0094a7da2d339mr19734519ejc.26.1684942452945; Wed, 24 May 2023 08:34:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VrLveeCMu2ys0lUPF7qZva7g6gOB0NcoxUq6lKjQX0cOjszplX5lU3+A9k/0AIpZbnoUuKA== X-Received: by 2002:a17:907:928c:b0:94a:7da2:d339 with SMTP id bw12-20020a170907928c00b0094a7da2d339mr19734509ejc.26.1684942452777; Wed, 24 May 2023 08:34:12 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:12 -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 v2 09/13] ceph: allow idmapped permission inode op Date: Wed, 24 May 2023 17:33:11 +0200 Message-Id: <20230524153316.476973-10-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_permission() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 2e988612ed6c..37e1cbfc7c89 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2408,7 +2408,7 @@ int ceph_permission(struct mnt_idmap *idmap, struct inode *inode, err = ceph_do_getattr(inode, CEPH_CAP_AUTH_SHARED, false); if (!err) - err = generic_permission(&nop_mnt_idmap, inode, mask); + err = generic_permission(idmap, inode, mask); return err; } From patchwork Wed May 24 15:33:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 454C1C77B73 for ; Wed, 24 May 2023 15:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237180AbjEXPhJ (ORCPT ); Wed, 24 May 2023 11:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237173AbjEXPgc (ORCPT ); Wed, 24 May 2023 11:36:32 -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 D238CE46 for ; Wed, 24 May 2023 08:35:12 -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-0.canonical.com (Postfix) with ESMTPS id 603DD423A2 for ; Wed, 24 May 2023 15:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942455; bh=Md8TLnFONebgQ4vC2/VtTKzXRXy8hQu8U3It9LdXrRE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bhC4YNeX35pSUHBPzJjqkYN07y71/FMuAMbEZfHv/nPaZqFTyAJm99sS2ujhe4vqo izO895S+AMYV8mlb5BQCYvN24FlHMIc4ChdUBPuxYIy6WC5O0MyjhUyNChh8UK88BL 4DtYmjQmpUyJ1II2mbLgAwd2gpm4V/3xKVlQGtSZKiQpykWLdyQRKgxt1d5gJGTPDo ev7ObDM/R9sRgwLz+G/d+hd8GvDQAhAT1eI4oMgIjjIGDI1C0Sxj3RUQGw/E2ck9YE rpqHY9iCystR7jUm9xjCfl30DJ5YNKMh3npXB69yeaSMPAvBPK5VIE37Q6gQuMr2vG HE74JZEpPQneQ== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-96f4f1bb838so105792466b.3 for ; Wed, 24 May 2023 08:34:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942455; x=1687534455; 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=Md8TLnFONebgQ4vC2/VtTKzXRXy8hQu8U3It9LdXrRE=; b=LC/IGvjhivK/dKzOKVN1WaOBCJVAAu43/qmHpXoK9OdUlcFGBKNgnG6p6lgZnDX8zD MNOme7no1wC7kfeeZUYwVzZkpA1kvaRKxK/nLwKAfVIxzIJ+p+nNHbTZmEcVYBppLw3q WyNOie6us2vTU55KU/sM/nOWV5NVw/CYFFjo3Umm/KYJBUEUcw4T1iBUAaKYVYeAjrIN RvRvEmbn8SVE+LpWhXYBAvS55N72TqrAKKk6jiei6j9Gh2Pi9zRh7ptFSVjInNBZak/D 1U9+pHTZ8/BM1uCm+TWQrmxrJlmFlls1n5WSU82TlJNWxV4j+TN7i7DnwImUQqPBt3av z9Fw== X-Gm-Message-State: AC+VfDwq5ELBEqSVuhKjppHFOrA7LV5V194RbDJTDGe4c4VJJVs+mAqh GFDKpnmnv7TyZMnEhBZ4oss88M94P/3WlJEa3ThvziZcC7t40Bxy9bqfmbsC3/0jD5YcOzJy2Tu ldoAG0f58N4WO1NFD+iVAT34GWK3n3QnVOjMV1OE= X-Received: by 2002:a17:907:a42b:b0:96f:9cea:a346 with SMTP id sg43-20020a170907a42b00b0096f9ceaa346mr12483831ejc.1.1684942455178; Wed, 24 May 2023 08:34:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4wBfGopEZ/PbcB7gaSEiXxq8R0KVY7IbTh7GgeLo03JonIsvQba/f+t+zD7HunE0mybct/6w== X-Received: by 2002:a17:907:a42b:b0:96f:9cea:a346 with SMTP id sg43-20020a170907a42b00b0096f9ceaa346mr12483820ejc.1.1684942454952; Wed, 24 May 2023 08:34:14 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:14 -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 v2 10/13] ceph: allow idmapped setattr inode op Date: Wed, 24 May 2023 17:33:12 +0200 Message-Id: <20230524153316.476973-11-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable __ceph_setattr() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/inode.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 37e1cbfc7c89..f1f934439be0 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2050,6 +2050,13 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) dout("setattr %p issued %s\n", inode, ceph_cap_string(issued)); + /* + * The attr->ia_{g,u}id members contain the target {g,u}id we're + * sending over the wire. The mount idmapping only matters when we + * create new filesystem objects based on the caller's mapped + * fs{g,u}id. + */ + req->r_mnt_idmap = &nop_mnt_idmap; if (ia_valid & ATTR_UID) { dout("setattr %p uid %d -> %d\n", inode, from_kuid(&init_user_ns, inode->i_uid), @@ -2240,7 +2247,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, if (ceph_inode_is_shutdown(inode)) return -ESTALE; - err = setattr_prepare(&nop_mnt_idmap, dentry, attr); + err = setattr_prepare(idmap, dentry, attr); if (err != 0) return err; @@ -2255,7 +2262,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, err = __ceph_setattr(inode, attr); if (err >= 0 && (attr->ia_valid & ATTR_MODE)) - err = posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode); + err = posix_acl_chmod(idmap, dentry, attr->ia_mode); return err; } From patchwork Wed May 24 15:33:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B31AEC77B7C for ; Wed, 24 May 2023 15:37:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237250AbjEXPhM (ORCPT ); Wed, 24 May 2023 11:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236782AbjEXPgd (ORCPT ); Wed, 24 May 2023 11:36:33 -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 5FD2AE5A for ; Wed, 24 May 2023 08:35:13 -0700 (PDT) Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (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 83469423AB for ; Wed, 24 May 2023 15:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942457; bh=iDvGWD+26D2Z+S1TMox8zoqslkMySxbj4ujfm+xfm2I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vrMYXkGriAviV9qWwNkbWKOpq2y/pYuxaMpgv6HSGch/09joM0c4d4Jm9yccjMyNT 5XN4nnRT1VtV6hfhcuQLoyvvLTblZvvNq32DZgisWlSMcdZX6lgEE3zG0JoSFsdOfo GU1WpcpKhhqhmZANfPG8C7Yebu6yehSEo/ZsZUq1MAGsGuioCS8GZdzSQhU6urV43Z WdMVs+bUTH67gs9j5652QSUwEZzm88TRRlB2EnRSscTLl8IVT4Kbl4VqNiKVJBTDfc AV0vTkB90cUYmGDTGMSJUJHcOV9raToGwVof27ZLADaePwvW7ejSEcN5LihborjSGi ZxkGFtA7x7++A== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-97005627685so120420266b.2 for ; Wed, 24 May 2023 08:34:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942457; x=1687534457; 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=iDvGWD+26D2Z+S1TMox8zoqslkMySxbj4ujfm+xfm2I=; b=PAdFtjHz02ZBHy29PrQH4k2HNaIE//T+pywmIvU0kfEf9paZA4JPhi74UL9nBDN6IP xLTrgfX/vZdCcj6A5PEqjraQ3mJHs54okuG3/M4zdQr8oDY49yg86eIu3BItgiV41ey6 QEW1Cu+uy0R4ys6VjOTtWn1G9+wd+sU62hOpGGm7jq0tVhcIkYtpJ9ezHcEPpDgNoFdV fxv4WQiJw+3VSSXCDwI5FxC6O7jPjTXz2yGF3kwNmoMpBbRIKzpyL/6d+9iip068n05J M7KQyvSeZ8kR01gM/FGE7TNt+5VOvAI6RLae3rFStPQR3+Dllz58uIFqDvBejFMrWuhc Mi8g== X-Gm-Message-State: AC+VfDzTo3E5ivEScwz3DatqmXJI4BVa6ecXnX4hWVqtuXZUl0/sHo0X tTARdqXQVFzmjcTvLOtk9CychY0+VIC1N0yKSD2gPsX4YVolZqQb7cyAEzC/mhXJx+5M4dO22Zm jncT6+Id9GNMhXqkaQJhH7M5RG2uE9PWXA1tljgs= X-Received: by 2002:a17:906:dac1:b0:966:471c:2565 with SMTP id xi1-20020a170906dac100b00966471c2565mr15855324ejb.48.1684942457336; Wed, 24 May 2023 08:34:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7DVPnmHEEXyH6/S3ZdnkASC78MliSVSX6eChUtaO68Ytw9hQ0oJ2rkgjtW+JQ8P1CYQhOU4w== X-Received: by 2002:a17:906:dac1:b0:966:471c:2565 with SMTP id xi1-20020a170906dac100b00966471c2565mr15855304ejb.48.1684942457080; Wed, 24 May 2023 08:34:17 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:16 -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 v2 11/13] ceph/acl: allow idmapped set_acl inode op Date: Wed, 24 May 2023 17:33:13 +0200 Message-Id: <20230524153316.476973-12-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_set_acl() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 6945a938d396..4291c890e324 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -105,7 +105,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, case ACL_TYPE_ACCESS: name = XATTR_NAME_POSIX_ACL_ACCESS; if (acl) { - ret = posix_acl_update_mode(&nop_mnt_idmap, inode, + ret = posix_acl_update_mode(idmap, inode, &new_mode, &acl); if (ret) goto out; From patchwork Wed May 24 15:33:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53384C7EE2E for ; Wed, 24 May 2023 15:37:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237360AbjEXPhT (ORCPT ); Wed, 24 May 2023 11:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236491AbjEXPge (ORCPT ); Wed, 24 May 2023 11:36:34 -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 3AACA139 for ; Wed, 24 May 2023 08:35:14 -0700 (PDT) Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (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 8C81D4074B for ; Wed, 24 May 2023 15:34:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942460; bh=j/vZphe6iawzwC+GAFA6qRSN3lvkZ4mAE+bgyLQQZEQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=imXshkHuCw3/YUan0IJiKbujCfMF+5vkS7QhmvJJg1R3yQIkewLDUKGjaXPTUiami cDqpNs3ctWg5EVmqcMZskEWrJPpR9hArStgk5SsqJlSdzJnlELz+7N/mbcmMrj+q7D Zb9GtZLgmf22NXdBYgNzY6opF2ywxkMKZ8mfJTJ9t69Nz5Y75Yr4sfvfsMc5Ey8hop sbdaL19jbL19dCbpXERe/52AjcIwwlJ+JKvUi+jz74g04oAJk0Irt0wkQsP0riXUkU HEauFkKME9pG+sRn2AirER6O9IPaDWO2c11lU2D++tSo545jqyEsEsUfEgYekyjdfa WGcodyCVO+n+w== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-96feeddb1f8so131014466b.3 for ; Wed, 24 May 2023 08:34:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942459; x=1687534459; 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=j/vZphe6iawzwC+GAFA6qRSN3lvkZ4mAE+bgyLQQZEQ=; b=HVe6SHRh+6I/2W8bIuPfHl/h79/ff45/m71aWsPUsnLQeXV5bOdkoEXziEg7Nb+kW0 EY18kcGBcEa4ImJrt6XXnU5PBtHjXsGXz9qbSlPXEzocbR9uGGIsx92qbXZ/SINcLmP4 rjzv9wMu3nSi5xYVcUl1R9agDKYWiqIV3Cs61XOJFqyGDufBEdtbaKajkgtoX17lqckb TUaQwisY7B1jHYw8aB8r7qHHQAoLpcbBvtuk75iWMr96FNlqKBdGHVKhsy0p61lyoaAz Yvo1rfkiedl0vpNO7/baUKVME24jAkcqYdrC5xc2vXMxfc3zCZa9+lcSMjJjbfwAQPaN XlUQ== X-Gm-Message-State: AC+VfDxNgZNB5ICig+jERYR1qoRLME9h5/9OyHY17ktl3H6AfgZYnxdx 8zCBjdpyL7MnMawj3CExWzKCxrGb1GAmhhHwX7/q2iVZ/fTcEJtVBHfjbNEexCLnrMyvf0vJ3ew ag6JI04Vta7EAu9vyRdG0fXqavqxXVHGs97T3niQ= X-Received: by 2002:a17:907:c26:b0:94e:e859:7b07 with SMTP id ga38-20020a1709070c2600b0094ee8597b07mr22066653ejc.32.1684942459658; Wed, 24 May 2023 08:34:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ70ze+kK5xwEjLwX+w5pYZq2/22Y+g7DXsfrlfW78Xsf0MHGqqXeUaXUY3B25KagsieuVK90w== X-Received: by 2002:a17:907:c26:b0:94e:e859:7b07 with SMTP id ga38-20020a1709070c2600b0094ee8597b07mr22066628ejc.32.1684942459495; Wed, 24 May 2023 08:34:19 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:19 -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 v2 12/13] ceph/file: allow idmapped atomic_open inode op Date: Wed, 24 May 2023 17:33:14 +0200 Message-Id: <20230524153316.476973-13-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_atomic_open() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- v2: - rebased, see also 5fadbd9929 ("ceph: rely on vfs for setgid stripping") --- fs/ceph/file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index f4d8bf7dec88..f00bfda4b1d2 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -654,7 +654,9 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, in.truncate_seq = cpu_to_le32(1); in.truncate_size = cpu_to_le64(-1ULL); in.xattr_version = cpu_to_le64(1); - in.uid = cpu_to_le32(from_kuid(&init_user_ns, current_fsuid())); + in.uid = cpu_to_le32(from_kuid(&init_user_ns, + mapped_fsuid(req->r_mnt_idmap, + &init_user_ns))); if (dir->i_mode & S_ISGID) { in.gid = cpu_to_le32(from_kgid(&init_user_ns, dir->i_gid)); @@ -662,7 +664,9 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, if (S_ISDIR(mode)) mode |= S_ISGID; } else { - in.gid = cpu_to_le32(from_kgid(&init_user_ns, current_fsgid())); + in.gid = cpu_to_le32(from_kgid(&init_user_ns, + mapped_fsgid(req->r_mnt_idmap, + &init_user_ns))); } in.mode = cpu_to_le32((u32)mode); @@ -731,6 +735,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, struct file *file, unsigned flags, umode_t mode) { struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_mds_client *mdsc = fsc->mdsc; struct ceph_mds_request *req; struct dentry *dn; @@ -786,6 +791,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, mask |= CEPH_CAP_XATTR_SHARED; req->r_args.open.mask = cpu_to_le32(mask); req->r_parent = dir; + req->r_mnt_idmap = idmap; ihold(dir); if (flags & O_CREAT) { From patchwork Wed May 24 15:33:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13254250 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4F68C77B7C for ; Wed, 24 May 2023 15:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237323AbjEXPhR (ORCPT ); Wed, 24 May 2023 11:37:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237199AbjEXPge (ORCPT ); Wed, 24 May 2023 11:36:34 -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 E033C10EB for ; Wed, 24 May 2023 08:35:14 -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-0.canonical.com (Postfix) with ESMTPS id BBAAE42267 for ; Wed, 24 May 2023 15:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1684942462; bh=MmBaaHI8VpALzyIfbDDcm88Bn4QWndtQOfQJ2qpYUhg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t8Y7bPxuj5p0Dqm3r2khDAY4TO10Uhs6uLwzpMXCJLWnQsXob+3l7PP8RUt5Ln8Z8 IYTy6zV8cUPJRdr/qzNYV4BJvwnhgGHxcB4EvCyVoOcUHYr8OpvUoB3Ov3aF+kz1+c yzAccG7xpyLbsqDe0rQZ7K+VjkmdAzkrJDpjoFRaF7Orbms/EnqvI/lO5IYfaANyBr uJxUJ4t5P1PQ9ZxuAoLPGTF/neiF5O1KbwPP39Bm95Jr5tRoHO9y8mCiC+j6xeJTzM lJUlC78TEvTx7RNtGRE9gtEGwnzbr2iVr2KOaC9T1a5/vU+L6FxRUqj3pIvYWnXpCC lLKe9+OedQP4w== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-96fd3757c1dso121088266b.1 for ; Wed, 24 May 2023 08:34:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684942462; x=1687534462; 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=MmBaaHI8VpALzyIfbDDcm88Bn4QWndtQOfQJ2qpYUhg=; b=HrYL3JEOCKgM6+UOV8Wxh0hYXSQtyi4nYxKH4mIWaQA/H4m76K8pMwmqU5GQGlq0Kf +Je432pzGhOKTtOdGxM3pjBxDONcRq29Yg/bNfF+BqfItVfGbppKFPHmXhymgmd340BK EZlkasBsw9GCTT8rot45Rn6A6xwa65XjIFiBkQjJjefH+0PDuppMh2/XESuQ4ai5zLTJ t4hUF5h4NNccFsTSN0B6NSMw/eN41nvyGXbhw+CU4RCrysmDEFYWfWsPdOu5WVjvPCuw 2flqXs8wRIQRYT7fR3OJW19fLDaPceBQw+d2NMgjf/tERPjcM5QLfcpoiEujc6I0gUVe 4TCg== X-Gm-Message-State: AC+VfDzacK2eF1MlRifRV5GmlAx2zQrd8laYy6pbzPj27xvWTZqf9wM8 LrH7ngXb59QLZrCfehkTXw2Y47DgoiDH72KK/7FLmtopS3TyPvvdv5DhplFi6h2dQP4Y5g501Ec 6FuViHdvMFnkzUJ20Sz9Al4txPzNHVRwdPD+M1JU= X-Received: by 2002:a17:907:2d90:b0:96f:a935:8998 with SMTP id gt16-20020a1709072d9000b0096fa9358998mr15705805ejc.39.1684942462502; Wed, 24 May 2023 08:34:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ44n45ezB0KardR5KNvgVnID6UZeZRJn1zaN+1xQ4m7BE5LFwiKYKe0ULefNGmTnlmYv5+ifQ== X-Received: by 2002:a17:907:2d90:b0:96f:a935:8998 with SMTP id gt16-20020a1709072d9000b0096fa9358998mr15705780ejc.39.1684942462292; Wed, 24 May 2023 08:34:22 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-074-206-207.088.074.pools.vodafone-ip.de. [88.74.206.207]) by smtp.gmail.com with ESMTPSA id p26-20020a17090664da00b0096f7105b3a6sm5986979ejn.189.2023.05.24.08.34.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 May 2023 08:34:21 -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 v2 13/13] ceph: allow idmapped mounts Date: Wed, 24 May 2023 17:33:15 +0200 Message-Id: <20230524153316.476973-14-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> References: <20230524153316.476973-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Now that we converted cephfs internally to account for idmapped mounts allow the creation of idmapped mounts on by setting the FS_ALLOW_IDMAP flag. Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 3fc48b43cab0..4f6e6d57f3f1 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1389,7 +1389,7 @@ static struct file_system_type ceph_fs_type = { .name = "ceph", .init_fs_context = ceph_init_fs_context, .kill_sb = ceph_kill_sb, - .fs_flags = FS_RENAME_DOES_D_MOVE, + .fs_flags = FS_RENAME_DOES_D_MOVE | FS_ALLOW_IDMAP, }; MODULE_ALIAS_FS("ceph");