From patchwork Fri Aug 4 08:48:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13341476 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 A4AC8C001DF for ; Fri, 4 Aug 2023 08:49:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229789AbjHDIt4 (ORCPT ); Fri, 4 Aug 2023 04:49:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbjHDItd (ORCPT ); Fri, 4 Aug 2023 04:49:33 -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 23EFC49F0 for ; Fri, 4 Aug 2023 01:49:32 -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 3CD62417BB for ; Fri, 4 Aug 2023 08:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138970; bh=GFNwWvhavDkNrI4eqwez7OWrv+w+Iw1WNhnwQW/Fw7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZdFh0yafbC1h4o4Creja86XLjlgPqIw/8g5zh1Q0AtHR/4uzszzMuJlGO4lyCf9Be jAhiXOyM/aRWrGH4Wx4sz4dt2tv3ArPqt+n7+IBT9Hlu568dxViaJFyj8kVDclsdTP q0ymyzearB/6eY2LF7LBhFC8uf73UVi/L1+2REXLtLOpA/0lQfWcq9G9Av3NZp2vWg dujJ8ovwsNtYcbi0pXOtwLKH6Oq7XBVqHG0ywFvD8CnFTeOkPIgct944T2/cIXmZte Bo6TqW76euy/qTRxSWNM/Ha6fy6zBQQ/PjI+q/RKaMOaN3FS6JIoZ9TJv6HEpyXo48 Z8SWEK4uH/9mA== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-99bcf6ae8e1so122978666b.0 for ; Fri, 04 Aug 2023 01:49:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138969; x=1691743769; 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=WlEYznstUTvlQ8EwGVMfqFFakX1ytPu/gncn1Tnk1b9aHSHxiz5ypBHiFmUPOJwaWz 3zWXDSMAaCjaK/cuBv2qNu6k+WcwsCoYuGOtkW5qSdveyDTv7JubPZNVPrDbVTfgua0K OXXvoLBEUZd7Rmsnuhrs6lHJmj6RXbN1bk5R1BesaGHSSAKUDe2vc9x7c0bBzOf0722v /y3ODl7Tc0cV9cQPA2NCU1Eb38KVsUjOOBs8uDtOhJTg8lD+ddXZmlciMdPO9/qEHnjc bqkqq4acKGck4JsyzlcWS99eA3cNloPp+wEYD/wlKqbLz61V4xmPfNtYtJXwWiV5psnj VpOA== X-Gm-Message-State: AOJu0Yy0m5pIh1UPGsYHgwBU9Frqvii6nhkPGzDD3r5bmNFo4Bz/NaMO 1+Ts96130GECEE2ElxnZTUPTIeSyWK6+Claq5giRI7EjImV1EMenZUlYYVhXi46eQDPRzbq3lz3 psEIg24pWN5SUjiRr3/P/DTLdagpWV1WTvUXffYH6y7g= X-Received: by 2002:a17:907:75c9:b0:98e:26ae:9b07 with SMTP id jl9-20020a17090775c900b0098e26ae9b07mr856008ejc.35.1691138969807; Fri, 04 Aug 2023 01:49:29 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGzJvUEdQ1szBS20TzLv4pF+D/kH4bm1Trv3iQThRWbQMHWUfpqSKG2LY+85emIKvwXfeMoXA== X-Received: by 2002:a17:907:75c9:b0:98e:26ae:9b07 with SMTP id jl9-20020a17090775c900b0098e26ae9b07mr856001ejc.35.1691138969650; Fri, 04 Aug 2023 01:49: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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49: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 , Alexander Viro , Seth Forshee , linux-kernel@vger.kernel.org Subject: [PATCH v9 01/12] fs: export mnt_idmap_get/mnt_idmap_put Date: Fri, 4 Aug 2023 10:48:47 +0200 Message-Id: <20230804084858.126104-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 Fri Aug 4 08:48: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: 13341478 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 596BFC04A94 for ; Fri, 4 Aug 2023 08:50:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229827AbjHDIuT (ORCPT ); Fri, 4 Aug 2023 04:50:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbjHDIti (ORCPT ); Fri, 4 Aug 2023 04:49:38 -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 D08DA4C0D for ; Fri, 4 Aug 2023 01:49:34 -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 EBC67417BC for ; Fri, 4 Aug 2023 08:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138972; bh=StxqveXF5moq9iJU4D0IjENKfN6jaIfCw60woBc2a1E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dV95e+C6a8+U9YNmwYyII74LQQbMgCqRI2qE7d4jbZ8XgNEPoftl2N8GyUbCXIBdv gJ79USRnE/uMQtTg+//vj1HJ7ACh6h5wsiQrls2ehb6TZdxLyu4SZGZoO+UALGGIg1 oCQSAmBBtE/dRBAKqwtT9AxXKak6L4cv/ne1OGOvYFPMaiwaG435V0UP/ySBvwcmYw 26aTldcnxGaOoGb2O2Omk5P2h0tSDAgnfb26lgV9FG8SrbW0J8Zg99CA4A22MBlq7F 3Sbd/wGrhewOcfM9yifdT60aHednsSDpzb8bTV8c0B1DuOmZ6szcyPJsOzM1zPS8GZ 88hlgEj6ij2jg== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-51da39aa6dcso1298872a12.2 for ; Fri, 04 Aug 2023 01:49:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138972; x=1691743772; 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=J+QSXnduW5g0QTi31NkdNpcYyho1W26VuQ6GYyVL+ptl3j8cWMi0pwaERJSNOPRjbo nCikrBpyQ2NsQVxNk5/VHEaDoZyMJitlhnbI+mdkP9riFljhggMaNmISaJdPI58xGL8h uOOui1fnqhfA5SsR3axO3EP0A7kHe1qKUcjeh1QBxLbFwnxAi25UckdtXUql7is6Mljs L/39cplPfyZd4itJHJ3Rt/Tv3QIjkyy00UpitLfyf2wYjjSFRq3p2yxVugi8HzW1+IGs JJmogR/VCkvRolbJJn3+zZoxx52LZ2c4fhxNlLpFRro0CLKOfe/HszkcegE/OSBW7hq2 ljHw== X-Gm-Message-State: AOJu0YzncYg3rSQRDXyShKRliUTepDuZhVoYsTYtPqumHrlIk7VN9qrl 9Co2OpehElhMgDe2IgxewjprekpUpIYzKLIOZ4JRQKa85uzg/+GZgs+C3QfKr1yR5uKJuOPvJbx 1znj4WTFzknwwaXJG+BsslTNMa3q52rxcMLG43U7+N7LQqdRuPkE= X-Received: by 2002:a17:907:2c4d:b0:99b:bf8d:b7e1 with SMTP id hf13-20020a1709072c4d00b0099bbf8db7e1mr863832ejc.17.1691138971899; Fri, 04 Aug 2023 01:49:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHt0cJxyxNVN8MFBPcovFv21DNeI/vcPblkJxrD4B89INifTjeigoUO/zvfSlO7YIYpAZQAKA== X-Received: by 2002:a17:907:2c4d:b0:99b:bf8d:b7e1 with SMTP id hf13-20020a1709072c4d00b0099bbf8db7e1mr863822ejc.17.1691138971748; Fri, 04 Aug 2023 01:49:31 -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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49:31 -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 v9 02/12] ceph: stash idmapping in mdsc request Date: Fri, 4 Aug 2023 10:48:48 +0200 Message-Id: <20230804084858.126104-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 Fri Aug 4 08:48: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: 13341479 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 A8C8CC001DF for ; Fri, 4 Aug 2023 08:50:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229837AbjHDIuY (ORCPT ); Fri, 4 Aug 2023 04:50:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229744AbjHDItj (ORCPT ); Fri, 4 Aug 2023 04:49: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 B33134C18 for ; Fri, 4 Aug 2023 01:49:35 -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 754D444278 for ; Fri, 4 Aug 2023 08:49:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138974; bh=Sm84/KT93swuS/ikVEAwSnx6TJ8Tr5bzLLYRGJZTQPA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ETsG7J1SVkjD7bA7aDMbcMogsJdV7zbpbnY77WKzdPdK4ELDje+5qO2jugfg0cGMh PbVKbCutnTjaDCt3IciwUsns3WS1CZNUl+TcCxa/x1WxILY7NbGg9DsqnO0mfPTn// ZTJNk+HTBiDlVHnwr1uPh6mmJp/H+80vNa8og0FLyVHpflyqc0vTa31aIVAGHjJozZ HjIodifTOLJo6q51O8D7cmfduOxXTRSZs70p9G3z8iyEoxjsZLvbJxmtD2a0J9rtjX LjHqEsYlHf+iVXiuug07msgpRsU0iktd75P1WWjETKBY8k7AaQulBhrKj7K6ZpS9DR Px12znWVBt5Kw== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-94a348facbbso127956066b.1 for ; Fri, 04 Aug 2023 01:49:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138974; x=1691743774; 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=Sm84/KT93swuS/ikVEAwSnx6TJ8Tr5bzLLYRGJZTQPA=; b=RLJoP9SSCgXm0ohT40/a5lwh/OAPy+5AFSFxqKIfmxyTLZ7syccI+FT5BcZx052kxx r1gSiKYugIp6gAAJ9iJ7jM2MeDyVWeJNQLyiDoKVxYoslTnCt0MoSxCwhMWNM+tzVRqC VG5nIExeP/MRNZ2g4eaqIY+B50pNDqOUm2lQzj/LVlIQ++0a+mekkrqw6akPSVj11KEv 9md83au+ucyGwWQnAsoGsDcTDlrVgAG2D6EFxPy4LYCUONncJmOB+4YCQiy0v//Npjg+ ZHvrBOpwIRH5JWGtJhmdqK0xp+8Bx+D9GmmROdcz+v6TSChbBlhCPmfwST+X2ZN8OaO1 vQcQ== X-Gm-Message-State: AOJu0Ywcmuhn/I7ZVF8NfRU89eIXdGAR9PQjyFAgj2WvCARxs9VCa6iE spYyGGDth338A8iMbfJiMp7dvMzlrSYxzoqARPKO8xhEy52ZdYZyD7v2VpOpAsAY1CuxFLftHC/ j33Kwyqg4lxf3CB9hCxWzi4iqOIV/4TUcdUE4htUjzb0= X-Received: by 2002:a17:906:2112:b0:99c:4ea0:ed18 with SMTP id 18-20020a170906211200b0099c4ea0ed18mr952381ejt.8.1691138973828; Fri, 04 Aug 2023 01:49:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGgdSPLTZJvYlL3Mzi5CnZ68sMi9r2jxcre66CKNzUiIEhpEQczFn48u3hw7bTM9iJAgWJeVg== X-Received: by 2002:a17:906:2112:b0:99c:4ea0:ed18 with SMTP id 18-20020a170906211200b0099c4ea0ed18mr952369ejt.8.1691138973644; Fri, 04 Aug 2023 01:49: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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49: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 v9 03/12] ceph: handle idmapped mounts in create_request_message() Date: Fri, 4 Aug 2023 10:48:49 +0200 Message-Id: <20230804084858.126104-4-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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/ 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 --- fs/ceph/mds_client.c | 47 +++++++++++++++++++++++++++++++++--- fs/ceph/mds_client.h | 5 +++- include/linux/ceph/ceph_fs.h | 5 +++- 3 files changed, 52 insertions(+), 5 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 8829f55103da..41e4bf3811c4 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,34 @@ 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 = sizeof(struct ceph_mds_request_head); + + 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..b91699b08f26 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,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 Fri Aug 4 08:48:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13341480 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 90C0FC001DF for ; Fri, 4 Aug 2023 08:50:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229851AbjHDIum (ORCPT ); Fri, 4 Aug 2023 04:50:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbjHDItk (ORCPT ); Fri, 4 Aug 2023 04:49:40 -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 7E4464C27 for ; Fri, 4 Aug 2023 01:49:37 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 4AEDE417B9 for ; Fri, 4 Aug 2023 08:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138976; bh=vA7Z34zBj4jzvwwxICC6DC+yM3ZqeVgNJDmT3zJBPQ8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ci2CMG3ncGg0IP9U/609DPvQt4Pgj4bbyeLT5R6FJ4R2H8mAcvLRCyj9MtpEgd2+J LlfysVhxwidJcKpKR01MY5nAgILNP+wYytWvBe9EQVmWvqEqFlDkaoIhCtZ+dVC9lT W1BNrABfg416RqhgRX+oVP88nFt4Z7LIAImcJohKl43lRJbk5L/k87uhoxtsHcb7zC xl592aKEBkYPa+40tN/zuzAGhQKHAX1QL8R20inRpNEsqslsZ7XTJgkKL3pjO2kJRU DVoUxIV1xvoFDe4njpQ9jTR+00USjCkRIfKkpHVGyn7xQwjjICdM2fvKH4V3XJ09UB RNMHUe1xQUfFg== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-99bdee94b84so243390866b.0 for ; Fri, 04 Aug 2023 01:49:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138975; x=1691743775; 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=vA7Z34zBj4jzvwwxICC6DC+yM3ZqeVgNJDmT3zJBPQ8=; b=B+aDHrf5Px/gEjZ2/8blmw1g4+5rGI7RhDbk24Xt7HEIepC2NEgOm+iSbjKOGTt2TN pE7eM/AFrtQFaXCss50LeAiurhB8fHkLIYSWYr63hOkmNIh3IFqYmAr3Y0aII4mi24TR zCRP1MS9q1go8MQkHDQjwIxAmkJIjhpY59V4KaaIWn/lKbs96brReSFRKzE3PZU6c86e mjkYiehTxgzNfIISZ5PF2pet1vion/uzGt3YEdZ0rCyLkf2/6+WZEDZ5WagvJV8BFLdx taa4Cn0ZUnt6x+ArC0xfJB4/vji3hqcvTjb6Or25fnvBi97kNIRavo7bmi+4AbRVeqVa P2vA== X-Gm-Message-State: AOJu0YyGVCTNdH77twFsSvqiSGFEBC/bxZqi8pg96UG8SArf0f+2GLx5 1Z+NhNuVe2o0bgV9se4XwsRQZSoBD1WmtSrUUV4PED8jcOdu6rxYn1B3DyTiObR4jll/mHxw82N L/VhJHMwURfMJ0i9Clw+Nu4e0NvxzqFBKJ9h8kY80e3W/Qfi9fxc= X-Received: by 2002:a17:907:1ca5:b0:96f:9cea:a34d with SMTP id nb37-20020a1709071ca500b0096f9ceaa34dmr1440492ejc.21.1691138975510; Fri, 04 Aug 2023 01:49:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHaLHd/m8ShBoFoitgZ3ppJ4N/JTnjCwUDlUN77awev8PwhYvcw899vgUcnvDYDfWuRJ/FGTg== X-Received: by 2002:a17:907:1ca5:b0:96f:9cea:a34d with SMTP id nb37-20020a1709071ca500b0096f9ceaa34dmr1440479ejc.21.1691138975358; Fri, 04 Aug 2023 01:49: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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49:34 -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 v9 04/12] ceph: add enable_unsafe_idmap module parameter Date: Fri, 4 Aug 2023 10:48:50 +0200 Message-Id: <20230804084858.126104-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 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 41e4bf3811c4..42c0afbb6376 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; + } } /* @@ -3095,9 +3109,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 Fri Aug 4 08:48: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: 13341481 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 91A90C001DB for ; Fri, 4 Aug 2023 08:50:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229883AbjHDIux (ORCPT ); Fri, 4 Aug 2023 04:50:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229759AbjHDItm (ORCPT ); Fri, 4 Aug 2023 04:49:42 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C7054ECA for ; Fri, 4 Aug 2023 01:49:38 -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 7A1FB417BE for ; Fri, 4 Aug 2023 08:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138977; bh=mZe9Srkw8mk9+UpxCgBj79JVdzJ8PXD8OnJawp13C+4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SwHT3qEFYsgQTrcZKivEqLIyocWHk2VxMCYuienXEU18fS4cv6hal/HXWkDzmt0oh Pm45Cs2lIcWL99S8Tyz8F7Njb0RorTEg0+vD9iyULOra7alfT0gn4t1492ra1bNlFI qQYdK+GbdZ5dt57SU/y9BrInO+GFuTXW72Fu3dnWs9NEWPBMqtQhPLS2hgbm+68FDI zFNd3fyxY2XOCZXjIASAmt1Qk8GUobh62c7RsYQoAtqTHrIx6HDWBAc4dztBIbhWvA uMdyUKDH/Mwij9CJqlHBJmTMWD86kmcO71VpmavIDTffnYcRR+Ixu5nBH2n43SyQSV Q2mHx0+ud503w== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-99bdee94b84so243393566b.0 for ; Fri, 04 Aug 2023 01:49:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138977; x=1691743777; 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=A94w/7X/QayZSrQ/F0h7o/eVWyA0tScMuLGfOE6fNoL7ky4D6VuOz1q1sO16qIHI3Y D9ZKnZyigr0/xzULSDY0utqK/JaNyd4zxGftmO6d9obOaXAOGxiqNcZShqjHoWf0vv1C GQPBZAHOazuHlNxUgVfq5fGO4B8vsznZj01p2s5ZFiYK2ZFSsaYvQVPmS+BRoa4yJCmI 0YszL9yVTif0NZdy876CLfQ/lBPBnJtqCeQN5cvOOBhpboECVSuACZuwWpofIluN6wIl JPn+sG3hUKPaS6HdP/5IYlC7pKcGNIs5HQYrVc6CKaF588UsXoeAsi7V9HPM4d5WuhRb jrlQ== X-Gm-Message-State: AOJu0YxGn+FaReSlp038qBrgZ9ykGGZIe/66JXbIeXDhmks0QNuIdYCP 4/Dh+QeYHWxGQ7JCj+Hd+HIcM9iaxFPWe2Tn0EChWM6viQrOdxf6HUFqPk8Ow+tYMWjua/WIWBx 10fgllsjqY00WyLFfYkafhhXzN5VcE7jvD+tqA1PiWlQ= X-Received: by 2002:a17:906:30c4:b0:99b:50ea:2f96 with SMTP id b4-20020a17090630c400b0099b50ea2f96mr1353114ejb.12.1691138977188; Fri, 04 Aug 2023 01:49:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IENvJC3KHm+M7be5nN+fqKwo0plcwe5syTouQ0tjPAcuDJqmboM6FZDl+R6VHCgZD1KqsNuNA== X-Received: by 2002:a17:906:30c4:b0:99b:50ea:2f96 with SMTP id b4-20020a17090630c400b0099b50ea2f96mr1353099ejb.12.1691138976964; Fri, 04 Aug 2023 01:49:36 -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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49: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 v9 05/12] ceph: pass an idmapping to mknod/symlink/mkdir Date: Fri, 4 Aug 2023 10:48:51 +0200 Message-Id: <20230804084858.126104-6-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 Fri Aug 4 08:48: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: 13341482 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 161D7C001DB for ; Fri, 4 Aug 2023 08:51:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbjHDIvL (ORCPT ); Fri, 4 Aug 2023 04:51:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229652AbjHDItq (ORCPT ); Fri, 4 Aug 2023 04:49:46 -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 9EB8449E0 for ; Fri, 4 Aug 2023 01:49:43 -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 A81F3417C0 for ; Fri, 4 Aug 2023 08:49:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138979; bh=dbq6NgAMN4t7wxNwyddA+VrJjiC20GkONqywDZDeteI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=edXdGDcEtsqo8doV8kunlQD0coNauOaZVaUTViowv+QcRw+CVs1fZojjFCTALl84e Dy4VIouV/7PIzHeiRU1pkGewYL/EeBCU513DzJoZwbOFb0gSr3sJQMUdHfuaelygzO hBz3BIEGL6AujCjvuzD6MA37w/ZVOrWOltPo6e7XK+h9uFk994w7CzRyiNZ1cmddXf jLzonDlrVp4GM1WQGp3Mg9FzjG4NxPLVyQduc1dBzWwJtMz4gVSGIzeh/lum3B1Teo 7YwJ4wryXuhE9A+fQ3gru7APn+CURcSgcoFS5PIs41qEJ9pJjxgVZmcF5GtB7Lk0z2 VhvxQZcS1kU1A== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-51d981149b5so1286838a12.3 for ; Fri, 04 Aug 2023 01:49:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138979; x=1691743779; 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=KRPVroRlmHXN4VX278kBplnDZlNyl1nqcdlWpCBqqpDUPnl/ehId3jdUh6w0e3Dg2r asRgZhJE9Y5ZDh0XqYp8TQHjuGFt5jm8JqT0v1voybabmJnKSk1GmQ/eVWQ/ED+TFKZz ElY5+a83qzDoDrLFU6Iqn2WJoQLpufbaHWHqrIUapDjRXFczWLjxkJKwdZ+tjf9s4cjH Th9tJtg81c1uChqwg+oiCRNBjY6TNgEL8aVoETb5HtLoEX7FaKe3R50fVkUPgKNexmQm VX2lQllUer8oDAZ/rLY1XOuZ1+8nrswJP9/abkBrERLAhuTz0aURIgPYihml1fRdYw7z RifA== X-Gm-Message-State: AOJu0Yy6WYYnNRx9/pAhicuo3TmFLSt1o08jj84jZ07oTtlMX/k7eEp1 6YgUIsNjFcWhiJ0rXyUfadID6q0xPIx6+lu0+VslI5C5sjm4oCSC+57GcEroKYj/KkO2xXPBFGM iOIqisAjUyscBaw3BH+XmGnsfCRYavxypAvyHy8BbKmE= X-Received: by 2002:a17:907:2c75:b0:99c:331:4194 with SMTP id ib21-20020a1709072c7500b0099c03314194mr876524ejc.45.1691138979382; Fri, 04 Aug 2023 01:49:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IESWXoXKkpSChoFK7yg9A+13bbRcRctLrscoYkM2GH7k6ZkVluHa/bbcpxuaBSQemmgRG6ytQ== X-Received: by 2002:a17:907:2c75:b0:99c:331:4194 with SMTP id ib21-20020a1709072c7500b0099c03314194mr876517ejc.45.1691138979203; Fri, 04 Aug 2023 01:49:39 -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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49: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 v9 06/12] ceph: allow idmapped getattr inode op Date: Fri, 4 Aug 2023 10:48:52 +0200 Message-Id: <20230804084858.126104-7-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 Fri Aug 4 08:48: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: 13341483 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 981FDC41513 for ; Fri, 4 Aug 2023 08:51:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229921AbjHDIvP (ORCPT ); Fri, 4 Aug 2023 04:51:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229657AbjHDItr (ORCPT ); Fri, 4 Aug 2023 04:49: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 5768049EE for ; Fri, 4 Aug 2023 01:49:44 -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 099513F205 for ; Fri, 4 Aug 2023 08:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138983; bh=dyWOzKMsgYqMEu72C+uRJxx6NqzlAitmeRu8HoKY4M0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZNrOGyMdhSbUWaPxbXUByW//QlkHyWsBSHBkmnrqa3XJTaf36P70SYs13RwxBQjfL P91uMcwmComDokDVOQD+cay0H8FtpsC4biBcP6F2zQWxSCXAorcwGa3/mJ51Z+AbgN wzgyltI6rAhU2ZDVa725rhxeHcWQ/O6sf1f0EsuabKLjEdR41UUJ8KRqJaKhrhWccH 2dcV6sL+UlkDfICjPqy/EHucmZJzEFIaPhcyBssOEsKoTt1zMUmZxWihmzqeqFuBEr ya6kzfN9mjfrPgZk2WhN99jGFC7RHIS+SRH3FpWc+BZ+yC8HqjBWIAb8RZjjKm6S18 NGmSyevmIfstA== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-94a34a0b75eso125083766b.1 for ; Fri, 04 Aug 2023 01:49:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138981; x=1691743781; 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=VeckfOE1XShkogX0db6nxb8c+ukbLcKgQlPmjNxIZz/HfiB2g53iMFJs3Gb9IiEmwI LyIsNsdBIbwxNrRcbSr28MDtEnMHOmA11n4/zHSNeJWzEA92wuN2Up2yK0J7a65EYO45 f8aAPi1mL98WnmdQvUAIpgYOIsfiSooUkVm9QGQFcHRbMKblJ/o7d72Q+hqiuIRen/zB DPjiT7sXFpYo9tQTDWjOFTbib7hsWtGSS/b55jjN+vVKaht8dZvXGAJgp4cDGvJjR6Js Y7Nx1S3/z9MYmXEKc70f/X+8eshVq1lCBmB2menhNAcmekujFvH+KChrtZ/2+B4fC8vK eSNg== X-Gm-Message-State: AOJu0Yw8kkK+E3tG6pkNjEdtXcMotJ4t6EBPsZuWYNEFsDxBWuY+IQ80 8zRzBzU9WFiJHlLs28BYwjw3CatocnXT7B/pYqo+4pQ34S+W/uWHOd80KTiqirdJIBzNJxd2cGA 4baOOTIdMuTWbr8F5foFULOXs91DZfgy8hsB75p5vykjnu5EmWNQ= X-Received: by 2002:a17:906:1045:b0:997:e9a3:9c59 with SMTP id j5-20020a170906104500b00997e9a39c59mr1098704ejj.6.1691138981178; Fri, 04 Aug 2023 01:49:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH95AAsx4OwruricX0LBMySZoccvHc9K7IbrBk/rcTzsxclDEI57KHtgRFatiy3JlDtPKgKBw== X-Received: by 2002:a17:906:1045:b0:997:e9a3:9c59 with SMTP id j5-20020a170906104500b00997e9a39c59mr1098698ejj.6.1691138981036; Fri, 04 Aug 2023 01:49:41 -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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49: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 v9 07/12] ceph: allow idmapped permission inode op Date: Fri, 4 Aug 2023 10:48:53 +0200 Message-Id: <20230804084858.126104-8-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 Fri Aug 4 08:48: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: 13341484 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 D0787C04E69 for ; Fri, 4 Aug 2023 08:51:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbjHDIvR (ORCPT ); Fri, 4 Aug 2023 04:51:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjHDIts (ORCPT ); Fri, 4 Aug 2023 04:49:48 -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 259F14C04 for ; Fri, 4 Aug 2023 01:49:45 -0700 (PDT) Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id E03434248D for ; Fri, 4 Aug 2023 08:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138983; bh=nLZMqtT0BTuD0r3ld9T+VcVOIz8LP+RVDN6gyhT7tPs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kPXWFDv4IaWNdstC8tRD6ftykQZ0hcsdvqVN3fA48GNJBDTmBaxh4X5ucm/Crxo7w 3xWVR9TV9WLcHPqVmXHFe858m1qWaIAuifPvsWeUFi0Rt0yrx32vkzItQnu/m/1th3 8+XO/a8mdmT1XO2gPYgHjMUP+8aR9VHL1kRLfvcr6lEXprQgQU3dDJ93Ts9s4Ueel5 xIyW6+xmKOaWIBLNeWAhQSywywqMM+VnxLbB4AvbwOu5NiNwh45BhMjLUk9NcxCnJ6 MRr980wphPQX2bl7iE67KCRSLYcokPTy/fw5OwOBS11QppxaFFln/o+P2Tqbms3eCu Sg9HBS+RvHg6g== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-99bc711a20eso132903766b.1 for ; Fri, 04 Aug 2023 01:49:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138983; x=1691743783; 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=ZSO4LttLLns0I33m2TJv82gMSBPhcYyhpTS1eQjfMyu4XBC1OG4K8fwAuUejJtKXUY RY5y/sI+YR6j6cKUyrrueQHVJiCDoC9vxzS6UUAPKnyb/k1iwVdP5HknmGI4fOyDw7OF 1TPAFspR336VNRmKwvMXzvQ6T0kBr2ceG27bxFkO/MGdx1RlnDuFYR5XXY+TWtKNLJ/T 80vrJNMe+gUuK5NkBSkHK4IfZ69BPrU7Q2HJoD4thzvBe+6y9wpJ5MNJ3+nqOmqJLzzw p0OatcfxJeJQKRXpn3fox7+br99VGaT04LinYDurp3PE7NHWEiTw8XzDYoJ91MRw5ytU Jf9A== X-Gm-Message-State: AOJu0Yzod/BptndhMrmlUVKiBuPNeq3apgACSPCvQ2Iam7jZN/7xgAPz rSww3Y8kI0NevwphntUmrFNflJYgbirZ6Tt6ExTgUXL65ZPvNDsHeadAiZ6fJxgHD99m7poh23j pxbHP5Cv05LtyuWCzSaoKjS7aJKg9N60E9sO7p8bPvBc= X-Received: by 2002:a17:906:3002:b0:99b:f66a:3189 with SMTP id 2-20020a170906300200b0099bf66a3189mr1057460ejz.8.1691138983095; Fri, 04 Aug 2023 01:49:43 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHYz1ENmxKq5uJlqK2BTiCUQ/3Q6puy0cdofBV5YjhsVwU4EydDgdIUCcgv/xVB11YsU0I69w== X-Received: by 2002:a17:906:3002:b0:99b:f66a:3189 with SMTP id 2-20020a170906300200b0099bf66a3189mr1057451ejz.8.1691138982931; Fri, 04 Aug 2023 01:49:42 -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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49:42 -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 v9 08/12] ceph: pass idmap to __ceph_setattr Date: Fri, 4 Aug 2023 10:48:54 +0200 Message-Id: <20230804084858.126104-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 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 Fri Aug 4 08:48: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: 13341485 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 71934C001DB for ; Fri, 4 Aug 2023 08:51:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbjHDIve (ORCPT ); Fri, 4 Aug 2023 04:51:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbjHDItz (ORCPT ); Fri, 4 Aug 2023 04:49:55 -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 690924C01 for ; Fri, 4 Aug 2023 01:49:48 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 456F7417B9 for ; Fri, 4 Aug 2023 08:49:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138987; bh=CQAHRH/ms/cFOl3S4jtiakCJJYzaMB08Yq0KPV8/UVY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dHCinPhIwLfckZkFU7tt4yPZR4kmCSgq/DySlrKITX/xaRPrdWkOudxg4LcEbYLVa AKxThHX1/+lsoaoaEARPNEy39iIUUVuDPr2P6wKyl5VJhcsHw8jBX3h68kqLcfPnzJ s/++6LuUDGkU7JlMDruW6fy727ZYasa9yZBgK/rQ4kWfSjsWmM9D6cVsNECsUYZr7I 6ZJRd5O3GUJIL/9qwP6+ieqRPFK8h0v5Qh1msWe/eNKGYa94jKk+e8yIHudosB29jO OEKaQXbxgrWFZhyycaU1O2NHE/oaUY1BNRxRHI4JQDv0nCYU4nhHdRtRZg1HIkOK6k tNN6dV0qSDz2w== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-94a35b0d4ceso122137666b.3 for ; Fri, 04 Aug 2023 01:49:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138986; x=1691743786; 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=Ti3lkOj7aCEf1f1EK9UnA/Ohva/UoVJCNtupL4ZOVpNxYRlECZOBIIrntpwBnJFVyj k/fN4ozbmwwsPhZt0EA0QZDDnfBTGtEtl3WUGzYDygtJ4HmMcolwm8H6b306+1MTeUxJ 5KnjGSoGmRyaBvaxwEkLJ1i0Vqg6mdpwlUYQzM2Tjd0GNiXcPUphYtlYRhMwhyrlrjdq 7IByMBvvgRxG5Kangr6I+IN6ecOejCyMd1WSfmMFWrD1nmlyppShoSbE4VG91AsVN6rg NxKJec9KEaM7AASwrqfCvBHhLA4XnuxrTFrNC4gwtbrj+yIe70meB2Is+ftrbdYEZsiI UHlA== X-Gm-Message-State: AOJu0Yx75KCyxVcwUD7SbPYN7n2B1vqdwz1lmY2pVSzZ/wOqj9+qS4MK H3q5neWX/EdY75Q6Gbpt/Ky1TTw94+0jaxKhAK5toboZpfFLoJ0yO90vslHPLEiGSwDhCA5gB6W d80K39ytybbxT2GLss6PmaN3vBK+E3nbA/yp5LcgFeO0= X-Received: by 2002:a17:906:7494:b0:99c:4b70:4d6a with SMTP id e20-20020a170906749400b0099c4b704d6amr934857ejl.63.1691138985975; Fri, 04 Aug 2023 01:49:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVvZo5HsarBNOVycY50aKC5Clr4BW+jwzyxSFJ0XsHAbQYXZZdVEQArwzBO3xTW2T0oLqbNg== X-Received: by 2002:a17:906:7494:b0:99c:4b70:4d6a with SMTP id e20-20020a170906749400b0099c4b704d6amr934851ejl.63.1691138985538; Fri, 04 Aug 2023 01:49:45 -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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49:45 -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 v9 09/12] ceph: allow idmapped setattr inode op Date: Fri, 4 Aug 2023 10:48:55 +0200 Message-Id: <20230804084858.126104-10-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 Fri Aug 4 08:48:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13341486 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 6F3CBC04E69 for ; Fri, 4 Aug 2023 08:51:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbjHDIvg (ORCPT ); Fri, 4 Aug 2023 04:51:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbjHDIuN (ORCPT ); Fri, 4 Aug 2023 04:50:13 -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 DC50930EB for ; Fri, 4 Aug 2023 01:49:51 -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 4F6063F205 for ; Fri, 4 Aug 2023 08:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138988; bh=ARhwDsiPa3Ci/G2xteJutduXCGuj42UUR3o8sfJhjpo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tB0vkqV4+JXkkhN8K0zglXZiN0t1WkUTs/obTiAROq/xYXjQ2vQ8AVSb8fmIHaOPD RaKWuVVpSIZRBxRj+BpAnhcco5unBlCDFk37eSSFt55Xjw0+d+XAb51pM3ILQqOHSH 4PFu2jQ3CWODiVjsiV4z5b9Mld4hkzJBAvzMHe96Q3V9YUwIWywNXniVteOK80X2IN HRiaEsRS3aUG0usPlKSbw841deTUDGgujOBXHxnrh+WFe2sI0d05mD4+ed+hR7kVgJ jS0V2dpmIxuKgyYHVNfge1KPucGyOBQ/EQqwpJU5/DesBgoiovARzzImp4fHgAk0Os 9TQmtLT60COMg== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-99c03869a67so124527766b.1 for ; Fri, 04 Aug 2023 01:49:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138987; x=1691743787; 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=Gz51yg3AZ/0Ld3Yt4qBpqnXCWP13W+3wpo88wdlZL6R16fzL1PDq8gTiOlINaSU6D9 z+J0XTUKd4WkeoH3/qvK4DH8nb2hHdmg0Lk1XdaN04zXRMqRQO7fG3uylJmavW8Ao4bL E0CbBzKdN/9Utf3pJxTgca6bsE56N33YTy1PuQyYwJ19j+qwg0tXWEBKgv4VjJK4GTCs Tu2gIUJBt8FRiOmEUWMMsUHUEMJ2ZWyReqGLQrNK4ULE6WSz5AIWTqFFzv41H246Irpy XJtjtxRAdJmJtDs5/AWKcPK/FS5ML93zt0o5MMMNDByQ7jbEVaTlCjwzUiXM0V8Bf8fE 0i3g== X-Gm-Message-State: AOJu0YyvPr1/0czx1eT4I+72WkcCNhkp7dOuypcqlDHpWKwJwEMZHgyp qNyylL/0IC0ni/+VFri9bczbZqbFoua4JuAOI8BerqJo+f97npFHZYS+lFbaLL6mPbi31T1x9B4 ac74V+TDUsOHlTcuPv0khSPZ0YRnihPH922CcmZc/jONvKcXQ2h0= X-Received: by 2002:a17:907:77d0:b0:994:5577:aeed with SMTP id kz16-20020a17090777d000b009945577aeedmr995719ejc.5.1691138987400; Fri, 04 Aug 2023 01:49:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFij2ZN/HuBWc4Nu5STOSW9BVGSH6Wz3WtoLMx8eDAi/KUmbdzucsXu/L2vGnsUCM+iyzwOrQ== X-Received: by 2002:a17:907:77d0:b0:994:5577:aeed with SMTP id kz16-20020a17090777d000b009945577aeedmr995708ejc.5.1691138987251; Fri, 04 Aug 2023 01:49:47 -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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49:46 -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 v9 10/12] ceph/acl: allow idmapped set_acl inode op Date: Fri, 4 Aug 2023 10:48:56 +0200 Message-Id: <20230804084858.126104-11-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 Fri Aug 4 08:48:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13341530 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 5CFACC001DF for ; Fri, 4 Aug 2023 08:52:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230010AbjHDIwM (ORCPT ); Fri, 4 Aug 2023 04:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229840AbjHDIul (ORCPT ); Fri, 4 Aug 2023 04:50:41 -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 B12A449CB for ; Fri, 4 Aug 2023 01:49:52 -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 8C1CD417BA for ; Fri, 4 Aug 2023 08:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138991; bh=3z9qgb9ifPvjMsignbqopXQPiRZw936kb1zQwGNpHt4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OV7Xk6DYmrC9Bf1PfSJ4bhX+xzNohrVjBEnPx6DGl++fVi2DA4kX01J21rPhi8tnT dmmF9krrAGvvYsxjH4WxtthhYci7J7fbg4bW6VtmPeFL/DGZe7Ir4s1+pIt7e39vNv BGNzDqTGOCMpRCg/R0uIlC4jaijuJ/wSIMDYeeb0Klli9w0ufYAABWRzs9xX9lMVQo IQni/E9ysiynKJT6a1nuozBVITP+kO2MGgCTP9RltVG2/ruvZ0UwAxd9BYoqyx1AfE W7hEU+au3ac6T5VI0pTdwhP9bcVW8DsTJ+pBALN+8yru3Sfm+h+DORYIla3EIq3FlJ zV6qxwS1sy+mg== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-518676b6d09so1290084a12.1 for ; Fri, 04 Aug 2023 01:49:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138989; x=1691743789; 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=C008urClSf5C0vbheo7ovgq+BGe6k77IBSZrwlywFugW78vZDatYGvuvBlZzYFvzud kLCPOXPTuj9CcjHYjb1FBOkdmzjBZcW3EhEObS8mQJfPrpwKiE72SF9676BwviQLQFai uUTMXED2bcTkJJ0L+PhfBjullG47kUs6X1/bVfamUEfpHANqSSes72NlRh1RB0EB/N9K 9mo0MQZhMrZsc1+gvZf3lBtrfjWbik8CxCFVeK66XnggPboIkbC/ycQa0orsfctZu8Fg HgEDyn8MA1+AEKwL/P0kvo0oYs2CuI/G9EIBeH/sYrA9o99MTlaaUr8x6JoA+4VMDBWG vNzg== X-Gm-Message-State: AOJu0Yz7vXrka7pCPIe5itnRxvUPM+ctkK5NCF9Y5HBtzBj42nYRDlO7 jqVEATdowIfMOdv9XucgX4xfKWtXt3xFsSCFg6/jTvEkTj8taWdFFrpk/FxSlZBPuF8G1cBjFuK L2MaEdY61MWOqa4yXlI1rI/lSX5t5rkJVgwZdAKRy1HKhBFXVT0c= X-Received: by 2002:a17:906:76c8:b0:99c:524d:5052 with SMTP id q8-20020a17090676c800b0099c524d5052mr947632ejn.0.1691138989328; Fri, 04 Aug 2023 01:49:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGTym5TfzlHG1lZSavhyqmoZ0wMSQV6UssfY2G4oAk1V8i7SJ+uZP+Mld/WvvtmdYlgx9LngQ== X-Received: by 2002:a17:906:76c8:b0:99c:524d:5052 with SMTP id q8-20020a17090676c800b0099c524d5052mr947623ejn.0.1691138989153; Fri, 04 Aug 2023 01:49:49 -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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49:48 -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 v9 11/12] ceph/file: allow idmapped atomic_open inode op Date: Fri, 4 Aug 2023 10:48:57 +0200 Message-Id: <20230804084858.126104-12-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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 Fri Aug 4 08:48:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13341529 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 45709C001DB for ; Fri, 4 Aug 2023 08:52:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229743AbjHDIwJ (ORCPT ); Fri, 4 Aug 2023 04:52:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229835AbjHDIuY (ORCPT ); Fri, 4 Aug 2023 04:50:24 -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 493CC4EDA for ; Fri, 4 Aug 2023 01:49: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-0.canonical.com (Postfix) with ESMTPS id EF3454421A for ; Fri, 4 Aug 2023 08:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1691138991; bh=4z/daiO88HhZeOEnY3F9QYhLlQO1p3UrY3NiyEq1U7U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EyZI9tm/ie9SLrIP74WTf7r0qW2ki2tXuHU2LF9h8Tt1OZG3guyFwioLzVwQzhTJq nqxyYs9XZK2ubfL+6kbcYYjFN+Bk9/LymL3i7v2L9C+INNf8ILHrrMAQY2UX8YOpLi rtlyWaLonpBbQuXvn5ISQBKg/awAQ2rYB9z5wwWA9HoVMc2XkEDKXEJMRzMmhr41Vx ot58a9Ivvp3UivJ5iT8AxeEIAI7TJGzfaSm6HO0mTVmJS9z438aUuj9gH7XVr6q/Zf l7+tvB3vzMjbgXl/lEMounq0rwUPvLPBuUq0b+8y9JcpwLqUA1LgHMNMgqlHMTWYKg XAwkCZwHU+4CQ== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-94a34d3e5ebso124427266b.3 for ; Fri, 04 Aug 2023 01:49:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691138991; x=1691743791; 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=MXdLITlZHc8hgoaCDb5i/wGXyg1qQ+2aMvTYA110VMPOqAu7S9ElpLrIJ9a8yd90SN 7kJMdg3CTQzXeduowvnhS08Bga+cS8cMsbz9hkyeEzbs/6261vhd+1+9H61AYjOk1XOp 0pT5be1aKCleiBdLXtkVhZy6k718W8SVyIstzh6c03v4jtC+7+VUWhV3WGSBS21nJFKi nfq4RQEcTm6sbeVNYHAdW8BW3wsftgjkX8IE1fJfXu4akjQB2/SyGIVo8uASGJlUT5uH lCkkiJCIqv4s9KFKCMFNWA76JsDRysCHpPO/h+Av54aOTxJidRIfhlkCbi1mwhM140Ku aokg== X-Gm-Message-State: AOJu0YzhbFkMGkHmb4ZKcU71BOlHmEGwWTxQLd9mR/6khRdwe65gRiVk E7PH0GVrDzf4QnQI2eXi3Z76RdKikvXkUV4jtOz7RS/fFY+Bwl+cMGW0sEgbQ4Xnqu8VkdQLYLP meFGuE2wKw9+Syw+j/IwaKuI3PzSGHpj6Mjlz4JrstpM= X-Received: by 2002:a17:906:2cb:b0:99c:ae35:ac0 with SMTP id 11-20020a17090602cb00b0099cae350ac0mr32347ejk.61.1691138991754; Fri, 04 Aug 2023 01:49:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdh2YBW+3zSthygL5eMI53A2dql4TVwWtXDEJAl+omt1I6HfFzDgF/roaG3QRdDVBhhechfA== X-Received: by 2002:a17:906:2cb:b0:99c:ae35:ac0 with SMTP id 11-20020a17090602cb00b0099cae350ac0mr32336ejk.61.1691138991574; Fri, 04 Aug 2023 01:49:51 -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 k25-20020a17090646d900b00992e94bcfabsm979279ejs.167.2023.08.04.01.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Aug 2023 01:49:51 -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 v9 12/12] ceph: allow idmapped mounts Date: Fri, 4 Aug 2023 10:48:58 +0200 Message-Id: <20230804084858.126104-13-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230804084858.126104-1-aleksandr.mikhalitsyn@canonical.com> References: <20230804084858.126104-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. 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");