From patchwork Thu Jun 8 15:42:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272484 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 0CDB6C7EE37 for ; Thu, 8 Jun 2023 15:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236598AbjFHPn3 (ORCPT ); Thu, 8 Jun 2023 11:43:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235623AbjFHPn2 (ORCPT ); Thu, 8 Jun 2023 11:43:28 -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 239582D65 for ; Thu, 8 Jun 2023 08:43:23 -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 499A03F13F for ; Thu, 8 Jun 2023 15:43:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239002; bh=GFNwWvhavDkNrI4eqwez7OWrv+w+Iw1WNhnwQW/Fw7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UzQqOx/afwCY8VI7jYOfHqsG3g9AVlJgJZrZiw8W31u1LIaM5ZO3c3sIih6wUZdvL aUJOtvvV/BzsqfdtD8fMYU7OydbrFS3KVcFTISZxG1fhBHiH1sqPutGP639xOflx6s 7bMnbHeeZgRHPzp3QhecTonM6svuXatBNkkZuwh0C4derx9yZrHVjoZui/LhGzRpdZ e2FkLjc69ONX6Ua/7QWEjoC8MVWlD1JZJZLkGMskZdhdHUp4WwoRaKEPLTEJikKYLV oiR9HKK/zNktk7/jkFK565WV4zqyqw2/8QGZHoTa69OOclTFoHl+zejc7P/6fgA/A8 M0YvudZojkP5w== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-513f5318ff2so754117a12.3 for ; Thu, 08 Jun 2023 08:43:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239001; x=1688831001; 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=hUIQVaj7y4ELRiWZl9uRFHO1xK0V6aVaZ871LM+Rmh7nYh2hKF/lYnyZNFSlg1NVTR ApE0CSJlL7C4m0mf1dm5koXifwuycDulDuJDGr3DauE2zw6XVbwgaDuf3vmIE39p+crn B5NlAyTvYaXVgEIE0DPUvis/CAxGvLyWcCOAQwjwk8dvtYhvEUWXyN8/dAEpNi0BKa4w wi17B0W8et9l4qx8L2sszjtyPfoyceK/PSs9eMWp75dyf9wlO8RDS8y0Y9h+OvjtSxte pp7s7mqBVU4I4ZIQng3/3VB6Iqb4L0tTF/ahFl88GnTV205gE+a4or7Yxnzt1+yqMdaT WmsA== X-Gm-Message-State: AC+VfDwSAAq3gOfvVwtcirtMNa0KuNUor5oFnudYztchXlO4p00o2n4h 55YAbOP186XEsjFoaf0rMQ6ccJ0gmllFZSD9KVyUZp3xT4+nP9VlDqjcVd6TWAF7iv2ufh9uwi6 p8Q5In1/4eyCUaP9aNDhe16ziPhcZQIbarUxVexs= X-Received: by 2002:aa7:c48f:0:b0:514:a4b9:d76b with SMTP id m15-20020aa7c48f000000b00514a4b9d76bmr7147032edq.25.1686239001446; Thu, 08 Jun 2023 08:43:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6D65qutYZn/dsggFwwsDjY8pGikammSJwWJPaGnVmVUjtpy9lSBHuLU5+l7FJU+gbu4LrgNA== X-Received: by 2002:aa7:c48f:0:b0:514:a4b9:d76b with SMTP id m15-20020aa7c48f000000b00514a4b9d76bmr7147022edq.25.1686239001194; Thu, 08 Jun 2023 08:43:21 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43: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 , Alexander Viro , Seth Forshee , linux-kernel@vger.kernel.org Subject: [PATCH v5 01/14] fs: export mnt_idmap_get/mnt_idmap_put Date: Thu, 8 Jun 2023 17:42:42 +0200 Message-Id: <20230608154256.562906-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org These helpers are required to support idmapped mounts in the Cephfs. Cc: Christian Brauner Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn Reviewed-by: Christian Brauner --- v3: - EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL as Christoph Hellwig suggested --- fs/mnt_idmapping.c | 2 ++ include/linux/mnt_idmapping.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c index 4905665c47d0..57d1dedf3f8f 100644 --- a/fs/mnt_idmapping.c +++ b/fs/mnt_idmapping.c @@ -256,6 +256,7 @@ struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap) return idmap; } +EXPORT_SYMBOL_GPL(mnt_idmap_get); /** * mnt_idmap_put - put a reference to an idmapping @@ -271,3 +272,4 @@ void mnt_idmap_put(struct mnt_idmap *idmap) kfree(idmap); } } +EXPORT_SYMBOL_GPL(mnt_idmap_put); diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h index 057c89867aa2..b8da2db4ecd2 100644 --- a/include/linux/mnt_idmapping.h +++ b/include/linux/mnt_idmapping.h @@ -115,6 +115,9 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid) int vfsgid_in_group_p(vfsgid_t vfsgid); +struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap); +void mnt_idmap_put(struct mnt_idmap *idmap); + vfsuid_t make_vfsuid(struct mnt_idmap *idmap, struct user_namespace *fs_userns, kuid_t kuid); From patchwork Thu Jun 8 15:42:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272485 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 1FA42C7EE25 for ; Thu, 8 Jun 2023 15:43:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237129AbjFHPnc (ORCPT ); Thu, 8 Jun 2023 11:43:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237142AbjFHPnb (ORCPT ); Thu, 8 Jun 2023 11:43:31 -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 16D0426B2 for ; Thu, 8 Jun 2023 08:43:28 -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 CDCA23F33C for ; Thu, 8 Jun 2023 15:43:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239005; bh=PnimYtsU8L1wziru+PbLo9AAv92Qytxkfm0LOSGrer8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CvTapLYwYU6+j2zGj0+69m+ot7YodTRJ+5pzKEZRV6XeT1aosffwoPehZ02vcDQRA RML6lROgrl1CU6yaW2asSOLM1CElbiwc6P2OvnAzbejPVlHzTkqa8edhXJ3rzX8Xsu tHkNhB6+IqH+W7qYuYtThZ+Cv0+WS8bl/JW3yxhqwCTo2B8a/NgyoR+EjhtriadnoQ NmhrJpGM/hoM41o/0a5HCLaqHhyf7MIuRWG9yVne+/dFxP3/cKZoXF3DEvvTMeQJlA 7fYCXSvQWrb9IZKTHUKfeb+OYtZpIC7nO4g3hKR4vyxUI5t4QQQrv20/cDEeIfv5I6 AalCJMAJiDdSw== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-506b21104faso766572a12.1 for ; Thu, 08 Jun 2023 08:43:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239005; x=1688831005; 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=PnimYtsU8L1wziru+PbLo9AAv92Qytxkfm0LOSGrer8=; b=ZKxoBEH/VuxAEzNY+VJ5ydmqy3AtkGwMTD+yo0GBH2DEJ7T6B3vieVb/cPU2Ym8qRt 7rGH/qaH4foOtivNAeGn1KCVX7M1rl5rNUVfVnMesGUwBs/FH+XT0i61mol2nk9mSkFC JR5fXdiD5n8yT+dko/XueBRcr/DGsObQAQys3bGdJCZxdL3LAU72aLw/sBlsNmA42g0D Sk5JdjTBaNkucIs1ckfnoRK/KJbMHmBWIswDsseN7c0HQ550wEloXfpDswqnIr4oRNrW vVsuBPpNf4liKczHuaxh5RGlhPE9yuEcOjpl/SGLcv8MmRxYu4M/v17SIRYYCDT/Anba VpDA== X-Gm-Message-State: AC+VfDyvObrTESmXz55FkcU8U2kb0NKZUpU1i7vHF6eUFyoyecDly9zM UHKfBYjxHy7ow8/3pWbkrLwqJ0T7F02oVKnq9i5ER4aAT5TeABGwQyNR2hkDnJHCAZczLgRZKNU UCHE7AEtqvLCl2MLb2Yh3nRotLlpK/7SsZNTAUrMNee4J/v8= X-Received: by 2002:aa7:c30c:0:b0:514:9e61:e7b8 with SMTP id l12-20020aa7c30c000000b005149e61e7b8mr6336301edq.40.1686239005206; Thu, 08 Jun 2023 08:43:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ428Ky4b2SF1PG2wMyWsEazOGW/rlbctHmYfe0//BeE4mQV4gnb+YnP44CwXFQOVf1dkIVDfA== X-Received: by 2002:aa7:c30c:0:b0:514:9e61:e7b8 with SMTP id l12-20020aa7c30c000000b005149e61e7b8mr6336286edq.40.1686239005041; Thu, 08 Jun 2023 08:43:25 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:24 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 02/14] ceph: stash idmapping in mdsc request Date: Thu, 8 Jun 2023 17:42:43 +0200 Message-Id: <20230608154256.562906-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner When sending a mds request cephfs will send relevant data for the requested operation. For creation requests the caller's fs{g,u}id is used to set the ownership of the newly created filesystem object. For setattr requests the caller can pass in arbitrary {g,u}id values to which the relevant filesystem object is supposed to be changed. If the caller is performing the relevant operation via an idmapped mount cephfs simply needs to take the idmapping into account when it sends the relevant mds request. In order to support idmapped mounts for cephfs we stash the idmapping whenever they are relevant for the operation for the duration of the request. Since mds requests can be queued and performed asynchronously we make sure to keep the idmapping around and release it once the request has finished. In follow-up patches we will use this to send correct ownership information over the wire. This patch just adds the basic infrastructure to keep the idmapping around. The actual conversion patches are all fairly minimal. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- v4: - don't call mnt_idmap_get(..) in __register_request --- fs/ceph/mds_client.c | 5 +++++ fs/ceph/mds_client.h | 1 + 2 files changed, 6 insertions(+) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 4c0f22acf53d..05a99a8eb292 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "super.h" #include "mds_client.h" @@ -962,6 +963,8 @@ void ceph_mdsc_release_request(struct kref *kref) kfree(req->r_path1); kfree(req->r_path2); put_cred(req->r_cred); + if (req->r_mnt_idmap) + mnt_idmap_put(req->r_mnt_idmap); if (req->r_pagelist) ceph_pagelist_release(req->r_pagelist); put_request_session(req); @@ -1018,6 +1021,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 724307ff89cd..32001ade1ea7 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -280,6 +280,7 @@ struct ceph_mds_request { int r_fmode; /* file mode, if expecting cap */ int r_request_release_offset; const struct cred *r_cred; + struct mnt_idmap *r_mnt_idmap; struct timespec64 r_stamp; /* for choosing which mds to send this request to */ From patchwork Thu Jun 8 15:42:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272486 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 BDB1DC7EE37 for ; Thu, 8 Jun 2023 15:43:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235668AbjFHPnp (ORCPT ); Thu, 8 Jun 2023 11:43:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237155AbjFHPnn (ORCPT ); Thu, 8 Jun 2023 11:43:43 -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 CA2E92D74 for ; Thu, 8 Jun 2023 08:43:30 -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-0.canonical.com (Postfix) with ESMTPS id 195F83F14A for ; Thu, 8 Jun 2023 15:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239009; bh=MVopSiFXJtuCZDFmw4k6EoX9EHPj+DJ/m9lrNV/HJJI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JWdaS8R3Biql39BOapnIA4ExxbHPU42lNZA3icuDXDdH8D8EG2AWOPhiNIMZi90Bx /KTTieD2fAkKQ6jUwEXtn3PqveQc78LM+jR4k3X456qZ/8ezTkRD5DiLqtAVkYQ71M 60DJBH2xhvn3z70XvH3rSXV1sdE1BE1PtzbXhtivV5ICcvbdjwtC0rZN5Wgv5fplHo w5bEZEP8DFPL1RKQmu3Ho5GBV3PI+ggGzj3dS3IcIuqog9QWJ5K2SR1WplivRuV47a E6Pk1KcPiYsi7wffaxKsXMjWbTfCv6407UdjnkIFcwvey/jpPrUZI1t/HhhBKF2vla 7LOdcyS+Lx0Ow== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-51664cc4c07so756456a12.3 for ; Thu, 08 Jun 2023 08:43:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239008; x=1688831008; 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=MVopSiFXJtuCZDFmw4k6EoX9EHPj+DJ/m9lrNV/HJJI=; b=dqOwHLr/qSsMXWhuyo4hHob3ei9Q/o87oVTAC8msyaHzm+HGpzmqDWOMxQni+6M/hg BKUE1+UjZNtXGftISODdP9ZkA2ML150RQgUhrs4aiPqinwN7Z/aGtzH0iHo89QeW9rSR VCWhSq7TLdc9xtVK/jGjju4tdLmero0LUT5xNG3pznfswln9uVgXnQe/3HlDZgPyYvqM V3KCn76IsvI70FbddBkAwfmP73XQzst0ypBhCaREsSdh7EcWQnz/VxNu2T1+rN8EQGRH MQrUr5SNuHOpn2krh5OjyVsbU2XvQ+bZUYObx8Wb1Mpj3fILi2nlLU0mfTKzm2O4KuUh OJLA== X-Gm-Message-State: AC+VfDxKDHp+yw+vFRLHdr70lE4Wfgqs/r799RopEpseBKMETKFPmQYI qASxUmHUq9gOmfgD9+fikp2Esz/e8UHIHPaX2Cr2Zki7++fddZK1SDs8MPA/tgO+zK75/gDUw6R ejdBja67OWSq1pMCwUwCTr3AhXlszk15zGUX2XKg= X-Received: by 2002:a05:6402:1218:b0:50e:412:5a50 with SMTP id c24-20020a056402121800b0050e04125a50mr7251914edw.29.1686239008688; Thu, 08 Jun 2023 08:43:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6aHZ5F2WlbAZXf+JA7fUchj6Pwo85kKEqXk5pWSEZo0h3QxyhCK3FkPsP0UU6edRHkd19sAw== X-Received: by 2002:a05:6402:1218:b0:50e:412:5a50 with SMTP id c24-20020a056402121800b0050e04125a50mr7251892edw.29.1686239008441; Thu, 08 Jun 2023 08:43:28 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:28 -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, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 03/14] ceph: handle idmapped mounts in create_request_message() Date: Thu, 8 Jun 2023 17:42:44 +0200 Message-Id: <20230608154256.562906-4-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Inode operations that create a new filesystem object such as ->mknod, ->create, ->mkdir() and others don't take a {g,u}id argument explicitly. Instead the caller's fs{g,u}id is used for the {g,u}id of the new filesystem object. Cephfs mds creation request argument structures mirror this filesystem behavior. They don't encode a {g,u}id explicitly. Instead the caller's fs{g,u}id that is always sent as part of any mds request is used by the servers to set the {g,u}id of the new filesystem object. In order to ensure that the correct {g,u}id is used map the caller's fs{g,u}id for creation requests. This doesn't require complex changes. It suffices to pass in the relevant idmapping recorded in the request message. If this request message was triggered from an inode operation that creates filesystem objects it will have passed down the relevant idmaping. If this is a request message that was triggered from an inode operation that doens't need to take idmappings into account the initial idmapping is passed down which is an identity mapping and thus is guaranteed to leave the caller's fs{g,u}id unchanged.,u}id is sent. The last few weeks before Christmas 2021 I have spent time not just reading and poking the cephfs kernel code but also took a look at the ceph mds server userspace to ensure I didn't miss some subtlety. This made me aware of one complication to solve. All requests send the caller's fs{g,u}id over the wire. The caller's fs{g,u}id matters for the server in exactly two cases: 1. to set the ownership for creation requests 2. to determine whether this client is allowed access on this server Case 1. we already covered and explained. Case 2. is only relevant for servers where an explicit uid access restriction has been set. That is to say the mds server restricts access to requests coming from a specific uid. Servers without uid restrictions will grant access to requests from any uid by setting MDS_AUTH_UID_ANY. Case 2. introduces the complication because the caller's fs{g,u}id is not just used to record ownership but also serves as the {g,u}id used when checking access to the server. Consider a user mounting a cephfs client and creating an idmapped mount from it that maps files owned by uid 1000 to be owned uid 0: mount -t cephfs -o [...] /unmapped mount-idmapped --map-mount 1000:0:1 /idmapped That is to say if the mounted cephfs filesystem contains a file "file1" which is owned by uid 1000: - looking at it via /unmapped/file1 will report it as owned by uid 1000 (One can think of this as the on-disk value.) - looking at it via /idmapped/file1 will report it as owned by uid 0 Now, consider creating new files via the idmapped mount at /idmapped. When a caller with fs{g,u}id 1000 creates a file "file2" by going through the idmapped mount mounted at /idmapped it will create a file that is owned by uid 1000 on-disk, i.e.: - looking at it via /unmapped/file2 will report it as owned by uid 1000 - looking at it via /idmapped/file2 will report it as owned by uid 0 Now consider an mds server that has a uid access restriction set and only grants access to requests from uid 0. If the client sends a creation request for a file e.g. /idmapped/file2 it will send the caller's fs{g,u}id idmapped according to the idmapped mount. So if the caller has fs{g,u}id 1000 it will be mapped to {g,u}id 0 in the idmapped mount and will be sent over the wire allowing the caller access to the mds server. However, if the caller is not issuing a creation request the caller's fs{g,u}id will be send without the mount's idmapping applied. So if the caller that just successfully created a new file on the restricted mds server sends a request as fs{g,u}id 1000 access will be refused. This however is inconsistent. From my perspective the root of the problem lies in the fact that creation requests implicitly infer the ownership from the {g,u}id that gets sent along with every mds request. I have thought of multiple ways of addressing this problem but the one I prefer is to give all mds requests that create a filesystem object a proper, separate {g,u}id field entry in the argument struct. This is, for example how ->setattr mds requests work. This way the caller's fs{g,u}id can be used consistenly for server access checks and is separated from the ownership for new filesystem objects. Servers could then be updated to refuse creation requests whenever the {g,u}id used for access checking doesn't match the {g,u}id used for creating the filesystem object just as is done for setattr requests on a uid restricted server. But I am, of course, open to other suggestions. Cc: 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/mds_client.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 05a99a8eb292..8826be3c209f 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2581,6 +2581,8 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, void *p, *end; int ret; bool legacy = !(session->s_con.peer_features & CEPH_FEATURE_FS_BTIME); + kuid_t caller_fsuid; + kgid_t caller_fsgid; ret = set_request_path_attr(req->r_inode, req->r_dentry, req->r_parent, req->r_path1, req->r_ino1.ino, @@ -2649,10 +2651,22 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, head->mdsmap_epoch = cpu_to_le32(mdsc->mdsmap->m_epoch); head->op = cpu_to_le32(req->r_op); - head->caller_uid = cpu_to_le32(from_kuid(&init_user_ns, - req->r_cred->fsuid)); - head->caller_gid = cpu_to_le32(from_kgid(&init_user_ns, - req->r_cred->fsgid)); + /* + * Inode operations that create filesystem objects based on the + * caller's fs{g,u}id like ->mknod(), ->create(), ->mkdir() etc. don't + * have separate {g,u}id fields in their respective structs in the + * ceph_mds_request_args union. Instead the caller_{g,u}id field is + * used to set ownership of the newly created inode by the mds server. + * For these inode operations we need to send the mapped fs{g,u}id over + * the wire. For other cases we simple set req->r_mnt_idmap to the + * initial idmapping meaning the unmapped fs{g,u}id is sent. + */ + caller_fsuid = from_vfsuid(req->r_mnt_idmap, &init_user_ns, + VFSUIDT_INIT(req->r_cred->fsuid)); + caller_fsgid = from_vfsgid(req->r_mnt_idmap, &init_user_ns, + VFSGIDT_INIT(req->r_cred->fsgid)); + head->caller_uid = cpu_to_le32(from_kuid(&init_user_ns, caller_fsuid)); + head->caller_gid = cpu_to_le32(from_kgid(&init_user_ns, caller_fsgid)); head->ino = cpu_to_le64(req->r_deleg_ino); head->args = req->r_args; From patchwork Thu Jun 8 15:42:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272487 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 7602DC7EE23 for ; Thu, 8 Jun 2023 15:44:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237195AbjFHPoD (ORCPT ); Thu, 8 Jun 2023 11:44:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236599AbjFHPns (ORCPT ); Thu, 8 Jun 2023 11:43: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 9A4FB30DC for ; Thu, 8 Jun 2023 08:43:35 -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 637643F537 for ; Thu, 8 Jun 2023 15:43:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239013; bh=h11FfWaHHNNtwvZRIcKn5zgsctxJ3ebjyEZJ//czxrM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C3odLjjMTnC4GmK2gIb11CBC+Ff1sl3Q7D6IborxstpXI29fuhqeRoJOOApGUj0wr o3I8MYSRzRcsg6EvC2X/mOVYS15ZfqQhAPwlZjgZ4ajgayBg4NVRgQ2f14doPD+/69 E3+ZAhfjRfUzm/FU33aS51EQTH1hVgCbWqG2y6n2RTN+5hstVQmVF0ZPzWx8AEwQ39 2RQ5CpOmglbEWkAAKoacfu9ILDHjzu0lRm3j8yp+diGwB7DlKn+sRKvBVLlvvERSdl 70dfTJSRoexuNjK3dHO4zharLWHnzwfZpGBcULI3MySFASSbrB2GVxacK883eamiV/ 0BzayAOKOgxsQ== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-514a4cfa313so774389a12.0 for ; Thu, 08 Jun 2023 08:43:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239011; x=1688831011; 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=h11FfWaHHNNtwvZRIcKn5zgsctxJ3ebjyEZJ//czxrM=; b=b9Vf8Z+Ewwz6piUD3AxwIkVLXtlPVc2KwnJhTwCppRxpge3uaWYXkXIOkn7QdxPnJE rz3PE6K9LwNpJYO1JRizlpdImB9MoonYc8D5MOM9+vncx8nIViBWe3Rx+aGvWYX0NfRx KyJ/kGy/xL/nADBIBuy/jQs3KAQCzx26nBK2jmx1DIOt+IoFqUQJeo16g46V+BxbSj0q 6WfOX7WimiKCAZesBPlDSca2ZFdA2lc5vH+1F0BI4chEKducQ4qb4gGjjB6VnSiIyAE7 TP1d6j+FK+3fLif/oMPAWI154PbMMOiGTpmUtZeHooWrJKqdV0ftZbCv8HmwuNJ1UXg6 yNlQ== X-Gm-Message-State: AC+VfDwEMzpZfXvm5SUHlgiPu0u8a3eF4YVv/lLenqOpgA4x5VWJYjcQ Y0stqyPZN+uqqRhq/SbpSlVyTx0EYpINJr4MphFb9Mp3ho8gGwXXxp+nBkNXtJVHF/dUuc0fLhA hyqTUdazYg1+GMcxe+4/SdUi8BSiMGfpiWMD7xpg= X-Received: by 2002:a05:6402:799:b0:514:a6bd:144a with SMTP id d25-20020a056402079900b00514a6bd144amr7678707edy.11.1686239011194; Thu, 08 Jun 2023 08:43:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ46MI6AGDMIKSmvYESXHXyqShI61cTt9qF9ZEPOi25XHZ18WeG4MWokNCW+1PIE0IeOqUiLMA== X-Received: by 2002:a05:6402:799:b0:514:a6bd:144a with SMTP id d25-20020a056402079900b00514a6bd144amr7678690edy.11.1686239010947; Thu, 08 Jun 2023 08:43:30 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43: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, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 04/14] ceph: pass an idmapping to mknod/symlink/mkdir/rename Date: Thu, 8 Jun 2023 17:42:45 +0200 Message-Id: <20230608154256.562906-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable mknod/symlink/mkdir/rename 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 --- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index cb67ac821f0e..355c5574ad27 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -884,6 +884,7 @@ static int ceph_mknod(struct mnt_idmap *idmap, struct inode *dir, req->r_parent = dir; ihold(dir); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); + req->r_mnt_idmap = 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; @@ -955,6 +956,7 @@ static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir, req->r_num_caps = 2; req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; + req->r_mnt_idmap = mnt_idmap_get(idmap); if (as_ctx.pagelist) { req->r_pagelist = as_ctx.pagelist; as_ctx.pagelist = NULL; @@ -1022,6 +1024,7 @@ static int ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, ihold(dir); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); req->r_args.mkdir.mode = cpu_to_le32(mode); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; if (as_ctx.pagelist) { @@ -1324,6 +1327,7 @@ static int ceph_rename(struct mnt_idmap *idmap, struct inode *old_dir, req->r_old_dentry_unless = CEPH_CAP_FILE_EXCL; req->r_dentry_drop = CEPH_CAP_FILE_SHARED; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; + req->r_mnt_idmap = mnt_idmap_get(idmap); /* release LINK_RDCACHE on source inode (mds will lock it) */ req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; if (d_really_is_positive(new_dentry)) { From patchwork Thu Jun 8 15:42:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272488 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 1B67EC7EE37 for ; Thu, 8 Jun 2023 15:44:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237244AbjFHPoR (ORCPT ); Thu, 8 Jun 2023 11:44:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237153AbjFHPoK (ORCPT ); Thu, 8 Jun 2023 11:44:10 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FA4D2D73 for ; Thu, 8 Jun 2023 08:43:44 -0700 (PDT) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id B259C3F462 for ; Thu, 8 Jun 2023 15:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239015; bh=U9FNme5iBEpufhowdmn6D6u4P9E81AUlwyvYSH4GMyo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nXEpBLY25uGlswDTSF7+yXtJxiY9OwrEtmJLmgwjg/Oo59EbJaUOK2vhQSm74loZa FCODoM1TQBmmbteEHWTQe9Uz1dPt/LrlOGThyjSmuUnXmmasEHCRSbUzriLZOHg80t onJim6o8miaXTgd7HqKRWVDJZgDD0nRQbxCS2kJYcJiBadzy8FVYH9cQRe/eG6Ni1I XPricqkktgfX0Wf3Xb44Oj5oNdWXWn2D3j1mjIlh1k8l8sZM3O7iCmgudltqPmC08J hF21HTH3zFO7TeKhLgLrH+xkni+D13q9/ayUglCR1i7j8oqoAYCeV8kUHVo67F4kyD 3TBtVQcuReAtA== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5128dcbdfc1so758529a12.1 for ; Thu, 08 Jun 2023 08:43:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239013; x=1688831013; 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=U9FNme5iBEpufhowdmn6D6u4P9E81AUlwyvYSH4GMyo=; b=h0cciUxLN7JCiKuC/KA14NaHwtBZgGw8SHK4yn+aSv/EVo+vgKPWptHyiF8/E/Cw+r BhldiXhDREAl79VeXECuKzFQUeS3DIo6O53PHfJ/Rs80tcr4du20U5IAHhoE3Fyk+LAM FvGxSLc2cWeciQEe9RpiTubLstebl0cMxRTbUOsxRNxdfUl5wf68IwLleG4TeUwPt0fj L2M/lZ2ey4JiDMKk8hj2GHzytVquGycBap9pyIEUwbyQPws6+XYse89cSl76z/la8hgr HgTT3qR2Ad1jXYN10sXeIjzBDR34bJ19LI8se9/UuPaUPUfX4XXrDeWVvJDWi6lOJo7Y MsRA== X-Gm-Message-State: AC+VfDztv+q9pboACeGNSfoLm5OdNUpz8QrQCSaALbMA39h67GkgZDE8 nxWeigJT1EzCnmg//YXhNVo+dhNwWX7xR7ch1gjExiP4pDHijVr0349rln9wC406cR+31cQCgvx xIopDN8frrigRIbdMPZDSZ0q/gMyKzUrJeM7fDpw= X-Received: by 2002:a05:6402:147:b0:514:9c05:819e with SMTP id s7-20020a056402014700b005149c05819emr7681650edu.0.1686239013829; Thu, 08 Jun 2023 08:43:33 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ735DyjETywLYDs+jXXCutddOvsHT2twFvkzH160wtul6aVFuOgt/4u3yyoBsAtPQpaf211Jg== X-Received: by 2002:a05:6402:147:b0:514:9c05:819e with SMTP id s7-20020a056402014700b005149c05819emr7681635edu.0.1686239013667; Thu, 08 Jun 2023 08:43:33 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43: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, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 05/14] ceph: allow idmapped getattr inode op Date: Thu, 8 Jun 2023 17:42:46 +0200 Message-Id: <20230608154256.562906-6-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_getattr() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 8e5f41d45283..2e988612ed6c 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2465,7 +2465,7 @@ int ceph_getattr(struct mnt_idmap *idmap, const struct path *path, return err; } - generic_fillattr(&nop_mnt_idmap, inode, stat); + generic_fillattr(idmap, inode, stat); stat->ino = ceph_present_inode(inode); /* From patchwork Thu Jun 8 15:42:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272489 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 8FDE7C7EE23 for ; Thu, 8 Jun 2023 15:44:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236927AbjFHPoi (ORCPT ); Thu, 8 Jun 2023 11:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33324 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237251AbjFHPoS (ORCPT ); Thu, 8 Jun 2023 11:44:18 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C419030D1 for ; Thu, 8 Jun 2023 08:43:53 -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 8F2A93F54C for ; Thu, 8 Jun 2023 15:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239020; bh=Yx9DhBwZ0J2oRahK7SO/c3VRSYe4JEpen4id9pbwqa8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZIu31rtcGkQaJQ6m9PtMuLdkYLC6zIySosyhSVOSJ0pl+rqf4LqVW+uqeg1HTtLXK cZYcxuRpVr0OtPrwelazSrLEB7C45gARG5tmbK830coPyw51A95VZkWkXtOr4PJtke KwJGqPwy8ghG3X9WcElAOq9Luj5ozGCb5HcCP3JWH88RmEdFRt0mvIiWnYWsiIjV9n xEALX2unNkWe4QGvQ69xSNSDC3YtWIhoYxTxInXUXb0VwI58b+sMh7m0QM//TweMSA 8YNpeXbKvBHX5lSJF3i7adrccaST0yfdOKhI11cNxAmVHqLZps+UMFctkW1Nifp5KY xmfTVzu7nrTyg== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-97463348446so100774866b.2 for ; Thu, 08 Jun 2023 08:43:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239016; x=1688831016; 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=Yx9DhBwZ0J2oRahK7SO/c3VRSYe4JEpen4id9pbwqa8=; b=hBBhPXCu/SSQ+SYXG6GgMLSp38Lp5k8z1GD2P5kEQkwsV5amSCZnvhcJI+RQybuC7p cnlNV0aRbTTlndOT18NU4Bxw2dzrXOLC8IRnlPbjaAEiC0goXAGifa743FY7zSwPnTYX B+DhCHwr1X+rYh810Il8H8PFuaf9SkQvCsOZmwJdUbgVksrzJzge3AX1i6a9qOFLp0Q6 yjofnTrfhg4uTvuJtYIc0+lbeZlJoQn8oZ0W0n0ikFQhEJI1I6zXmO9WcJV07IJNMvPw gKZesvqXLbjBjjfSgUniXChGuSpQKK2oJFzNt7YC+wJRMNLGCJWpAB0TFOwibyK5w+9O NsSQ== X-Gm-Message-State: AC+VfDz90gNN2ENwFVgrC/MUYFIaJfQ9v20z+MX4fBgm2+jrvTMTfWr7 7Oy7IVoyUI4e/7P/OVuVpyBK89cxmRsMwKbrqugewiiMCtaF0utujFS9IL4g0wpQXvQBiLyfn13 3IBsQ/8pJvY2maNHwZCwtj43NpPOHkUeNfKAXSqI= X-Received: by 2002:a17:906:5d14:b0:974:61dc:107c with SMTP id g20-20020a1709065d1400b0097461dc107cmr124321ejt.44.1686239016663; Thu, 08 Jun 2023 08:43:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6ne1iCo8Tos3DO3RFYOmA4y/yhsSlWIhQ3oh+fPsJqZlkBw3DxskCMN6/mGkwdL9uWvu/RPA== X-Received: by 2002:a17:906:5d14:b0:974:61dc:107c with SMTP id g20-20020a1709065d1400b0097461dc107cmr124301ejt.44.1686239016513; Thu, 08 Jun 2023 08:43:36 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43: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, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 06/14] ceph: allow idmapped permission inode op Date: Thu, 8 Jun 2023 17:42:47 +0200 Message-Id: <20230608154256.562906-7-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_permission() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 2e988612ed6c..37e1cbfc7c89 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2408,7 +2408,7 @@ int ceph_permission(struct mnt_idmap *idmap, struct inode *inode, err = ceph_do_getattr(inode, CEPH_CAP_AUTH_SHARED, false); if (!err) - err = generic_permission(&nop_mnt_idmap, inode, mask); + err = generic_permission(idmap, inode, mask); return err; } From patchwork Thu Jun 8 15:42:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272490 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 6F99DC7EE25 for ; Thu, 8 Jun 2023 15:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237259AbjFHPok (ORCPT ); Thu, 8 Jun 2023 11:44:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237271AbjFHPo1 (ORCPT ); Thu, 8 Jun 2023 11:44: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 B813E359B for ; Thu, 8 Jun 2023 08:43:57 -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 8799D3F460 for ; Thu, 8 Jun 2023 15:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239024; bh=g/m6XNFvTOUfG03RZDOMzrTB4ATEHu4pMqVecpMcDjA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sOONllG8WOh6dK38sGcLA/iIm4e8QCiy+vWWylOj+bHIZMiB9c+pj57Vu61ylxWJO F53YEoQpm39UrQ6C3z659bu22tVUZ9qOvZnU15hR9puN33xufzNsm/FlFGmcKBtH8M JFdXpqx+IFYq8JRkkhbcK2KYAopdO6cKkyZ72nMj2TFk32yq/o9cDh7YJyh7Re2vVk lJ8X4qB8+TjbHc5auW8aOU9pAxWAQYRwEuU9hPQvRLyQ7VRixgnmVqyXar3wSF8iGp 1h7Ro57QcQ0McgAz9RsrqYce2eRdUUrqo+f5yEqB/W+GJetQdtDAGkIrWSiWTYQ32r 8CcqR41+j4Vyg== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-977e6c94186so81448366b.1 for ; Thu, 08 Jun 2023 08:43:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239019; x=1688831019; 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=g/m6XNFvTOUfG03RZDOMzrTB4ATEHu4pMqVecpMcDjA=; b=EWGUCzxCNF/CST8cSmvDUCRjrPx1YCtUWE1lzZFVAyPOEsz+IfHttlEGR5T3ny+GzW Iv+GsDSa4F79v5moWrzRzbb15Zv8EeWdUe/s6s8yQkOfJkCfgNsq1Yx9OAm92wYLKWyB k9Atkc9JFmvAcwy1f3R5u9ruriXSDRnh9ihWlEA7Z9G7Z7T9UXTfEIhN9kcDCA81duYf NLM/rLu9e6LMAxH4ooohiSEP1dvwYu08aGEiumeSUvbSXYt7gLgNlL0fpFqSvwSGVJ5B E9WLXZ5E724+1SwqYEIq570myP4kyG7R48Igw1jtJP+/5aWzvtImvfyOLDofE8POu3vp 83KQ== X-Gm-Message-State: AC+VfDzuN0Q6831apdkc8N1YkVZoYlF9JwEPCIEEunaBB4BKLyoHxdsh 5AfK3KQFPR+65do1HwXJWYNJMM4lM2zUqgjo9t0tXJ7gzPTDWGhkUdPDTRe3eOEsHTyggL6MiWw WwPxkrs/bdQv41oAOX4tEcSCUBxmfzJYvz981WEo= X-Received: by 2002:a17:907:74b:b0:978:a964:106e with SMTP id xc11-20020a170907074b00b00978a964106emr142675ejb.17.1686239019654; Thu, 08 Jun 2023 08:43:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4pVQz3zv+TMo0+MaPPdtqVPMggAHC+bOqWfjMzKnxBsBC+2g434NLItKfhx6N5DzgjQsn0CQ== X-Received: by 2002:a17:907:74b:b0:978:a964:106e with SMTP id xc11-20020a170907074b00b00978a964106emr142658ejb.17.1686239019513; Thu, 08 Jun 2023 08:43:39 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:39 -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 v5 07/14] ceph: pass idmap to __ceph_setattr Date: Thu, 8 Jun 2023 17:42:48 +0200 Message-Id: <20230608154256.562906-8-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Just pass down the mount's idmapping to __ceph_setattr, because we will need it later. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: brauner@kernel.org Cc: ceph-devel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/acl.c | 4 ++-- fs/ceph/inode.c | 6 ++++-- fs/ceph/super.h | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 6945a938d396..51ffef848429 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -140,7 +140,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); + ret = __ceph_setattr(idmap, inode, &newattrs); if (ret) goto out_free; } @@ -151,7 +151,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); + __ceph_setattr(idmap, inode, &newattrs); } goto out_free; } diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 37e1cbfc7c89..bface707c9bb 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2009,7 +2009,8 @@ static const struct inode_operations ceph_symlink_iops = { .listxattr = ceph_listxattr, }; -int __ceph_setattr(struct inode *inode, struct iattr *attr) +int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, + struct iattr *attr) { struct ceph_inode_info *ci = ceph_inode(inode); unsigned int ia_valid = attr->ia_valid; @@ -2206,6 +2207,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr) if (mask) { req->r_inode = inode; ihold(inode); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_inode_drop = release; req->r_args.setattr.mask = cpu_to_le32(mask); req->r_num_caps = 1; @@ -2252,7 +2254,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); + err = __ceph_setattr(idmap, inode, attr); 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 d24bf0db5234..d9cc27307cb7 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1052,7 +1052,8 @@ static inline int ceph_do_getattr(struct inode *inode, int mask, bool force) } extern int ceph_permission(struct mnt_idmap *idmap, struct inode *inode, int mask); -extern int __ceph_setattr(struct inode *inode, struct iattr *attr); +extern int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, + struct iattr *attr); 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 Jun 8 15:42:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272491 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 EF21AC7EE23 for ; Thu, 8 Jun 2023 15:44:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237409AbjFHPoq (ORCPT ); Thu, 8 Jun 2023 11:44:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33558 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237279AbjFHPo1 (ORCPT ); Thu, 8 Jun 2023 11:44: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 8073F359F for ; Thu, 8 Jun 2023 08:43:58 -0700 (PDT) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id ECAC43F4B3 for ; Thu, 8 Jun 2023 15:43:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239025; bh=gghyNGCh9Nhwv51CwrkrRVAEuotD0ib4eCZetw54L9Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Pj9lCWbiPjyh5LGyVf+GKe7bjrDLCbOVOTZGXKwncP5ayZGSDFBNKiZeM1HxmqPwu 6/oDscono4oiKUTdTRldj1+r580RcuNrzyR+C3ZIQ6gUdvjx783XttUDq3rd2U5Csh 9/ivz5vDQJsrk5zP4uGehcsEq8Xofuw6FeanQjzmfX20ReNr+2o8gHjL9+A5O6CJCR XOUVnz2STX5WwQJInH+IH8z16A9O4snmmJHLFxTcZvKaz2QLL9VG0R8KwwnXq1/176 sNgfw0KTyTQwH6PAZqLLphjEePBWhg8/M8I0pO5DEb3aFe9v8JfL/+S3wO1g+G9e6y X/hto9xuNWIIw== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-97455ea1c14so80868566b.2 for ; Thu, 08 Jun 2023 08:43:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239022; x=1688831022; 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=gghyNGCh9Nhwv51CwrkrRVAEuotD0ib4eCZetw54L9Q=; b=JmfjnTMupR7pnlk3Scmi1j+YyZFtdjw+RRZ4qA/1vSvyPZ1aFwGqOcFGlElpLAPcUZ q8g5miZxIC3UOc0a4P3xQPhhZrJpCz+juJ4f5rcmTej+JiAu2Mk8dANaW1BHivwMyHq7 FKnZv0BRmphqWXbwUvmGnI3KAH5YkgNn4Tsxyoxd99SrHOx1Q8Ct7y9WbE6dq+mSt2Zs 9UZevh+sxxkInUJSdtEhfr73aJuVLWytuXHmff/q1Q7iLzElfmOyp8sxOIuOEpuJrUHX yOrmfFlsqOI0ATp/sGcsb6HR81QlJ8WQBXwOjEvb7WGG2PrKMQmqMdFKLQ2WUVNaD9PQ 3BVA== X-Gm-Message-State: AC+VfDzngivFvodqEL+WgYQkpooeb7aDoA44Wm8+YxpC8qXLXlTpJv6t aUAk2t2Uo6vAJZYSvHGvVKFdHw6g6rG+PFuXTdyalBAdSelsEcDTiJ3XtUCytFDxF/Ql1gpVQsO lczQ93GYLCc3KIoR7LUMA+XCqzcBr+5ObtT3ScLh2GmxLyzA= X-Received: by 2002:a05:6402:2cc:b0:514:ae18:1637 with SMTP id b12-20020a05640202cc00b00514ae181637mr7681213edx.23.1686239022297; Thu, 08 Jun 2023 08:43:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ63b1wA/FX3sQfco4KxR832VVJA6Hb0940jQo24+Gp017FLpW0d586mQ7ovqxlzwyLxzMj3Mw== X-Received: by 2002:a05:6402:2cc:b0:514:ae18:1637 with SMTP id b12-20020a05640202cc00b00514ae181637mr7681197edx.23.1686239022090; Thu, 08 Jun 2023 08:43:42 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:41 -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, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 08/14] ceph: allow idmapped setattr inode op Date: Thu, 8 Jun 2023 17:42:49 +0200 Message-Id: <20230608154256.562906-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable __ceph_setattr() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner [ adapted to b27c82e12965 ("attr: port attribute changes to new types") ] Signed-off-by: Alexander Mikhalitsyn --- v4: - introduced fsuid/fsgid local variables v3: - reworked as Christian suggested here: https://lore.kern --- 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 bface707c9bb..58ec603a55af 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2052,31 +2052,35 @@ int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, dout("setattr %p issued %s\n", inode, ceph_cap_string(issued)); if (ia_valid & ATTR_UID) { + kuid_t fsuid = from_vfsuid(idmap, i_user_ns(inode), attr->ia_vfsuid); + dout("setattr %p uid %d -> %d\n", 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); + dout("setattr %p gid %d -> %d\n", 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; } @@ -2242,7 +2246,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, if (ceph_inode_is_shutdown(inode)) return -ESTALE; - err = setattr_prepare(&nop_mnt_idmap, dentry, attr); + err = setattr_prepare(idmap, dentry, attr); if (err != 0) return err; @@ -2257,7 +2261,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, err = __ceph_setattr(idmap, inode, attr); if (err >= 0 && (attr->ia_valid & ATTR_MODE)) - err = posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode); + err = posix_acl_chmod(idmap, dentry, attr->ia_mode); return err; } From patchwork Thu Jun 8 15:42:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272492 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 1CCE7C7EE37 for ; Thu, 8 Jun 2023 15:44:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237430AbjFHPor (ORCPT ); Thu, 8 Jun 2023 11:44:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237197AbjFHPo2 (ORCPT ); Thu, 8 Jun 2023 11:44:28 -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 EC8F235A1 for ; Thu, 8 Jun 2023 08:43:58 -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 0FF9B3F36D for ; Thu, 8 Jun 2023 15:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239027; bh=/It8VSgZDTEKktJxHTMOOJHpvqL0RXNtakCJDr6cWYA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ObtfvNV2iw12/IKKewTsdrTLGAno9BpIqYam4KC64dfWEm5G0JJ64DRHJ1e8mkoyx ttRgItwONHhWFfcR0VBUtG5prTqxUtw7N0FU/SqUyXqp5Qc3OhIbAj5iVfRrCKZfKC p+wEgBekwUAU/KGv9+VQFUGWptT8kBiDkQcMwsMNTuTt3ewQEPA5EO2MvMZGBdcfVv M30u0rfxNRykbLTcLy9wVQK2+xigYKplbtsuWxToDgs3YacfdnEflTOjK4B05WGtDA 4ybidUpvrKd0K+kFa63W/ovy7UUrw0BRw25yJu9B0qVG4HKtxuJhDSVpuwhS8Bn/3P 0mxOuwC67Te1Q== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-5149385acd0so825219a12.3 for ; Thu, 08 Jun 2023 08:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239024; x=1688831024; 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=/It8VSgZDTEKktJxHTMOOJHpvqL0RXNtakCJDr6cWYA=; b=Rf/VjYzSkuhDe+klhMlv3zdHNWVJMbrNgHlK1M7KAxeevTKxsBk6L8gLu1uWdOrkAA wV8L8c4/zmkGGzaptfHobwY9F3j2vKEMUeVKCqKVMmuYyYFqwclln29k+2r5p2FcXwP1 kyjp279M4Y7HNghoOokLhVfX4gDlXpnTUg1pCM7caxpnj7z7VqmhS7xMWLpBu/AW+OM3 1RsZR7Y0f8ga8Dxm+uYAKb8OmcZGGp4Y5H4YihC+eYs14TEq+K0NyECvJaTydsxrpfV5 T+hTUFuUySYrLI/RqxNRrGE519cNTDLjUyOdccfJpWPtwh6mefY/Ci3OSU2tC5TmdJJr MnWw== X-Gm-Message-State: AC+VfDzokQrxn97e2ncGT/WCatllhKztma2tPPJXPEgD57jMv+KrmuNP X17plB90CtF9jXD55QelHHIW2S7NiiTGUISDvMvzxnVvJII0/BduvtAOjCNds/HCYW7qIDyEFjI DcnmGXQlRZ57tCiYDpLcB1jX5DKgso6o3Sf6pVzQ= X-Received: by 2002:aa7:d88a:0:b0:50c:cde7:285b with SMTP id u10-20020aa7d88a000000b0050ccde7285bmr7205762edq.29.1686239024658; Thu, 08 Jun 2023 08:43:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5tT5xavWGRWqFP+Xk984KHDRSysXvYgAU9oqoxCsm4e3n0WS1ECv+yEbe0VUIEcNDMbW8raA== X-Received: by 2002:aa7:d88a:0:b0:50c:cde7:285b with SMTP id u10-20020aa7d88a000000b0050ccde7285bmr7205750edq.29.1686239024530; Thu, 08 Jun 2023 08:43:44 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:43 -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, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 09/14] ceph/acl: allow idmapped set_acl inode op Date: Thu, 8 Jun 2023 17:42:50 +0200 Message-Id: <20230608154256.562906-10-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_set_acl() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 51ffef848429..d0ca5a0060d8 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -105,7 +105,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, case ACL_TYPE_ACCESS: name = XATTR_NAME_POSIX_ACL_ACCESS; if (acl) { - ret = posix_acl_update_mode(&nop_mnt_idmap, inode, + ret = posix_acl_update_mode(idmap, inode, &new_mode, &acl); if (ret) goto out; From patchwork Thu Jun 8 15:42:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272493 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 8938EC7EE25 for ; Thu, 8 Jun 2023 15:45:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237295AbjFHPpA (ORCPT ); Thu, 8 Jun 2023 11:45:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231626AbjFHPog (ORCPT ); Thu, 8 Jun 2023 11:44:36 -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 91D4D30E1 for ; Thu, 8 Jun 2023 08:44:04 -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 ECC143F466 for ; Thu, 8 Jun 2023 15:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239027; bh=Q8ymt4aVYk7+c3UhjbPSUCbNsUrFX+gS8T8907goBG0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BGqEI8qCHxOYtapB0SRpXTz3tiuulDWtRLvtxc5YNoZQLqUCE2dV3meQV1Mgol7j/ QYbNWw8Ja2pa+Wgv1PSW3sg8oIRKFyeauYeNNxRKVNRlBkcpkSpQuuIyJRXQMgGAqI o6MNP+5A7M2GHkfY7Z5wO06pGpSlUaLaVLRfozNNLz/1lEFwFpXTbJ4rEHpG0bu3ZJ H8K6Kd19QF7gavUk5prBU4YGxfBV/NiwZfZWlKQu6JIxP0mpYN7ftSTUipw40IOD2W AE5GbFRSNwIsqTWePhJxTe1CwOgXUZ97bUNtIZjGUuP+8zg0ed6rkV1LFM8D+NOG84 wV7Av5Bkb1Dcg== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-514a6909c35so793668a12.3 for ; Thu, 08 Jun 2023 08:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239027; x=1688831027; 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=Q8ymt4aVYk7+c3UhjbPSUCbNsUrFX+gS8T8907goBG0=; b=Zo8sjwnyAYnGBNyM1a1aYNyAA2Mn6YTFiRPd/a+diUQDX4O71XMyDYkMCRvkaVvwzl gUdPKt/ZAcHWJwhg3yTkKuYcmZJ5T0X6MjmvdrhvYFi0lHaWfgoU3h1vXRfx+qzzhmpF X01TXArjLndsRT9SGPy9InSQfAsS1iBy/1ZRM2NdqgR/rBESs9sO3rQy3buwHefzbmWK 5ogS7HXnvGTaup+cRiC7+G5r2iTxAA4gQ+cf8Y4LgZNaI2Vg6ybI1CC6xIRg2xk9UHyW 8bffvlnTVP4yWQVqP+F2aSuGOikUPT9hytlDc38VJCZMyNGpJ8z3uu+ia1AsT1o9CO/x b0/A== X-Gm-Message-State: AC+VfDwsgyl4T09R4GVoEzcC0ngWuYFuXOpGggh/B3p0NtG8Ffs5SyN/ D6tUV8pwn2YyZJMg/4+V9JKsI/dJIvs6Edm2+46Xte0OvEoih6IWNQJsXbiAOzOM2dd9TsAGbdu dHemVJ1QZIiSZ39xje2/uI7NhGrSn7GHJc+9FlCQ= X-Received: by 2002:aa7:c7d4:0:b0:510:f462:fc47 with SMTP id o20-20020aa7c7d4000000b00510f462fc47mr7221337eds.7.1686239027038; Thu, 08 Jun 2023 08:43:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5SIwlHUtUQuOR+2n8x3ozlfAhG+H692BA1AqZYBvyR8GuRlxkZ3QdxFRxS1M3KIsoA0ELo3A== X-Received: by 2002:aa7:c7d4:0:b0:510:f462:fc47 with SMTP id o20-20020aa7c7d4000000b00510f462fc47mr7221325eds.7.1686239026831; Thu, 08 Jun 2023 08:43:46 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43: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, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 10/14] ceph/file: allow idmapped atomic_open inode op Date: Thu, 8 Jun 2023 17:42:51 +0200 Message-Id: <20230608154256.562906-11-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_atomic_open() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner [ adapted to 5fadbd9929 ("ceph: rely on vfs for setgid stripping") ] Signed-off-by: Alexander Mikhalitsyn --- 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 f4d8bf7dec88..d46b6b8b5fcb 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -654,7 +654,9 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, in.truncate_seq = cpu_to_le32(1); in.truncate_size = cpu_to_le64(-1ULL); in.xattr_version = cpu_to_le64(1); - in.uid = cpu_to_le32(from_kuid(&init_user_ns, current_fsuid())); + in.uid = cpu_to_le32(from_kuid(&init_user_ns, + mapped_fsuid(req->r_mnt_idmap, + &init_user_ns))); if (dir->i_mode & S_ISGID) { in.gid = cpu_to_le32(from_kgid(&init_user_ns, dir->i_gid)); @@ -662,7 +664,9 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, if (S_ISDIR(mode)) mode |= S_ISGID; } else { - in.gid = cpu_to_le32(from_kgid(&init_user_ns, current_fsgid())); + in.gid = cpu_to_le32(from_kgid(&init_user_ns, + mapped_fsgid(req->r_mnt_idmap, + &init_user_ns))); } in.mode = cpu_to_le32((u32)mode); @@ -731,6 +735,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, struct file *file, unsigned flags, umode_t mode) { struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_mds_client *mdsc = fsc->mdsc; struct ceph_mds_request *req; struct dentry *dn; @@ -786,6 +791,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, mask |= CEPH_CAP_XATTR_SHARED; req->r_args.open.mask = cpu_to_le32(mask); req->r_parent = dir; + req->r_mnt_idmap = mnt_idmap_get(idmap); ihold(dir); if (flags & O_CREAT) { From patchwork Thu Jun 8 15:42:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272495 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 3D675C7EE25 for ; Thu, 8 Jun 2023 15:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236726AbjFHPpG (ORCPT ); Thu, 8 Jun 2023 11:45:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237251AbjFHPoi (ORCPT ); Thu, 8 Jun 2023 11:44:38 -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 4BA1930E3 for ; Thu, 8 Jun 2023 08:44:09 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.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 39B5F3F513 for ; Thu, 8 Jun 2023 15:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239032; bh=2SBMId8uucXXsmkpO9XvsuxzyfuN3DNew61ExZTJFDc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BolIxDhAzLBC8uySL7kGm02+jQQGJr1+Zgvz3V0Xb6D55PqqKyUuCb9zj24/gcHBY N2YDlmOQJg34YLODmb88SFmIAocZbqoVmkMhLgzUgkDLW5Uj/t+Figt7l9q7cj/JVX K0lwArv3DaY14ZoMg8as590/cZo7sf09xAjkuPCevW/wnzwMEhYzeyRiiFTY90sdi/ UN7rByIahctw/VgxujcGo4y5NObwf8jRTpYwKCoCVzbF2D69RyMlngNmRJCL/3H1nG GqL+Eau0H6lhgU44KAChd/AfW8Mr9+5/kJHoUv4pVRfItGprHYo2MHmPwip8oXUtEU jfWUAtigHvfWQ== Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-30af00323b0so351658f8f.2 for ; Thu, 08 Jun 2023 08:43:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239030; x=1688831030; 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=2SBMId8uucXXsmkpO9XvsuxzyfuN3DNew61ExZTJFDc=; b=HulBIUp7Cx8/rtUb42epaEgeSH62SCqrlGNziKEV5jStglBqiB6mJJdXiLqG6TjPPa ddxZQGVSj0OMKxov/+cWMEC+oporxD/9rsT6JPusoAXwSE3pT22ONqq/AA0ZNv4Kf9mB 249EGZnjpvZK7uIDQcpArXwaLTkHJEcCPxVQx8BJaT1mWSfsQ7gLTg7VRBZPA4l8QQIc kJoEiY9pQuhR4dEIxcHB2J8yO95CrULfJao4ERbMCFus/DUpa+JdZgdNHfBmbpTVp1nR foqTr5ZOSCsjpA6R+EAFxbsxYufxrucJhww16hp1+DN+3cPRz07MGnVa0xZpTX2Mkx0Z iDcA== X-Gm-Message-State: AC+VfDx+m2r3sTIUfkzxVm3pBB3F/9bXcfMq3otFwHYkXwqWvLsmM9kv xZdPkYZKVnoWRSn8UrntVlRtUGyi5D0wLEm9prc1980XITSFs3sdHKqZbffPS9eQ7XKpv3f+qTE iwDULxxwU68fm/1boODcO/v67reJt0of4XCHnF/I= X-Received: by 2002:adf:e5c6:0:b0:30e:5380:5eb3 with SMTP id a6-20020adfe5c6000000b0030e53805eb3mr5859729wrn.33.1686239030041; Thu, 08 Jun 2023 08:43:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6CnFwNtGDWr2OK/EAx3WMAMTXiL6rTtLft1GHY7iGNq7Fq8yKZ5L3UVTQTUEfrAGR5aQWg7Q== X-Received: by 2002:adf:e5c6:0:b0:30e:5380:5eb3 with SMTP id a6-20020adfe5c6000000b0030e53805eb3mr5859717wrn.33.1686239029789; Thu, 08 Jun 2023 08:43:49 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:49 -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 v5 11/14] ceph: pass idmap to ceph_do_getattr Date: Thu, 8 Jun 2023 17:42:52 +0200 Message-Id: <20230608154256.562906-12-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Just pass down the mount's idmapping to *ceph_do_getattr, everywhere when possible, because we will need it later. Here we have two cases: - filemap_fault/read/write/lseek (when idmap is accessible) - export_ops/list_xattr/get_xattr (when idmap is not accessible) in this case we pass &nop_mnt_idmap. So we can meet permission issue when MDS UID/GID-based path restriction is used. 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/addr.c | 3 ++- fs/ceph/caps.c | 3 ++- fs/ceph/export.c | 2 +- fs/ceph/file.c | 9 ++++++--- fs/ceph/inode.c | 8 +++++--- fs/ceph/ioctl.c | 6 ++++-- fs/ceph/quota.c | 2 +- fs/ceph/super.c | 4 ++-- fs/ceph/super.h | 8 +++++--- fs/ceph/xattr.c | 6 +++--- 10 files changed, 31 insertions(+), 20 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 6bb251a4d613..757e8e170c48 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1471,6 +1471,7 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf) /* does not support inline data > PAGE_SIZE */ ret = VM_FAULT_SIGBUS; } else { + struct mnt_idmap *idmap = file_mnt_idmap(vma->vm_file); struct address_space *mapping = inode->i_mapping; struct page *page; @@ -1481,7 +1482,7 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf) ret = VM_FAULT_OOM; goto out_inline; } - err = __ceph_do_getattr(inode, page, + err = __ceph_do_getattr(idmap, inode, page, CEPH_STAT_CAP_INLINE_DATA, true); if (err < 0 || off >= i_size_read(inode)) { unlock_page(page); diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 2321e5ddb664..d083ec5fda36 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -2906,6 +2906,7 @@ int ceph_get_caps(struct file *filp, int need, int want, loff_t endoff, int *got struct inode *inode = file_inode(filp); struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_fs_client *fsc = ceph_inode_to_client(inode); + struct mnt_idmap *idmap = file_mnt_idmap(filp); int ret, _got, flags; ret = ceph_pool_perm_check(inode, need); @@ -3015,7 +3016,7 @@ int ceph_get_caps(struct file *filp, int need, int want, loff_t endoff, int *got * getattr request will bring inline data into * page cache */ - ret = __ceph_do_getattr(inode, NULL, + ret = __ceph_do_getattr(idmap, inode, NULL, CEPH_STAT_CAP_INLINE_DATA, true); if (ret < 0) diff --git a/fs/ceph/export.c b/fs/ceph/export.c index f780e4e0d062..9f3c6e911ae6 100644 --- a/fs/ceph/export.c +++ b/fs/ceph/export.c @@ -187,7 +187,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino) if (IS_ERR(inode)) return ERR_CAST(inode); /* We need LINK caps to reliably check i_nlink */ - err = ceph_do_getattr(inode, CEPH_CAP_LINK_SHARED, false); + err = ceph_do_getattr(&nop_mnt_idmap, inode, CEPH_CAP_LINK_SHARED, false); if (err) { iput(inode); return ERR_PTR(err); diff --git a/fs/ceph/file.c b/fs/ceph/file.c index d46b6b8b5fcb..0019d5b4ae3c 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -1613,6 +1613,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to) size_t len = iov_iter_count(to); struct inode *inode = file_inode(filp); struct ceph_inode_info *ci = ceph_inode(inode); + struct mnt_idmap *idmap = file_mnt_idmap(filp); bool direct_lock = iocb->ki_flags & IOCB_DIRECT; ssize_t ret; int want = 0, got = 0; @@ -1693,7 +1694,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to) return -ENOMEM; } - statret = __ceph_do_getattr(inode, page, + statret = __ceph_do_getattr(idmap, inode, page, CEPH_STAT_CAP_INLINE_DATA, !!page); if (statret < 0) { if (page) @@ -1768,6 +1769,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = file_inode(file); struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_fs_client *fsc = ceph_inode_to_client(inode); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_osd_client *osdc = &fsc->client->osdc; struct ceph_cap_flush *prealloc_cf; ssize_t count, written = 0; @@ -1801,7 +1803,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) current->backing_dev_info = inode_to_bdi(inode); if (iocb->ki_flags & IOCB_APPEND) { - err = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false); + err = ceph_do_getattr(idmap, inode, CEPH_STAT_CAP_SIZE, false); if (err < 0) goto out; } @@ -1957,9 +1959,10 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence) { if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) { struct inode *inode = file_inode(file); + struct mnt_idmap *idmap = file_mnt_idmap(file); int ret; - ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false); + ret = ceph_do_getattr(idmap, inode, CEPH_STAT_CAP_SIZE, false); if (ret < 0) return ret; } diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 58ec603a55af..3838d7dd7cd7 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2300,7 +2300,8 @@ int ceph_try_to_choose_auth_mds(struct inode *inode, int mask) * Verify that we have a lease on the given mask. If not, * do a getattr against an mds. */ -int __ceph_do_getattr(struct inode *inode, struct page *locked_page, +int __ceph_do_getattr(struct mnt_idmap *idmap, struct inode *inode, + struct page *locked_page, int mask, bool force) { struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb); @@ -2325,6 +2326,7 @@ int __ceph_do_getattr(struct inode *inode, struct page *locked_page, return PTR_ERR(req); req->r_inode = inode; ihold(inode); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_num_caps = 1; req->r_args.getattr.mask = cpu_to_le32(mask); req->r_locked_page = locked_page; @@ -2411,7 +2413,7 @@ int ceph_permission(struct mnt_idmap *idmap, struct inode *inode, if (mask & MAY_NOT_BLOCK) return -ECHILD; - err = ceph_do_getattr(inode, CEPH_CAP_AUTH_SHARED, false); + err = ceph_do_getattr(idmap, inode, CEPH_CAP_AUTH_SHARED, false); if (!err) err = generic_permission(idmap, inode, mask); @@ -2464,7 +2466,7 @@ int ceph_getattr(struct mnt_idmap *idmap, const struct path *path, /* Skip the getattr altogether if we're asked not to sync */ if ((flags & AT_STATX_SYNC_TYPE) != AT_STATX_DONT_SYNC) { - err = ceph_do_getattr(inode, + err = ceph_do_getattr(idmap, inode, statx_to_caps(request_mask, inode->i_mode), flags & AT_STATX_FORCE_SYNC); if (err) diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index deac817647eb..07be54ecc94d 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c @@ -17,10 +17,11 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg) { struct ceph_inode_info *ci = ceph_inode(file_inode(file)); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_ioctl_layout l; int err; - err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false); + err = ceph_do_getattr(idmap, file_inode(file), CEPH_STAT_CAP_LAYOUT, false); if (!err) { l.stripe_unit = ci->i_layout.stripe_unit; l.stripe_count = ci->i_layout.stripe_count; @@ -64,6 +65,7 @@ static long __validate_layout(struct ceph_mds_client *mdsc, static long ceph_ioctl_set_layout(struct file *file, void __user *arg) { struct inode *inode = file_inode(file); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; struct ceph_mds_request *req; struct ceph_ioctl_layout l; @@ -75,7 +77,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) return -EFAULT; /* validate changed params against current layout */ - err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false); + err = ceph_do_getattr(idmap, file_inode(file), CEPH_STAT_CAP_LAYOUT, false); if (err) return err; diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c index 64592adfe48f..aea122ac3cbe 100644 --- a/fs/ceph/quota.c +++ b/fs/ceph/quota.c @@ -150,7 +150,7 @@ static struct inode *lookup_quotarealm_inode(struct ceph_mds_client *mdsc, } if (qri->inode) { /* get caps */ - int ret = __ceph_do_getattr(qri->inode, NULL, + int ret = __ceph_do_getattr(&nop_mnt_idmap, qri->inode, NULL, CEPH_STAT_CAP_INODE, true); if (ret >= 0) in = qri->inode; diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 3fc48b43cab0..797a6cb3733c 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1415,8 +1415,8 @@ int ceph_force_reconnect(struct super_block *sb) fsc->mount_state = CEPH_MOUNT_MOUNTED; if (sb->s_root) { - err = __ceph_do_getattr(d_inode(sb->s_root), NULL, - CEPH_STAT_CAP_INODE, true); + err = __ceph_do_getattr(&nop_mnt_idmap, d_inode(sb->s_root), + NULL, CEPH_STAT_CAP_INODE, true); } return err; } diff --git a/fs/ceph/super.h b/fs/ceph/super.h index d9cc27307cb7..ccef4a6bac52 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1044,11 +1044,13 @@ static inline void ceph_queue_flush_snaps(struct inode *inode) } extern int ceph_try_to_choose_auth_mds(struct inode *inode, int mask); -extern int __ceph_do_getattr(struct inode *inode, struct page *locked_page, +extern int __ceph_do_getattr(struct mnt_idmap *idmap, struct inode *inode, + struct page *locked_page, int mask, bool force); -static inline int ceph_do_getattr(struct inode *inode, int mask, bool force) +static inline int ceph_do_getattr(struct mnt_idmap *idmap, struct inode *inode, + int mask, bool force) { - return __ceph_do_getattr(inode, NULL, mask, force); + return __ceph_do_getattr(idmap, inode, NULL, mask, force); } extern int ceph_permission(struct mnt_idmap *idmap, struct inode *inode, int mask); diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 806183959c47..d3ac854bc11f 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -952,7 +952,7 @@ ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value, mask |= CEPH_STAT_RSTAT; if (vxattr->flags & VXATTR_FLAG_DIRSTAT) mask |= CEPH_CAP_FILE_SHARED; - err = ceph_do_getattr(inode, mask, true); + err = ceph_do_getattr(&nop_mnt_idmap, inode, mask, true); if (err) return err; err = -ENODATA; @@ -989,7 +989,7 @@ ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value, } /* get xattrs from mds (if we don't already have them) */ - err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR, true); + err = ceph_do_getattr(&nop_mnt_idmap, inode, CEPH_STAT_CAP_XATTR, true); if (err) return err; spin_lock(&ci->i_ceph_lock); @@ -1038,7 +1038,7 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size) if (ci->i_xattrs.version == 0 || !__ceph_caps_issued_mask_metric(ci, CEPH_CAP_XATTR_SHARED, 1)) { spin_unlock(&ci->i_ceph_lock); - err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR, true); + err = ceph_do_getattr(&nop_mnt_idmap, inode, CEPH_STAT_CAP_XATTR, true); if (err) return err; spin_lock(&ci->i_ceph_lock); From patchwork Thu Jun 8 15:42:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272494 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 3800AC7EE23 for ; Thu, 8 Jun 2023 15:45:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237203AbjFHPpE (ORCPT ); Thu, 8 Jun 2023 11:45:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237343AbjFHPoh (ORCPT ); Thu, 8 Jun 2023 11:44:37 -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 A444730E5 for ; Thu, 8 Jun 2023 08:44:08 -0700 (PDT) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id C0BA83F13F for ; Thu, 8 Jun 2023 15:43:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239033; bh=hMEKg4eGVgDXkovGDpYWIZx/H1D1uxAjXSI9jX8bPYQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NZTbyJX/dfJjYfoQbRzUwXtPcO7bh4rnISUnC1ZcLPB/RBRabXRMh0S7HOfWYvISx JatKKDLD3YtukfbIKXYbQ1PDtv+4Tbgjzp41YCp2iZRw/qlNoInJ4nh1ZKuXHXg4fK wsnkkLri6EhtLv9psEe8pa0FAhlddGJoqxiYrJkv7AejfID1bThNSR8UeJIavrn8mp 9DQFSFqG4AVH5TeojLndHYf/Qhh3OdP+ZCbrftQtVvYMgvaM6jrcxL4IbkQKjDSrnS 1hZfxXxc5eNS8TbWXylfimrUjCwYjDgwPPSBI5bT613JMABvhwEykTaQ/aTSbYXnUM jO3CfO5sQNbPQ== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9715654ab36so87028766b.0 for ; Thu, 08 Jun 2023 08:43:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239032; x=1688831032; 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=hMEKg4eGVgDXkovGDpYWIZx/H1D1uxAjXSI9jX8bPYQ=; b=YEk67rK9rJhDSYQRwKYvs0zqDRMwPA3vTiuwGfHLA1QlwtOxmbIsIijNuhnA6DjtFw /QW9HJd0hp7NUmf7D9JfWLmGLAYIUxEZ+Hpu9hF8YV+Nq5/Aud8JbwnyKwqbqnFZrDul UrSX93TNIHnRaueIyYfOkozZv6IKYPTiBB59HisAHZXJo3ozkinu4om6b2BIfNZhC8sy TbVLOIPrx+TTmkyenw9y4kur2duoq7/2vVnqcjkQ2fYcCLRKafzOayLAEWPcCy1ojQwL C7tBWTWC6p7abYXIi7o1eWoZsz5Y6pH2WwW5Hh75USX+wRbpzegTOt8BYtzTvSZxO3ub 4DIA== X-Gm-Message-State: AC+VfDyGN8nulfQ/L7Jzpsn0mVwxx9IDOClyz0sqDS5E4/ZM/03AoZBI blYP8PqiEt7vbUZ5L6L0GgwC4ZKysExJ1Gd8Qb2MMdauZwZogwQRjcymmUvsgD2+SRwnZEOXBj6 kyBnugjLINDNrOjY66AMn5hA4Bow3FQuKvHrVwzQ= X-Received: by 2002:a05:6402:147:b0:514:9c05:819e with SMTP id s7-20020a056402014700b005149c05819emr7682638edu.0.1686239032690; Thu, 08 Jun 2023 08:43:52 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ47f/M3Pn0HYOzhFIP9nhAo5elf7zfS/8PYInY9g89YRrer/rMZF1pnuQSZX3FuSKqLLPPkhg== X-Received: by 2002:a05:6402:147:b0:514:9c05:819e with SMTP id s7-20020a056402014700b005149c05819emr7682624edu.0.1686239032523; Thu, 08 Jun 2023 08:43:52 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:52 -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 v5 12/14] ceph: pass idmap to __ceph_setxattr Date: Thu, 8 Jun 2023 17:42:53 +0200 Message-Id: <20230608154256.562906-13-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Just pass down the mount's idmapping to __ceph_setxattr. 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 | 2 +- fs/ceph/super.h | 3 ++- fs/ceph/xattr.c | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index d0ca5a0060d8..bb02776e3df2 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -145,7 +145,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, goto out_free; } - ret = __ceph_setxattr(inode, name, value, size, 0); + ret = __ceph_setxattr(idmap, inode, name, value, size, 0); if (ret) { if (new_mode != old_mode) { newattrs.ia_ctime = old_ctime; diff --git a/fs/ceph/super.h b/fs/ceph/super.h index ccef4a6bac52..e23aec9554b3 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1073,7 +1073,8 @@ static inline bool ceph_inode_is_shutdown(struct inode *inode) } /* xattr.c */ -int __ceph_setxattr(struct inode *, const char *, const void *, size_t, int); +int __ceph_setxattr(struct mnt_idmap *, struct inode *, + const char *, const void *, size_t, int); int ceph_do_getvxattr(struct inode *inode, const char *name, void *value, size_t size); ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t); extern ssize_t ceph_listxattr(struct dentry *, char *, size_t); diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index d3ac854bc11f..0acb292f600d 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -1064,7 +1064,8 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size) return err; } -static int ceph_sync_setxattr(struct inode *inode, const char *name, +static int ceph_sync_setxattr(struct mnt_idmap *idmap, + struct inode *inode, const char *name, const char *value, size_t size, int flags) { struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb); @@ -1118,6 +1119,7 @@ static int ceph_sync_setxattr(struct inode *inode, const char *name, req->r_inode = inode; ihold(inode); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_num_caps = 1; req->r_inode_drop = CEPH_CAP_XATTR_SHARED; @@ -1132,8 +1134,8 @@ static int ceph_sync_setxattr(struct inode *inode, const char *name, return err; } -int __ceph_setxattr(struct inode *inode, const char *name, - const void *value, size_t size, int flags) +int __ceph_setxattr(struct mnt_idmap *idmap, struct inode *inode, + const char *name, const void *value, size_t size, int flags) { struct ceph_vxattr *vxattr; struct ceph_inode_info *ci = ceph_inode(inode); @@ -1262,7 +1264,7 @@ int __ceph_setxattr(struct inode *inode, const char *name, "during filling trace\n", inode); err = -EBUSY; } else { - err = ceph_sync_setxattr(inode, name, value, size, flags); + err = ceph_sync_setxattr(idmap, inode, name, value, size, flags); if (err >= 0 && check_realm) { /* check if snaprealm was created for quota inode */ spin_lock(&ci->i_ceph_lock); @@ -1298,7 +1300,7 @@ static int ceph_set_xattr_handler(const struct xattr_handler *handler, { if (!ceph_is_valid_xattr(name)) return -EOPNOTSUPP; - return __ceph_setxattr(inode, name, value, size, flags); + return __ceph_setxattr(idmap, inode, name, value, size, flags); } static const struct xattr_handler ceph_other_xattr_handler = { From patchwork Thu Jun 8 15:42:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272500 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 9ADA9C7EE37 for ; Thu, 8 Jun 2023 15:46:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237431AbjFHPqW (ORCPT ); Thu, 8 Jun 2023 11:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237416AbjFHPqD (ORCPT ); Thu, 8 Jun 2023 11:46: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 352053C0E for ; Thu, 8 Jun 2023 08:45:15 -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-0.canonical.com (Postfix) with ESMTPS id 566373F537 for ; Thu, 8 Jun 2023 15:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239035; bh=MRxl+h7O52u/Mhs3Xvpqf/AHss8SBrlV6qztFSPEq4E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oAjswmV0RQuZTyKzf4M1ahiTaVsJJ7Y0Jd7y7lbClp5uoJ+45k9JHag2Y3r+Hd1Sx ryw1yQizFXPmAglU0+9D5zR8u3sXuqW8xz1X558LP5ekSeOcxD8Wzf27DCWUiX3cOV NZcK/+cw/hmgs9xLmaFpu9/eFsKh6doTNucHnyAmaGLDIsQq0CHlex5GHSG+ICJ1iv jHvRVpL/of4hgvXBlfjgJa1qfI93xcSz0iYELeA9oXJ3TKfi7ZLw5FArQoea9yNcg+ BC7v41GUQJO29RqcQIB29ObBM1yumjDAc536xqhlh0ZPfkpFAM5IrWmvqPMmHEFU7P PoZzVgXsLXU9Q== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5147e3dfccdso699106a12.1 for ; Thu, 08 Jun 2023 08:43:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239035; x=1688831035; 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=MRxl+h7O52u/Mhs3Xvpqf/AHss8SBrlV6qztFSPEq4E=; b=dH8eXXGOu7norXkblcTtf7O0o6D+tKW9Lv9xHFDp3IN3TXjOFIMLlHlqqtIHLvcTNV 8zQLnhyqooOTg7C2cZVGz0cTCJkY1Dr0XA/4ZzQVWQL+hV7nFzZKEqeY5uCP0gbwuJ8m DaPARvCC7jyZS6VjyTMVFP0+SUpIsBKRFNEkiM0/BBLJmzNrr31A5QZrYReErP9epZSx kohvOKvw32d5PzDHkiMSY2YUfd5k2NQ64n71bV14N+wZr+mAuA3DXkwCmeNWWy0OqbDN lXei6nY8OTP+PBatGa1ThmfcNpIsmL+G4qxp966p8YMWrtGy/uWw0Mr3YG6/b0QwpxGy bg/A== X-Gm-Message-State: AC+VfDxMAazN7gLLcjYCVc08VRwy9wLpkpWv7GZ9JT15AjzC8LpmRJ8b iC781FPfL8EX2vtwO6iOjxV5l5xJ8XH7LQqcsBXrsHuTa2bxIs9HYJ8RSxvTQTEyOPN7gIUtuCZ mt3KGn8AuimkNq1zWmCo9cG6V1bfC5vDO5IQhQGc= X-Received: by 2002:aa7:d9c3:0:b0:50c:4b9:1483 with SMTP id v3-20020aa7d9c3000000b0050c04b91483mr7476587eds.37.1686239035009; Thu, 08 Jun 2023 08:43:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7WAkIvBTLPsLVlcLZqIpFHfhaWbyyodUjVhRbSKji4rGeOK/h76P85OgiyBExHW4hLqYTozg== X-Received: by 2002:aa7:d9c3:0:b0:50c:4b9:1483 with SMTP id v3-20020aa7d9c3000000b0050c04b91483mr7476574eds.37.1686239034873; Thu, 08 Jun 2023 08:43:54 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:54 -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 v5 13/14] ceph: pass idmap to ceph_open/ioctl_set_layout Date: Thu, 8 Jun 2023 17:42:54 +0200 Message-Id: <20230608154256.562906-14-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Pass an idmapping to: - ceph_open - ceph_ioctl_set_layout 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/file.c | 2 ++ fs/ceph/ioctl.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 0019d5b4ae3c..3c3aacbf900b 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -356,6 +356,7 @@ int ceph_open(struct inode *inode, struct file *file) struct ceph_mds_client *mdsc = fsc->mdsc; struct ceph_mds_request *req; struct ceph_file_info *fi = file->private_data; + struct mnt_idmap *idmap = file_mnt_idmap(file); int err; int flags, fmode, wanted; @@ -426,6 +427,7 @@ int ceph_open(struct inode *inode, struct file *file) ihold(inode); req->r_num_caps = 1; + req->r_mnt_idmap = mnt_idmap_get(idmap); err = ceph_mdsc_do_request(mdsc, NULL, req); if (!err) err = ceph_init_file(inode, file, req->r_fmode); diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index 07be54ecc94d..d3568643d0af 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c @@ -113,6 +113,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) req->r_inode = inode; ihold(inode); req->r_num_caps = 1; + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL; @@ -138,6 +139,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg) { struct inode *inode = file_inode(file); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_mds_request *req; struct ceph_ioctl_layout l; int err; @@ -159,6 +161,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg) req->r_inode = inode; ihold(inode); req->r_num_caps = 1; + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_args.setlayout.layout.fl_stripe_unit = cpu_to_le32(l.stripe_unit); From patchwork Thu Jun 8 15:42:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Mikhalitsyn X-Patchwork-Id: 13272496 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 8D837C7EE23 for ; Thu, 8 Jun 2023 15:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237274AbjFHPqL (ORCPT ); Thu, 8 Jun 2023 11:46:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237500AbjFHPp6 (ORCPT ); Thu, 8 Jun 2023 11:45:58 -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 A45F03AB0 for ; Thu, 8 Jun 2023 08:45:07 -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 967163F375 for ; Thu, 8 Jun 2023 15:43:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239037; bh=i26tUKoxa8xxbhp04Sqa6+bBNOKneC25U0PHv+Eu/CE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WPv6nl9NogD3ad+NwdOu7YCQhOTLDfx7XN5PLUSPrBfb9/P8imf78rDPiAJsW6T9a nc1vHjcBhr1G1Ne2qxsnX/nrS1kagJAzCXFO/PvqkYhJdx58pAJuKZqDPsHquOiLmC b4oYubcKK8UEvEU8kGvfdSMk73x/RctZcdEwIX62eYJZ8Mw1gHd9zxPewJo1bxBDpE whUyulU6LS/iqGn1w6HF8bFzMacintNIWwh4qkw/fq+GkrKIPGnkeCNwCq6uRroJ2S GGkwpgcJsfkaoClfKO40cBEoeYbHrIBllr5fj55IjhZZtoGGM9K9XO6DvL/yI6Eh1T tx8an1lFcmFhg== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5147e3dfccdso699138a12.1 for ; Thu, 08 Jun 2023 08:43:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239037; x=1688831037; 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=i26tUKoxa8xxbhp04Sqa6+bBNOKneC25U0PHv+Eu/CE=; b=bgJYWfBSKkh5gKTiZvFrwdQrs5eeS8U3BWvBhvqkhrdeHeDhahVav5l7ylHEExF9x0 330gTJkfTTjgQa5cpIIhwL2zS7OprQnkkoJ7UaG0pkArOseFizheCLDDvJ3pRn/kSzWg eERz2eW3pxsOsXA0mH2s7Zfy8wegNjuNkHaFU2rCLLi2ZKkBpz9hzr+ihV3KqRvGn08z 6bOcHplAzd/YbcoHZfudS9UJX0JN8YO6BSAnQL/WONT7wQgA2UUOrSmH/fwvZZgbl74M a8n4wZzB8xx3aSpzCuIJDLHMqzcHYp7qtyY46qojjQFJr/Aa+HXOO/57YwSq7xjIivkx AK8Q== X-Gm-Message-State: AC+VfDwTgJ4sEZON8K2w0dk/xiZaWguJ2uMmGryxg+ftcla3nVRsdkfs 177Q/O9eOGblLEsDs6U4Yn5pQgvSg6h/ogVCioHhM59G7cQ57JZ8tjffp/w7zeOBW73h857IhSe kG8FSA/L29mzUSh9nChfSHvHJiMYMpZlSF1/PeKg= X-Received: by 2002:aa7:c602:0:b0:514:75ff:6a86 with SMTP id h2-20020aa7c602000000b0051475ff6a86mr7704524edq.29.1686239037404; Thu, 08 Jun 2023 08:43:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bqcG2rpS6htSHbxy+8xHn0si639Le+ztjyzfBKMeLcT3Phik1QuVCS8J6V17RxiDv98M7eQ== X-Received: by 2002:aa7:c602:0:b0:514:75ff:6a86 with SMTP id h2-20020aa7c602000000b0051475ff6a86mr7704509edq.29.1686239037226; Thu, 08 Jun 2023 08:43:57 -0700 (PDT) Received: from amikhalitsyn.local (dslb-002-205-064-187.002.205.pools.vodafone-ip.de. [2.205.64.187]) by smtp.gmail.com with ESMTPSA id y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:56 -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, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 14/14] ceph: allow idmapped mounts Date: Thu, 8 Jun 2023 17:42:55 +0200 Message-Id: <20230608154256.562906-15-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Christian Brauner Now that we converted cephfs internally to account for idmapped mounts allow the creation of idmapped mounts on by setting the FS_ALLOW_IDMAP flag. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 797a6cb3733c..a72adc21f489 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1389,7 +1389,7 @@ static struct file_system_type ceph_fs_type = { .name = "ceph", .init_fs_context = ceph_init_fs_context, .kill_sb = ceph_kill_sb, - .fs_flags = FS_RENAME_DOES_D_MOVE, + .fs_flags = FS_RENAME_DOES_D_MOVE | FS_ALLOW_IDMAP, }; MODULE_ALIAS_FS("ceph");