From nobody Mon Feb 9 05:01:14 2026 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 C12A8C83003 for ; Thu, 8 Jun 2023 15:43:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237144AbjFHPnb (ORCPT ); Thu, 8 Jun 2023 11:43:31 -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 S237131AbjFHPn2 (ORCPT ); Thu, 8 Jun 2023 11:43:28 -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 335F62D72 for ; Thu, 8 Jun 2023 08:43:25 -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 6B8763F466 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-514b8a3c0d3so767790a12.0 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=kbR1odEdZ5W8opHfAYmh9El5I5ZNB1WOk7M/mUFVYQyMvJG/VJAzwWWm18BeEj5LOG naM0Zv8okRChEF+oMoCKmPwE+SLNbMp4ehGoi5DDF+vo+17F6LnVnAivCqMW2F99tvzv GTEo1C8rMQIGc3CnQZHSxgkupdDVV6q2bLxBeRcGW9jtYYuZCVZrLS3kI8PXW0IgP3Vy Grsa/7fc/VeFKSWW17osWQSLFECL8k+reyopPHb+5KANgRzlEpmOt+SIOp+eRTNDgBrF Knh2xcWjSY2a2lAluAdyo00ZjA/R6B9nBjpFlvBQCjQuvO/k76izvH6RZqidBZocSmjW Fwlg== X-Gm-Message-State: AC+VfDwfCcOMKxgmd0ir5F5iyIDcvU+MbJ/yAYnfyOjDsy6xh84L28rq m7HGx9ag5iEgiQdz0/mxN1xCzGJnMc5SXwtpYnUhLoONDM6C6H1aUVS0oTezbu6oQiqPLd6CEDW oV+WUvpVopxxI/cwPdGelZ19XFcq1WCU1jeOvV3s4Ag== X-Received: by 2002:aa7:c48f:0:b0:514:a4b9:d76b with SMTP id m15-20020aa7c48f000000b00514a4b9d76bmr7147039edq.25.1686239001447; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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) =20 return idmap; } +EXPORT_SYMBOL_GPL(mnt_idmap_get); =20 /** * 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) =20 int vfsgid_in_group_p(vfsgid_t vfsgid); =20 +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); =20 --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 3F773C7EE23 for ; Thu, 8 Jun 2023 15:43:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237046AbjFHPnd (ORCPT ); Thu, 8 Jun 2023 11:43:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237130AbjFHPna (ORCPT ); Thu, 8 Jun 2023 11:43:30 -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 EB83E30C0 for ; Thu, 8 Jun 2023 08:43:27 -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 725413F462 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-f70.google.com with SMTP id 4fb4d7f45d1cf-514a4c3ff90so761624a12.2 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=YZgHyfBWft6lU8IO9YMMF4jC2+UkRbvb1q32MhZOyGLPk++kgJPZHv3ETQAoyR/phj ax74vYapNcaxq2kI6jLZDTeSh8ohh8tPQ1vHit5RxYQ8YqUSxQDbsN9K776aqVdOVNmT 88hissi57PexcdxiMaLkIxH6cHdYkf4nBVlJBS7/YHiTRwEiDPkgG+VT8099Lvap/j6p Lp6GEK2DIrrq4D7MBtgfD5OtcRWqad/j1hPRgjFPJ0S5Am2WYnMCMwdhOvnz3lodlj/H FdCNvBTt54NQDqBsIDcPGW2skrPU5M3ecZF9tXjgDmIy454wWkCTDEAKG4URmNQdOvkL kMVg== X-Gm-Message-State: AC+VfDwuDUEss+vPumVfHbcdQJvPaK0egEHnKUr3pftqxbQvPebQzIka zkEkJxSalte3rXIfc0S4Vb2IZLkkPjXgAg4zTq34komr2ImiPoTjVfPvtMxfcoOosZKEfQ2VSpu eUrfUQTHrGz46UFXCM5xyZ6iAXNeyV7tWHc7EZ4axYg== X-Received: by 2002:aa7:c30c:0:b0:514:9e61:e7b8 with SMTP id l12-20020aa7c30c000000b005149e61e7b8mr6336296edq.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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =20 #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); =20 req->r_cred =3D get_current_cred(); + if (!req->r_mnt_idmap) + req->r_mnt_idmap =3D &nop_mnt_idmap; =20 if (mdsc->oldest_tid =3D=3D 0 && req->r_op !=3D CEPH_MDS_OP_SETFILELOCK) mdsc->oldest_tid =3D 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; =20 /* for choosing which mds to send this request to */ --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 F0AD0C7EE23 for ; Thu, 8 Jun 2023 15:43:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237172AbjFHPnv (ORCPT ); Thu, 8 Jun 2023 11:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236344AbjFHPnr (ORCPT ); Thu, 8 Jun 2023 11:43:47 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 787D830DA for ; Thu, 8 Jun 2023 08:43:35 -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 C4B853F364 for ; Thu, 8 Jun 2023 15:43:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239010; bh=MVopSiFXJtuCZDFmw4k6EoX9EHPj+DJ/m9lrNV/HJJI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KOiDBApJlcDZy2xBPGX7JmWhdBBsz97WPR3z5NiwdrWX52svjYyFgp8pTeoWcTkxW 85aaygFC0gZca0o9Jr7zZdkSLVCI+IDnBfs5yFtcttllJQIKd53S8nk2gSmATFlX0G t0TxDDYAOyqEQ8I2Ppt8eF2uw+OOuu+fzjgdlWJ5KqMu6lyzaFez0V+vSDxVF6qgN3 tjpNPFKJ915ur2kw2vXyr5VgLYKBpTDFLo78wOcD6amEQe7ZBCfraLQKsnys4meANl AzOf9MOiLsUZNtZbi6E2wkl69p2nt4neBnIMdcTtg2s+q6+cHp0RKC3c9lKBYvcQZx RJY/CyumgWOug== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-51662972715so763388a12.1 for ; Thu, 08 Jun 2023 08:43:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239009; x=1688831009; 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=MNXM5/Phz41MXToEHHi2CNdScWcqgmeRS73QJhGQ0thDR+7aBU1dg8RS/P9cfF5yqY vW4TK6+JHW/89dhr9JPCmQKCtkoO2kVsFqoMOgQ5MIeskIsVS+tPrgN5QtsYnIn1s+Tz uiCVsXZCgbJudWyPHRsFOoGb33iX/bRy18wV8+q4/8kHHWKKC7MZ9nzEsyjc7y0SSOjb Jge+0GIHuNbb99dF6Te+61nDUp5xZVjRY0bel5u3piYmgC2cEVFQKASXln7aajt06BG2 hdP1LaiPY+rQuJbHG0vzi/4vGX/HOy+HdtmA83+MvoZ51ymZttbw4J1Vev8+6yrVQ98+ ZP3g== X-Gm-Message-State: AC+VfDyo/mFiY0Lr4Rytjsi6niFfyij1ozy52fvDXU1jgE6cLWxf/MpA eIzGzQ4MtiEXsXbzvYBqeG2YyP1N3tGv0Jj7jQOFyA3N1tbRKlA3fkFYqO3uc+Liyj0i77tZodF dIAhNpwxL54x1fHh49Gs/ApPBFDhS54vrkLD/2sC6XQ== X-Received: by 2002:a05:6402:1218:b0:50e:412:5a50 with SMTP id c24-20020a056402121800b0050e04125a50mr7251916edw.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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D !(session->s_con.peer_features & CEPH_FEATURE_FS_BTIME); + kuid_t caller_fsuid; + kgid_t caller_fsgid; =20 ret =3D 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(stru= ct ceph_mds_session *session, =20 head->mdsmap_epoch =3D cpu_to_le32(mdsc->mdsmap->m_epoch); head->op =3D cpu_to_le32(req->r_op); - head->caller_uid =3D cpu_to_le32(from_kuid(&init_user_ns, - req->r_cred->fsuid)); - head->caller_gid =3D 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 =3D from_vfsuid(req->r_mnt_idmap, &init_user_ns, + VFSUIDT_INIT(req->r_cred->fsuid)); + caller_fsgid =3D from_vfsgid(req->r_mnt_idmap, &init_user_ns, + VFSGIDT_INIT(req->r_cred->fsgid)); + head->caller_uid =3D cpu_to_le32(from_kuid(&init_user_ns, caller_fsuid)); + head->caller_gid =3D cpu_to_le32(from_kgid(&init_user_ns, caller_fsgid)); head->ino =3D cpu_to_le64(req->r_deleg_ino); head->args =3D req->r_args; =20 --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 1ACFAC7EE25 for ; Thu, 8 Jun 2023 15:43:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237185AbjFHPny (ORCPT ); Thu, 8 Jun 2023 11:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237043AbjFHPnr (ORCPT ); Thu, 8 Jun 2023 11:43:47 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DB1F30DB for ; Thu, 8 Jun 2023 08:43:35 -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 6E1E63F33C 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-f71.google.com with SMTP id 4fb4d7f45d1cf-514bcf60cd1so758666a12.2 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=Xft3SrLJR3AKq6atH2F5k9fdkN7Rxqlsruxso/UkIUnjQsNtUX5svAzah5fLybIR7c xdkRiMOns5AwLIgbMDhHl9LkOv6RXwbogDnXtRO6yfjS5xgqWrtLSlEiqwGOWAELgL5+ eaYsuz2WtuA+XM9wB1PQLHO0mIQ5hVMTEIAGv4Q7Se84AQJgLn6W0hDdZhiLsDAxQ9KO PKC5e411KVxVaEwcBnsU9RcLE6OlYyaDZA5ng6Y9q8a054i+Mv8JvJpdFbtjFpt5jsAP MT1PXR1Yh47kZNnr3KCC2ODgLiNO9I2NANklP/9yNYHLf2+JcO5ThFiNKwZcumxKlXAu yg7Q== X-Gm-Message-State: AC+VfDy1CguPpbeJvDuX4Dkypz6lmsrKfEJDC9df0ruaKuwiWm7Nn+is 05jmAGc5auckFIpamZQgqcxshPcbYgr2lOuSKqEwLYd9nUWbG5zCkQiuVxRANPHG9G4Y7QVr+EP lT6UOpfYqJVRPmNzQn2Y2upd3xsdMBrHrCipv8A5jnQ== X-Received: by 2002:a05:6402:799:b0:514:a6bd:144a with SMTP id d25-20020a056402079900b00514a6bd144amr7678708edy.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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 i= node *dir, req->r_parent =3D dir; ihold(dir); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); + req->r_mnt_idmap =3D mnt_idmap_get(idmap); req->r_args.mknod.mode =3D cpu_to_le32(mode); req->r_args.mknod.rdev =3D cpu_to_le32(rdev); req->r_dentry_drop =3D 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 =3D 2; req->r_dentry_drop =3D CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; req->r_dentry_unless =3D CEPH_CAP_FILE_EXCL; + req->r_mnt_idmap =3D mnt_idmap_get(idmap); if (as_ctx.pagelist) { req->r_pagelist =3D as_ctx.pagelist; as_ctx.pagelist =3D 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 =3D cpu_to_le32(mode); + req->r_mnt_idmap =3D mnt_idmap_get(idmap); req->r_dentry_drop =3D CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL; req->r_dentry_unless =3D CEPH_CAP_FILE_EXCL; if (as_ctx.pagelist) { @@ -1324,6 +1327,7 @@ static int ceph_rename(struct mnt_idmap *idmap, struc= t inode *old_dir, req->r_old_dentry_unless =3D CEPH_CAP_FILE_EXCL; req->r_dentry_drop =3D CEPH_CAP_FILE_SHARED; req->r_dentry_unless =3D CEPH_CAP_FILE_EXCL; + req->r_mnt_idmap =3D mnt_idmap_get(idmap); /* release LINK_RDCACHE on source inode (mds will lock it) */ req->r_old_inode_drop =3D CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; if (d_really_is_positive(new_dentry)) { --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 42D03C7EE25 for ; Thu, 8 Jun 2023 15:44:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236843AbjFHPoH (ORCPT ); Thu, 8 Jun 2023 11:44:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33016 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237162AbjFHPnt (ORCPT ); Thu, 8 Jun 2023 11:43:49 -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 0326830DF for ; Thu, 8 Jun 2023 08:43:37 -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 81FAB3F36B 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-f69.google.com with SMTP id 4fb4d7f45d1cf-51495d51e0fso754587a12.2 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=bhPHP8ltFo6rXAv/OqGmlrOuoSIuhZiJDImcWJGFa6vz4nrCB2vRP/oDDGFeVITWuL /OjwbJBk8yKrxIiS+7fEPbxefh/zz12B6UhM757CHpdwUecIfVIrTzYllhbVyllejpiM hRMFYFN//TOMhKgjLCeb2XS5NDwxEDQes/OMB8nBHCsmP52vI1Z11D4Njuhq9uKj5XOs kojGhVp3Yt4TQmZsAZmC3DIMH3UjEocWGAlFROZWWF4SZjYau8tFtxBWGEzwE8c6b9ME 5z2MYnijJml/h/j5an3xo788endVN3tVHu+sHSZ5VlJMShThqQe1Dag0GfGsE9/bJvhN H6cg== X-Gm-Message-State: AC+VfDw99TCbwqfUZCVRG0UR/l3Sj/mW9U3qu3aKQrmC/H4Mm4LJwJbd u07NvRFiPwggEH5vW8zXUyzBKhGiIiIqBZMKbCo9iPY39ZQDX31Cs2UGm7EntK9m46dYpyAPBUy ujrWhTYrwTpP9nUrohndwrNjy6O/yYIIOmq24z6B6SQ== X-Received: by 2002:a05:6402:147:b0:514:9c05:819e with SMTP id s7-20020a056402014700b005149c05819emr7681644edu.0.1686239013828; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 struc= t path *path, return err; } =20 - generic_fillattr(&nop_mnt_idmap, inode, stat); + generic_fillattr(idmap, inode, stat); stat->ino =3D ceph_present_inode(inode); =20 /* --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 7E8C7C7EE23 for ; Thu, 8 Jun 2023 15:44:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237376AbjFHPon (ORCPT ); Thu, 8 Jun 2023 11:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237153AbjFHPoU (ORCPT ); Thu, 8 Jun 2023 11:44:20 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BB4B30DA for ; Thu, 8 Jun 2023 08:43:55 -0700 (PDT) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 0F92B3F56E for ; Thu, 8 Jun 2023 15:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239022; bh=Yx9DhBwZ0J2oRahK7SO/c3VRSYe4JEpen4id9pbwqa8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bAj9D86lm7Kww9Am/3rrNGWc0XDsrvF4EhhX9nCHOvzkEALyjt0j6G0E1dN6YwP8U PvKr6lP9yyyrChWBn1CxenfhvJcZHBVQMEXHqDCUCJ+Ccr6SxfJ2jS/OKrY7igtjgi ur+YSwAqrF2uzXrCxmIZLMiy7kLUMhI4E3UDlYFea53yXrsGNm8gxwUnih5r/cR+98 Jq8eB38LfX5IR/zjlUXPLSMlkWrKTOz2XIDJSJEEmN8nZIOImBgJRHtpFzsGiBnfCO nb5Ke+Mll6mzzekQb7NC5WgQz5Hm4TbkI1V9S9G8OM5SINRihDzqWIAY9NmXpUs+/3 dIZXTUiCNZu6g== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-9744659b7b5so100326266b.3 for ; Thu, 08 Jun 2023 08:43:42 -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=hNJ3ZqcAjss8+mCa0iZe2Qzofz47TTGbZcZUnVEFJsEKAFp6aoI2l5z36kszsaPw2Y IqKj7M1VGRuUugEJ9E53RLqEO442M1tokYv4gPx2imVTeaZohHu61cRAJHw1FO2wqttx akgIpK0y41Q6HWZ3nevvMSxFsTQbjX/mBMPAmsZo7Jyt8BVHTWw88uYOh8Df9994l0rO oo3t5Mtcw7DAAerevjtX5zDkSdACwyWSJAaC2YiGat/nk4Hpg3Y3pk1/CfRBfEeXqjCa EEC4bA07V/y6PjaTQSmYetyqeLCfetDQZqik/aXJ1ukdmWOV0e0LQRsAqSY4DgcOXI1o c5tQ== X-Gm-Message-State: AC+VfDxOCplQQ0Z2v5vXzpTmAiI1LMQBtOIqUW7H4heKvOkrNn70urPV iGFmAg/5sYoOAvUDElxszSWL9Mg4Mj1L/TtFuobTBYzGcRA2tMauPxC1YbJmFMrvQbJXM5gMJeE QR1pWrUMA2qmEZYN2GH5vqXCq6pHgTNqwtuUXgnMJbw== X-Received: by 2002:a17:906:5d14:b0:974:61dc:107c with SMTP id g20-20020a1709065d1400b0097461dc107cmr124323ejt.44.1686239016664; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 i= node *inode, err =3D ceph_do_getattr(inode, CEPH_CAP_AUTH_SHARED, false); =20 if (!err) - err =3D generic_permission(&nop_mnt_idmap, inode, mask); + err =3D generic_permission(idmap, inode, mask); return err; } =20 --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 B4BAAC7EE23 for ; Thu, 8 Jun 2023 15:44:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234473AbjFHPoV (ORCPT ); Thu, 8 Jun 2023 11:44:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236585AbjFHPoK (ORCPT ); Thu, 8 Jun 2023 11:44:10 -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 8D05F2D69 for ; Thu, 8 Jun 2023 08:43:44 -0700 (PDT) Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id F290D3F36A for ; Thu, 8 Jun 2023 15:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239019; bh=g/m6XNFvTOUfG03RZDOMzrTB4ATEHu4pMqVecpMcDjA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RB2lXyPBazDFw+z18t6MQN0Mr90Ei3G+ZtYBxzCRhhi3dxlYtn5uHCunor/NvBEzx +IWGgn8+oXotj2rLTw8C16MgU/6yxavJIL3LMeQ6LcrB7s+gD/zrz62AS4zMtdF9rY 7ZjneORo8239/ULdI8obYeijOy0yIV5JIqm5Z2BJmYVdPdqocfH611mlhLg5ZAMaX0 5iqDqoQU6k0ZU9mHl+20ycuT0Mg6duXvfD/B2ZuAfCctLah+aum/I+LpE8viJJPW6c hYGObPAQ2IVyqIeemyYju8BFCmIeqvVC3Hl7w6bm3T97EhF7PLCbYGKCiHFncsnu/l IIa3hKcx90Jfw== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-977cb78acfcso80506566b.3 for ; Thu, 08 Jun 2023 08:43:39 -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=bZ/ZdqPj9RrmB5mPFzxth1v7nfvBJB5VkMU3YafKIlp20/Dq2cf9DJBqMr2PEEHLxg JShdTV8PLF2F9vn/+XLd7H3rqTGvEYZxK8I47vKYKKD6nsK08wtl4Q+8Hx5ib4CLnBCp aOkUonLPVYu/teV0R+KKIhcCXU99YCm2qAbh9xZGYgQLPq3BE1uQ9B8pPWe4v3P8RYfm ID0Sy40+iUsvKS4FTNsIEdPnFuYqWcfjBnoHV/dVXzcvcbgzSbr7YEry7G2L2bGHjOBv /LEqnuR3Buek/3yWSy0sNQvblBCPrpfpfEADAJDW1sG4jFkrXnH2p3SMuTIaoaxN3diW Qa7g== X-Gm-Message-State: AC+VfDzzzxhHpQiLDmgf79WJzDN+4lgXmZb0jHhPnzOqSdhbAUDhbBJ7 mMdz6LT+r5XSEOxqgEJxKOpKnj15btpBSFwAvwkB7uL0b6rl5iwhS+bwEv7U9cgMI4i2EubTvRf LaaW2YsI5sjFKFAvLRMDT5iq7/WtivmZaN+n4qeTkPA== X-Received: by 2002:a17:907:74b:b0:978:a964:106e with SMTP id xc11-20020a170907074b00b00978a964106emr142674ejb.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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D current_time(inode); newattrs.ia_mode =3D new_mode; newattrs.ia_valid =3D ATTR_MODE | ATTR_CTIME; - ret =3D __ceph_setattr(inode, &newattrs); + ret =3D __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 =3D old_ctime; newattrs.ia_mode =3D old_mode; newattrs.ia_valid =3D 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_iop= s =3D { .listxattr =3D ceph_listxattr, }; =20 -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 =3D ceph_inode(inode); unsigned int ia_valid =3D attr->ia_valid; @@ -2206,6 +2207,7 @@ int __ceph_setattr(struct inode *inode, struct iattr = *attr) if (mask) { req->r_inode =3D inode; ihold(inode); + req->r_mnt_idmap =3D mnt_idmap_get(idmap); req->r_inode_drop =3D release; req->r_args.setattr.mask =3D cpu_to_le32(mask); req->r_num_caps =3D 1; @@ -2252,7 +2254,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dent= ry *dentry, ceph_quota_is_max_bytes_exceeded(inode, attr->ia_size)) return -EDQUOT; =20 - err =3D __ceph_setattr(inode, attr); + err =3D __ceph_setattr(idmap, inode, attr); =20 if (err >=3D 0 && (attr->ia_valid & ATTR_MODE)) err =3D 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, --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 92D77C7EE37 for ; Thu, 8 Jun 2023 15:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236242AbjFHPoj (ORCPT ); Thu, 8 Jun 2023 11:44:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237236AbjFHPoR (ORCPT ); Thu, 8 Jun 2023 11:44:17 -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 BB10B30C8 for ; Thu, 8 Jun 2023 08:43:51 -0700 (PDT) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id C32F03F374 for ; Thu, 8 Jun 2023 15:43:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239022; bh=gghyNGCh9Nhwv51CwrkrRVAEuotD0ib4eCZetw54L9Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TtS9Bh644+5q0boodMQLUJ4lTBcUTjo9TteChfFF9hij/Y9chzQAQspjQE6avG+9X N+hV8WeWvPcuVo19hYohumj1sHWZ7YusJWHw56wtRQNPT+u5iD/L+e9uyZVDgli9h6 pGhdrtWe24hIj6gqvswg5lNHZa1L6e3iX8B4Kjet+rF50BoExtCK+c1gRfis//Cr0Y wA+fFGEQhhUL+NgdY0EPrebF8zccAQSuFow0UW9S6sT7rpRl25r8yCDUwUu+oPE8JI 94ltbnnVNOh4fdCAup3DnO/3QgdLFCMfD4KQfaJ+Hhbnh9ZJhcLpKnqALsxSqqaMBP bgKc0JbZfqq8g== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-50ddef368e4so706575a12.0 for ; Thu, 08 Jun 2023 08:43:42 -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=TwUvzty3w/KJB0FnJz1WPdjh9W1bfJwJJHZdaZf3TWVZHrCuew7RnFPfz3HwPaZtLR qCs5x+0J9xVLPnwoATB0/5Vqe56+MG/0x5jjGQTU7w/B0RWwXBVNYtMok1MnM8fjzk39 puifV91VHPa898sQWitMXc0qAnM+/HQAhf0jYYFlpxcJJVyrR2pT0yFbnw2v6B/66O4y Ldmkh1T4KkK4+l3maNCUSs2EiHZZDOs6AGw1Kz+UWRgcaO5psIwimZ51eOPT70WDaVIJ uiJXfvN5QBCOBzOwBWx7rBOXR/N6xecx3/nlqEVtjDcFIuR8xnk8LYwI+Mhd4oR58Tbe ZNdA== X-Gm-Message-State: AC+VfDybK8vO9RJOj1nH6/UbRxvwt2KM8NE7K0rer62QjwkJLbU1pl5U k4CKeNXF3rK8m0XErGRU1r7GgIZSiLNTPf5dl6MVI6uqL57nAK7UqNeQ/tb0IJJ7aRSHwd9pxf+ hJmDlKDqcrmRLLJMCcD/SaPUGNqX42p4QsdC57sc70A== X-Received: by 2002:a05:6402:2cc:b0:514:ae18:1637 with SMTP id b12-20020a05640202cc00b00514ae181637mr7681215edx.23.1686239022298; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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)); =20 if (ia_valid & ATTR_UID) { + kuid_t fsuid =3D 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 =3D attr->ia_uid; + inode->i_uid =3D fsuid; dirtied |=3D CEPH_CAP_AUTH_EXCL; } else if ((issued & CEPH_CAP_AUTH_SHARED) =3D=3D 0 || - !uid_eq(attr->ia_uid, inode->i_uid)) { + !uid_eq(fsuid, inode->i_uid)) { req->r_args.setattr.uid =3D cpu_to_le32( - from_kuid(&init_user_ns, attr->ia_uid)); + from_kuid(&init_user_ns, fsuid)); mask |=3D CEPH_SETATTR_UID; release |=3D CEPH_CAP_AUTH_SHARED; } } if (ia_valid & ATTR_GID) { + kgid_t fsgid =3D 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 =3D attr->ia_gid; + inode->i_gid =3D fsgid; dirtied |=3D CEPH_CAP_AUTH_EXCL; } else if ((issued & CEPH_CAP_AUTH_SHARED) =3D=3D 0 || - !gid_eq(attr->ia_gid, inode->i_gid)) { + !gid_eq(fsgid, inode->i_gid)) { req->r_args.setattr.gid =3D cpu_to_le32( - from_kgid(&init_user_ns, attr->ia_gid)); + from_kgid(&init_user_ns, fsgid)); mask |=3D CEPH_SETATTR_GID; release |=3D CEPH_CAP_AUTH_SHARED; } @@ -2242,7 +2246,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dent= ry *dentry, if (ceph_inode_is_shutdown(inode)) return -ESTALE; =20 - err =3D setattr_prepare(&nop_mnt_idmap, dentry, attr); + err =3D setattr_prepare(idmap, dentry, attr); if (err !=3D 0) return err; =20 @@ -2257,7 +2261,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dent= ry *dentry, err =3D __ceph_setattr(idmap, inode, attr); =20 if (err >=3D 0 && (attr->ia_valid & ATTR_MODE)) - err =3D posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode); + err =3D posix_acl_chmod(idmap, dentry, attr->ia_mode); =20 return err; } --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 8845DC7EE23 for ; Thu, 8 Jun 2023 15:44:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237202AbjFHPov (ORCPT ); Thu, 8 Jun 2023 11:44:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237203AbjFHPo2 (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 294AB35A2 for ; Thu, 8 Jun 2023 08:43:59 -0700 (PDT) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id E0FE73F370 for ; Thu, 8 Jun 2023 15:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239026; bh=/It8VSgZDTEKktJxHTMOOJHpvqL0RXNtakCJDr6cWYA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZhAFBfheINB8eE2BwI9zeoKJZLRNin5AAEkC7I74PxVXoNXw2gxoGhD3ddTXopxEv PbgOnXBh8osyvi109qX6yC4dhGv5hUEbBkta3fnlUNuuQLolI3chfK8THaFUOo2ywR Ryda4hye1cUOA1TLVeAZ8Ff9qdRAFAPgYd22p325I+xj9mtuPDuXK358YngLOpZBVR GkWLzNc7PYq+WVk96hCDE5w+RP2OV3NH09EY9u5zkL71SC1XMcufUjkBq/PXhemQVi zl2MGilLnXAQtVWFGacifoojo+3m7MS80zvlc8XES7sRuBNelluZKdZdkxd2XXJj8z 57OxDV6KtDTCg== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-514b05895f7so845264a12.0 for ; Thu, 08 Jun 2023 08:43:46 -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=ke4qHT7rDGnWThiYEbKEMavi3X2g44LcKhbx0ujdmTm49NfsRXKl+vX2iijqPpiHm+ Ldm62DFGVXcV67ZW4IrO3hdT0zz1OTp4lDxjwYqhl80LmkKK4nuJZSiKEJVJhrgWcFRP vlXPJ+4aEAm2gwjivtbIdJxnwIEzIFmW6jztE+K+bngE8koUwb7BjblbFK0jH4pEUWPV PIXxjpndt4v6+LuqWjBJxC7FQY7KHh/Hcb5DCgJkxqg+QE8+PBwgNk2xJAd8WJPqjbQC zb+zpZCoGY05L1fmLaThkIYLqqF4mxalAhp9gfFXpotD02uk8cNetAd14lIFoHusMGuw ISOw== X-Gm-Message-State: AC+VfDwx1GorwqjFxTkOp2RggacNY9uyrR8Hn2Ik1JlPlz75pKc6xzOl yx75+r2kPwhbyk9PGKfye8KZ22dnGLtwfhJFfXcrjAWF/khxtbfRrw7xRfH1wR3aqrM1lhrTrhH DPrp+yeyL6TZ2gLXl7Zgib79NOEBUOYuYl+1puX4dkg== X-Received: by 2002:aa7:d88a:0:b0:50c:cde7:285b with SMTP id u10-20020aa7d88a000000b0050ccde7285bmr7205759edq.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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D XATTR_NAME_POSIX_ACL_ACCESS; if (acl) { - ret =3D posix_acl_update_mode(&nop_mnt_idmap, inode, + ret =3D posix_acl_update_mode(idmap, inode, &new_mode, &acl); if (ret) goto out; --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 056C0C7EE23 for ; Thu, 8 Jun 2023 15:45:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231626AbjFHPpD (ORCPT ); Thu, 8 Jun 2023 11:45:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237221AbjFHPof (ORCPT ); Thu, 8 Jun 2023 11:44:35 -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 D9D4D35AB for ; Thu, 8 Jun 2023 08:44:02 -0700 (PDT) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 55B363F36E 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-f72.google.com with SMTP id 4fb4d7f45d1cf-50daa85e940so813901a12.0 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=ABtgICxA6hwEdmE6mBvoAwXpjgnD2eKsMkJJWPS9gmYI8rT7TIdO0lkhZOicl0YKPn wRHRlr/JYNcboLfjXmVikli6SS5cVViMzVevUh51/MBLiFxVYkuT/jJoB75kFubHs0td +2URhP+r46Hy3ICtIijPDRX+zVPq3hXkDqjolwypRsu0Tg2n724rH1ZKkyb9uCttYV8V e8geMrHkuCFy5EQEEKOEf9nABC4qF9yrStgPencyiYRHJ4qbW/h9g0tH4fR/NNCutLaO 1djXdSdQEvxPQaPaKfk5tq8u75ZgK3sOg82kYBC/eRCF/DmpzbhK5jGTGmBpl5F0lJr+ 12pw== X-Gm-Message-State: AC+VfDxInYuvZlmxPMGzmMHMY70oSY49oK08VS5aJZNi1iB7XK6SBMMu qJGRdhPqnP0D6SjdwO/mTxIduX80DgZjFlqzL0uq+K5YD5/+IXUdjHw6hc0e6Uz9uDx1nF0FmBU 6wTP5GQ5IpDrMaHgf27MwHbpgmmxprk53NO1OOv3mIQ== X-Received: by 2002:aa7:c7d4:0:b0:510:f462:fc47 with SMTP id o20-20020aa7c7d4000000b00510f462fc47mr7221334eds.7.1686239027037; 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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D cpu_to_le32(1); in.truncate_size =3D cpu_to_le64(-1ULL); in.xattr_version =3D cpu_to_le64(1); - in.uid =3D cpu_to_le32(from_kuid(&init_user_ns, current_fsuid())); + in.uid =3D 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 =3D cpu_to_le32(from_kgid(&init_user_ns, dir->i_gid)); =20 @@ -662,7 +664,9 @@ static int ceph_finish_async_create(struct inode *dir, = struct dentry *dentry, if (S_ISDIR(mode)) mode |=3D S_ISGID; } else { - in.gid =3D cpu_to_le32(from_kgid(&init_user_ns, current_fsgid())); + in.gid =3D cpu_to_le32(from_kgid(&init_user_ns, + mapped_fsgid(req->r_mnt_idmap, + &init_user_ns))); } in.mode =3D cpu_to_le32((u32)mode); =20 @@ -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 =3D ceph_sb_to_client(dir->i_sb); + struct mnt_idmap *idmap =3D file_mnt_idmap(file); struct ceph_mds_client *mdsc =3D 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 |=3D CEPH_CAP_XATTR_SHARED; req->r_args.open.mask =3D cpu_to_le32(mask); req->r_parent =3D dir; + req->r_mnt_idmap =3D mnt_idmap_get(idmap); ihold(dir); =20 if (flags & O_CREAT) { --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 7D610C7EE37 for ; Thu, 8 Jun 2023 15:45:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236972AbjFHPpH (ORCPT ); Thu, 8 Jun 2023 11:45:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237349AbjFHPoh (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 DE2F730DD for ; Thu, 8 Jun 2023 08:44:07 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.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 654103F371 for ; Thu, 8 Jun 2023 15:43:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239031; bh=2SBMId8uucXXsmkpO9XvsuxzyfuN3DNew61ExZTJFDc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nxJw72xQlyzZLWNibUYvv4UHFRUglQhF9+tWix7Ut+1bPPs9mDVY57o9XLIIBoFLs RsdxmjDWSl2zgsjQzKYKHVXFxbnsrNm3sJgptkeT5kOee0JZ24vcOoI0Ceqpnf+BDg k1JDJ7WBRydwreL0GSdPk3v/htaQvCbmj/WNXg0n/KWY0mpBH3UbETzsZFeBJm4zpn Za2SodNMZlLPNCiTkoBvmGsmaH2G/jiavqxUIhC9LQo/7wacq/a/intrxzGNTfTtIj ne9BA9PWti2k1EwZ1c+qcHTSuODGHNI0R/l4UP7kiBn8ose6edVD/5Y7rQuDoQcQ3O k6jy33uTqR/Mw== Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-30c3ad3238bso355782f8f.0 for ; Thu, 08 Jun 2023 08:43:51 -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=aw4WXq6aaJSIXeS/7RHBp2N5rGV3L77hURdwe8pVwk/+YIJ5E57LpNFFE/5AmqvvzC jZn8IhnsxdvzO9n2l8iJuC5Ugno/wl+CD69bwY7GYTOVnL0FfoaRmwCQHdnWmA/c+AxY 7fp46M7/wBsCgNFIxw0XFW0n6JbgjBeXfxftlosW8xAwKUFvw70P9vpVisRdPv/8umKE 336uPYzMNHdixr8jenArhBkwq0+2o0mJBSfGty0EATw9BsSebeUvBAaKpFkEW7CdUZc+ A+kIIQAgA9YlOrCABn2sXcjnfTQTyV04j2IRKNT7f3cxzA/RgbGewuPN8S2cCqnu8Pqc Gi9Q== X-Gm-Message-State: AC+VfDx2TOLklqFRR96p3OCGk46AOou7OY387C16voxwWKs48UmV4nsJ ThkDX+leLAASKn0448O7JD4kBOwDxGzKp24rbfyoGlrgg5+MPkLmhfwzsMLqi53uTNc+889kWLh 2OriXsONOmewiof5wjYrOpk7vIZS/5APD8t5WvcGU4Q== X-Received: by 2002:adf:e5c6:0:b0:30e:5380:5eb3 with SMTP id a6-20020adfe5c6000000b0030e53805eb3mr5859730wrn.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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D VM_FAULT_SIGBUS; } else { + struct mnt_idmap *idmap =3D file_mnt_idmap(vma->vm_file); struct address_space *mapping =3D inode->i_mapping; struct page *page; =20 @@ -1481,7 +1482,7 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault = *vmf) ret =3D VM_FAULT_OOM; goto out_inline; } - err =3D __ceph_do_getattr(inode, page, + err =3D __ceph_do_getattr(idmap, inode, page, CEPH_STAT_CAP_INLINE_DATA, true); if (err < 0 || off >=3D 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 wa= nt, loff_t endoff, int *got struct inode *inode =3D file_inode(filp); struct ceph_inode_info *ci =3D ceph_inode(inode); struct ceph_fs_client *fsc =3D ceph_inode_to_client(inode); + struct mnt_idmap *idmap =3D file_mnt_idmap(filp); int ret, _got, flags; =20 ret =3D ceph_pool_perm_check(inode, need); @@ -3015,7 +3016,7 @@ int ceph_get_caps(struct file *filp, int need, int wa= nt, loff_t endoff, int *got * getattr request will bring inline data into * page cache */ - ret =3D __ceph_do_getattr(inode, NULL, + ret =3D __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 =3D ceph_do_getattr(inode, CEPH_CAP_LINK_SHARED, false); + err =3D ceph_do_getattr(&nop_mnt_idmap, inode, CEPH_CAP_LINK_SHARED, fals= e); 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, str= uct iov_iter *to) size_t len =3D iov_iter_count(to); struct inode *inode =3D file_inode(filp); struct ceph_inode_info *ci =3D ceph_inode(inode); + struct mnt_idmap *idmap =3D file_mnt_idmap(filp); bool direct_lock =3D iocb->ki_flags & IOCB_DIRECT; ssize_t ret; int want =3D 0, got =3D 0; @@ -1693,7 +1694,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, str= uct iov_iter *to) return -ENOMEM; } =20 - statret =3D __ceph_do_getattr(inode, page, + statret =3D __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, st= ruct iov_iter *from) struct inode *inode =3D file_inode(file); struct ceph_inode_info *ci =3D ceph_inode(inode); struct ceph_fs_client *fsc =3D ceph_inode_to_client(inode); + struct mnt_idmap *idmap =3D file_mnt_idmap(file); struct ceph_osd_client *osdc =3D &fsc->client->osdc; struct ceph_cap_flush *prealloc_cf; ssize_t count, written =3D 0; @@ -1801,7 +1803,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, st= ruct iov_iter *from) current->backing_dev_info =3D inode_to_bdi(inode); =20 if (iocb->ki_flags & IOCB_APPEND) { - err =3D ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false); + err =3D 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 =3D=3D SEEK_END || whence =3D=3D SEEK_DATA || whence =3D=3D SE= EK_HOLE) { struct inode *inode =3D file_inode(file); + struct mnt_idmap *idmap =3D file_mnt_idmap(file); int ret; =20 - ret =3D ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false); + ret =3D 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 =3D ceph_sb_to_client(inode->i_sb); @@ -2325,6 +2326,7 @@ int __ceph_do_getattr(struct inode *inode, struct pag= e *locked_page, return PTR_ERR(req); req->r_inode =3D inode; ihold(inode); + req->r_mnt_idmap =3D mnt_idmap_get(idmap); req->r_num_caps =3D 1; req->r_args.getattr.mask =3D cpu_to_le32(mask); req->r_locked_page =3D locked_page; @@ -2411,7 +2413,7 @@ int ceph_permission(struct mnt_idmap *idmap, struct i= node *inode, if (mask & MAY_NOT_BLOCK) return -ECHILD; =20 - err =3D ceph_do_getattr(inode, CEPH_CAP_AUTH_SHARED, false); + err =3D ceph_do_getattr(idmap, inode, CEPH_CAP_AUTH_SHARED, false); =20 if (!err) err =3D generic_permission(idmap, inode, mask); @@ -2464,7 +2466,7 @@ int ceph_getattr(struct mnt_idmap *idmap, const struc= t path *path, =20 /* Skip the getattr altogether if we're asked not to sync */ if ((flags & AT_STATX_SYNC_TYPE) !=3D AT_STATX_DONT_SYNC) { - err =3D ceph_do_getattr(inode, + err =3D 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 =3D ceph_inode(file_inode(file)); + struct mnt_idmap *idmap =3D file_mnt_idmap(file); struct ceph_ioctl_layout l; int err; =20 - err =3D ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false); + err =3D ceph_do_getattr(idmap, file_inode(file), CEPH_STAT_CAP_LAYOUT, fa= lse); if (!err) { l.stripe_unit =3D ci->i_layout.stripe_unit; l.stripe_count =3D ci->i_layout.stripe_count; @@ -64,6 +65,7 @@ static long __validate_layout(struct ceph_mds_client *mds= c, static long ceph_ioctl_set_layout(struct file *file, void __user *arg) { struct inode *inode =3D file_inode(file); + struct mnt_idmap *idmap =3D file_mnt_idmap(file); struct ceph_mds_client *mdsc =3D 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; =20 /* validate changed params against current layout */ - err =3D ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false); + err =3D ceph_do_getattr(idmap, file_inode(file), CEPH_STAT_CAP_LAYOUT, fa= lse); if (err) return err; =20 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 cep= h_mds_client *mdsc, } if (qri->inode) { /* get caps */ - int ret =3D __ceph_do_getattr(qri->inode, NULL, + int ret =3D __ceph_do_getattr(&nop_mnt_idmap, qri->inode, NULL, CEPH_STAT_CAP_INODE, true); if (ret >=3D 0) in =3D 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 =3D CEPH_MOUNT_MOUNTED; =20 if (sb->s_root) { - err =3D __ceph_do_getattr(d_inode(sb->s_root), NULL, - CEPH_STAT_CAP_INODE, true); + err =3D __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 in= ode *inode) } =20 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 forc= e) +static inline int ceph_do_getattr(struct mnt_idmap *idmap, struct inode *i= node, + 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 |=3D CEPH_STAT_RSTAT; if (vxattr->flags & VXATTR_FLAG_DIRSTAT) mask |=3D CEPH_CAP_FILE_SHARED; - err =3D ceph_do_getattr(inode, mask, true); + err =3D ceph_do_getattr(&nop_mnt_idmap, inode, mask, true); if (err) return err; err =3D -ENODATA; @@ -989,7 +989,7 @@ ssize_t __ceph_getxattr(struct inode *inode, const char= *name, void *value, } =20 /* get xattrs from mds (if we don't already have them) */ - err =3D ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR, true); + err =3D 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 *n= ames, size_t size) if (ci->i_xattrs.version =3D=3D 0 || !__ceph_caps_issued_mask_metric(ci, CEPH_CAP_XATTR_SHARED, 1)) { spin_unlock(&ci->i_ceph_lock); - err =3D ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR, true); + err =3D ceph_do_getattr(&nop_mnt_idmap, inode, CEPH_STAT_CAP_XATTR, true= ); if (err) return err; spin_lock(&ci->i_ceph_lock); --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 29D21C7EE25 for ; Thu, 8 Jun 2023 15:46:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237153AbjFHPqM (ORCPT ); Thu, 8 Jun 2023 11:46:12 -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 S237476AbjFHPp4 (ORCPT ); Thu, 8 Jun 2023 11:45:56 -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 4269D3AAB for ; Thu, 8 Jun 2023 08:45:04 -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 7D2BF3F577 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-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-51495d51e0fso754789a12.2 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=SnmKSqF43dPZC68TbtOF9e0rYv5tdFrhRMWHULYpy1o6FDq2Fd4J0Y4s/pBUulLUx3 3w60CPxZeupzitgNAWYdWl4lAAcNLFFdeRto1GODjtjH6T7sJrHQTf2PkKE0UF1s7WNr dWf907Oc5H6zzpmAql7sUQO+sHh6hulln2o6SooBMfBkfABwqjA2JuC9BUvYzQ7IKrju Cuo+CDR44JD7WMBbQE+titQn2/BsTXY4CoI3nNQOoway37EmnDGjxOhLIIs8Lx9/VEQ8 WMDlroo1NcfAcqq6mJsx+VwGMkc/pw7suaGCxzNZyxPkmG5EslBOQ7hNMyVYQpNIZNlt dp1w== X-Gm-Message-State: AC+VfDzNUb9/E5PRXft3m8wBeLEuOkXGg9BtC+hQknjl3KLciI5lxrKM p2Fb5WicGzM1roDOTiboEEB3wFgjFOJMliAWrMfgXcwp+JJcAkzPSx6a1/klhdgTaSVoJtjiaGB ePmoYcHdvk/S0mxuq6hm+R9jCzZO7r4cGF6N1fN25Hw== X-Received: by 2002:a05:6402:147:b0:514:9c05:819e with SMTP id s7-20020a056402014700b005149c05819emr7682636edu.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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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; } =20 - ret =3D __ceph_setxattr(inode, name, value, size, 0); + ret =3D __ceph_setxattr(idmap, inode, name, value, size, 0); if (ret) { if (new_mode !=3D old_mode) { newattrs.ia_ctime =3D 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 inod= e *inode) } =20 /* xattr.c */ -int __ceph_setxattr(struct inode *, const char *, const void *, size_t, in= t); +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 *n= ames, size_t size) return err; } =20 -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 =3D ceph_sb_to_client(inode->i_sb); @@ -1118,6 +1119,7 @@ static int ceph_sync_setxattr(struct inode *inode, co= nst char *name, =20 req->r_inode =3D inode; ihold(inode); + req->r_mnt_idmap =3D mnt_idmap_get(idmap); req->r_num_caps =3D 1; req->r_inode_drop =3D CEPH_CAP_XATTR_SHARED; =20 @@ -1132,8 +1134,8 @@ static int ceph_sync_setxattr(struct inode *inode, co= nst char *name, return err; } =20 -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 =3D ceph_inode(inode); @@ -1262,7 +1264,7 @@ int __ceph_setxattr(struct inode *inode, const char *= name, "during filling trace\n", inode); err =3D -EBUSY; } else { - err =3D ceph_sync_setxattr(inode, name, value, size, flags); + err =3D ceph_sync_setxattr(idmap, inode, name, value, size, flags); if (err >=3D 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); } =20 static const struct xattr_handler ceph_other_xattr_handler =3D { --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 122A3C7EE25 for ; Thu, 8 Jun 2023 15:45:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237269AbjFHPpK (ORCPT ); Thu, 8 Jun 2023 11:45:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237363AbjFHPoi (ORCPT ); Thu, 8 Jun 2023 11:44:38 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4616730E7 for ; Thu, 8 Jun 2023 08:44:10 -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 455593F36B 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-f69.google.com with SMTP id 4fb4d7f45d1cf-5147e3dfccdso699104a12.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=jQ2FiPYZFjMy18JHBRkFIh3zfaeV5tfDI/bgwrKz0NKC+275jX2AuXH84cw6feajqB SLamfDMar3gbbLgoamzjDnfKv0BlYhdT7iLSO4AJhZMsBnKt8/bT3i5Y/g+bljHJyAbJ TmZuozDiWKEK2EwbDlZFn6Aog46p00m5lNvJ2ykn+8GO4LqJFWgeO5HFiEOEwSyLmGPE L/w96Z/Ur3n0eNR2V5HlBZPuOrbVu6nSH+GvEJEftgI69CioYy0W+Ms8/1wnuU4wxhan PLhqTWoTIAKRd5pzEIxvvAkyC3mZ8u8+p55yFTm3Lq7uNbApYJsI7+ysnapj51DgQMIu Ryvw== X-Gm-Message-State: AC+VfDzO4yaxh/Zz0/iKcw+1UPsuXZauO0Zh7AwcxotwNvudW27ERX7U idu/lzvtLIfIgLQL+XHWRORAsRihnKsclOLNMy5CNahGb0XHX9w931TyOXjRZ/YyL6PWA3CEh74 +e2nxPh7gkOUOpaK6eCmlm5ZXJzCRv+GOW1T0zSe2rA== X-Received: by 2002:aa7:d9c3:0:b0:50c:4b9:1483 with SMTP id v3-20020aa7d9c3000000b0050c04b91483mr7476589eds.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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D fsc->mdsc; struct ceph_mds_request *req; struct ceph_file_info *fi =3D file->private_data; + struct mnt_idmap *idmap =3D file_mnt_idmap(file); int err; int flags, fmode, wanted; =20 @@ -426,6 +427,7 @@ int ceph_open(struct inode *inode, struct file *file) ihold(inode); =20 req->r_num_caps =3D 1; + req->r_mnt_idmap =3D mnt_idmap_get(idmap); err =3D ceph_mdsc_do_request(mdsc, NULL, req); if (!err) err =3D 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, vo= id __user *arg) req->r_inode =3D inode; ihold(inode); req->r_num_caps =3D 1; + req->r_mnt_idmap =3D mnt_idmap_get(idmap); =20 req->r_inode_drop =3D CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL; =20 @@ -138,6 +139,7 @@ static long ceph_ioctl_set_layout(struct file *file, vo= id __user *arg) static long ceph_ioctl_set_layout_policy (struct file *file, void __user *= arg) { struct inode *inode =3D file_inode(file); + struct mnt_idmap *idmap =3D 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 =3D inode; ihold(inode); req->r_num_caps =3D 1; + req->r_mnt_idmap =3D mnt_idmap_get(idmap); =20 req->r_args.setlayout.layout.fl_stripe_unit =3D cpu_to_le32(l.stripe_unit); --=20 2.34.1 From nobody Mon Feb 9 05:01:14 2026 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 94EE7C7EE45 for ; Thu, 8 Jun 2023 15:46:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237442AbjFHPqX (ORCPT ); Thu, 8 Jun 2023 11:46:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237405AbjFHPqC (ORCPT ); Thu, 8 Jun 2023 11:46:02 -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 659EF3C04 for ; Thu, 8 Jun 2023 08:45:13 -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 E8E3E3F37E 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-f69.google.com with SMTP id 4fb4d7f45d1cf-50ddef368e4so706680a12.0 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=HGFIXqwmX+N6eQHOftkNugT4r8+INMYl2hX26yxTM3tSQU9aQT1EEw4mGx2re0FhAW GSSjpDulfrmmrVKkgEpVUz7kAjIT3pu+FcAuM4g2LAvia3fdf4FRJixDHMWg9xL1Bqpf GTikIQ1+yGtmZwspJ4EIvqjU0LFrPKBEaeZFhHJaf9Tcb4T9isJmYrov8g1e2XSb+UFq sObd+xN+xhhLfbPwDtUKwFh0EoAhyc/DMS5EuxzYPrFv4YvGzK2vxves62xA4omDkMPs fVMzoCNuI4e7MvD0A3NOUJ2o9HOJ72GMoyLU7LK/h3dxRGH/cwdHagdLZRO3LkPdNNXe DJ6Q== X-Gm-Message-State: AC+VfDyvUj3quJhnftC7Cpco5Ax2BOMTSfqM5kmQV+XtNAkYSaeQivfF tt6jmPe00/y608kUnroqFVTFXdIfK4vp6lgxghUjaRKp22JOTezENsRHGR/kst8gz2xoHsKhxMx iWdiMWAmJL2CGsxb+yhlpSxi9azSqh/7ZaxsTzec2iEL2Q1klcg== X-Received: by 2002:aa7:c602:0:b0:514:75ff:6a86 with SMTP id h2-20020aa7c602000000b0051475ff6a86mr7704526edq.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 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 =3D { .name =3D "ceph", .init_fs_context =3D ceph_init_fs_context, .kill_sb =3D ceph_kill_sb, - .fs_flags =3D FS_RENAME_DOES_D_MOVE, + .fs_flags =3D FS_RENAME_DOES_D_MOVE | FS_ALLOW_IDMAP, }; MODULE_ALIAS_FS("ceph"); =20 --=20 2.34.1