From patchwork Mon Aug 7 13:26:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344230 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 CF0BCC001DB for ; Mon, 7 Aug 2023 13:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234015AbjHGN2y (ORCPT ); Mon, 7 Aug 2023 09:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233848AbjHGN2r (ORCPT ); Mon, 7 Aug 2023 09:28:47 -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 7AC8A1BC6 for ; Mon, 7 Aug 2023 06:28:26 -0700 (PDT) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.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-1.canonical.com (Postfix) with ESMTPS id B7BD13F20E for ; Mon, 7 Aug 2023 13:28:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414882; bh=GFNwWvhavDkNrI4eqwez7OWrv+w+Iw1WNhnwQW/Fw7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kEsiTuUaGvgiZixzSK5tdhGyQohFuGub9EDTjE3KOpKq+YhpJ3pw9pcphgZcg4AJH 9/JF1ZVM0VrdfSONyEyg9tQNWjNA8ZTdmkvARrN4N0mm7negxE08ztHWwOG11HNV+X bcCJ7NdzJiKvXzi/vQ+aGAc2Z2kaMJwLI6FC0Bz5g+C3RCx4aysuh7YyWaSfVW0PMh iOq7uU5pRGQdCh9sWJX5+6zn6urjCR73ZJ4oX9vtnxYwmEPBH9QAa7B6a+mLlOzNRw CAV3LvCEAlJSeTNqoPl7MGXt2jXYnQlX07tWUbki2bB3I/oUqNoWSIjPqCLf0ScNz9 F7lsW11lqx4Vg== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5225a8f625dso3359743a12.0 for ; Mon, 07 Aug 2023 06:28:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414882; x=1692019682; 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=GFNwWvhavDkNrI4eqwez7OWrv+w+Iw1WNhnwQW/Fw7E=; b=TtElqzBtuQ+B3wpX4cjBGYj7ZmTllYbQxJCOMfbbIKS5UTJbRHzsPv4pwrMx7qy1Zn 6/wxiWOOIMlGKcNmbKTbacvp1Z8d7g5Kxc1TcKkDeFLNrU1j+9qwM0+1riSWhzK2roZP 4B+VBVFDvVHkzQQe3nUj/dZk/2+7Kd7Sj0WEmVLm/M7g4ZUAGVu6khTV8cklmGRkvLLe wj5zo8AqlgpvkzGoYdh2Z1Hwk4bEqfVN8uibFY71x1qZtH78g9EQ0P3uX+zMCM+mgKIj ye1mZ72iMubXIq3TjCxpmCB+KJyuomM5YKN3YhRnuZwqHGyDgL1gX1s4VOvgxZArGGhK OsKg== X-Gm-Message-State: AOJu0YyZn2wivXRg0k9tlxY1n/V/J5U6NHyCnaf7iT8pHjf5/BI0eotH AOqaSwm+ZdGlKwlr+CB8wXTVzM4/uLAiS2wovhwgs+8EMG0+2/mwUy+WD3csWuJDRXlklinNoQo V3iCM9yBYEb4oQ0vaCpb93fpg4AuKraCdY9m+HJM= X-Received: by 2002:a17:906:1db:b0:993:f2c2:7512 with SMTP id 27-20020a17090601db00b00993f2c27512mr10084636ejj.33.1691414882353; Mon, 07 Aug 2023 06:28:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJO/0vqqE3tOHSpFzVew5B2QmVjKhzPumTSIkC7c+m2kty/8ghyCXqQKoZTu6KRcvPeoWfNg== X-Received: by 2002:a17:906:1db:b0:993:f2c2:7512 with SMTP id 27-20020a17090601db00b00993f2c27512mr10084624ejj.33.1691414882075; Mon, 07 Aug 2023 06:28:02 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:01 -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 , Alexander Viro , Seth Forshee , linux-kernel@vger.kernel.org Subject: [PATCH v10 01/12] fs: export mnt_idmap_get/mnt_idmap_put Date: Mon, 7 Aug 2023 15:26:15 +0200 Message-Id: <20230807132626.182101-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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. Cc: Christian Brauner Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn Reviewed-by: Christian Brauner --- v3: - EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL as Christoph Hellwig suggested --- 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..57d1dedf3f8f 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_GPL(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_GPL(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 Mon Aug 7 13:26:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344231 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 DA24FC00528 for ; Mon, 7 Aug 2023 13:28:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232429AbjHGN2z (ORCPT ); Mon, 7 Aug 2023 09:28:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233736AbjHGN2v (ORCPT ); Mon, 7 Aug 2023 09:28:51 -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 5BC101BF5 for ; Mon, 7 Aug 2023 06:28:27 -0700 (PDT) Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.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-1.canonical.com (Postfix) with ESMTPS id 93C90417BA for ; Mon, 7 Aug 2023 13:28:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414885; bh=StxqveXF5moq9iJU4D0IjENKfN6jaIfCw60woBc2a1E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vw9pr0c6YCf32t2r70+2SVyfe7Hdbrf46brAr5cDFKgGWqmDfbqzKhE8LQzkpc8NZ Qw6JQDuC2glVDrjXwnOxWmnfSjUrcRDEUI2VajOnpEsl2IXwDOYWpLCrC1Oj8cWhqa NM+LeTkQW9xiuXdm26QwJ3bwZcTTRtiKUgyI7dSVmwfEsI8zmMPpG9cgm5GxOQ3zsU r6qBfyRaRvK5Tni3WVSea9geyI83KhYk4SSTXFQZJbwAFfQs6SrXSVcRm1Ua1zMgr4 pv8YbSyUWf0hgOlFVNS+9CUyivRRIFOi05N3tBLQYEihQg3A3VugjDacigdbaDHbo+ fWaYNgDBrFiuQ== Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-4fe32cab9b7so4549593e87.1 for ; Mon, 07 Aug 2023 06:28:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414885; x=1692019685; 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=i00B9C8NKXamX/cRTGcVH+X5PjyJatk3rQhbDKTohzyt1wJm+6E1Dl/M8hXAhB3iq0 Ksb9ozsJ6F6IWhFZzCCpWtVyh4xD23StHwQ/N1LrhjXcY2SV+hmr7B/m2AgQMzrKL+FU a9KWyqUax3+lvfHbjH1LdbcwShgfZigL7515iJpvs57JahR7OWR1bdoqON1h5kgx5gKQ LEzc/EXcXBT8g+pd8EEPVD+w3Gw5u5+S8eJT8v7/E30aIhotXoaH1Z+1CAglR7wGwqFL JXcWwFF6Q832iEcFdWt8ge5qP4C/Au5yRU0epgJq2gUNvWZT8QhNwkAENaoHSEE7Ue1R Dfcw== X-Gm-Message-State: AOJu0Yy78ZAluEGgnXnNsl6cqyojfJsPXnomhfShVKsOuEB++jQg1KhB Yk9SQvoqR6viI/QUCVkg8VseOh7MCMKbAdsobZMM33h54wAz0K/UfIJvDYOAW7E3qafJWan173W 3ZP3eJpTnkxLqm0MjA1LTKs5AT1Q8ZDOCJJfmLSo= X-Received: by 2002:a19:384d:0:b0:4fd:f85d:f67a with SMTP id d13-20020a19384d000000b004fdf85df67amr5042656lfj.61.1691414885027; Mon, 07 Aug 2023 06:28:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGH8dpV5asuzqi3+idsYjvpcoY+P3TuwWpXio+/xGhWIZTKsOh87DyxGbqpTlfVO9qsRuKnSQ== X-Received: by 2002:a19:384d:0:b0:4fd:f85d:f67a with SMTP id d13-20020a19384d000000b004fdf85df67amr5042642lfj.61.1691414884702; Mon, 07 Aug 2023 06:28:04 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:04 -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 v10 02/12] ceph: stash idmapping in mdsc request Date: Mon, 7 Aug 2023 15:26:16 +0200 Message-Id: <20230807132626.182101-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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: 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 */ From patchwork Mon Aug 7 13:26:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344232 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 E21BAC04A94 for ; Mon, 7 Aug 2023 13:28:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233968AbjHGN25 (ORCPT ); Mon, 7 Aug 2023 09:28:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233995AbjHGN2x (ORCPT ); Mon, 7 Aug 2023 09:28:53 -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 969FA199B for ; Mon, 7 Aug 2023 06:28:28 -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 49E7F44279 for ; Mon, 7 Aug 2023 13:28:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414888; bh=CtBJRc4HIc+srecN6BR4LVumWEoikJhCfq0jTrx0/xU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=W6Kd+PuooTohbbUm+R3cZkXtBhewoL8EaFWpeGphkKMGEPR/ThsVO3g7cMUrtOhib JB7HD1LaqJj9OlJcmx0v6kN3mZ2LlGmz2HqbqzxWcsSx4OzpWjBuJkjtykDZmzx6kG SOdWQ0aZGHXxq8WuprmJjHrGExga2pTs3XgRqdtYKeXqCjESan4nUKwRXYnDqVE9nI +5l9aBCBkMoDNcrKJtRytDVKOnRCdDB/f+bLqh0zCf1gTCyrwZN6g3w0cdPsDpjaSB v3BrvPem33nOzdjQZ3UlCk/2zMZaBvOnBl9TJrkRxAraFW6EmFKI2tHlOtJAd4tiJP xg3ese3zJZmsQ== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-98e40d91fdfso344105366b.3 for ; Mon, 07 Aug 2023 06:28:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414888; x=1692019688; 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=CtBJRc4HIc+srecN6BR4LVumWEoikJhCfq0jTrx0/xU=; b=Z9cXdXxPUS3dHCQhWxNNq6jHtxU/RlDuf9zPniZ1H6ep2VK+eQwlmZwXTqY3grD2GO TUIIwyTsCEtZyrOJrXdkPzU01bOS5CoSgkDcUtfX/FcL3ldFbxAXDx9+AC+qkeqQvUp5 kuBYLKwFD5LOBfV6HutYjsKizyFmiQSuJkUJI9VKSUgRZT0qKEFaEwYpularxY5U/0YG jLpMaXlOYVFxpqOB0/FTnoziF0Q65cuq0KfTTHjSyJuEGVwPLEbHSoI3z7CoytNU2b77 mQpxmNrOIVNcFR7zHRgHAYV26/NjG60ZI0Xn9Eq5YQFai74dF+3bJISpmE73rKAA/MFO bPZg== X-Gm-Message-State: AOJu0YwWAREOzGP/hG5cVNszFFl2Sm1cg0a18JZPaOoITJrVBAWSy/s/ DipiNGkbDEjOULxvGb4G7icYZ3hkMRDstUYQ7jAmdoM4lslXnTZs8Ev+E5/+onK8RifbKnLmMmT AXk6aUygiZckZ93xPoqPUFHx8dnQDbnURsXrKS2E= X-Received: by 2002:a17:906:209c:b0:99b:d599:5086 with SMTP id 28-20020a170906209c00b0099bd5995086mr9623735ejq.75.1691414887905; Mon, 07 Aug 2023 06:28:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGyP5yIIrtiTVTtjzAf4BH44AU/ig6VCb8VPJwFX70tY7iKrYzWW3+k82ej/+HuCN4g9kHkJQ== X-Received: by 2002:a17:906:209c:b0:99b:d599:5086 with SMTP id 28-20020a170906209c00b0099bd5995086mr9623729ejq.75.1691414887721; Mon, 07 Aug 2023 06:28:07 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:07 -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 v10 03/12] ceph: handle idmapped mounts in create_request_message() Date: Mon, 7 Aug 2023 15:26:17 +0200 Message-Id: <20230807132626.182101-4-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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. 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. This change uses a new cephfs protocol extension CEPHFS_FEATURE_HAS_OWNER_UIDGID which adds two new fields (owner_{u,g}id) to the request head structure. So, we need to ensure that MDS supports it otherwise we need to fail any IO that comes through an idmapped mount because we can't process it in a proper way. MDS server without such an extension will use caller_{u,g}id fields to set a new inode owner UID/GID which is incorrect because caller_{u,g}id values are unmapped. At the same time we can't map these fields with an idmapping as it can break UID/GID-based permission checks logic on the MDS side. This problem was described with a lot of details at [1], [2]. [1] https://lore.kernel.org/lkml/CAEivzxfw1fHO2TFA4dx3u23ZKK6Q+EThfzuibrhA3RKM=ZOYLg@mail.gmail.com/ [2] https://lore.kernel.org/all/20220104140414.155198-3-brauner@kernel.org/ Link: https://github.com/ceph/ceph/pull/52575 Link: https://tracker.ceph.com/issues/62217 Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Co-Developed-by: Alexander Mikhalitsyn Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn Acked-by: Christian Brauner --- v7: - reworked to use two new fields for owner UID/GID (https://github.com/ceph/ceph/pull/52575) v8: - properly handled case when old MDS used with new kernel client v10: - fill struct_len field properly (use cpu_to_le32) - add extra checks IS_CEPH_MDS_OP_NEWINODE(..) as requested by Xiubo to match userspace client behavior --- fs/ceph/mds_client.c | 55 ++++++++++++++++++++++++++++++++++-- fs/ceph/mds_client.h | 5 +++- include/linux/ceph/ceph_fs.h | 10 ++++++- 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 8829f55103da..5114de5ea65e 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2902,6 +2902,17 @@ static void encode_mclientrequest_tail(void **p, const struct ceph_mds_request * } } +static inline u16 mds_supported_head_version(struct ceph_mds_session *session) +{ + if (!test_bit(CEPHFS_FEATURE_32BITS_RETRY_FWD, &session->s_features)) + return 1; + + if (!test_bit(CEPHFS_FEATURE_HAS_OWNER_UIDGID, &session->s_features)) + return 2; + + return CEPH_MDS_REQUEST_HEAD_VERSION; +} + static struct ceph_mds_request_head_legacy * find_legacy_request_head(void *p, u64 features) { @@ -2923,6 +2934,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, { int mds = session->s_mds; struct ceph_mds_client *mdsc = session->s_mdsc; + struct ceph_client *cl = mdsc->fsc->client; struct ceph_msg *msg; struct ceph_mds_request_head_legacy *lhead; const char *path1 = NULL; @@ -2936,7 +2948,7 @@ 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); - bool old_version = !test_bit(CEPHFS_FEATURE_32BITS_RETRY_FWD, &session->s_features); + u16 request_head_version = mds_supported_head_version(session); ret = set_request_path_attr(mdsc, req->r_inode, req->r_dentry, req->r_parent, req->r_path1, req->r_ino1.ino, @@ -2977,8 +2989,10 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, */ if (legacy) len = sizeof(struct ceph_mds_request_head_legacy); - else if (old_version) + else if (request_head_version == 1) len = sizeof(struct ceph_mds_request_head_old); + else if (request_head_version == 2) + len = offsetofend(struct ceph_mds_request_head, ext_num_fwd); else len = sizeof(struct ceph_mds_request_head); @@ -3028,6 +3042,18 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, lhead = find_legacy_request_head(msg->front.iov_base, session->s_con.peer_features); + if ((req->r_mnt_idmap != &nop_mnt_idmap) && + !test_bit(CEPHFS_FEATURE_HAS_OWNER_UIDGID, &session->s_features)) { + WARN_ON_ONCE(!IS_CEPH_MDS_OP_NEWINODE(req->r_op)); + + pr_err_ratelimited_client(cl, + "idmapped mount is used and CEPHFS_FEATURE_HAS_OWNER_UIDGID" + " is not supported by MDS. Fail request with -EIO.\n"); + + ret = -EIO; + goto out_err; + } + /* * The ceph_mds_request_head_legacy didn't contain a version field, and * one was added when we moved the message version from 3->4. @@ -3035,17 +3061,40 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, if (legacy) { msg->hdr.version = cpu_to_le16(3); p = msg->front.iov_base + sizeof(*lhead); - } else if (old_version) { + } else if (request_head_version == 1) { struct ceph_mds_request_head_old *ohead = msg->front.iov_base; msg->hdr.version = cpu_to_le16(4); ohead->version = cpu_to_le16(1); p = msg->front.iov_base + sizeof(*ohead); + } else if (request_head_version == 2) { + struct ceph_mds_request_head *nhead = msg->front.iov_base; + + msg->hdr.version = cpu_to_le16(6); + nhead->version = cpu_to_le16(2); + + p = msg->front.iov_base + offsetofend(struct ceph_mds_request_head, ext_num_fwd); } else { struct ceph_mds_request_head *nhead = msg->front.iov_base; + kuid_t owner_fsuid; + kgid_t owner_fsgid; msg->hdr.version = cpu_to_le16(6); nhead->version = cpu_to_le16(CEPH_MDS_REQUEST_HEAD_VERSION); + nhead->struct_len = cpu_to_le32(sizeof(struct ceph_mds_request_head)); + + if (IS_CEPH_MDS_OP_NEWINODE(req->r_op)) { + owner_fsuid = from_vfsuid(req->r_mnt_idmap, &init_user_ns, + VFSUIDT_INIT(req->r_cred->fsuid)); + owner_fsgid = from_vfsgid(req->r_mnt_idmap, &init_user_ns, + VFSGIDT_INIT(req->r_cred->fsgid)); + nhead->owner_uid = cpu_to_le32(from_kuid(&init_user_ns, owner_fsuid)); + nhead->owner_gid = cpu_to_le32(from_kgid(&init_user_ns, owner_fsgid)); + } else { + nhead->owner_uid = cpu_to_le32(-1); + nhead->owner_gid = cpu_to_le32(-1); + } + p = msg->front.iov_base + sizeof(*nhead); } diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index e3bbf3ba8ee8..8f683e8203bd 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -33,8 +33,10 @@ enum ceph_feature_type { CEPHFS_FEATURE_NOTIFY_SESSION_STATE, CEPHFS_FEATURE_OP_GETVXATTR, CEPHFS_FEATURE_32BITS_RETRY_FWD, + CEPHFS_FEATURE_NEW_SNAPREALM_INFO, + CEPHFS_FEATURE_HAS_OWNER_UIDGID, - CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_32BITS_RETRY_FWD, + CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_HAS_OWNER_UIDGID, }; #define CEPHFS_FEATURES_CLIENT_SUPPORTED { \ @@ -49,6 +51,7 @@ enum ceph_feature_type { CEPHFS_FEATURE_NOTIFY_SESSION_STATE, \ CEPHFS_FEATURE_OP_GETVXATTR, \ CEPHFS_FEATURE_32BITS_RETRY_FWD, \ + CEPHFS_FEATURE_HAS_OWNER_UIDGID, \ } /* diff --git a/include/linux/ceph/ceph_fs.h b/include/linux/ceph/ceph_fs.h index 5f2301ee88bc..d0ead0b6354c 100644 --- a/include/linux/ceph/ceph_fs.h +++ b/include/linux/ceph/ceph_fs.h @@ -357,6 +357,11 @@ enum { CEPH_MDS_OP_RENAMESNAP = 0x01403, }; +#define IS_CEPH_MDS_OP_NEWINODE(op) (op == CEPH_MDS_OP_CREATE || \ + op == CEPH_MDS_OP_MKNOD || \ + op == CEPH_MDS_OP_MKDIR || \ + op == CEPH_MDS_OP_SYMLINK) + extern const char *ceph_mds_op_name(int op); #define CEPH_SETATTR_MODE (1 << 0) @@ -499,7 +504,7 @@ struct ceph_mds_request_head_legacy { union ceph_mds_request_args args; } __attribute__ ((packed)); -#define CEPH_MDS_REQUEST_HEAD_VERSION 2 +#define CEPH_MDS_REQUEST_HEAD_VERSION 3 struct ceph_mds_request_head_old { __le16 version; /* struct version */ @@ -530,6 +535,9 @@ struct ceph_mds_request_head { __le32 ext_num_retry; /* new count retry attempts */ __le32 ext_num_fwd; /* new count fwd attempts */ + + __le32 struct_len; /* to store size of struct ceph_mds_request_head */ + __le32 owner_uid, owner_gid; /* used for OPs which create inodes */ } __attribute__ ((packed)); /* cap/lease release record */ From patchwork Mon Aug 7 13:26:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344233 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 DFAA3C00528 for ; Mon, 7 Aug 2023 13:29:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234178AbjHGN3W (ORCPT ); Mon, 7 Aug 2023 09:29:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233848AbjHGN3M (ORCPT ); Mon, 7 Aug 2023 09:29:12 -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 B70371BF2 for ; Mon, 7 Aug 2023 06:28:48 -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 36A8D413C3 for ; Mon, 7 Aug 2023 13:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414891; bh=9n6Y3+R2z8MxgQphIes473oPxL5sL8PFIQL+RUTLs6I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=m4qhKaTImBND8WcuT2ePvUE9SDmU/9xC+DMM6b6agp1PfWK+4M5QX6tqAei19opL8 4YZ6E3TlUoP5M3BKJApBR/7cXAaKtk34tK1cszvtvfunqnZI/w00K0jXWrf2b+Ne3+ PQJWKgap38TAqnN8tul3jHX5lSTgCJjjX0TP7mqYxYt/0BwTA3Z+RSqyjg1RMXmes3 MEnQFx8B9laGDzxT++6cLlqK3npATjXC9uRHZGsuXkw5r52xyKRCb2aHlVfpnvTMQB +4i+5qRFUmgv7yArprYEAxfbUIvm3gt+kEGBLSmdG4CIlFYp/vrSfUE0E6U36052d0 KhSHm+5vx6b5Q== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-94a34d3e5ebso300367466b.3 for ; Mon, 07 Aug 2023 06:28:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414891; x=1692019691; 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=9n6Y3+R2z8MxgQphIes473oPxL5sL8PFIQL+RUTLs6I=; b=i1RdDjJkPfTQ49o2yie7/4KnVUbhbpMrrxUNcajCgoeVcNUPyuoW9xfLskFT+KCII7 2qCcAB9dB7RsII2caf4OZzBOiuXLitN+uXYxAU8Hxn2Y7qLyDzyblZwteB8x42ZMb6DQ BZfFCRSTSEMvunr1ScbVcNIejm/mNbMttrByJTM2DJEv+x3CfD/rZ3hHcYuAuvmKxjCp heuhc5oX98R2DAsm/DuR+u8S/dKtG005CGr1+8pkCbcKnKGzwTAAQJY/oezW/nYVWRJF 1VYwn84NbDiP69Ht3s2HNdu8efZiWKxNTQmapmroJob41l3PaoqkudM7JwuIdFzI33Wj J9LQ== X-Gm-Message-State: AOJu0Yy29g92xKr5+AoMFE5A8n/iS/9CLOHtubVVBmgJiXhpHpJiovY5 +Fh+p+14vFkRwrbUEnuRsZNixN3gvO9VLSdyjAbGKLtyj5sLT0RxsVriJ7E8hgu9TbAIAuK2Hg5 5mPxjCqhCjCoCOCrxWxeogYd/9Zdqm5F75WiFckQ= X-Received: by 2002:a17:907:2c44:b0:99c:825:6076 with SMTP id hf4-20020a1709072c4400b0099c08256076mr6544993ejc.35.1691414890933; Mon, 07 Aug 2023 06:28:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEBU4i6R38ul+frqeZevZOxWpLNRxj0oiRwvcU1y4whm1La4MwJf9y9wAgsB1yXAlivGYfFGw== X-Received: by 2002:a17:907:2c44:b0:99c:825:6076 with SMTP id hf4-20020a1709072c4400b0099c08256076mr6544975ejc.35.1691414890543; Mon, 07 Aug 2023 06:28:10 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:10 -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 v10 04/12] ceph: add enable_unsafe_idmap module parameter Date: Mon, 7 Aug 2023 15:26:18 +0200 Message-Id: <20230807132626.182101-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org This parameter is used to decide if we allow to perform IO on idmapped mount in case when MDS lacks support of CEPHFS_FEATURE_HAS_OWNER_UIDGID feature. In this case we can't properly handle MDS permission checks and if UID/GID-based restrictions are enabled on the MDS side then IO requests which go through an idmapped mount may fail with -EACCESS/-EPERM. Fortunately, for most of users it's not a case and everything should work fine. But we put work "unsafe" in the module parameter name to warn users about possible problems with this feature and encourage update of cephfs MDS. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Suggested-by: Stéphane Graber Signed-off-by: Alexander Mikhalitsyn Acked-by: Christian Brauner --- fs/ceph/mds_client.c | 28 +++++++++++++++++++++------- fs/ceph/mds_client.h | 2 ++ fs/ceph/super.c | 5 +++++ 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 5114de5ea65e..90c4b0689cd6 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2949,6 +2949,8 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, int ret; bool legacy = !(session->s_con.peer_features & CEPH_FEATURE_FS_BTIME); u16 request_head_version = mds_supported_head_version(session); + kuid_t caller_fsuid = req->r_cred->fsuid; + kgid_t caller_fsgid = req->r_cred->fsgid; ret = set_request_path_attr(mdsc, req->r_inode, req->r_dentry, req->r_parent, req->r_path1, req->r_ino1.ino, @@ -3046,12 +3048,24 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, !test_bit(CEPHFS_FEATURE_HAS_OWNER_UIDGID, &session->s_features)) { WARN_ON_ONCE(!IS_CEPH_MDS_OP_NEWINODE(req->r_op)); - pr_err_ratelimited_client(cl, - "idmapped mount is used and CEPHFS_FEATURE_HAS_OWNER_UIDGID" - " is not supported by MDS. Fail request with -EIO.\n"); + if (enable_unsafe_idmap) { + pr_warn_once_client(cl, + "idmapped mount is used and CEPHFS_FEATURE_HAS_OWNER_UIDGID" + " is not supported by MDS. UID/GID-based restrictions may" + " not work properly.\n"); - ret = -EIO; - goto out_err; + 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)); + } else { + pr_err_ratelimited_client(cl, + "idmapped mount is used and CEPHFS_FEATURE_HAS_OWNER_UIDGID" + " is not supported by MDS. Fail request with -EIO.\n"); + + ret = -EIO; + goto out_err; + } } /* @@ -3103,9 +3117,9 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, lhead->mdsmap_epoch = cpu_to_le32(mdsc->mdsmap->m_epoch); lhead->op = cpu_to_le32(req->r_op); lhead->caller_uid = cpu_to_le32(from_kuid(&init_user_ns, - req->r_cred->fsuid)); + caller_fsuid)); lhead->caller_gid = cpu_to_le32(from_kgid(&init_user_ns, - req->r_cred->fsgid)); + caller_fsgid)); lhead->ino = cpu_to_le64(req->r_deleg_ino); lhead->args = req->r_args; diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 8f683e8203bd..0945ae4cf3c5 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -619,4 +619,6 @@ static inline int ceph_wait_on_async_create(struct inode *inode) extern int ceph_wait_on_conflict_unlink(struct dentry *dentry); extern u64 ceph_get_deleg_ino(struct ceph_mds_session *session); extern int ceph_restore_deleg_ino(struct ceph_mds_session *session, u64 ino); + +extern bool enable_unsafe_idmap; #endif diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 49fd17fbba9f..18bfdfd48cef 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1680,6 +1680,11 @@ static const struct kernel_param_ops param_ops_mount_syntax = { module_param_cb(mount_syntax_v1, ¶m_ops_mount_syntax, &mount_support, 0444); module_param_cb(mount_syntax_v2, ¶m_ops_mount_syntax, &mount_support, 0444); +bool enable_unsafe_idmap = false; +module_param(enable_unsafe_idmap, bool, 0644); +MODULE_PARM_DESC(enable_unsafe_idmap, + "Allow to use idmapped mounts with MDS without CEPHFS_FEATURE_HAS_OWNER_UIDGID"); + module_init(init_ceph); module_exit(exit_ceph); From patchwork Mon Aug 7 13:26:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344234 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 AEDFAC04A6A for ; Mon, 7 Aug 2023 13:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234195AbjHGN3Z (ORCPT ); Mon, 7 Aug 2023 09:29:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234099AbjHGN3O (ORCPT ); Mon, 7 Aug 2023 09:29:14 -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 0BA952107 for ; Mon, 7 Aug 2023 06:28:52 -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 DBA0D44274 for ; Mon, 7 Aug 2023 13:28:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414893; bh=dSSVvNS5h70J5u6vsFuPYT4MXnye3oVzKXsF0V62fVM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P2/vAXc7Bbz09iex+UErlyuv34chXKMALZx/orp8v79P/HPubtjVSe5GPWc1Ifp1P Q/qpIz1YzN5gsKo4/1eNE1Y1SXX4+zkqkTuGg7spsh57F2fQnKxTwLw1NlFSpeNIxQ s2dNvtt3hg47YLBjrCKaxzvQpTOdiJCTCJrxW3FIMtOkg7rRxXQKIoAq1evhoin+Be dXaleWsyF2Mgk9UtVOOhnpjKzSCBOXmbkRSZmv+NMDYFyrs38D+DmDo3JdEylIvwsw Z2Vkcvy/4bhMrhp/ZgjVPnXvzhXUTZhI/SLdD9SAlALf3wPQW8lsR4gJZe2bqiEtf4 enZq1fvotTO0A== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-99cc32f2ec5so124061366b.1 for ; Mon, 07 Aug 2023 06:28:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414893; x=1692019693; 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=dSSVvNS5h70J5u6vsFuPYT4MXnye3oVzKXsF0V62fVM=; b=WPBMZkU1dAkopbboN4lDKBwuDMvEMhV709yJS2GjOCW6F6M1MdShpfenal0Xyj4K8I 0oHBmHj84dFXFLGrix9g7NPXFDiDkbA99yzJjAMxnTgI3BrmmiC/7jWpkpRcPCEo0SPq FaO3tgBGLfzxVZ9Bx0PTvUq9FzOCUpurbmCUo9IOHieWIz/wFyhBKdubeK7v4f6iXAkC GD89/epOawJCXDcEon5mUGE071/EH4xoaXMFj4ai9AKwoulaGAGhLgSEfS2ORUuHdoIq ZMYu+fdauV15ICXHmCoQ3TS9I/fq1GjkBoo5xmokC8lgqYtuSPBjJlQhvu8v1ejBYEq+ eDEQ== X-Gm-Message-State: AOJu0Yz/GL6o7fFvcmM80c2GNR1c10bcuwpd8nGZhjhEBOXkq2URo1hP SCeM1QCe2Ot9jn2HAodQHsIp744cCp5MrQoHFQPSqSsYOd4E0gEp49Uh8ZGKWV/WwGQsT2idn/V rf0kU4N2q5b1paD7dn9oiMOUMkoy6tS/1Wybwb1M= X-Received: by 2002:a17:906:259:b0:99c:3b4:940f with SMTP id 25-20020a170906025900b0099c03b4940fmr8960493ejl.27.1691414893696; Mon, 07 Aug 2023 06:28:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGa0CjsHfJWZ04OQaM2nEIQHZnEMwjGZHzg3KFBLXF85/4ug5/dORHqOGj+uj7M8E5GiyJxWQ== X-Received: by 2002:a17:906:259:b0:99c:3b4:940f with SMTP id 25-20020a170906025900b0099c03b4940fmr8960481ejl.27.1691414893493; Mon, 07 Aug 2023 06:28:13 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:13 -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 v10 05/12] ceph: pass an idmapping to mknod/symlink/mkdir Date: Mon, 7 Aug 2023 15:26:19 +0200 Message-Id: <20230807132626.182101-6-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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 mknod/symlink/mkdir iops to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. 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: - call mnt_idmap_get v7: - don't pass idmapping for ceph_rename (no need) v10: - do not set req->r_mnt_idmap for MKSNAP operation --- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index b752ed3ccdf0..d6db6d861cd9 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -952,6 +952,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 = mnt_idmap_get(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 | @@ -1067,6 +1068,7 @@ static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir, } set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_dentry = dget(dentry); req->r_num_caps = 2; req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | @@ -1146,6 +1148,8 @@ static int ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, req->r_parent = dir; ihold(dir); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); + if (op == CEPH_MDS_OP_MKDIR) + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_args.mkdir.mode = cpu_to_le32(mode); req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL; From patchwork Mon Aug 7 13:26:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344236 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 6093EC001DB for ; Mon, 7 Aug 2023 13:29:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233999AbjHGN3q (ORCPT ); Mon, 7 Aug 2023 09:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232110AbjHGN3S (ORCPT ); Mon, 7 Aug 2023 09:29:18 -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 371F41BCB for ; Mon, 7 Aug 2023 06:28:58 -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 85B6B4427C for ; Mon, 7 Aug 2023 13:28:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414897; bh=dbq6NgAMN4t7wxNwyddA+VrJjiC20GkONqywDZDeteI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cDMh1TFltob3E+cLFQxoYH8TQL5S6/9dVb0IAS+fnD5D34lIXUVa1uiSDz5+TJyys H//9qpZq6y5ar8+V9zixY5D+lCzYhcch0fn/j9c+8Es7QX7ZQxBhde2fVgXATrPE8p /pCe8I5YGLxYYeL1LZHsZYHvTON+DSg/b8Pw2FV+zTILaRGs/IBQek8cwNl8VzPkVw MpxIYeZh0bhdNsXiKDgXvn4UFDunU6eX33mwJuw2F4Dm1VDQKrkJYZlNWjkLn5aJok tsUcDDidw9p7NrPTgEXb6k9k5ntcUgFOmfB1w8eB3b2NPAGr1y916SHnHV891uOXzK Aglr6SMDxQ0Hw== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-99bd6ea0d9eso362681666b.3 for ; Mon, 07 Aug 2023 06:28:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414897; x=1692019697; 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=dbq6NgAMN4t7wxNwyddA+VrJjiC20GkONqywDZDeteI=; b=hO2fVMsiEwJPZr3Vm6p4SV7QUWpDJFRFOAZPJLVFUcca1DChPcj/H4CrNkgEeSi5tf afF2cHZt8CJi7NLqDCD3pMIRM6vKiBzpTfjjX6pXUz7pcUmZk7k/RbUr36h2YvhoWLXE w2I4ZizAs1L2LijOq4+Pn0Wxiit5Dpx3BFajUUXWUarcWtf4U0Tb1IQgAIMSTxenOUBW IiwD8IzwTQ6gtkr7LFi3JPGjKNSQxv+Gu44PMXViPIYAWITK46fHaoSoMLTgQt3WUp4F +Enc29TbBwF35863cJ71FymF5JCZaG9jtKObkyH0T5W46hWg5fZkPIrsqahUvZ6zoSNj RWeQ== X-Gm-Message-State: AOJu0YyUkf0zdbMBAhI3nYtkKSfxRzlbGHelRsBrYbBwSTP78OxafCiD PnNvh7pY2I4HLX2IeUjvGBX5pnnJ5LDrb0izmHXFRtROjhRI1HYdhtCBlOu8SJhICAr4qTXbD/W oVaW+So9hkwnhmtDJZ8A2vFfVxLC/p+iK6Q/OYdQ= X-Received: by 2002:a17:906:5dd9:b0:99c:d069:d1e with SMTP id p25-20020a1709065dd900b0099cd0690d1emr3469986ejv.46.1691414897151; Mon, 07 Aug 2023 06:28:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkQ8KMlwVzyxsmXgNgAf7VeSk8c2NyZW9xrTMgDHQCTpHcK/uSnnQ4DPTGpDy3R5g22kXPCQ== X-Received: by 2002:a17:906:5dd9:b0:99c:d069:d1e with SMTP id p25-20020a1709065dd900b0099cd0690d1emr3469974ejv.46.1691414896935; Mon, 07 Aug 2023 06:28:16 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:16 -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 v10 06/12] ceph: allow idmapped getattr inode op Date: Mon, 7 Aug 2023 15:26:20 +0200 Message-Id: <20230807132626.182101-7-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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: Xiubo Li 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 3ff4f57f223f..136b68ccdbef 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -3034,7 +3034,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 Mon Aug 7 13:26:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344237 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 F2050C001DB for ; Mon, 7 Aug 2023 13:30:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234031AbjHGNaF (ORCPT ); Mon, 7 Aug 2023 09:30:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234006AbjHGN3T (ORCPT ); Mon, 7 Aug 2023 09:29:19 -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 C4EBD2123 for ; Mon, 7 Aug 2023 06:28:59 -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 3D27844277 for ; Mon, 7 Aug 2023 13:28:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414901; bh=dyWOzKMsgYqMEu72C+uRJxx6NqzlAitmeRu8HoKY4M0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kM05WPvONwmOxJ76VhmPQscD4eahAPaI6K7gyMXLKVtk3+b8/ANE86DpouGTV9ZSY JSFuOWLIuQIzQFchmhf2noKOX30FcUPWf9vVkDjf8UOPLsQhdVldeB4R6phd1TTLEF RzD/y5OdLRdWVuselFcn2jkFGuQzTvtxd7XR9FlphNjfLXVu5wbaFWHmeV8w4eflp2 2wOL3b3s1rRdzGa3WefQxykRibLcfiltdaU9UA5vWvkED+ShBZQTfr5W6TLCK+4xbj PSk6JMdoOKpGLIgNJ2lbfw0/iTS9PAp+YIJqwW2cTeALMNxyE24BM3XFiLnFKA5mT9 f2vJvqOf+/05A== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-993c2d9e496so316018966b.0 for ; Mon, 07 Aug 2023 06:28:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414901; x=1692019701; 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=dyWOzKMsgYqMEu72C+uRJxx6NqzlAitmeRu8HoKY4M0=; b=CzJRTwWb/2DFLNrqxUVV3h73Uvb1GqcYhoDX39M573LawgrYGkZm8cMQ/bEyEHrjyk zG27y/8NLrsICf0o92k+fCAILpYk9s6bNsaE9NjLWuW7e0xzw5yE6KyV8/PGutZIAnK+ PmApxRogT6dYjVf7o9WpK6iF0OlZcvajNXsrQ2nOHdXmhvZHVcMS8QCTw3oAAyVDjpNA p/hgRbI5fqnIYHMufm1+jr9nse9W7+x9W1kUXESUq5fVLZOtMnkw8RAg54xUL8EWJwcZ 5dgNhsR0RsQtRaNJ+ndw7bi19O0ZDWbO05kMbCSrSY6Zs23BtOgHqCzgkO56Dyjx73dB spiQ== X-Gm-Message-State: AOJu0Yyu2XhngVgIanK0MuIGuN6D4PnOhdPIqSXfrd11KABeREw3hkQx Jxl9tfu/JCnJG8FC/3imbk0DWt3gFVrlwsgpO8OiEtcPGIN0TF18rS70V5eXnmhK6Pe14557nZO WK07XYs20jdp9gkIkjrxk8icHXHcwhJwpkhkRKpQ= X-Received: by 2002:a17:906:1011:b0:99c:3b4:940c with SMTP id 17-20020a170906101100b0099c03b4940cmr9039178ejm.7.1691414900866; Mon, 07 Aug 2023 06:28:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3ADA4o2cJQwyFlv49UMgDsjmvjuXfeU1vTiwFnYE1XpiRQKXsUX4t+Epk7AEPPGhbvKUbow== X-Received: by 2002:a17:906:1011:b0:99c:3b4:940c with SMTP id 17-20020a170906101100b0099c03b4940cmr9039165ejm.7.1691414900716; Mon, 07 Aug 2023 06:28:20 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:20 -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 v10 07/12] ceph: allow idmapped permission inode op Date: Mon, 7 Aug 2023 15:26:21 +0200 Message-Id: <20230807132626.182101-8-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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: Xiubo Li 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 136b68ccdbef..9b50861bd2b5 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2977,7 +2977,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 Mon Aug 7 13:26:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344238 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 59894C00528 for ; Mon, 7 Aug 2023 13:30:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234023AbjHGNaG (ORCPT ); Mon, 7 Aug 2023 09:30:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234021AbjHGN3U (ORCPT ); Mon, 7 Aug 2023 09:29:20 -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 C67182125 for ; Mon, 7 Aug 2023 06:28:59 -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 D324B4427D for ; Mon, 7 Aug 2023 13:28:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414906; bh=EnTEEZ7+oa3hM+NWnyW7RuhD3+Wjh3nw4+rmmgyNCZM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ovghgD12bm8Jm/QhqbujjFl6/X/qqYdXZX6HxCO57azpNFahRgYaRszemN5OdNQAN nsA0ii9zvDlVaQWVpITX7r13JGBBkg0gTgtxITxGi6A2eihxedWLUKGcoEFWtgCr/T 7gt+0bAg7C3w0kukiQz0ljbwjgGOnE5FzW+GqyaqNClR7HbAhRv3yIElyXOP6lgynN jOu8S9nIWL4GPYvIS1Bs+E9mCDY+a4geHGoP2a6UX5YyO+zEdsVr3jcHSy/jjnDfnU nrmrIhCmfn+M1WNPUVUkLd+KcyRxeJpCyqJY8GAGb9jb93Y4K0n95Ob9zCkwjUzZZx p37Wh5VHuuZbA== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-94a355cf318so362497566b.2 for ; Mon, 07 Aug 2023 06:28:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414905; x=1692019705; 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=EnTEEZ7+oa3hM+NWnyW7RuhD3+Wjh3nw4+rmmgyNCZM=; b=BgAq0Y/jKTA4/NUTlgl/+R5BIKl1Vm70Eu2uu11oUZwcu4Kx5d3weKBhAbdzrU8C9R duWVGviwbHfQ3hky6TaYSyhCj/ylnhEubhw7R8l26Bx8uuxKzkaXSI34v747+5qq+H6e 0zONnY7G7kP4JyeSuJB8YgxEwBdZZWweBIMUgb+XzND4kQN0yRix8mX5wVm00RCx02Hy qWs/CmBLukI5WBiBeddH0TBjBzz1tiofweWUbD++ZKiu7ENHWVg7Eogn0iJ05DlQQZ/L F0PFrru2dncEfaEZ+hiHXwk9wndg29erJPS4qsmoABlDh1PTThQbYwANEm6vSiEgKKcl sk+g== X-Gm-Message-State: AOJu0YyMyc0BW0Gz5fjAWW143xK8ac9RWoeHTkMSyaHdBZGiGLj1Khku kzPXx4jIxoh8j375hEu1RE6qFMCBLa0kmhWdzKLnpzliXH9hinECzYSJpy9ecLsPmP9+OJEykiY ApZrXED1+M9nExgF3aQigd3atIrwI1Xk4QyCo83Y= X-Received: by 2002:a17:906:d6:b0:99b:ed8f:551d with SMTP id 22-20020a17090600d600b0099bed8f551dmr8792969eji.55.1691414905241; Mon, 07 Aug 2023 06:28:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHPYr2Sn/4wtYZpvSbkMFiW8P3TR0v/BNNt8ZkylTWoSaA6YpZQj1j2zTP+kTyapQ44F3q4cQ== X-Received: by 2002:a17:906:d6:b0:99b:ed8f:551d with SMTP id 22-20020a17090600d600b0099bed8f551dmr8792958eji.55.1691414905079; Mon, 07 Aug 2023 06:28:25 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:24 -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 v10 08/12] ceph: pass idmap to __ceph_setattr Date: Mon, 7 Aug 2023 15:26:22 +0200 Message-Id: <20230807132626.182101-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Just pass down the mount's idmapping to __ceph_setattr, because we will need it later. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: Christian Brauner Cc: ceph-devel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn Acked-by: Christian Brauner --- fs/ceph/acl.c | 4 ++-- fs/ceph/crypto.c | 2 +- fs/ceph/inode.c | 5 +++-- fs/ceph/super.h | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 32b26deb1741..89280c168acb 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -142,7 +142,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, newattrs.ia_ctime = current_time(inode); newattrs.ia_mode = new_mode; newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; - ret = __ceph_setattr(inode, &newattrs, NULL); + ret = __ceph_setattr(idmap, inode, &newattrs, NULL); if (ret) goto out_free; } @@ -153,7 +153,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, newattrs.ia_ctime = old_ctime; newattrs.ia_mode = old_mode; newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; - __ceph_setattr(inode, &newattrs, NULL); + __ceph_setattr(idmap, inode, &newattrs, NULL); } goto out_free; } diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c index b9071bba3b08..8cf32e7f59bf 100644 --- a/fs/ceph/crypto.c +++ b/fs/ceph/crypto.c @@ -112,7 +112,7 @@ static int ceph_crypt_set_context(struct inode *inode, const void *ctx, size_t l cia.fscrypt_auth = cfa; - ret = __ceph_setattr(inode, &attr, &cia); + ret = __ceph_setattr(&nop_mnt_idmap, inode, &attr, &cia); if (ret == 0) inode_set_flags(inode, S_ENCRYPTED, S_ENCRYPTED); kfree(cia.fscrypt_auth); diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 9b50861bd2b5..6c4cc009d819 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2466,7 +2466,8 @@ static int fill_fscrypt_truncate(struct inode *inode, return ret; } -int __ceph_setattr(struct inode *inode, struct iattr *attr, struct ceph_iattr *cia) +int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, + struct iattr *attr, struct ceph_iattr *cia) { struct ceph_inode_info *ci = ceph_inode(inode); unsigned int ia_valid = attr->ia_valid; @@ -2818,7 +2819,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ceph_quota_is_max_bytes_exceeded(inode, attr->ia_size)) return -EDQUOT; - err = __ceph_setattr(inode, attr, NULL); + err = __ceph_setattr(idmap, inode, attr, NULL); if (err >= 0 && (attr->ia_valid & ATTR_MODE)) err = posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode); diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 4e78de1be23e..e729cde7b4a0 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1101,7 +1101,8 @@ struct ceph_iattr { struct ceph_fscrypt_auth *fscrypt_auth; }; -extern int __ceph_setattr(struct inode *inode, struct iattr *attr, struct ceph_iattr *cia); +extern int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, + struct iattr *attr, struct ceph_iattr *cia); extern int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr); extern int ceph_getattr(struct mnt_idmap *idmap, From patchwork Mon Aug 7 13:26:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344235 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 3D6F5C41513 for ; Mon, 7 Aug 2023 13:29:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234134AbjHGN3l (ORCPT ); Mon, 7 Aug 2023 09:29:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233962AbjHGN3P (ORCPT ); Mon, 7 Aug 2023 09:29:15 -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 9CEC02112 for ; Mon, 7 Aug 2023 06:28:53 -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-1.canonical.com (Postfix) with ESMTPS id A9AE9417C0 for ; Mon, 7 Aug 2023 13:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414909; bh=CQAHRH/ms/cFOl3S4jtiakCJJYzaMB08Yq0KPV8/UVY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=wQ1hU/ppKY7wcxL7+1DWkdjyQPUulMHa/ItrbOMcJBRnYdtkPwFl+O/ByVMPamc2B d6++rk0yp5CQkMYdqRc5cxFYJNUsy56OQl3ZXZnu4pfoTCk43WD9po1NDCcVgwlW0o IyR4A08xXl4uP7kmA/anf9HoLbRVMVZhdYLx72CbWt4et1XiENgEN/3zZQ1BJzowa1 KsSdA0hkDDBsyN5apkYGYCKhYVtkmCJmppFRq6g+hzmI7uFJnMvBLLW6se8OwOYfLz r3lHsNgO85FmVPW0vFvyR6TbHSPqMmwLMJKpWL+k7U7B23Bxr27g3RRRHYold5gZUR +jAmueKqVPYqA== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-94a348facbbso344545566b.1 for ; Mon, 07 Aug 2023 06:28:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414909; x=1692019709; 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=CQAHRH/ms/cFOl3S4jtiakCJJYzaMB08Yq0KPV8/UVY=; b=LHecoAaRQcbcztw6YhK/05fCsU0YC5XfFRWJm1sU8iQPtkPyqrQf7jIRzx3VspVUaF 24XCH+6FQvoEOI7cr1wvLAZDilCJaj/uc9KrrmKGrRmB2lVAMVJxtB69kyRTJdfQ8YZI XXq3iqU5KER70Te3b7B9m1r1Wf1zVkQErO25LMR2X7HDXKC9Lk+La0k6YP9UiZ5LMGov p/Nk8Gy7PeUFC54Vb4xwW8PMWu9Rwow3Ow54lCg0sLahEdDRpPa9YJ9L926JQ9g8Ji5r rcM9+zKR+FpgnnOJGWUtIgU/Wa8tEJirdrZkafWVRbvjhvukAhELBkfs54t9hs6UXucY Blsg== X-Gm-Message-State: AOJu0YyIWBMBQAXHJ0PVqFo0rtDUvHAAqZ3pRpllyA9CoegVUkE22POx lyD54dQgXpPa2lRpm7VhPLGX71CFtRqq/cvK1DgcuRGHmbAvm8tQ9k14Yz0GZnmx/lRd1C9icKU VRNiSnR3M+dQ5NOZa//9B0x0yh2qdCNZxSKwpVJg= X-Received: by 2002:a17:906:41:b0:99c:47a:8bcd with SMTP id 1-20020a170906004100b0099c047a8bcdmr9099854ejg.67.1691414909457; Mon, 07 Aug 2023 06:28:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgxLGvA+W26confnfTAXig7L7dd3JYPpVQO+961emsoepRkzqFS8FTAnx3jrfgTDKBFgX4Uw== X-Received: by 2002:a17:906:41:b0:99c:47a:8bcd with SMTP id 1-20020a170906004100b0099c047a8bcdmr9099847ejg.67.1691414909294; Mon, 07 Aug 2023 06:28:29 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:29 -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 v10 09/12] ceph: allow idmapped setattr inode op Date: Mon, 7 Aug 2023 15:26:23 +0200 Message-Id: <20230807132626.182101-10-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner [ adapted to b27c82e12965 ("attr: port attribute changes to new types") ] Signed-off-by: Alexander Mikhalitsyn --- v4: - introduced fsuid/fsgid local variables v3: - reworked as Christian suggested here: https://lore.kernel.org/lkml/20230602-vorzeichen-praktikum-f17931692301@brauner/ --- fs/ceph/inode.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 6c4cc009d819..0a8cc0327f85 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2553,33 +2553,37 @@ int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, #endif /* CONFIG_FS_ENCRYPTION */ if (ia_valid & ATTR_UID) { + kuid_t fsuid = from_vfsuid(idmap, i_user_ns(inode), attr->ia_vfsuid); + doutc(cl, "%p %llx.%llx uid %d -> %d\n", inode, ceph_vinop(inode), from_kuid(&init_user_ns, inode->i_uid), from_kuid(&init_user_ns, attr->ia_uid)); if (issued & CEPH_CAP_AUTH_EXCL) { - inode->i_uid = attr->ia_uid; + inode->i_uid = fsuid; dirtied |= CEPH_CAP_AUTH_EXCL; } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 || - !uid_eq(attr->ia_uid, inode->i_uid)) { + !uid_eq(fsuid, inode->i_uid)) { req->r_args.setattr.uid = cpu_to_le32( - from_kuid(&init_user_ns, attr->ia_uid)); + from_kuid(&init_user_ns, fsuid)); mask |= CEPH_SETATTR_UID; release |= CEPH_CAP_AUTH_SHARED; } } if (ia_valid & ATTR_GID) { + kgid_t fsgid = from_vfsgid(idmap, i_user_ns(inode), attr->ia_vfsgid); + doutc(cl, "%p %llx.%llx gid %d -> %d\n", inode, ceph_vinop(inode), from_kgid(&init_user_ns, inode->i_gid), from_kgid(&init_user_ns, attr->ia_gid)); if (issued & CEPH_CAP_AUTH_EXCL) { - inode->i_gid = attr->ia_gid; + inode->i_gid = fsgid; dirtied |= CEPH_CAP_AUTH_EXCL; } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 || - !gid_eq(attr->ia_gid, inode->i_gid)) { + !gid_eq(fsgid, inode->i_gid)) { req->r_args.setattr.gid = cpu_to_le32( - from_kgid(&init_user_ns, attr->ia_gid)); + from_kgid(&init_user_ns, fsgid)); mask |= CEPH_SETATTR_GID; release |= CEPH_CAP_AUTH_SHARED; } @@ -2807,7 +2811,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, if (err) return err; - err = setattr_prepare(&nop_mnt_idmap, dentry, attr); + err = setattr_prepare(idmap, dentry, attr); if (err != 0) return err; @@ -2822,7 +2826,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, err = __ceph_setattr(idmap, inode, attr, NULL); 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 Mon Aug 7 13:26:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344240 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 026F0C41513 for ; Mon, 7 Aug 2023 13:30:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234198AbjHGNax (ORCPT ); Mon, 7 Aug 2023 09:30:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234106AbjHGNal (ORCPT ); Mon, 7 Aug 2023 09:30:41 -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 2BDBB199B for ; Mon, 7 Aug 2023 06:29:46 -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 BBF2B44280 for ; Mon, 7 Aug 2023 13:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414913; bh=ARhwDsiPa3Ci/G2xteJutduXCGuj42UUR3o8sfJhjpo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tASI92dghztMQQ32j5Aclvvn1dHF17vXAKXK0AYsxbS+rPMsmMjB7wllx9U4vA2LE 0adXRhYHOADfpGCofTO5CbHdQ8XgrnW3tKftCYM0e6nn4PKNi6sfmdVUZMKIeno9Mi xbQvbbBAarTVnJYCwSj84ejTrRIZWgLJBrvSHTXD1p/ZlmXniI7UkN9aISfRJkl/iA Mt7BNqrvpes8I+d/tn7Fr3RwJydHuy2VxfBcaMglBrnJt+dqaabPKoWNHAs7Md5uAm 3zxktNfhfX9T3P/8fiSqoK13xsAIiMGq1QW1n/8sWAl4gNvDLEWufpn3Qe/Czo+vRg OWOCltjln2USA== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-99beea69484so344973266b.0 for ; Mon, 07 Aug 2023 06:28:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414913; x=1692019713; 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=ARhwDsiPa3Ci/G2xteJutduXCGuj42UUR3o8sfJhjpo=; b=Un8FUudZBdKAOn25fP3Fnl0DghTqidSQS82eQZ5Bx+HA9hgIIpEekaDNARHmULPjKa kfR5929zFU421BT1PgYC+MART6WhDBcsUFKwa72VgTXHLDOhZkppijQuaLOn7rA4CwXT +bXM5KvPPc/QzPZfmiLs3swHxczWjoqsSPGsjN1+AgG3YSMoLvAccbUknfTIrC33EAxq R2x6Z/KQwY4up0m1TSQPEE+H/Hc2/xfQiEW2A8CYJ76NbzWbCKfIX+cwtnijGlBkymAG IxvGPf3r/vYrOIuLSy8Xu4vq5axsamS0rWljnojZ/AL9ODiQYtbBJG49Elco3ZcLcwHY YJWQ== X-Gm-Message-State: AOJu0YxcHgt2k38FlV1BhyGCnPhCU1+MJpqNHYpDBNtA0JFAak8dyf+k Ai3r8qJIrq/A//FB80FmsHlaK27A0m4K3YmlfmJvoB434onNLFgP0MV6gIywUlc2tIMPJQNKyea L8kVvF3nejKyCKPm/QZuQ89xZnOl2lLnlXfxCsyE= X-Received: by 2002:a17:906:10cc:b0:98e:2097:f23e with SMTP id v12-20020a17090610cc00b0098e2097f23emr7419784ejv.77.1691414913482; Mon, 07 Aug 2023 06:28:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGltB/ZZoCQVwgCS4UTRIz0u73a/bCvTNvfAJknZZvuyuqC87rnvtadbkCLyDzGWG1RAK7amQ== X-Received: by 2002:a17:906:10cc:b0:98e:2097:f23e with SMTP id v12-20020a17090610cc00b0098e2097f23emr7419770ejv.77.1691414913267; Mon, 07 Aug 2023 06:28:33 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:33 -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 v10 10/12] ceph/acl: allow idmapped set_acl inode op Date: Mon, 7 Aug 2023 15:26:24 +0200 Message-Id: <20230807132626.182101-11-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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: Xiubo Li 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 89280c168acb..ffc6a1c02388 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -107,7 +107,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 Mon Aug 7 13:26:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344239 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 3D6FDC001DB for ; Mon, 7 Aug 2023 13:30:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233534AbjHGNas (ORCPT ); Mon, 7 Aug 2023 09:30:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234167AbjHGNag (ORCPT ); Mon, 7 Aug 2023 09:30:36 -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 A9AD52723 for ; Mon, 7 Aug 2023 06:29:33 -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-1.canonical.com (Postfix) with ESMTPS id CA3B3417C8 for ; Mon, 7 Aug 2023 13:28:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414920; bh=xpiLhv9pMb/Lv4/5VSZ89gvBpTNtUdWbUPiCds9RH7k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iJdIbKPg+O2J7DvQ41pX+v1KpvDdLawPhVQ3otT2ublXvA5eTTXhRyE1BeaHxsmIY q3YlYlQEHWELsLdU61BRBC2lf7qf/1ZYsWhjN4rYx8Qt+1TfPSp3FxxhFY+j3k4um+ PNWXITW3Wi7bWsdlGoGBPYXuZdsMli9RGG8zpjxu14RL2sd5n5h/4Lnyb2+unv7hIj 58hzlz7DCZwqmtjETt1FvLJAZxH65cGcMJlumZ/IGaLJ3YWMTep5FQbG4veodJ3iH3 ZlZJvytKUQH5ybBXLeeFyLepg1kF4D6GPbGApSNhMEhqY+YP7tAKYzGy6biswxqWTM HqDY7Xn53220Q== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-997c891a88dso330032466b.3 for ; Mon, 07 Aug 2023 06:28:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414917; x=1692019717; 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=xpiLhv9pMb/Lv4/5VSZ89gvBpTNtUdWbUPiCds9RH7k=; b=atKIqErf2ASId64F/11tStz6KEGFQgeCusDKyiLhLtp2VQCPKnFuroIsvFZnR5q8H4 ayg9CtNfVwcDMuKRZv1ZddvOGsWZvHwF3Y+5IUgGNuFi8UTQSUujI3q/lYtxppxSgZ0t A5cdRx+UrnxiBgNMZakDQwzR/FiFBOLbSq1TJXLd+gFvZ7/yc2LwiTJ6xL6jA39/2bA3 Dzb3j3CnQVHzv1YDHLQkXUYoFl4TwfgzEk80KlcBbAYl+oLMZGN23zy4Ie5QMs7aLeTc EVPJZqUc3YfPV7koy9Wtts8O2jYDhWBH60V8Yu4BL6ezvjaRS1zp5+dpAZDezCwj3gMY 8ciQ== X-Gm-Message-State: AOJu0YxZYjpCz4tUSRBsvAtZ4Ku1sWxDtbUa9Jm/AR2S534jwwT8gWiA wSztjUvVQrd3+1a0neAaQhYKYBTrH1tsIP0S9dqlEEg6aPv4pTtMUJopwlJ7dWfbZYY6vr6pqYD nQHcZsbai5Nn0kri2M0VBIUsu7MCYa15kRU/E6Dz2VvaMcYo= X-Received: by 2002:a17:907:2c5b:b0:99b:d1d8:d747 with SMTP id hf27-20020a1709072c5b00b0099bd1d8d747mr9319740ejc.27.1691414917347; Mon, 07 Aug 2023 06:28:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtpifuTuuc4crxqNMY+VAWpJwdyowZ7ngPgg9io1b455puHMLlf5TLmqcm6c+4ofOhD5eVqA== X-Received: by 2002:a17:907:2c5b:b0:99b:d1d8:d747 with SMTP id hf27-20020a1709072c5b00b0099bd1d8d747mr9319727ejc.27.1691414917152; Mon, 07 Aug 2023 06:28:37 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:36 -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 v10 11/12] ceph/file: allow idmapped atomic_open inode op Date: Mon, 7 Aug 2023 15:26:25 +0200 Message-Id: <20230807132626.182101-12-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner [ adapted to 5fadbd9929 ("ceph: rely on vfs for setgid stripping") ] Signed-off-by: Alexander Mikhalitsyn --- v10: - set req->r_mnt_idmap only for CEPH_MDS_OP_CREATE as userspace client does v4: - call mnt_idmap_get --- fs/ceph/file.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 7470daafe595..4a12174b7bc0 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -668,7 +668,9 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode, 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)); @@ -676,7 +678,9 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode, 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); @@ -743,6 +747,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode, int ceph_atomic_open(struct inode *dir, struct dentry *dentry, struct file *file, unsigned flags, umode_t mode) { + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dir->i_sb); struct ceph_client *cl = fsc->client; struct ceph_mds_client *mdsc = fsc->mdsc; @@ -802,6 +807,8 @@ 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; + if (req->r_op == CEPH_MDS_OP_CREATE) + req->r_mnt_idmap = mnt_idmap_get(idmap); ihold(dir); if (IS_ENCRYPTED(dir)) { set_bit(CEPH_MDS_R_FSCRYPT_FILE, &req->r_req_flags); From patchwork Mon Aug 7 13:26:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13344241 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 A57DEC04A94 for ; Mon, 7 Aug 2023 13:31:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234284AbjHGNa7 (ORCPT ); Mon, 7 Aug 2023 09:30:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234239AbjHGNap (ORCPT ); Mon, 7 Aug 2023 09:30:45 -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 B67E72D69 for ; Mon, 7 Aug 2023 06:29:52 -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 380A744282 for ; Mon, 7 Aug 2023 13:28:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691414921; bh=4z/daiO88HhZeOEnY3F9QYhLlQO1p3UrY3NiyEq1U7U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kLWym1tpcF36phHFDefL9y77tzGIPb2o+gsRAA6ZblR3Vl5dh1tvntKF1GwfXgw9H ve5jTFhIg8zYF7qzMGZs0tfSe3lfZIt4HxLv/cZ8Vw2P1KIRgz5u51YUXrmWuzhu1h tnrmMBuCA4hEZAWO+un3Cv69xjl/XqhX/irAvo5BemvCjzCnReZ0VvHJ53rhWsh+dK 0j4WTG4xsi3HNXJKhWpg3AMaia56TGe8csPjUEYoxqK/7YS083SUghGIg3LUOqkYsO uUcYPKiTC761JloRpw9ZVFwUdjXwJpt8Nrno+sAHOmv2M586WEvDjjYDjaieEDtWYF hJRD4mtqj+8jg== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-99bdee94b84so637561666b.0 for ; Mon, 07 Aug 2023 06:28:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691414921; x=1692019721; 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=4z/daiO88HhZeOEnY3F9QYhLlQO1p3UrY3NiyEq1U7U=; b=CLtu/ljEvBecuEc213goclKYEnG+SOC+VrW+5OiXJNQYxey7L07kQBDKZcDGqELPoa 9wI06b8Eq8j4DgQtnf5Xl2KXvnU3x2zyhPkkMljk4Zs7eYVAdcLED4hhTPuvTwqLwWMR OCF+ZZm42lVUWXDyWGOTbLZaA/kWIUYfk3afMsIn7o+lf8n5fXy4sllS8kDSg5jdgAFx wyUjaoHZwqfJobY59t9D5raWp7Hj5ED7kv44LtpepudLVyxbMQBgv+Xzh+U6xpt0yBmS J58ffjKOjBHYlU+C4FZmTIqdsAg94WMMxeehgnKsj4RG+CozkMOSFOUO7jEBfjgU8+2f sPAA== X-Gm-Message-State: AOJu0Ywv9QyE1u8UQJC0E38IjARqNR8xr/5KhoVZvr++qj8elFEzWtSa JrUiYOYXAn6fEq7q7JrIKsu3Fpw+MT2AfnK/uRCYucDq7LzbxWdGPyHVBhKF5W9z4WxeAmn0KFR 7r2SgKclYFH4ddWQ2j2Q5bPPXwclOl1Yax5IIyGg= X-Received: by 2002:a17:906:8a44:b0:99b:cdfd:fb44 with SMTP id gx4-20020a1709068a4400b0099bcdfdfb44mr7381516ejc.9.1691414920939; Mon, 07 Aug 2023 06:28:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwy+L+nCPnNmq6S3V19tL64bywfoR6mM7JJPFsVDhKATekruSoiqA62F3J2sZzqV/zbNE/KQ== X-Received: by 2002:a17:906:8a44:b0:99b:cdfd:fb44 with SMTP id gx4-20020a1709068a4400b0099bcdfdfb44mr7381510ejc.9.1691414920783; Mon, 07 Aug 2023 06:28:40 -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 lg12-20020a170906f88c00b00992ca779f42sm5175257ejb.97.2023.08.07.06.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 06:28:40 -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 v10 12/12] ceph: allow idmapped mounts Date: Mon, 7 Aug 2023 15:26:26 +0200 Message-Id: <20230807132626.182101-13-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230807132626.182101-1-aleksandr.mikhalitsyn@canonical.com> References: <20230807132626.182101-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: Xiubo Li 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 18bfdfd48cef..ad6d40309ebe 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1581,7 +1581,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");