From patchwork Thu Aug 3 13:59:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340090 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 04CA2C04A6A for ; Thu, 3 Aug 2023 14:00:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236479AbjHCOAt (ORCPT ); Thu, 3 Aug 2023 10:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234004AbjHCOAl (ORCPT ); Thu, 3 Aug 2023 10:00: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 106652109 for ; Thu, 3 Aug 2023 07:00:16 -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 C231742420 for ; Thu, 3 Aug 2023 14:00:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071214; bh=GFNwWvhavDkNrI4eqwez7OWrv+w+Iw1WNhnwQW/Fw7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kJ7jaag9qoW/v/GDVLSWB2NvvzbRwSLLIsn9wjPbzrXIqsJS5Ta/yDMbgq8VKlstQ 9AVfRVwks7t05MaL2sbCY60BRs5yQ7mArPVKuDz7BYwROEUv0RlxwxyW6vu0bO84vT I85mTa4pIoy3D/kidbBiVGNdpWPatZuYgLXLMS24SOZb3xfIsJ5tOWigJNi22s/axM r9+rxf30Ir3D7xEdghGMPf+E1FHItcD0JbozAR5RouN/xMUYIm/Cmf6Ym1NZHSVmmu GKmUYmElAZIrkSfk1gkd9KitGiIfv8OAYcctbqlFy2frxzrOLrNtGrU7Dq0bcdOrvW jxBRQFkQ+bFsw== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-521da4c99d4so698858a12.1 for ; Thu, 03 Aug 2023 07:00:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071212; x=1691676012; 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=lYDHcp0BrePMDRiREY/VAEV7wnWMRzeLWOs7b2eGYZWTmD5/3WQBFEed4K2IashH5M 4UODuiWryP3fNAr6ABiWLl0wR2nGQFf6CyBSPhpqpfFyHp4yQxcoRAYzrd1IeTDLvqPU nGJMMpKwFJy2KgwUV0IxWClSXPyuIMbjOfz3Pgaotttx/Qr36w8SxCd13JAhr7A3uDg0 yTMSvXGqhqiKwLTntfSAODopgEgeTHMxjvWvAwvn2q9+PBtLN62OeekOKcjOOz7uqQEl fn+oRBOA5us5XRZkn9bmfMs/LmrWv409E8/65SopBt6XFnl089tZ3yqJjHY1mnzpuioD DoNQ== X-Gm-Message-State: ABy/qLZhbTWaW3LocOXqUnnmSXSnFiGd8axQ1gI+4CDbcqJLqeLwb/yr 4UvfH0LfnKRe/goxN3aszjd32+9YVnKCjeqv/Lq9MUKlQzTWJwtwjtzY0BygcpiKO0naiShMPUm 9BuHtRj2NhvQQn34uvb0rXZaxud8mWftbmN8hKvgw5klIQnHt/AU= X-Received: by 2002:aa7:c49a:0:b0:522:3855:7ec5 with SMTP id m26-20020aa7c49a000000b0052238557ec5mr8584103edq.10.1691071212141; Thu, 03 Aug 2023 07:00:12 -0700 (PDT) X-Google-Smtp-Source: APBJJlEfIOUItlo0hjwrY4HJh2AtdBwv8To0WNWjW3o7KEaguO5IXHRwEyXe3XNgge+1GeScqXxVOA== X-Received: by 2002:aa7:c49a:0:b0:522:3855:7ec5 with SMTP id m26-20020aa7c49a000000b0052238557ec5mr8584083edq.10.1691071211914; Thu, 03 Aug 2023 07:00:11 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:11 -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 v8 01/12] fs: export mnt_idmap_get/mnt_idmap_put Date: Thu, 3 Aug 2023 15:59:44 +0200 Message-Id: <20230803135955.230449-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 Thu Aug 3 13:59:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340091 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 947E9C04A6A for ; Thu, 3 Aug 2023 14:01:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236524AbjHCOA7 (ORCPT ); Thu, 3 Aug 2023 10:00:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235693AbjHCOAm (ORCPT ); Thu, 3 Aug 2023 10:00:42 -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 01C212129 for ; Thu, 3 Aug 2023 07:00:17 -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 846EA42409 for ; Thu, 3 Aug 2023 14:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071215; bh=StxqveXF5moq9iJU4D0IjENKfN6jaIfCw60woBc2a1E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bM7T98vZY4tTrHSYUs4vXVdjUO+ibr4C+W92R3e1/wfFq54m7eNQZxsdB8GZvRIIC hyo/rTHKjBf3EZAnHxDhCBuVH0BOmRGlrbpm1UxHmAiX3KRBCggY5YmxL3i6D6glzt 69YSO4bNmttCbeNSdFmc95ruCHcPHtCqheyBanXPF7vjmZ6m1l2moU1iRJWh4KBwP8 FFYpXJNIxCUaxbAt172Cgr2zE7iUgzeELn18/CUoWvqj5dFQ50GzpnuwjDhFV3rXmM ZLt3gLEDZQgYKNCL+hOE7qvOdAMpzcTdBSL2/+xkT/Bs7pPxPrBS71O77c81R5LlEL kBI5JHiRIehhw== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-52256d84ab1so693287a12.3 for ; Thu, 03 Aug 2023 07:00:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071215; x=1691676015; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=StxqveXF5moq9iJU4D0IjENKfN6jaIfCw60woBc2a1E=; b=QLMEEj1WPkid2mU6E+HfS05CURzZg1KcI/361YCFfflTRZxPGzeEZ4pBkSVEUElNI2 H5G59Dd0vZE8L51D/y+yDqulNYCUibf/0q8RNTARtexblNYdWyWlBEHD0GBtGkQXzfze BaPvzNIRGYRaMXFElpQpiQnhr/vfvb0yMA6B0INMJqOB6XnqnDqGVu9ZxLOZ0/Bm1Nsd r2EiLLdJLQwcF80t1dJCeSa/esZBUmMDTta+svv4Znld6D8xPfgLndad5cbLR4+iw7BU tZzSnlsEfgbZk90HvOHse0OsUwv8r1QXxyRnH8BMDFrd8GTl1hsCdHA4+B6DR7EO0cBJ duyA== X-Gm-Message-State: ABy/qLZRvz+the2NgZZv0m9reBbsBK4GAQXrTT/cEmoIqFsNnx0k+Mv4 nV0sRBdlJ5ZNOtp76OUWDFTA7rlo2kRcBiuUhfOPRWVn921Gca/vhG1Y8+4bN2B52mu6YBJ/2Q2 RLn/jIQG3T6iWH4hOdem8AWLbv/N/O+StIbaMnIQQTZgJKVaRssU= X-Received: by 2002:aa7:de14:0:b0:519:6a6a:7659 with SMTP id h20-20020aa7de14000000b005196a6a7659mr8931904edv.18.1691071214979; Thu, 03 Aug 2023 07:00:14 -0700 (PDT) X-Google-Smtp-Source: APBJJlG5paflJLz4JBRbHPhL+2+ULYp98vUnpGsRBpJboWm8CHBV4DSIx5ONfbc9tYUeWfPNtNGOIA== X-Received: by 2002:aa7:de14:0:b0:519:6a6a:7659 with SMTP id h20-20020aa7de14000000b005196a6a7659mr8931880edv.18.1691071214671; Thu, 03 Aug 2023 07:00:14 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:14 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 02/12] ceph: stash idmapping in mdsc request Date: Thu, 3 Aug 2023 15:59:45 +0200 Message-Id: <20230803135955.230449-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 Thu Aug 3 13:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340098 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 AFA3DC04A6A for ; Thu, 3 Aug 2023 14:01:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236570AbjHCOBn (ORCPT ); Thu, 3 Aug 2023 10:01:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236552AbjHCOBU (ORCPT ); Thu, 3 Aug 2023 10:01: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 300E419A4 for ; Thu, 3 Aug 2023 07:00:42 -0700 (PDT) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.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 DD8D342478 for ; Thu, 3 Aug 2023 14:00:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071218; bh=SRA2CxbC6ceQPxXoZHupL9znEMzT1kYcPE4TFQwQ4sw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LgWNtHaWnBZZ3vI1FqFYr1XdMz9ELdXGNsKXKTMUbVUqTQp8U9VgkmLJl79nut1f5 wyApUmZeb8jxLkTGHa69bQJOlZtqkVHi+r8NZSgQROXPV1HhUdl/xvVZKVOmJJR0YI zJvj+nC7/5+O7SPd8AaWUQ80u11qap/ilbtm1gbIt/hqLjlNGbKhFEeuZ0mNiv2DmR OT77JqC/APlGsjyymRhJCnFE/2bx6b2/Njcz6/Byv9bfBaWU0d3B7e6mt2qHLCnwU2 4uaogCxjb6Q0ZoccE8udKEvF+GJGGWic1OrdQTUiZNckeJtQQ9IH5RpeG+LM0Y7P0j LeMvCK8sRGo8Q== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-522e6bcde75so678820a12.2 for ; Thu, 03 Aug 2023 07:00:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071218; x=1691676018; 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=SRA2CxbC6ceQPxXoZHupL9znEMzT1kYcPE4TFQwQ4sw=; b=L2o61lli2HbsroDSonVOGsXVPofdqGgcA5IF/iseQE7qQG2y+iQxQolU7WlrqEXr59 yjdPJTN9DPoA7zFlvelT8RoXUhLevKW9LRSOdyayG8GwtHoOm/iPMoIh4Zngiwxk1q+o deeQyTFMpnZNX+Vv5OiIZ4FfV74pVGdRzFaQmvNH5R3UTA6UkuqRfglkXrSxFhYsUVIN XhQbJwXid+4kkrKqG1GsHkhi6cTALw2ifXoc6VFOqkyFTS40sjwAoskixnEO5AdFzPHp NzcMb5DX5SU810byS8k7vlnawaK6KrrlgzPz9O7qNG09iYI7moV9M3iDL/OuPuqTM3DA kyRw== X-Gm-Message-State: ABy/qLb/PidF2XxLo6PFQAGbwDt8m+1ZZrNC5X2YeNhq+LikXADYI2wN ZLEvOdi5dHs2rrB1lhV/z+ShejO2CJoN8Gt3MWyKXLtQ2Wsfkh+RtwPQrOYFu2MjVslmrx6ZThR pUxT7UskL01yllMIWqUC4hD4gftq45yZ7Lb8lqOO2icY= X-Received: by 2002:aa7:ca50:0:b0:522:39b7:da3a with SMTP id j16-20020aa7ca50000000b0052239b7da3amr8004200edt.31.1691071218112; Thu, 03 Aug 2023 07:00:18 -0700 (PDT) X-Google-Smtp-Source: APBJJlFZDwcdmjl6HdMcQMLVnKLyAyrPvUFUxG6kRGiaI4UWCyJqXsMhNiMTsHJmAnGr/1ax69BTEQ== X-Received: by 2002:aa7:ca50:0:b0:522:39b7:da3a with SMTP id j16-20020aa7ca50000000b0052239b7da3amr8004184edt.31.1691071217918; Thu, 03 Aug 2023 07:00:17 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:17 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 03/12] ceph: handle idmapped mounts in create_request_message() Date: Thu, 3 Aug 2023 15:59:46 +0200 Message-Id: <20230803135955.230449-4-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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/ https://github.com/ceph/ceph/pull/52575 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 --- 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 --- fs/ceph/mds_client.c | 46 +++++++++++++++++++++++++++++++++--- fs/ceph/mds_client.h | 5 +++- include/linux/ceph/ceph_fs.h | 4 +++- 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 8829f55103da..7d3106d3b726 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,16 @@ 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)) { + 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 +3059,33 @@ 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); + + 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)); 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..6eb83a51341c 100644 --- a/include/linux/ceph/ceph_fs.h +++ b/include/linux/ceph/ceph_fs.h @@ -499,7 +499,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 +530,8 @@ struct ceph_mds_request_head { __le32 ext_num_retry; /* new count retry attempts */ __le32 ext_num_fwd; /* new count fwd attempts */ + + __le32 owner_uid, owner_gid; /* used for OPs which create inodes */ } __attribute__ ((packed)); /* cap/lease release record */ From patchwork Thu Aug 3 13:59:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340092 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 72984C04A6A for ; Thu, 3 Aug 2023 14:01:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236550AbjHCOBI (ORCPT ); Thu, 3 Aug 2023 10:01:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236373AbjHCOAp (ORCPT ); Thu, 3 Aug 2023 10:00:45 -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 2A52B2137 for ; Thu, 3 Aug 2023 07:00:25 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.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 CAE923F36D for ; Thu, 3 Aug 2023 14:00:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071221; bh=9W3amFuCFaMdLEZWgVp07pDZ7km3dCVDUs8gQZd55IA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ZfLQ7d/coFIGTAiabuzKvyh3jTxGGdSP6hTasz+TsZZyZzVB81Os76ZVo+5a5/fMr hPyvjFYHBC85tbd6bE0EnniQL/x89N/gQS7Iraayrp4V+PVE/kAt3REiA3gBvV/jO7 0vVxvIK1nV/3fP30/m4btNFvH/CeFtfXb76LVeclv8IP1ADgbry+Lt4PXXZ5UE1E9l 5objCIIQeiuq1yWrKmNO3HnpOP3CJQfezFh3WIoUBebnCx0jDaIiT27JagFAjNivHs BBdtCEc70vBWU9kz873R2lWp8pfYWriYgFnezd1xdRt0S3X2qDrxTCl5NR7gxOo1sM NNbu+kDHs9OaA== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-521a38098faso678346a12.2 for ; Thu, 03 Aug 2023 07:00:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071220; x=1691676020; 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=9W3amFuCFaMdLEZWgVp07pDZ7km3dCVDUs8gQZd55IA=; b=cBOwf4Awu1DuMoXxOes4PT7vz2ELhSVT3vt29Hb3YXLTRVe2bI/kJKuIklqyxgJZVR jNGzKbHIhw8B6cLA5BYc/eJbnY7IYD5FUCbDlAd+QBto1nAh57G8ygUr31+SxYN6dt7q 4RXoCtw7G+ItjJj+YOt5MMcSvv+T0TS+G7guk+RWIZv9h6iHvAq/zxojbKIw1mIa8a28 Uz8upWQ7Mw+vY9N4lVb7Uw8qw4aDSExW2MbAeSt8ZTe3pZ9hmpGmlL4zJMaf6RyrQcBL wrtDHycsP3Ev+9xFt+ITZzC2jqylz31hB8yH236fdota35OWGXR9gsnj8hgfhSXudTFC XCpg== X-Gm-Message-State: ABy/qLYPDbLIrRDR9lbnH+noDZ8g9uBE7t2mynIB/64zAnHZIAyYUtjT Brq3/lEe9yWTBr7fovnTU2o3/pnPLPjOobi6vK1IR/2ll+xoZf0YcFvvFIV2xUIvYpGTyevOWoF 6X7LAqV8i9PmfNPz6nIjtB0D5m0Q50ECgKzeYFpI1efc= X-Received: by 2002:a50:fa8d:0:b0:522:38cb:d8cb with SMTP id w13-20020a50fa8d000000b0052238cbd8cbmr6675512edr.20.1691071220748; Thu, 03 Aug 2023 07:00:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlFSUBGl00xYVgZu1n5QXjWGAchYdp2zZyXd+HoKtwgE5xEvzgdLvZUVhlHU8FZGINndDOCSng== X-Received: by 2002:a50:fa8d:0:b0:522:38cb:d8cb with SMTP id w13-20020a50fa8d000000b0052238cbd8cbmr6675499edr.20.1691071220564; Thu, 03 Aug 2023 07:00: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 bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00: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 v8 04/12] ceph: add enable_unsafe_idmap module parameter Date: Thu, 3 Aug 2023 15:59:47 +0200 Message-Id: <20230803135955.230449-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 --- 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 7d3106d3b726..d8097e84a5ee 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, @@ -3044,12 +3046,24 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, if ((req->r_mnt_idmap != &nop_mnt_idmap) && !test_bit(CEPHFS_FEATURE_HAS_OWNER_UIDGID, &session->s_features)) { - 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"); + + 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; + ret = -EIO; + goto out_err; + } } /* @@ -3094,9 +3108,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 Thu Aug 3 13:59:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340093 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 0E585C04A6A for ; Thu, 3 Aug 2023 14:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236627AbjHCOB3 (ORCPT ); Thu, 3 Aug 2023 10:01:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236559AbjHCOBV (ORCPT ); Thu, 3 Aug 2023 10:01:21 -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 5F8492101 for ; Thu, 3 Aug 2023 07:00:43 -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-0.canonical.com (Postfix) with ESMTPS id 2C7FC4247E for ; Thu, 3 Aug 2023 14:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071225; bh=mZe9Srkw8mk9+UpxCgBj79JVdzJ8PXD8OnJawp13C+4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hQ94tLgZhZxjBhm3kAse5zvk4HUg01EyK4tg2hWDiMgenUHO5qFaLo5onT4JteuHv xnCpv2WTPw9pWa25KpIIUIT5meatWbYpry//1uJqevvF8hlql3cYwaB1kgGwqFw/rs hkRbPguOIazISBDu7CmQrcGRp2XUIk+TmL6wwGRe4H4rq1Stbzyb2pBxAUTpC2AV5Z nOiZteY506lnZWNZ9JPdHaYE4K2wb7ja6yDb5QfNfMWOQ7+Yre21MEJ5kNj6KMs4+0 dOvrKEioawt5/qph/tgILwHBbpoe5rZB+Fg/kDYvl+Ji1lJ9M3I69RXrwlA8+p5K/x 1vLCBDyy0/2Uw== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5218b9647a8so681779a12.1 for ; Thu, 03 Aug 2023 07:00:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071223; x=1691676023; 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=mZe9Srkw8mk9+UpxCgBj79JVdzJ8PXD8OnJawp13C+4=; b=a/jzQ817lcdcElDi3qGr5DjLPMz54aYPT1hs/hFNrc7r5BzLcv8SvL41F7K80vkohm 3SVkyraA8RJ/182Fzwy/vj4Ukys0NhYyFVxNiGLeTBQUOKd14sUHV47X+FlBFPydUrGd KaR+536i1Lbd9W7C0+bj1WnRLhQHHXZ4i7taohC3zNf+UKNUWvOJ/6/iEvSxwxw0qLiD 534jPgxuMakSj3iPVYlXJQZsIOL1P0eA27gGNP0E/kN/Qaxa5UAnxb6SPHsZmjwDHHVT psxmQ0Z5ptx37iEAnUxQNqPMNmVspw+94Yx8yE7ut1YmInkorj2ZL05/NDWFR4jTh1eY fqyQ== X-Gm-Message-State: AOJu0YxrHJWAkr/huLlUoY/pSZ+4/wXMNDZiUZnPxe9fFYtt/opszsi3 nUZ2JnoMFIARS4pumSXz/OHFHotta9ifNhVea7FSAs/9t9wCMOHgLPL46p8dWizj2daXFm3YRUY rDncM0NvK5trM1LG11msiaq1ZcmdJioFXaF/G+BpRuFw= X-Received: by 2002:aa7:dbda:0:b0:523:f29:a912 with SMTP id v26-20020aa7dbda000000b005230f29a912mr1338861edt.21.1691071223232; Thu, 03 Aug 2023 07:00:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHNXClq9w1vu3j+/MCpqQ1qf7yVb7U3H47Lv374blmqMtgY6wWk79A9/cAXoEkoeyvY03jUKw== X-Received: by 2002:aa7:dbda:0:b0:523:f29:a912 with SMTP id v26-20020aa7dbda000000b005230f29a912mr1338852edt.21.1691071223066; Thu, 03 Aug 2023 07:00:23 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:22 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 05/12] ceph: pass an idmapping to mknod/symlink/mkdir Date: Thu, 3 Aug 2023 15:59:48 +0200 Message-Id: <20230803135955.230449-6-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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) --- fs/ceph/dir.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index b752ed3ccdf0..397656ae7787 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,7 @@ 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); + 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 Thu Aug 3 13:59:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340096 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 91947C04FDF for ; Thu, 3 Aug 2023 14:01:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236408AbjHCOBf (ORCPT ); Thu, 3 Aug 2023 10:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236505AbjHCOBV (ORCPT ); Thu, 3 Aug 2023 10:01:21 -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 466C830E9 for ; Thu, 3 Aug 2023 07:00:44 -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-0.canonical.com (Postfix) with ESMTPS id 952B442482 for ; Thu, 3 Aug 2023 14:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071228; bh=dbq6NgAMN4t7wxNwyddA+VrJjiC20GkONqywDZDeteI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gI5zM2pRwUCwl5VFAatFvkhZX8N4UtTOu9zj0c5rtyzUtKG4RdyIFEkT6L/E5WjTK ueMdD02pLPVk+AL2CB0e5SG58JPgVNpCZZOH4tUjxI6vPOhj3u74PaIiFzI/JRlDku CezAcq18Y3FRzSh2BEKrM9aY87XNQ6hAheAb0fYJl51er2OCIQ9VDJ2Z0yG6etm5ZS o8iFF15lA+NSRbmfFy3gqNrc2FpHgAw2EaLcdd8WgPBB4FBD6ZguH6ZpCX41lz5D3l TL14diNa76ARdB3bEDZUIYVLMJwwEdpbhXhN79k/Nwv96lgPoEZYbFo8zlAyIy1f6y 2eNJa7h+C1lhQ== Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-4fe3fb358easo1056101e87.2 for ; Thu, 03 Aug 2023 07:00:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071225; x=1691676025; 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=CHnsfg4UMRCXvLlZ7+ZwYRZHTPU0f/8xuxwYQWoe+i2cKqlO3DP+x25MWjSPbkXHgp qCcXzF4jiSHCzF4PQwdR683ewW8auFjGag1Mk6dpa2E7T8tlA6nFBU2M8EJfhnCSLuD/ 2ZQU67ho+2YSByTw2LlFSNThm/uZf59kVrSLy4itXMCimRucj+UYPNw30FEu0PHZ5Xlf ykP7ibw8EhBDhuVQ6xzz2LB+fOkFWkwzKpV1f6UkTIzi49nMXEwacv50pxvv2mSexDhp lxCtorOBh5Eed/wTp26cJve3bT2g6iRnYRMwelL72c0eEbpDSX+x4ndt8oyGEVYTlKe2 8mLQ== X-Gm-Message-State: ABy/qLaFUEM4ORqp9JDtfQwU9PTMaC4VvznF+BsBXQ1OIz2vH3ZHERz6 uxeJBgpMRkkUjE18oGxsyHNfOra1fO28MaXc9MNj4hm/xWblwzoe3IDcndnm8D6i/TvvbGUFTyc pXSAGi/expexD2amGmk2VCQMZXAIU1l9f0/h/7vVVPbw= X-Received: by 2002:a19:504a:0:b0:4fb:94fd:645f with SMTP id z10-20020a19504a000000b004fb94fd645fmr6531919lfj.68.1691071225619; Thu, 03 Aug 2023 07:00:25 -0700 (PDT) X-Google-Smtp-Source: APBJJlHGwj0wtDI8iNxIwzK1IOpeEx1Ty6UrtKDYlpyeVt4cmW1eycKEacTWhMO/37ZGK1a8a68Q6A== X-Received: by 2002:a19:504a:0:b0:4fb:94fd:645f with SMTP id z10-20020a19504a000000b004fb94fd645fmr6531906lfj.68.1691071225425; Thu, 03 Aug 2023 07:00: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 bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:25 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 06/12] ceph: allow idmapped getattr inode op Date: Thu, 3 Aug 2023 15:59:49 +0200 Message-Id: <20230803135955.230449-7-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 Thu Aug 3 13:59:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340136 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 BC486C04E69 for ; Thu, 3 Aug 2023 14:02:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236660AbjHCOCY (ORCPT ); Thu, 3 Aug 2023 10:02:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236617AbjHCOB1 (ORCPT ); Thu, 3 Aug 2023 10:01:27 -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 60AE3423E for ; Thu, 3 Aug 2023 07:00:56 -0700 (PDT) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.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 EB96642483 for ; Thu, 3 Aug 2023 14:00:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071228; bh=dyWOzKMsgYqMEu72C+uRJxx6NqzlAitmeRu8HoKY4M0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AEAArPRqZNJ0vesOF8RCUdDwSEncyLzF1iUVsRhZj62DtXGrLEK3VI1t3m5SaPD9W x+dSd0n1zQBqWj/fz8OfWltlOlFITioytdxEs9S4SNdwLaC8jPeUFzntH2zflr6lVb jv0j+CdLaWjhcJ9ziRw44hGh2doSUAX4Vl81yGW+N8BL8uyMVGOib28SpWmA+M9wUG nznHWbXegj20ETANM3vNOFIsd81diig1DFD+rSIMoKni4X5Th4R0D8/9Ev+WyMq9zt CAjsx1FcICwAoRIHW4tqHQdScfbDaqh6kHq5bFFmAwyG80q8g4eBz/3s2ZytR64udU R+tA39vo67MQQ== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-52310058f1eso683045a12.0 for ; Thu, 03 Aug 2023 07:00:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071228; x=1691676028; 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=M9VBxg1Pkj9terWGg9AZ3BUeLO7RoU4vCt5RkQsz1bEomIV9r9vkPFsVXp/hvGlMMT jsHYGTjCKaGt2PdB+6w4czjqd5xhdyRvD+N8nKnLCZjThJ2MHQZWrbgGx3A8ruUjhoNa ajhfLAH9y+hEZ3/bKN4ApqPHugeTHLTxTMg+GTYGaMtcXFO83O2iDDkz1M8qqHpkCexD jJ+Bq0G8cJzE1wrHBShofCH0U2MBGBrXhOCl0h8lf0Fa2tskqSypV7QuviVHzi9BLNgO prYVnu+wPPPAX3bumqPcg191GAkkr6YlFsjtMWZ/ALKb2GtmHz9VBeRUcO9E40wJ0zUJ 6k7g== X-Gm-Message-State: AOJu0YzbCs15XNNqa1zLmoB0se+nhF6y9c8tFqIuZsceo4lMiQVEZMz8 P8mIouQiBvI/cRpOFMsWFnZ27KCbkUdN0VN74tqZ6rM9dSNHXIKKMebZorlPOvD5CNxlnBNJGYA FRo5BpkCNU5V896+7KEPhasy+sofgVz9en5Y9G2V+xj8= X-Received: by 2002:a05:6402:1e92:b0:523:108c:9da1 with SMTP id f18-20020a0564021e9200b00523108c9da1mr1310094edf.15.1691071228224; Thu, 03 Aug 2023 07:00:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGXIWH00hAA9JhRO4ltGaLPgi5HRMsa3dnowPuj7IPYkjIJeJxq8gWd9F+PV91tcL+ROU9eWQ== X-Received: by 2002:a05:6402:1e92:b0:523:108c:9da1 with SMTP id f18-20020a0564021e9200b00523108c9da1mr1310065edf.15.1691071228019; Thu, 03 Aug 2023 07:00:28 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:27 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 07/12] ceph: allow idmapped permission inode op Date: Thu, 3 Aug 2023 15:59:50 +0200 Message-Id: <20230803135955.230449-8-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 Thu Aug 3 13:59:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340094 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 C166EC04A94 for ; Thu, 3 Aug 2023 14:01:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236564AbjHCOBa (ORCPT ); Thu, 3 Aug 2023 10:01:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236517AbjHCOBW (ORCPT ); Thu, 3 Aug 2023 10:01:22 -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 734E830ED for ; Thu, 3 Aug 2023 07:00:44 -0700 (PDT) Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.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 702243F22F for ; Thu, 3 Aug 2023 14:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071231; bh=nLZMqtT0BTuD0r3ld9T+VcVOIz8LP+RVDN6gyhT7tPs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n41ONHbnupQ7Tsn2U099FutAo4tozFz+TyztHNUwNOQuT+r5iTW347Y7u14kCy9X9 BoV42FrPc+Va87fIwKlOTkV0TUJaukW4U2lCmrudBMwwQ+FUrvCWNEar5FFawkwtY0 t0LPYk2TrC83b3xzFIHTQjoQgJzk/iWJ9uyxL1b0NXoe7f5/XyixyAgKH0N8d9aVA2 Ak0Sg6f0MZhBqx39wvp9rltWs9r9dHZ/yuqqFZ7uyn9VfC5GHxDg9mQKF7i8vQdy01 X4l2TBau3auLf5m5ubwO63iieEm+b4kowxh+5U6ypaBVj0gzyW4voqNDQJsYzmBsa9 kEVpgE/yr3Flg== Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-4fe3fb358easo1056199e87.2 for ; Thu, 03 Aug 2023 07:00:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071231; x=1691676031; 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=nLZMqtT0BTuD0r3ld9T+VcVOIz8LP+RVDN6gyhT7tPs=; b=G6CVpIttq13NoZIb5bAh/vSEbzGsXaBlHEr+kWPTPc/Q6NshsjKZsZ2ZwKMISmFxJA kJ8iEbEnZiUNudZpUfwWKoMI2lAiz7nHmXfBCiBp8na7L1ePlWs2KX4CFf0lXs5A/z3m C/3nh6c+xF35Z9brzpNZK/gGaRyhftp/AzxY1cUzhg+qHHvyB6N1nm1+MbllZXZE2NOu TuAPAe6jqPSu7tyYLRwhVavmJeja/jDyRNNDGhO5xeRZbT+F2zZ46kwZi5Je6HxS2d2D 0GlFP55jbKSnCZC59O/bk6VZylB3B3dHjMTRalLoRvcH+TPUZTwvae74g48Jz0Xsgmz/ Oc7g== X-Gm-Message-State: ABy/qLariTud0DmsUqVP6SeecQpbU0GfaygZrYJ1PcrJ1U/zrih8lrpw TGfGU0rvtlukoZLbt9NW9om9T5aZn6+oz1b3U+2xCtDlOpoa3CJtaq8U7nJ91WWDQAyjyttuV/u DBiSpkP1gu0QQ5gd1SjIMCCdjn/Zz6cxLYKhJku7oQjU= X-Received: by 2002:a19:2d17:0:b0:4f9:69af:9857 with SMTP id k23-20020a192d17000000b004f969af9857mr6618066lfj.51.1691071230957; Thu, 03 Aug 2023 07:00:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlG7tSVwtfZPt17hde6VkgzoI0n5qb+fDHHvUxsRIf2WmuuuskJA8Kt16XnZNxTZtNp51Rx5pQ== X-Received: by 2002:a19:2d17:0:b0:4f9:69af:9857 with SMTP id k23-20020a192d17000000b004f969af9857mr6618048lfj.51.1691071230642; Thu, 03 Aug 2023 07:00:30 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:30 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 08/12] ceph: pass idmap to __ceph_setattr Date: Thu, 3 Aug 2023 15:59:51 +0200 Message-Id: <20230803135955.230449-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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: brauner@kernel.org Cc: ceph-devel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn --- 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 Thu Aug 3 13:59:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340097 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 A59E4C04E69 for ; Thu, 3 Aug 2023 14:01:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234466AbjHCOBm (ORCPT ); Thu, 3 Aug 2023 10:01:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236570AbjHCOBW (ORCPT ); Thu, 3 Aug 2023 10:01:22 -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 9512130F8 for ; Thu, 3 Aug 2023 07:00:45 -0700 (PDT) Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.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 4AAF0413CA for ; Thu, 3 Aug 2023 14:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071234; bh=CQAHRH/ms/cFOl3S4jtiakCJJYzaMB08Yq0KPV8/UVY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=L9SQQCM2L1t0eF+GcnbEpskA8H2VXKalllhgVsx0RXSdoJ0HSOrrH71ZTDiYFXkZb x84H8VgnQwsSqj0R3+GQIDlmuuqfeABsO9qHU717A6eNq/ZRQdTqtNu2nLEt0UzF0l VIQ5rfCCFVpTryRkdpOALw4bbhHvJHNeFnnLKaZ3va7jEuHHU20u4oQKd+NA1s7xA+ tYJqqlHLzYOwvftTjjI0nm8/TfdvmM4T/INuJhDp8uIrrX7Q/2VB0arxc4pM+bBpvi onCuMI18GyGKt/7w56ICIbQJsb8/OF+cvyYnENifXh1jIyXVYuiFt6Q995MnBsG3Oo FFp5/M+uu37hw== Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-4fe55c417fcso579943e87.0 for ; Thu, 03 Aug 2023 07:00:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071233; x=1691676033; 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=gSnEd8xBqhVcfg4krPjfdOXT1KAup+yYT0lPxBClZlcYtaw+ArYMHyo+5hPhtyCyvH RWgbe4qDD75P8bRXBpsbyOGYh7Y4peqCIYKyQfWXza/e7owUiS0FbDXv0kwbnGPFLBf0 In8HOVuYIfTQa9YXvcG3wkHKmxWrvGkWDrv2Bt+GAoamx9NkR4+Ykb3JlpK47PTHd90w X3d0CKT8ift5R819RyJ5MH6nfz1aGPfSxBozkvpccp8BNIPZbWsXGEF7Vr76qiM+3xtb VFs02kmvgmFEWtdqrGG/jsLk9qwCkMxWE4A91ZwAdjKaoVjpcFrcSSCAZaUnYOKjVI76 Z16Q== X-Gm-Message-State: ABy/qLYXMZIBuasbslUq8GPaeBPBrL9tgn9iiiY9yJipEaD6x+gDnWuE 5gpJ+oui0eK+FHtqWq+hUJsiVU3/O0nxFQaMBQEpvh8c9WG6vREPxkahWdC1B2F9TosumaftWOX 87XQs2jNYpXZOOhcfXd9ghyw04qTCKbMQYa6FjauF5Ck= X-Received: by 2002:a19:7b12:0:b0:4fe:958:88ac with SMTP id w18-20020a197b12000000b004fe095888acmr6943478lfc.6.1691071233258; Thu, 03 Aug 2023 07:00:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlG2TlvShKJZGbBHpD/d9LrhdQiwMDiZTZ4bezS5dBphDImXuO3CGQo3Us9u6iBPnakIcoP6jQ== X-Received: by 2002:a19:7b12:0:b0:4fe:958:88ac with SMTP id w18-20020a197b12000000b004fe095888acmr6943455lfc.6.1691071232890; Thu, 03 Aug 2023 07:00:32 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:32 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 09/12] ceph: allow idmapped setattr inode op Date: Thu, 3 Aug 2023 15:59:52 +0200 Message-Id: <20230803135955.230449-10-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 Thu Aug 3 13:59:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340095 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 7C155C04A6A for ; Thu, 3 Aug 2023 14:01:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235889AbjHCOBd (ORCPT ); Thu, 3 Aug 2023 10:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48100 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236566AbjHCOBW (ORCPT ); Thu, 3 Aug 2023 10:01:22 -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 4944F30F6 for ; Thu, 3 Aug 2023 07:00:45 -0700 (PDT) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.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 552C0417A2 for ; Thu, 3 Aug 2023 14:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071237; bh=ARhwDsiPa3Ci/G2xteJutduXCGuj42UUR3o8sfJhjpo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YPaEm74UBhZ4IswqsnXdrKtiZbfGJIDdznc2z5O/+/Hw7R9h1SUf8zDpa5fl/i7uQ hhO8ROyTwnrq4du4AkmmqVw1ChicBQ6AURI2Q0yJnh689LIN7YRTzsEj8ia9wTU7Xh AcqXQo4YPLWw54oqezQUVi7CaQMnfJg72CyH+BnA2u2sOssyESlTMcO1RgaP4NR0mK HLSW3j/eho+ucQ+bhpfiJ348Bsj+WZjimmD+REjsTgz8ZnK3o4NSVP0br3BEDDroqw cs8LKK9cKSfzc/pjXjYTqmVhwcZbXeUUyiaJHw6SHsJIn2xAVC0ywkhuMwcRuE1ibj L4U0/SeC+FQow== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-522307b7188so788032a12.3 for ; Thu, 03 Aug 2023 07:00:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071236; x=1691676036; 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=TjCuOx3/y6ZZHy/0nLAwdd+2LqIuDovTa2VTMRZ2tEZ/o0WhiccDBb0gIbK9d4nGm1 gm194rZbum0aPD9lC5f+frBGB7jTsDGJslyPBl2CNx8blxRGpO4TRReA90JVMatyUsvW gejK/2wkLpn5DcfvebF+75WscgPJ+YVasr1nlb1rGYL/0IloQHcxVAsUCXRWrY7VbPgk pF2GMOY6cbD4pU7tUprbhWjOJ2OP/k6TCWWlW0Um5eAk/y1xXqt8FEQEF0XXDFA3qd96 8ebfzKqEDEo/57CboMYnb6croZYECpIpWO8OJtXTZgYL1cIGEY9lfQzVI2HavhpWOylF MzDQ== X-Gm-Message-State: ABy/qLZhkLC3DdM5BTFy9zWNrJFQ8uXXeRYYQFY/EoNItxcHGXU7mYuN Cp/KGOGcEbrgocIgswTLK24lN3SExHg1/gY8YxbmOXLEEr04CXvpCtW8TTTXUuQc7sht0U6HVs5 XpynOPS389FAFjH6RBCBJ2So6/vbM6oNU2Q9Xx3/mLT5bkIg2l/E= X-Received: by 2002:a05:6402:3d8:b0:522:3a0d:38c2 with SMTP id t24-20020a05640203d800b005223a0d38c2mr7902003edw.9.1691071235960; Thu, 03 Aug 2023 07:00:35 -0700 (PDT) X-Google-Smtp-Source: APBJJlHqUeh1b6pdCPnI6/QplOiCygliR0OiJNslAGmiFZTzhfRRFy9liUqsb+aWN3xG2roMQBYCqw== X-Received: by 2002:a05:6402:3d8:b0:522:3a0d:38c2 with SMTP id t24-20020a05640203d800b005223a0d38c2mr7901988edw.9.1691071235823; Thu, 03 Aug 2023 07:00:35 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:35 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 10/12] ceph/acl: allow idmapped set_acl inode op Date: Thu, 3 Aug 2023 15:59:53 +0200 Message-Id: <20230803135955.230449-11-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 Thu Aug 3 13:59:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340138 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 CD2BAEB64DD for ; Thu, 3 Aug 2023 14:02:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235840AbjHCOCi (ORCPT ); Thu, 3 Aug 2023 10:02:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234888AbjHCOCD (ORCPT ); Thu, 3 Aug 2023 10:02: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 9BE3D44A7 for ; Thu, 3 Aug 2023 07:00:58 -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-0.canonical.com (Postfix) with ESMTPS id 4D4F74247F for ; Thu, 3 Aug 2023 14:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071241; bh=3z9qgb9ifPvjMsignbqopXQPiRZw936kb1zQwGNpHt4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=A+nWR5bgWoJQcgiYA023ok+0cjcbpeRqld769eF2RUOOJyu9S6/yPQy3Q/DXTYMVH hJd3fhso0wyEQ+XGgmdGdn3OHkfBvIbVL++6De/Iok51J7QGINVsfDI7txJcww8H25 EEx4lbq9KSaY/Y3UlEHgcEDMzKGEgrsY9J2H4dhMH2/NS+M+OgXeI6NIf7ybyxVAim ZIFA45Jz3RLF+e3f+S+cspa9JagqwE+mvfzzUjovewMyCFCAsfKFFt6n8laaq7l8z2 NN9zfPxcSRuopbvhDC3o/rUp+1d3F42c3xgQ5y5gdLlnOZ0aiYeJYJhpxr+15+Asf2 rVXJzx3h7Osdg== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-5230e9ef0e6so539082a12.0 for ; Thu, 03 Aug 2023 07:00:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071238; x=1691676038; 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=3z9qgb9ifPvjMsignbqopXQPiRZw936kb1zQwGNpHt4=; b=EEcE7BuX8w05XraMQuPMno4yrAaQ2PgnSir3z3Ykyb46YXqtUDmNw9+0joJw+sl6it mJpYKtm9MfDyTOvAC9Nru4EUfDZOtZGfnHaXw6i7ZI0Ss7uWKN/QBi/GTWGGjEucBZZu /xfptVMfS0KgsDPef0GWXocAkP6itGJOKe590mTD7+5NxQ7DgPaQz8caBwYm6cIyZk6C 5MDCP5L5WeI545RTYKauoXvU/QQAoMK93vUxKhu3dBqSlHogI1bPeX/ARqjKs12gYFZj vYMYGDnVlcSnHyRsuoK3auWSA0/tU5RLizKzJCcouMrKBHcLC3Yqruy2dwRv22Ou7hPM heuQ== X-Gm-Message-State: ABy/qLYzgrvTU5srdApl0JxNbDJog52jB0aOoE1JjYfFiXOyvSnzLrJf zC+c0UcyAAC1GSQ4isbTvlaku5aBe48Bo4F/1XqxHLdZpM/APi38ORv/22xTPFS01zQefwXVFX9 30fPq5qZuldiuYIrY6LMSU9T9inimMPQKz7kzLVjANd4ojr43FMQ= X-Received: by 2002:aa7:d7c9:0:b0:522:2b76:1985 with SMTP id e9-20020aa7d7c9000000b005222b761985mr7132496eds.2.1691071238722; Thu, 03 Aug 2023 07:00:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlE0pp6lmcBwuEsjLXRAH6NybsqxtfW1AOq9hV5+FXgfxFhIOUTjX8q9MHOhwq4qu7jI+RVc6Q== X-Received: by 2002:aa7:d7c9:0:b0:522:2b76:1985 with SMTP id e9-20020aa7d7c9000000b005222b761985mr7132484eds.2.1691071238558; Thu, 03 Aug 2023 07:00:38 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00:38 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v8 11/12] ceph/file: allow idmapped atomic_open inode op Date: Thu, 3 Aug 2023 15:59:54 +0200 Message-Id: <20230803135955.230449-12-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 --- v4: - call mnt_idmap_get --- 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 7470daafe595..f73d8b760682 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,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 = mnt_idmap_get(idmap); ihold(dir); if (IS_ENCRYPTED(dir)) { set_bit(CEPH_MDS_R_FSCRYPT_FILE, &req->r_req_flags); From patchwork Thu Aug 3 13:59:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13340137 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 40C31EB64DD for ; Thu, 3 Aug 2023 14:02:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236678AbjHCOCf (ORCPT ); Thu, 3 Aug 2023 10:02:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236565AbjHCOBj (ORCPT ); Thu, 3 Aug 2023 10:01: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 9BC082129 for ; Thu, 3 Aug 2023 07:00:58 -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 DF7944248A for ; Thu, 3 Aug 2023 14:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691071241; bh=VUgFUdqFi9+fVf4KBmHgMSHcrOKks48HLHXKSZR7nM0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JIRRfFumk1KY9LDcMpWwjJ90vLnQarrxyxZjplJtu/Vurq9gBwGboIOlerOQhzlKO c8NpAmjijcKMOiQ+O5XzppV//nZ6aECE9D4/UWeo8/x1h/Yinop9Oh+/+1JKGdE5dN 24NWgAR/6NAwkg3GVrZlk2DoMIF77B1eg2CVvWdqanxnF6HwZ9+flPObW//Kv2xDuN bbrmz5AmcSXAdYZHShoGAjORp65Bw0v37GbU0ygaQETLLpoZtJMzw5KdspRvXlrIMe JB8pCRbin34GBqST0G0hJuVsMhjNre9ak+iwBt7cNJo05IFB1OQJhGKgt5pV9BZ+6S zZ6xOsiG4o06g== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5223854ef71so685391a12.1 for ; Thu, 03 Aug 2023 07:00:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691071241; x=1691676041; 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=VUgFUdqFi9+fVf4KBmHgMSHcrOKks48HLHXKSZR7nM0=; b=C7ZZAIguksOFm5xYaW7Z+j0jp77tW3vlFk5/SmCK0Op1tHzns1BAx2Oy9m/GPE64SO eJazHgeUNrHsUhSlr9PeEIsJnKp5WGxCOMeKStZMfoxOReY0PnH6bAQsT4sOiM7ACuK9 9hYgkh3zLCWVe0E+SAMLxCmnux64ePvErH5TrmFivmUxLFeCeQonsVmQF+OdRm13C3LR TxoWf+xkKz+Von5xw34iK/6Y1zGei+tzaz7Wnl0euNciPRYrAx/0wDGZ1W/tES6hixtR aRSsgjHavwEIpxu9QHgHSjvvqGYblNVuhY32rKh1ssGaYyFchGYKrMta9dO8sL3Jb+8M IYxg== X-Gm-Message-State: ABy/qLZwCpE9UU56mpPqC8N8t8ixUzrsOKQel2ztPNhcqLJftaxGigrl W+uZ7q1uyYC2WrxLcStJsabkq7Cl9rXuQWdQoyAwI/dO8iLKc8tSBlClQGAgdVkokxKo7Z96W6G EXQE+rGEmtbgZi84Zo0D+Xrp4593bRcXucfPf7DFPQU4= X-Received: by 2002:aa7:cb48:0:b0:522:37ca:a51c with SMTP id w8-20020aa7cb48000000b0052237caa51cmr7051509edt.40.1691071240822; Thu, 03 Aug 2023 07:00:40 -0700 (PDT) X-Google-Smtp-Source: APBJJlG6Q02R9Pwuh55imXZTjVXNaetMucDVc5mJ3+DcQHv4FmT8HpUH72N1OhXDUzrzxEYbQpmVdA== X-Received: by 2002:aa7:cb48:0:b0:522:37ca:a51c with SMTP id w8-20020aa7cb48000000b0052237caa51cmr7051500edt.40.1691071240663; Thu, 03 Aug 2023 07:00: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 bc21-20020a056402205500b0052229882fb0sm10114822edb.71.2023.08.03.07.00.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Aug 2023 07:00: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 v8 12/12] ceph: allow idmapped mounts Date: Thu, 3 Aug 2023 15:59:55 +0200 Message-Id: <20230803135955.230449-13-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> References: <20230803135955.230449-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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. https://github.com/ceph/ceph/pull/52575 https://tracker.ceph.com/issues/62217 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");