From patchwork Fri Jun 9 09:31:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273573 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 CA64CC7EE37 for ; Fri, 9 Jun 2023 09:38:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241707AbjFIJi3 (ORCPT ); Fri, 9 Jun 2023 05:38:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241756AbjFIJhm (ORCPT ); Fri, 9 Jun 2023 05:37:42 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12E1D7AB3 for ; Fri, 9 Jun 2023 02:32:50 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id A5BA33F363 for ; Fri, 9 Jun 2023 09:31:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303119; bh=GFNwWvhavDkNrI4eqwez7OWrv+w+Iw1WNhnwQW/Fw7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bDs0oUKY7vUzjUomCHbVjx3YR+ivI5FZooz/1y3g/Jsg2y0lHGRi/pJCaAyt3kJyb eFW6A3UBmCIMG6MHZIryRDrIpnkODkhoxliwA0NMUpuJD9HTmyXtxG5tHWC+LH7VMi gwdkDS1ui28+A4GMZ/louD90qi8IbRCoCZSxI+mCX0chhPXx90M5oxPRCWQfA5WLUi H3tPvXkvwM1oTpMvUfnT6W6QuiOtldfQ9En1MyRLEchivDW0Gaj7s7peSM0B4TXmt2 L2KLY5S8C6SLoUgwbPlr/J5EfU1zGE9x48tWh+T8YuYC8V/5FQG8hoMoZEfU+QrseI +99te75F6OXSQ== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-977c8170b52so183992066b.0 for ; Fri, 09 Jun 2023 02:31:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303119; x=1688895119; 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=LgJUqBsrnQw1i1nHCEb8FeCqyBPpBHTCQ6rrC+jogBBdOM2GOnZ+MyQf2vMVQSITSN saLH5LrBXQ1KYGauQMFJLwW875sahEYo81zH6Lp+MEt/Z/K2w+uqO6o+n/Z1KnduqYdt 1l0momO1P0HDvh/40t7IAGcTpTUdOahm7oEJajmkwNYBgzp41eBybcDAAYsTGwfvpNXM JE5IINLQlhtcQIpZz45iMdMuHqbvXCE50cCyreF62etDwuQrnVn5HVSvCpHBrOweuzur DWWup7o56L56FwP2Siwh7/YZKJ0Bbj3WRaZOu8Kj0qjutahZ/8YUHxjV9/QkZChNQRvT zhKw== X-Gm-Message-State: AC+VfDz1IDpo+w5tSL6S6Y3Xk8yO1VLUXb3k9jnyL1HHRhob/S0eS2oJ SQMMiZJFUM/xI4x1KnZDnUiiTrlieDEvV1GqLaknEZ3hjWhPit2GsNRBGKFOgqBLylKgbMmyiDF HN0E+4VECvTPtxYlywIJlrpc47+UMEE/n43EW9KBxATI= X-Received: by 2002:a17:907:70a:b0:96f:a935:8997 with SMTP id xb10-20020a170907070a00b0096fa9358997mr1328425ejb.12.1686303119326; Fri, 09 Jun 2023 02:31:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7KTDPE0tV+H7gY9GZ34++hd2WgdCfXpbS52PAeja+APzcvyP7PE8xa61fw03DjcBadMICTyA== X-Received: by 2002:a17:907:70a:b0:96f:a935:8997 with SMTP id xb10-20020a170907070a00b0096fa9358997mr1328411ejb.12.1686303119167; Fri, 09 Jun 2023 02:31:59 -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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:31:58 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Alexander Mikhalitsyn , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Viro , Seth Forshee , linux-kernel@vger.kernel.org Subject: [PATCH v6 01/15] fs: export mnt_idmap_get/mnt_idmap_put Date: Fri, 9 Jun 2023 11:31:11 +0200 Message-Id: <20230609093125.252186-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org These helpers are required to support idmapped mounts in the Cephfs. Cc: Christian Brauner Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn Reviewed-by: Christian Brauner --- v3: - EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL as Christoph Hellwig suggested --- fs/mnt_idmapping.c | 2 ++ include/linux/mnt_idmapping.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c index 4905665c47d0..57d1dedf3f8f 100644 --- a/fs/mnt_idmapping.c +++ b/fs/mnt_idmapping.c @@ -256,6 +256,7 @@ struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap) return idmap; } +EXPORT_SYMBOL_GPL(mnt_idmap_get); /** * mnt_idmap_put - put a reference to an idmapping @@ -271,3 +272,4 @@ void mnt_idmap_put(struct mnt_idmap *idmap) kfree(idmap); } } +EXPORT_SYMBOL_GPL(mnt_idmap_put); diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h index 057c89867aa2..b8da2db4ecd2 100644 --- a/include/linux/mnt_idmapping.h +++ b/include/linux/mnt_idmapping.h @@ -115,6 +115,9 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid) int vfsgid_in_group_p(vfsgid_t vfsgid); +struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap); +void mnt_idmap_put(struct mnt_idmap *idmap); + vfsuid_t make_vfsuid(struct mnt_idmap *idmap, struct user_namespace *fs_userns, kuid_t kuid); From patchwork Fri Jun 9 09:31:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273629 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 51167C7EE29 for ; Fri, 9 Jun 2023 10:09:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240164AbjFIKJd (ORCPT ); Fri, 9 Jun 2023 06:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238001AbjFIKJD (ORCPT ); Fri, 9 Jun 2023 06:09:03 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A5204C17 for ; Fri, 9 Jun 2023 02:58:49 -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 E1C1D3F466 for ; Fri, 9 Jun 2023 09:32:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303158; bh=Qh/WJ81ZpXRyl0gQ4ukcXvtFhi/qxOmZnI5fUrSNycI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SSHqyNCAGo2nxvXcirbMdWsFWKwk2WQLsap0cHr9nOkiqfPaKKzkqOByjXNfgnn2/ NqpLMAKc+DUU6yz8mKaRp8/kf8UXXzP44lM53pKIfIjwkPbj8T/9LPMCCDqCsQA86Q oVEJ3oKrlRA+ozmSL6iq2nmmr/O+wRJk5jzxmzvRtIvjbuhL2QofkeUxg+wFSl4Qvj BTLep6C8LUpsHylClWSDg8LK5dxhFKFNuAvttEdFFBbdlPYWyJQ9dtELzpcTx0/Srq YlEe73VctATEFvNqHWla5GpoEwLue3bhx2ROIS2XSZQQBNLRIwN2L0wK/Pf4tjWU+b ifZyLEl87rJqQ== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-50bf847b267so1431686a12.3 for ; Fri, 09 Jun 2023 02:32:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303157; x=1688895157; 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=Qh/WJ81ZpXRyl0gQ4ukcXvtFhi/qxOmZnI5fUrSNycI=; b=hatAJ67gCbUDy2pUQFdfdQ2/xh181rRU0l2/aj4kM0UyuDEbEGZJ6Sab7gnNtsqAP5 Tz9ODnqcRL5XMPK+UtR0uljnhepGpxN/EQLCuu6pKoCy3a8YM9X8o+s3oRhtDYvZ+Emf eH4IL+J2BFXhsE5SgpfRCGGl7xF0xXNG2mzNgePlf19B99A2hRy6pXG/BLEq79vSPcXO 3DfLj9PqaRpxEz3JEbwiKGu4h/kFrP128cjiVYHXaI2qK2hp+6CyNweM4gsAdGcqPYie krsip6NYVa7ioY2wIyukohqKNgwn8jsyPLa50kas2ysWgk/4JYoxG0Ai0wnTQ70M1s/T BDsA== X-Gm-Message-State: AC+VfDysCb/7gxSYLetYZyDCbPYnCpNO5bk/LJGp8wlmsUOP9WWNHazH XigxIsgnFhUpjeXbaidq3hCF4ZDORfOelspsN4DnA4pG0w4kpYZ2rwM3T4ZuuMzATx12dQNdr6l 8GqPMaYc4FWgTduYFz7ZO2hCLp8oFbdp+FMgJyEBIJKg= X-Received: by 2002:a17:906:ee83:b0:974:5480:171e with SMTP id wt3-20020a170906ee8300b009745480171emr1462452ejb.32.1686303156921; Fri, 09 Jun 2023 02:32:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4VQ7NQSOiIOTdYHqbG/vALAaZAqtr0peZI68CNDA6sXkaWXr8PTJSD5GsVy3Ejtu/h5mXQKw== X-Received: by 2002:a17:906:ee83:b0:974:5480:171e with SMTP id wt3-20020a170906ee8300b009745480171emr1462432ejb.32.1686303156625; Fri, 09 Jun 2023 02:32: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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:36 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 02/15] ceph: stash idmapping in mdsc request Date: Fri, 9 Jun 2023 11:31:13 +0200 Message-Id: <20230609093125.252186-3-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner When sending a mds request cephfs will send relevant data for the requested operation. For creation requests the caller's fs{g,u}id is used to set the ownership of the newly created filesystem object. For setattr requests the caller can pass in arbitrary {g,u}id values to which the relevant filesystem object is supposed to be changed. If the caller is performing the relevant operation via an idmapped mount cephfs simply needs to take the idmapping into account when it sends the relevant mds request. In order to support idmapped mounts for cephfs we stash the idmapping whenever they are relevant for the operation for the duration of the request. Since mds requests can be queued and performed asynchronously we make sure to keep the idmapping around and release it once the request has finished. In follow-up patches we will use this to send correct ownership information over the wire. This patch just adds the basic infrastructure to keep the idmapping around. The actual conversion patches are all fairly minimal. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- v4: - don't call mnt_idmap_get(..) in __register_request --- fs/ceph/mds_client.c | 5 +++++ fs/ceph/mds_client.h | 1 + 2 files changed, 6 insertions(+) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index c808270a2f5d..083d0329f62d 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "super.h" #include "crypto.h" @@ -1115,6 +1116,8 @@ void ceph_mdsc_release_request(struct kref *kref) kfree(req->r_path1); kfree(req->r_path2); put_cred(req->r_cred); + if (req->r_mnt_idmap) + mnt_idmap_put(req->r_mnt_idmap); if (req->r_pagelist) ceph_pagelist_release(req->r_pagelist); kfree(req->r_fscrypt_auth); @@ -1173,6 +1176,8 @@ static void __register_request(struct ceph_mds_client *mdsc, insert_request(&mdsc->request_tree, req); req->r_cred = get_current_cred(); + if (!req->r_mnt_idmap) + req->r_mnt_idmap = &nop_mnt_idmap; if (mdsc->oldest_tid == 0 && req->r_op != CEPH_MDS_OP_SETFILELOCK) mdsc->oldest_tid = req->r_tid; diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h index 351d92f7fc4f..89799becec90 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -298,6 +298,7 @@ struct ceph_mds_request { int r_fmode; /* file mode, if expecting cap */ int r_request_release_offset; const struct cred *r_cred; + struct mnt_idmap *r_mnt_idmap; struct timespec64 r_stamp; /* for choosing which mds to send this request to */ From patchwork Fri Jun 9 09:31:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273595 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 33030C7EE37 for ; Fri, 9 Jun 2023 09:53:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241910AbjFIJxQ (ORCPT ); Fri, 9 Jun 2023 05:53:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241430AbjFIJwe (ORCPT ); Fri, 9 Jun 2023 05:52:34 -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 81A543C21 for ; Fri, 9 Jun 2023 02:44:58 -0700 (PDT) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 356C53F36C for ; Fri, 9 Jun 2023 09:32:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303160; bh=+ZXNJzxGWGsPdae4AE9sODEjkcVKgoTQCtJS4YUBoj8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t0R85owjgKAifVfpub0FOmpRsFLc+pzJcBAOuwYi2Zd444pzIMFAbkt3DiVRA3C6T q4ThxuvoX+bnRvvSwH+FxEgFzDAak2VoDxEj31Z6s3xDo/KN2ZriMIS/4wyeogaBu+ sARb2LyjLJho5QBu8Tt4Nrqq7ne93iF/Vh+jwBBSGcUPAKYAPh8hC/1cXgC22gB1yE o7ftZJpZo6FQTh2oT2LaC/7UaLhV0kEkG59HxGMNJmslHa+Y/NZ8Fs/Vs356eNXxfo Rm/anDwogNTggn4rOvBpEYTSc7HS179xxCoJOmaqzLHH+bYV3NdyzcTnmizQeGImSF 2ADYQqHg2H0rQ== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-9749b806f81so146503666b.1 for ; Fri, 09 Jun 2023 02:32:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303160; x=1688895160; 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=+ZXNJzxGWGsPdae4AE9sODEjkcVKgoTQCtJS4YUBoj8=; b=MWHjI9kj9e3Rw2lnMG6vbcL7P0/mIxYazYUMspQhsKPNIs6t2OBBotejJBUxmM7j1B 1itQCFYtcK05b8bL1lIMdJTsNzrND7+WTzd/ey2W4zCe1tYHBI7pkemW8RciQx2PfR+Y CVnCE6WRrMqsyx6mrsAKyd8vXHpegOi0sOiSXYUIPj1rEKgSU1lWk3dl9zeNDoDBipUX 5PhDYvbF6WHjd5cLJJv5Jk8PYNyV86YJ59ckVmg4i+QO/BueQuWV3cNbsl9DbkGnDqeO RW2hI8d1jo6fVOa/P6/cpHdV8MqsAoPZjibWv6mPGT4cMEgbhJuY3rr18EyqmlpKutFh nCfA== X-Gm-Message-State: AC+VfDzDEnZZK4AFA/G5PBcOMIzhK2PUgIWfh4KQEg8SkynNweErLMnY MnI6o+YUAMmrRYR37z6EIRSpJXYhkcSrp0Rb0Zf0RXFefOflo9ONCPBc6HyGUOMUPm4NnKzuI4o VWdFdlPAA/v/1hh4mCF7rhaV7j5f7FXu0tFAiX0w7Gpk= X-Received: by 2002:a17:907:a49:b0:961:272d:bdb9 with SMTP id be9-20020a1709070a4900b00961272dbdb9mr890203ejc.43.1686303159769; Fri, 09 Jun 2023 02:32:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7VqlSsk8gsTl2VwGNKDG9KIKCrS8w8mAhrmZPyw2RDEHCUca7gFHg2dmkq6oitdS04CtjiJQ== X-Received: by 2002:a17:907:a49:b0:961:272d:bdb9 with SMTP id be9-20020a1709070a4900b00961272dbdb9mr890180ejc.43.1686303159346; Fri, 09 Jun 2023 02:32: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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:38 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 03/15] ceph: handle idmapped mounts in create_request_message() Date: Fri, 9 Jun 2023 11:31:14 +0200 Message-Id: <20230609093125.252186-4-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner Inode operations that create a new filesystem object such as ->mknod, ->create, ->mkdir() and others don't take a {g,u}id argument explicitly. Instead the caller's fs{g,u}id is used for the {g,u}id of the new filesystem object. 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 083d0329f62d..73fd5784daf8 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c @@ -2887,6 +2887,8 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, void *p, *end; int ret; bool legacy = !(session->s_con.peer_features & CEPH_FEATURE_FS_BTIME); + kuid_t caller_fsuid; + kgid_t caller_fsgid; ret = set_request_path_attr(req->r_inode, req->r_dentry, req->r_parent, req->r_path1, req->r_ino1.ino, @@ -2984,10 +2986,22 @@ static struct ceph_msg *create_request_message(struct ceph_mds_session *session, head->mdsmap_epoch = cpu_to_le32(mdsc->mdsmap->m_epoch); head->op = cpu_to_le32(req->r_op); - head->caller_uid = cpu_to_le32(from_kuid(&init_user_ns, - req->r_cred->fsuid)); - head->caller_gid = cpu_to_le32(from_kgid(&init_user_ns, - req->r_cred->fsgid)); + /* + * Inode operations that create filesystem objects based on the + * caller's fs{g,u}id like ->mknod(), ->create(), ->mkdir() etc. don't + * have separate {g,u}id fields in their respective structs in the + * ceph_mds_request_args union. Instead the caller_{g,u}id field is + * used to set ownership of the newly created inode by the mds server. + * For these inode operations we need to send the mapped fs{g,u}id over + * the wire. For other cases we simple set req->r_mnt_idmap to the + * initial idmapping meaning the unmapped fs{g,u}id is sent. + */ + caller_fsuid = from_vfsuid(req->r_mnt_idmap, &init_user_ns, + VFSUIDT_INIT(req->r_cred->fsuid)); + caller_fsgid = from_vfsgid(req->r_mnt_idmap, &init_user_ns, + VFSGIDT_INIT(req->r_cred->fsgid)); + head->caller_uid = cpu_to_le32(from_kuid(&init_user_ns, caller_fsuid)); + head->caller_gid = cpu_to_le32(from_kgid(&init_user_ns, caller_fsgid)); head->ino = cpu_to_le64(req->r_deleg_ino); head->args = req->r_args; From patchwork Fri Jun 9 09:31:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273581 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 01823C7EE25 for ; Fri, 9 Jun 2023 09:40:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241555AbjFIJk4 (ORCPT ); Fri, 9 Jun 2023 05:40:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241216AbjFIJjb (ORCPT ); Fri, 9 Jun 2023 05:39:31 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 327646599 for ; Fri, 9 Jun 2023 02:33:57 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1ED973F370 for ; Fri, 9 Jun 2023 09:32:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303163; bh=LI2l8EJ+sB/HFX7H7shv6XhttNoaeY5XoeYDpHH2kwI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=AMMyW/NK+XcsRtAcYWPGiSDChEYT1Ej+2sM67810W4WhrtpRy4UerOgzFyoo6HkTS hTr2LY2UWrDntAyvtD0m1mfYocjm4Cl20RxaW4jUwoXcI0jE1k9SmWpsvYqtvadlXI mx1s9eqQfT2rfdycg95gem7N88obloUfXRv0mf555g6JtJQCcOp0Up7mXKb2ckj50/ pX1E+rOkIZjiQTdZu6WgZvN5E87bWZHSpgFSm8R0uwSNWb7HIsggYh1Z6pYO/DDchi tORhSWC4FoIxy1yM1K3xIlHiOuCTD8agGK+UELcZFGoow/CpPYhGKrv6y6mKFaCAhu lvigP3aBY+M3g== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-94a356c74e0so150943266b.2 for ; Fri, 09 Jun 2023 02:32:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303162; x=1688895162; 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=LI2l8EJ+sB/HFX7H7shv6XhttNoaeY5XoeYDpHH2kwI=; b=RFT8c7+6igB7Ix0B9gSrG/C9OMui9YEHmuUOgyIHQniUR05Eo7gP2Y0tVnMkwoiuxU UIw0tjzgeF3jyY9yxkiQ88YqhieOuqwsj3XbycQWUVqJj+STcCMxGHbbSNqvgx0AQD+3 B5IAwTLcWJZbDgqh6gSCZWhH8hDDM1OZE/1erMnyw6A/bbR3xHcq2IgNb+xWMsSd+GkQ hxonJJYYrchLlMSiyzf7uCnNurYPID6guKcIICrWmyAsl4ioOMgrgU++4Tb/IBPlBoXT 8e68LJCchbIyKF7YEp6uc+iAWifVvoaI3CjjH9vEISiqaACESUAkXZgGp1LqSHxe23at TCOg== X-Gm-Message-State: AC+VfDw64aXiupSZRKQjKW20jyp9zT7yxx0IuOlBORy6iiFEtruIdaaF XsiS62ezb90puKcmE5j2olDva41IJpfP96C6dp5pAEZ78mm7g+/gEqwebe58IyTmogwE7Ecuwca 0Mqq0huNvYT7U2FPjcXIjB7U7Y3MhgP/rdkwFcqrDVv8= X-Received: by 2002:a17:906:9b85:b0:96f:dd14:f749 with SMTP id dd5-20020a1709069b8500b0096fdd14f749mr1013827ejc.23.1686303162163; Fri, 09 Jun 2023 02:32:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ77wxEqwisvkM7+2vPR5pOe0yqJEVm3fqKHexLUXhCzHN6fLXH9IQYibj/vo6ANsqqCr7Q5EA== X-Received: by 2002:a17:906:9b85:b0:96f:dd14:f749 with SMTP id dd5-20020a1709069b8500b0096fdd14f749mr1013810ejc.23.1686303161710; Fri, 09 Jun 2023 02:32:41 -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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:41 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 04/15] ceph: pass an idmapping to mknod/symlink/mkdir/rename Date: Fri, 9 Jun 2023 11:31:15 +0200 Message-Id: <20230609093125.252186-5-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner Enable mknod/symlink/mkdir/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 1b46f2b998c3..2c0c2c98085b 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -923,6 +923,7 @@ static int ceph_mknod(struct mnt_idmap *idmap, struct inode *dir, req->r_parent = dir; ihold(dir); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_args.mknod.mode = cpu_to_le32(mode); req->r_args.mknod.rdev = cpu_to_le32(rdev); req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL; @@ -1035,6 +1036,7 @@ static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir, } set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_dentry = dget(dentry); req->r_num_caps = 2; req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL; @@ -1111,6 +1113,7 @@ static int ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir, req->r_parent = dir; ihold(dir); set_bit(CEPH_MDS_R_PARENT_LOCKED, &req->r_req_flags); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_args.mkdir.mode = cpu_to_le32(mode); req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_AUTH_EXCL | CEPH_CAP_XATTR_EXCL; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; @@ -1422,6 +1425,7 @@ static int ceph_rename(struct mnt_idmap *idmap, struct inode *old_dir, req->r_old_dentry_unless = CEPH_CAP_FILE_EXCL; req->r_dentry_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_XATTR_EXCL; req->r_dentry_unless = CEPH_CAP_FILE_EXCL; + req->r_mnt_idmap = mnt_idmap_get(idmap); /* release LINK_RDCACHE on source inode (mds will lock it) */ req->r_old_inode_drop = CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL; if (d_really_is_positive(new_dentry)) { From patchwork Fri Jun 9 09:31:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273631 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 BEA2EC7EE29 for ; Fri, 9 Jun 2023 10:10:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239891AbjFIKKk (ORCPT ); Fri, 9 Jun 2023 06:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241231AbjFIKKQ (ORCPT ); Fri, 9 Jun 2023 06:10:16 -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 8ED528689 for ; Fri, 9 Jun 2023 02:59:14 -0700 (PDT) Received: from mail-lj1-f200.google.com (mail-lj1-f200.google.com [209.85.208.200]) (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 C30563F56C for ; Fri, 9 Jun 2023 09:32:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303165; bh=/3eW+11n/4iCvn/s3430tPb8fe2pR8+LzRYCxQYjku8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hsc/0qFxiAJd+6xMaE6G7qfBnVl+jGWuthrN9UowzskuZyMKiqGGQfIsp9g69q8DN P/doNxFdycjyKCY4jmzhRiqmnAkoYGlqMqkzriZP3mk7QpIZU7Mkkp4Jp64DFj51qC nH1zfho8IfT12OX77MupyANCEbFCATI30yP19wAGQmdXrINXdnQkHZrHxe5LpWOFQq X5wmSYoJmhySdEysylXtIV2fetyt+gWw9nEuCU9V0HjkOZOBux7pqsDfqxCZZUbDkN Up3tlEqvMLR+q0hDd77xsu+MsDIHNR9G8h168iUWNyNjjNUhOMVxLQKsmY7Do6zoUh 2YREtS9VmF1TA== Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2b1c60977e3so12490411fa.0 for ; Fri, 09 Jun 2023 02:32:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303164; x=1688895164; 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=/3eW+11n/4iCvn/s3430tPb8fe2pR8+LzRYCxQYjku8=; b=Ke5gaMyKneZlnR8QfqV4sjFBboKcwC8i05GJW5diF0z7jayHFJEvSvjhFxJd02Cmht sT97mnVbZs3GIBAPIk/IsAbcNnzZDulqwYKJHxKgSxHWIfTwNKjWQdmLKCdmfSwsZ6S4 3UdB+oWh8s2Kh3o6iypjSDyHpmZdV+IkpywROYmsWnj8mAMaZhRo0tBYvHZfqU2tHCvx Ur4BTwRHpSNbgIqs3KTfnLzdaWrCtfyoL6oBUpNXg9uM4CY7rXrcZEKHJ1AjS2p9HcZo lQaCZXEyfof6YymNY9tZfiEQ/o9a3Ue08rXUx8RNBB6oUgIU7DG0taxK+4XZhRoiSCO7 73nA== X-Gm-Message-State: AC+VfDxoZDZe/yv10UCuB+2glOAb+ErheYrYj+ZPik8if5KQHNJcvXs4 OTRkANYt8+vLBpzsQrHWu4uVQp/R5gV6jN2SEX53ndEujG+maCzIbI3ov3URYCO+ewahsgTcbcY PQcxPjeWbUP418Njc2677LVCYTCkt4Rhy7G6NgQRsdIo= X-Received: by 2002:a2e:8659:0:b0:2b2:3a4:4ebe with SMTP id i25-20020a2e8659000000b002b203a44ebemr802391ljj.48.1686303164552; Fri, 09 Jun 2023 02:32:44 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Xp6K9xKO9YEjHS2qWVmuHEJbD+pzRh3X4TI7BNImhUPEhsy5RO+Z9y84aSm4a3Lt8GGRPiw== X-Received: by 2002:a2e:8659:0:b0:2b2:3a4:4ebe with SMTP id i25-20020a2e8659000000b002b203a44ebemr802382ljj.48.1686303164306; Fri, 09 Jun 2023 02:32: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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:43 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 05/15] ceph: allow idmapped getattr inode op Date: Fri, 9 Jun 2023 11:31:16 +0200 Message-Id: <20230609093125.252186-6-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner Enable ceph_getattr() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index fe8adb9d67a6..533349fe542f 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2979,7 +2979,7 @@ int ceph_getattr(struct mnt_idmap *idmap, const struct path *path, return err; } - generic_fillattr(&nop_mnt_idmap, inode, stat); + generic_fillattr(idmap, inode, stat); stat->ino = ceph_present_inode(inode); /* From patchwork Fri Jun 9 09:31:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273594 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 8246AC7EE25 for ; Fri, 9 Jun 2023 09:53:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241903AbjFIJxK (ORCPT ); Fri, 9 Jun 2023 05:53:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239707AbjFIJw2 (ORCPT ); Fri, 9 Jun 2023 05:52: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 4FD1F5B9D for ; Fri, 9 Jun 2023 02:44:57 -0700 (PDT) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id B20433F377 for ; Fri, 9 Jun 2023 09:32:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303169; bh=/ZEyoJlFLaVuWVBzkT1cBDONkmXP3qyfK5/dTNb2H5c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fJR+PgP6BObU7rwPDF9QcGNRBi4uWM2p+g16+PSQg7XVffUEsBrFD1UPygFVVBfwl qaGAnWXV93vl4Sf/FM8LSPgwESHw0WEduguC+aqE62NB/x2sHRh/CoVyfbZ7K/JKnd T6XSsoxMT6xK/ShthzXB/m8q4H861WaHXD45LNM3h2m5YvP/iBi0EubK1gLVnJPBBr ETNvEaX6+863zRWi9Z7kbx8amnNhtiW6M1IIGOMoCY21I98/JnZk7EITzOOaJTzx3C l4mz39oEpjyP7L99MSbnGJvpHbuQJHkjJV+HTk4F6o1EVUXlecBXj1LFfAoaIstaPI 9LflhT5eSjlZA== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-94a355c9028so182121366b.3 for ; Fri, 09 Jun 2023 02:32:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303167; x=1688895167; 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=/ZEyoJlFLaVuWVBzkT1cBDONkmXP3qyfK5/dTNb2H5c=; b=aIMItFLU2FvJTbw/8uxo+k7Ott0deCq2iwpJsqlsQALmYbAI4TdMCZQx/NiZYkiP9O UYSabKL4GCDdnHqqKHa3NbZZpuKr/1V3aqeoV+5EKBswEOeEb+EoihuIVEk3bjGGzR3Y rFnpw6F7kcmuja6Tpp8JpSjTpaSZ+Zar+tTv00kuB5cLiSLL0sMm5ikBCobA/AQB3yXU cY8ji7ZLsKT6tGLr7frtRCMVmyUQZpLCKuLdKJDQuFuX2MvGyF99mPp3E/vl2GqX725p FwaZpDHSc2f4N2GLn28HPR9s+v3ud0jJLYEKOEX5m4N4v8sHlDJGC/1j1rBSdNVEzhZL 8lUg== X-Gm-Message-State: AC+VfDyaQu9cIj3lX3cfeqP4qQ87CTVPK5DzpY1PN7k0xg9Ss7+MWFvh txRcGIkxRM6JmPjVnBRIAb4F7oWpzycNlW8+Ncbap85JwxiIM6Gl7gyV2Su0Qjw3VUXQHNf8Flv SHqz4xs3CTnZa2St6jLfex/5X27Chl74xCR5/Z7ptrTI= X-Received: by 2002:a17:906:4792:b0:96f:608c:5bdf with SMTP id cw18-20020a170906479200b0096f608c5bdfmr1229555ejc.64.1686303166891; Fri, 09 Jun 2023 02:32:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40M5L5XkhSQA/QnoBcPEpFPgOUlmKAwDqyV+kolDwTxZ11t7xizkzr5a/UJGRyxfZTZYD9xg== X-Received: by 2002:a17:906:4792:b0:96f:608c:5bdf with SMTP id cw18-20020a170906479200b0096f608c5bdfmr1229533ejc.64.1686303166625; Fri, 09 Jun 2023 02:32: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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:46 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 06/15] ceph: allow idmapped permission inode op Date: Fri, 9 Jun 2023 11:31:17 +0200 Message-Id: <20230609093125.252186-7-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner Enable ceph_permission() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 533349fe542f..f45d9c066523 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2922,7 +2922,7 @@ int ceph_permission(struct mnt_idmap *idmap, struct inode *inode, err = ceph_do_getattr(inode, CEPH_CAP_AUTH_SHARED, false); if (!err) - err = generic_permission(&nop_mnt_idmap, inode, mask); + err = generic_permission(idmap, inode, mask); return err; } From patchwork Fri Jun 9 09:31:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273583 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 71D3CC87FE1 for ; Fri, 9 Jun 2023 09:41:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241591AbjFIJlB (ORCPT ); Fri, 9 Jun 2023 05:41:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242162AbjFIJkf (ORCPT ); Fri, 9 Jun 2023 05:40:35 -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 63BD04C02 for ; Fri, 9 Jun 2023 02:35:41 -0700 (PDT) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D354C3F4B3 for ; Fri, 9 Jun 2023 09:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303174; bh=ZRthp9gk8MduiBj9HJPfpfWTS97IoCeG1QDk4jIY0GY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iRVqD/MswAmS62UA8AG4OfYj3Qd+oUFNwUC7Rb2uJApmkT31uI9DKKigVsbkgHXmL FGcUy4axnJ2OqxsB7nr1nLsjAuekmzkk3ip95McROO7xx6aFa0/Q1Riu1S/khUUlkz sjdlnFXJ9YmnE3viXczQYfM8CRi6bH1vn0rQgD0fFYAlEKOtCcBLkzWJtu2jX0twT4 pREo7hS84yCjSJrvRDsQtO0anTTMh5Ybu8zwKi8siRZfAd4RZ7XWCJZpb6DVF3RUpz R/wld+rVqFWkm2JlA7SLqMjMevRGjJXbuUEfH/O4oQBU2Rmn65pWZJdyNJe/AaYnH8 Tnz0YedP7eeQw== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-97463348446so187479166b.2 for ; Fri, 09 Jun 2023 02:32:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303169; x=1688895169; 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=ZRthp9gk8MduiBj9HJPfpfWTS97IoCeG1QDk4jIY0GY=; b=G11nHpIyG+0RywBv3mNEk/wfCaE0LTTVOJJ2XtglWvEwmE1am7FXNNfAgCS9x585uS BPrF9VawU+Q0uvJB15ND4qxoey/mhYv9tIlV7GdCRwoqOmVk+oUV0JwQFv5vCQJMqPDj eLm8RuWICu35qN8+XgdCCKh14/Xcm86wJLHLtfR4PdD7bCar2UPR40hRIHDS8n0kjj1J uLec7GTwAEez2q4FzHzIM/qKczJPkka2neEjfr0hNA1VLngG57xN0uMNdfB31MrvFlJg A9TLxFjixhq5bQQqf72vXGbR2tfUbMJy0+KGtk8ci+u2OT95FgE0qVCZZrBbghro6oxU VyaA== X-Gm-Message-State: AC+VfDz53vyhplsCOk4cm+OluL8218N6OWgjr0rBRycLz8PVxv1Vg75F 99YGvdntTs3kGbYnHJOmgc3sg1666gRTDS3QCQQG9FNCJbZuN0i9WLejkMRtIjQTmL7ZRSKd6x8 RoyuGgvHCnFDlPjFy5dS1r02CrqhgKPkua0QqJREJLSw= X-Received: by 2002:a17:907:1c90:b0:974:ae01:3af4 with SMTP id nb16-20020a1709071c9000b00974ae013af4mr1458850ejc.68.1686303169217; Fri, 09 Jun 2023 02:32:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5xI/FJy6um65fKv9ua9Yvf6NnhnhnqnjMGghe1gn0Q2nUmrZmyXP+uaPPgjZNrTtgBdvemIg== X-Received: by 2002:a17:907:1c90:b0:974:ae01:3af4 with SMTP id nb16-20020a1709071c9000b00974ae013af4mr1458836ejc.68.1686303169020; Fri, 09 Jun 2023 02:32: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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:48 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Alexander Mikhalitsyn , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 07/15] ceph: pass idmap to __ceph_setattr Date: Fri, 9 Jun 2023 11:31:18 +0200 Message-Id: <20230609093125.252186-8-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Just pass down the mount's idmapping to __ceph_setattr, because we will need it later. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: brauner@kernel.org Cc: ceph-devel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/acl.c | 4 ++-- fs/ceph/crypto.c | 2 +- fs/ceph/inode.c | 6 ++++-- fs/ceph/super.h | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 8a56f979c7cb..f53f7a758c05 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -140,7 +140,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, newattrs.ia_ctime = current_time(inode); newattrs.ia_mode = new_mode; newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; - ret = __ceph_setattr(inode, &newattrs, NULL); + ret = __ceph_setattr(idmap, inode, &newattrs, NULL); if (ret) goto out_free; } @@ -151,7 +151,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, newattrs.ia_ctime = old_ctime; newattrs.ia_mode = old_mode; newattrs.ia_valid = ATTR_MODE | ATTR_CTIME; - __ceph_setattr(inode, &newattrs, NULL); + __ceph_setattr(idmap, inode, &newattrs, NULL); } goto out_free; } diff --git a/fs/ceph/crypto.c b/fs/ceph/crypto.c index e72bab29d5e1..8e298d7bf570 100644 --- a/fs/ceph/crypto.c +++ b/fs/ceph/crypto.c @@ -112,7 +112,7 @@ static int ceph_crypt_set_context(struct inode *inode, const void *ctx, size_t l cia.fscrypt_auth = cfa; - ret = __ceph_setattr(inode, &attr, &cia); + ret = __ceph_setattr(&nop_mnt_idmap, inode, &attr, &cia); if (ret == 0) inode_set_flags(inode, S_ENCRYPTED, S_ENCRYPTED); kfree(cia.fscrypt_auth); diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index f45d9c066523..9a4579da32f8 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2424,7 +2424,8 @@ static int fill_fscrypt_truncate(struct inode *inode, return ret; } -int __ceph_setattr(struct inode *inode, struct iattr *attr, struct ceph_iattr *cia) +int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, + struct iattr *attr, struct ceph_iattr *cia) { struct ceph_inode_info *ci = ceph_inode(inode); unsigned int ia_valid = attr->ia_valid; @@ -2695,6 +2696,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr, struct ceph_iattr *c if (mask) { req->r_inode = inode; ihold(inode); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_inode_drop = release; req->r_args.setattr.mask = cpu_to_le32(mask); req->r_num_caps = 1; @@ -2766,7 +2768,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, ceph_quota_is_max_bytes_exceeded(inode, attr->ia_size)) return -EDQUOT; - err = __ceph_setattr(inode, attr, NULL); + err = __ceph_setattr(idmap, inode, attr, NULL); if (err >= 0 && (attr->ia_valid & ATTR_MODE)) err = posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode); diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 107a9d16a4e8..8516ac571da9 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1095,7 +1095,8 @@ struct ceph_iattr { struct ceph_fscrypt_auth *fscrypt_auth; }; -extern int __ceph_setattr(struct inode *inode, struct iattr *attr, struct ceph_iattr *cia); +extern int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, + struct iattr *attr, struct ceph_iattr *cia); extern int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr); extern int ceph_getattr(struct mnt_idmap *idmap, From patchwork Fri Jun 9 09:31:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273591 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 8CF55C7EE2E for ; Fri, 9 Jun 2023 09:46:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241816AbjFIJqk (ORCPT ); Fri, 9 Jun 2023 05:46:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241815AbjFIJqI (ORCPT ); Fri, 9 Jun 2023 05:46:08 -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 8CF8B49F4 for ; Fri, 9 Jun 2023 02:40:49 -0700 (PDT) Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 8B7803F13F for ; Fri, 9 Jun 2023 09:32:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303175; bh=d5khlOcPOkR48ashhbagswr/xnjgstKG+L7ceqQR68I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=t6MJJajGgpqhLtt2ZIK2Vrind5EIIpdL8fNbYVs7VFf0zyttJSFkc6tCUp9F3vRMq meT9Ahciak7NE/P/GJfLTHFU4mq2spljEYmk0E7c/KPwsCzpOjUiZeYdVrpuJ3DI8P dfW8WCTp5hYRXhWQuEFVyEp6E81zp+fUEoBxYZvYQlLnIyq79+ieYytla7giiHMlz0 XpAWF/TXM6t6eaplHF9oBKbBP5iiUZB3QD9CgbLlB4Dd8amhfOOF9XQ5D4MHh9teG/ 8vNYKBU9sXHB4aISSk/VFp5ILxlO2yNEEkxWVcVKmdnJcFq1o+tGp8paKIT1fogCfp E/UA+s5ZGVW4A== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-94a34a0b75eso134160166b.1 for ; Fri, 09 Jun 2023 02:32:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303172; x=1688895172; 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=d5khlOcPOkR48ashhbagswr/xnjgstKG+L7ceqQR68I=; b=TbH6RqB+LsebYDIOGn7XpD4MJ1nuff4esqZRAqIliFCH/zdkeEmF9KoyjSVOCNyWj/ ZGue3Z1qLdRejwMtQV7gM/ql4HHa02AhVtCjTz0VZMu9NkZNNVXojw3z8uEMSv2rfwpW rO0n3sTEgnfcTpkYKChRId+fgw50RQN9ScRw4Y2epQR7xbXilZhYwc79Oj9jH2u2KJ5W ko9QWiYxykidpe5+RFocUKADZQmrIAEm3hoMckOgdTBEnVhWYVoC1ztjl7UNSE+5tKXQ 5lfff3M7h5phdwoh/0uWvOdany4geII355hX26FTBMm97kAf8yO5cy6kUiyFWeDyKsft XySQ== X-Gm-Message-State: AC+VfDwoFnsuiqPi+9W3AiS24kwpXDp6k61XPqlYehngjqDw3/qV9YlK PbDzWMrq07j9c5ue9M98QALDSkpnn9t98GKZ3OR1SGkSxJ1Xye0g4QLEr4LqxslPeGOyN/xvJ9p EgBRMP8jltu0yv3vnkQH4TXj65NjV4csU9hUOP8JlhG0= X-Received: by 2002:a17:907:2d0f:b0:965:6075:d0e1 with SMTP id gs15-20020a1709072d0f00b009656075d0e1mr1243439ejc.72.1686303171874; Fri, 09 Jun 2023 02:32:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ59kDZebVrWioHVCJrl8ktxJliY7MnEjejxAd9hrZlN9hAJ/qDACsG7YUf21ymnpatNXrM/eQ== X-Received: by 2002:a17:907:2d0f:b0:965:6075:d0e1 with SMTP id gs15-20020a1709072d0f00b009656075d0e1mr1243429ejc.72.1686303171703; Fri, 09 Jun 2023 02:32:51 -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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:51 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 08/15] ceph: allow idmapped setattr inode op Date: Fri, 9 Jun 2023 11:31:19 +0200 Message-Id: <20230609093125.252186-9-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner Enable __ceph_setattr() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner [ adapted to b27c82e12965 ("attr: port attribute changes to new types") ] Signed-off-by: Alexander Mikhalitsyn --- v4: - introduced fsuid/fsgid local variables v3: - reworked as Christian suggested here: https://lore.kernel.org/lkml/20230602-vorzeichen-praktikum-f17931692301@brauner/ --- fs/ceph/inode.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 9a4579da32f8..6a8aeb4b8fb8 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2509,31 +2509,35 @@ int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, #endif /* CONFIG_FS_ENCRYPTION */ if (ia_valid & ATTR_UID) { + kuid_t fsuid = from_vfsuid(idmap, i_user_ns(inode), attr->ia_vfsuid); + dout("setattr %p uid %d -> %d\n", inode, from_kuid(&init_user_ns, inode->i_uid), from_kuid(&init_user_ns, attr->ia_uid)); if (issued & CEPH_CAP_AUTH_EXCL) { - inode->i_uid = attr->ia_uid; + inode->i_uid = fsuid; dirtied |= CEPH_CAP_AUTH_EXCL; } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 || - !uid_eq(attr->ia_uid, inode->i_uid)) { + !uid_eq(fsuid, inode->i_uid)) { req->r_args.setattr.uid = cpu_to_le32( - from_kuid(&init_user_ns, attr->ia_uid)); + from_kuid(&init_user_ns, fsuid)); mask |= CEPH_SETATTR_UID; release |= CEPH_CAP_AUTH_SHARED; } } if (ia_valid & ATTR_GID) { + kgid_t fsgid = from_vfsgid(idmap, i_user_ns(inode), attr->ia_vfsgid); + dout("setattr %p gid %d -> %d\n", inode, from_kgid(&init_user_ns, inode->i_gid), from_kgid(&init_user_ns, attr->ia_gid)); if (issued & CEPH_CAP_AUTH_EXCL) { - inode->i_gid = attr->ia_gid; + inode->i_gid = fsgid; dirtied |= CEPH_CAP_AUTH_EXCL; } else if ((issued & CEPH_CAP_AUTH_SHARED) == 0 || - !gid_eq(attr->ia_gid, inode->i_gid)) { + !gid_eq(fsgid, inode->i_gid)) { req->r_args.setattr.gid = cpu_to_le32( - from_kgid(&init_user_ns, attr->ia_gid)); + from_kgid(&init_user_ns, fsgid)); mask |= CEPH_SETATTR_GID; release |= CEPH_CAP_AUTH_SHARED; } @@ -2756,7 +2760,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, if (err) return err; - err = setattr_prepare(&nop_mnt_idmap, dentry, attr); + err = setattr_prepare(idmap, dentry, attr); if (err != 0) return err; @@ -2771,7 +2775,7 @@ int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry, err = __ceph_setattr(idmap, inode, attr, NULL); if (err >= 0 && (attr->ia_valid & ATTR_MODE)) - err = posix_acl_chmod(&nop_mnt_idmap, dentry, attr->ia_mode); + err = posix_acl_chmod(idmap, dentry, attr->ia_mode); return err; } From patchwork Fri Jun 9 09:31:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273582 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 4BA93C7EE43 for ; Fri, 9 Jun 2023 09:41:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239898AbjFIJk5 (ORCPT ); Fri, 9 Jun 2023 05:40:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242148AbjFIJke (ORCPT ); Fri, 9 Jun 2023 05:40:34 -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 07E256A70 for ; Fri, 9 Jun 2023 02:35:37 -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 045C93F37A for ; Fri, 9 Jun 2023 09:32:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303176; bh=kRtya9vNnJsHnlJFsQiUMmcKKT8ZGQqP3swgCnXRiRw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bmEwusq0cnKXIIy90FwGLJgXUCarhP3s3EfiTRaTXDky+wOr+flgB6EYNucdXGErR TyAk/9Fy5jagq1Sy/sLoiFsrUkI8/vswtxmTpwylE2T/xZW9ZX/WVc6m3PfGbW41bn efz5ioFETHwNG5kNIxcZCLJrX9jY1PXmUsJDGhW/BA56UbzcG/+7oj9oCEWkKBFY/r 85iD2NQeeukpEjGVpYkISpkE3bNlL/8CdUAI3cU2rCXRC/BERPq/b9RPuR6rLI3C0p 3GOQ+tW8/z8MIjjcBpmFL+hmIPwZsyTKaaWalpINGw9P29yhS1Ci30p0D6j3zYqg5h +qb6k7XBuN2Zw== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-516302ba604so1585017a12.2 for ; Fri, 09 Jun 2023 02:32:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303174; x=1688895174; 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=kRtya9vNnJsHnlJFsQiUMmcKKT8ZGQqP3swgCnXRiRw=; b=UHrEIqEeKteb4UQY9AfoBa3l7Q9yj7nDDKsQLB3D1jhrNbFPMdy9Jm+RekuXFf47D3 qo6vua1XX0UkIR3r5olPNANS1IgfRK2AcyuKXblYIJpfgDR2UZP7Dg5BZ+jLeOKz7ih+ XjyoraTgpDBm1bvsL+I623+IPpg/zJW95WbcyiPqr1+lS5riLJLmxYrSt1R+kJEc5x9I LK4ZGa29lsL0O83JVB4/ZaPCW3yQAgEBSl/0Mya2iWo1O3Bvmi/hJd7Mn4dkdZTnn7DZ abDcUVk1amZLbtCv0Etsf62dP+bi05g/IOxoZnY6CQsX286+Z9MmxBDVL6lbBsgsdKvH 7jjA== X-Gm-Message-State: AC+VfDxpSmGaI59c5J0HLd7/UEMd/Wl1EYnRQ4Kzdim+BokHq4OPGqsn LuAxC1TPxbSBueCQF1Sghwe4tRy+KxNJgKpzi/wgH2aQ0IczUmTS1kMtM1YxcA6X37V/Kn33xOc /U/bYasSPhTZ6R/OVUvT79p1BssSnmdKN2gWwgTnHY405brHXBrc= X-Received: by 2002:a17:907:9801:b0:973:fd02:a40f with SMTP id ji1-20020a170907980100b00973fd02a40fmr1311010ejc.59.1686303174468; Fri, 09 Jun 2023 02:32:54 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4b1muZvFfgb/c2k7vkkSmRjeDpssO36RsAZdwjRFiNmZVFVAU5M9RWcnkHYxbMHbPnv7UcuQ== X-Received: by 2002:a17:907:9801:b0:973:fd02:a40f with SMTP id ji1-20020a170907980100b00973fd02a40fmr1310997ejc.59.1686303174276; Fri, 09 Jun 2023 02:32: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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:53 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 09/15] ceph/acl: allow idmapped set_acl inode op Date: Fri, 9 Jun 2023 11:31:20 +0200 Message-Id: <20230609093125.252186-10-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner Enable ceph_set_acl() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index f53f7a758c05..d4be4c2d63c3 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -105,7 +105,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, case ACL_TYPE_ACCESS: name = XATTR_NAME_POSIX_ACL_ACCESS; if (acl) { - ret = posix_acl_update_mode(&nop_mnt_idmap, inode, + ret = posix_acl_update_mode(idmap, inode, &new_mode, &acl); if (ret) goto out; From patchwork Fri Jun 9 09:31:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273628 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 94ECDC7EE25 for ; Fri, 9 Jun 2023 10:09:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239988AbjFIKJc (ORCPT ); Fri, 9 Jun 2023 06:09:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230431AbjFIKJC (ORCPT ); Fri, 9 Jun 2023 06:09:02 -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 8A1043A9B for ; Fri, 9 Jun 2023 02:58:49 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id E22D63F571 for ; Fri, 9 Jun 2023 09:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303178; bh=0OC8c+cJXxBkdMyTeJgnYb4yY2v9uQR7p5VsG0G1Yao=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mrUaKFj+XOfLwURNixxNEM3p7PHqtKZY1kcDCUMH3IC7XWdWsxdkkbgqcuk+YyvdO HOY0yxWTDY4WJLqgC+UHqeg1ehQ7K63piqyiweGpFd43JgH8XAjBT0Wsr3Uf2qnHa5 0E6y5oJy09HRP5ZRlG7A1pYOQ4hQMLHHY/Y/9pPYx2cBYVCz6PTzydCFnZbK4gSDpE fVHs/P01WIXwSaT1gjRFp76sNZqv57kU0woYMlDUYU0lbzuFuokCdS8UVHql5eSImn 6qewdoZcouRl54uYo5U/F/Dms4JK2AWtIhgtAvg8veKZiX4cjDcHMOM9bY2DwP3YnK 5PR3d3Zv8bQSQ== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-94a35b0d4ceso151199766b.3 for ; Fri, 09 Jun 2023 02:32:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303178; x=1688895178; 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=0OC8c+cJXxBkdMyTeJgnYb4yY2v9uQR7p5VsG0G1Yao=; b=C/dYogvVcDM8K1P6q7tpk7khMajbdsK/o9TbAzYQK6fmGmEAv3nVDOnM7i01CsqpPm 620bv1zXSrzu+3TdKUy2THvCozxqEO6YDm9hncq29qgVopNDVgFLrGPV+Ep4v7Wup8Of UaiaKPYw39A/dxxj1cKJX5OjYc5kXrmRgU5xW5nTf2UELOOOL2LXWuPediw7RQwutwnh 307DvY0nD5oOp8LUWIMZe30dlDi/v+EJSI5eflwSKDttFR9qFsSxnE2MQpKYU7BgbPUi ljCaWCjAz3wW/xVCHU04C9ixUFj6WZ9XccnNmZ9rjHdGsSyjZbQJh9MBUDS4xiLrxHhw B3mQ== X-Gm-Message-State: AC+VfDzFADG125GGppGd8RTtM0pHoJN9KhZOlxHqCbaYG62JWi608yt0 G9vj1bsakJKiVn9YrIFk/UJvdpcJcnvu3T16nTx+Fi0jWMUa/A94Dqa9fPv/vxzA7LP9wiPVN/f O015O3O+UKxpoWlGvzM8Nic49MbWx5xhoAGKr67dbWPM= X-Received: by 2002:a17:906:da82:b0:979:7624:1f71 with SMTP id xh2-20020a170906da8200b0097976241f71mr941174ejb.26.1686303178487; Fri, 09 Jun 2023 02:32:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5voXOwgPC15uM3+uocYLZ+BUkJYuHnkJgTaXNTEd5xkSD1BuZvardnf3r8WW0Z6UUfuUwMfQ== X-Received: by 2002:a17:906:da82:b0:979:7624:1f71 with SMTP id xh2-20020a170906da8200b0097976241f71mr941163ejb.26.1686303178315; Fri, 09 Jun 2023 02:32:58 -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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.32.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:32:57 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 10/15] ceph/file: allow idmapped atomic_open inode op Date: Fri, 9 Jun 2023 11:31:21 +0200 Message-Id: <20230609093125.252186-11-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner Enable ceph_atomic_open() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner [ adapted to 5fadbd9929 ("ceph: rely on vfs for setgid stripping") ] Signed-off-by: Alexander Mikhalitsyn --- v4: - call mnt_idmap_get --- fs/ceph/file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index e878a462c7c3..7be172f29c0b 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -655,7 +655,9 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode, in.truncate_seq = cpu_to_le32(1); in.truncate_size = cpu_to_le64(-1ULL); in.xattr_version = cpu_to_le64(1); - in.uid = cpu_to_le32(from_kuid(&init_user_ns, current_fsuid())); + in.uid = cpu_to_le32(from_kuid(&init_user_ns, + mapped_fsuid(req->r_mnt_idmap, + &init_user_ns))); if (dir->i_mode & S_ISGID) { in.gid = cpu_to_le32(from_kgid(&init_user_ns, dir->i_gid)); @@ -663,7 +665,9 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode, if (S_ISDIR(mode)) mode |= S_ISGID; } else { - in.gid = cpu_to_le32(from_kgid(&init_user_ns, current_fsgid())); + in.gid = cpu_to_le32(from_kgid(&init_user_ns, + mapped_fsgid(req->r_mnt_idmap, + &init_user_ns))); } in.mode = cpu_to_le32((u32)mode); @@ -731,6 +735,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, struct file *file, unsigned flags, umode_t mode) { struct ceph_fs_client *fsc = ceph_sb_to_client(dir->i_sb); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_mds_client *mdsc = fsc->mdsc; struct ceph_mds_request *req; struct inode *new_inode = NULL; @@ -788,6 +793,7 @@ int ceph_atomic_open(struct inode *dir, struct dentry *dentry, mask |= CEPH_CAP_XATTR_SHARED; req->r_args.open.mask = cpu_to_le32(mask); req->r_parent = dir; + req->r_mnt_idmap = mnt_idmap_get(idmap); ihold(dir); if (IS_ENCRYPTED(dir)) { set_bit(CEPH_MDS_R_FSCRYPT_FILE, &req->r_req_flags); From patchwork Fri Jun 9 09:31:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273611 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 557A9C7EE25 for ; Fri, 9 Jun 2023 09:58:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241234AbjFIJ63 (ORCPT ); Fri, 9 Jun 2023 05:58:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241826AbjFIJ5u (ORCPT ); Fri, 9 Jun 2023 05:57:50 -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 090B444A9 for ; Fri, 9 Jun 2023 02:49:47 -0700 (PDT) Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id EC24C3F372 for ; Fri, 9 Jun 2023 09:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303183; bh=0VGqwyhzl3JPGUl0HnnxKLIkvQp+JnBUhnrWkIN+oYU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=vJToR24oHCldmMTgDBxx8Bi+UuAhM0IyWQ/cOl/HQUgBlGnPtWwiZCTrstI6+qQcr YrCb5wc/nUMvxYuWO2hf6d9GiQ8zGgfVexOJWu1Q3MH1TOOld5q0UV+b4pxQl+L0f0 gHX6HYUEpERBoYAuWS/PHQICh161MQ3WODi/wZf8Eb6Nk/sX0V2tb9R4ClKuSk9dBB lc0umkmizIeKxFgeAEr6AcUgzPTyXHPqyKGdYI5j/R/5leyu3xdca4rBk9EeTqnnEP TeoSIH12AwjKzKjWVKoa4yHVZdz6oDjOIVGDrxGPKJtUGSKTVXXBjEDQegpldNRC8O r7wNQ5EvHTOQA== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-97467e06580so199724466b.1 for ; Fri, 09 Jun 2023 02:33:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303182; x=1688895182; 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=0VGqwyhzl3JPGUl0HnnxKLIkvQp+JnBUhnrWkIN+oYU=; b=BGvabQMktu9Z4SrXDsRRvBLHqTmjkzdsZA3mhTM/zbu6C0daRg0Ie+T6fqJAnRDXQH vNHw0MrGIMEKH01nbaFVG/XeAnswJty+usLqbvkbcU79k8d6D2paPwtbSAHAbTZHueIn V2ByUKiI4KRcEicq5PD49rLqad0KgX1nxuX3h1yMZz1t7aRsG3zI7ZWRD8XvnlLx2eDB tvpecsfvSpTJuUT/cixZ6ljo5ssZ2UFCpkBJ8zckP955qKJ3sE19/GxgJHRuOhVCJqkg ne/A++ZdI35vEZU+ZQIiQC4jBcr6M286XoxSMw9Y0a4BOiJcvraOFHwWd6G/XDf8i3Qb Adig== X-Gm-Message-State: AC+VfDzZpSwmGKx9zn/tcCSLMr0SOskA06H1vGxCR/J8e8r/jBM1urIm e9Q5abV8PR/3yTx72cUcWculUFoeccSwuMBLxX/p9ZhDqMTfPOojOD3Jy+IWfH3Rt8zzzqCEmeL zUdlbXJFx7WGBnu03tu6ovbYqVIhm9bQp9aUj44mkXR0= X-Received: by 2002:a17:907:2d91:b0:97a:bd0f:ac74 with SMTP id gt17-20020a1709072d9100b0097abd0fac74mr418763ejc.26.1686303181801; Fri, 09 Jun 2023 02:33:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/SqikdsfYSXklqv+/0nMob2hZYelAauenDQH0n/IpiNi8XX3qJPgqriPnk5aDgnpIEG/1FQ== X-Received: by 2002:a17:907:2d91:b0:97a:bd0f:ac74 with SMTP id gt17-20020a1709072d9100b0097abd0fac74mr418750ejc.26.1686303181608; Fri, 09 Jun 2023 02:33:01 -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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.33.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:33:01 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Alexander Mikhalitsyn , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 11/15] ceph: pass idmap to ceph_do_getattr Date: Fri, 9 Jun 2023 11:31:22 +0200 Message-Id: <20230609093125.252186-12-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Just pass down the mount's idmapping to *ceph_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 --- v6: - fscrypt rebase --- fs/ceph/addr.c | 3 ++- fs/ceph/caps.c | 8 +++++--- fs/ceph/export.c | 2 +- fs/ceph/file.c | 9 ++++++--- fs/ceph/inode.c | 15 +++++++++------ fs/ceph/ioctl.c | 6 ++++-- fs/ceph/quota.c | 2 +- fs/ceph/super.c | 4 ++-- fs/ceph/super.h | 11 +++++++---- fs/ceph/xattr.c | 6 +++--- 10 files changed, 40 insertions(+), 26 deletions(-) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index de9b82905f18..0a32475ed034 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -1630,6 +1630,7 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf) /* does not support inline data > PAGE_SIZE */ ret = VM_FAULT_SIGBUS; } else { + struct mnt_idmap *idmap = file_mnt_idmap(vma->vm_file); struct address_space *mapping = inode->i_mapping; struct page *page; @@ -1640,7 +1641,7 @@ static vm_fault_t ceph_filemap_fault(struct vm_fault *vmf) ret = VM_FAULT_OOM; goto out_inline; } - err = __ceph_do_getattr(inode, page, + err = __ceph_do_getattr(idmap, inode, page, CEPH_STAT_CAP_INLINE_DATA, true); if (err < 0 || off >= i_size_read(inode)) { unlock_page(page); diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index 5498bc36c1e7..b432f29e80dd 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -2958,7 +2958,8 @@ int ceph_try_get_caps(struct inode *inode, int need, int want, * due to a small max_size, make sure we check_max_size (and possibly * ask the mds) so we don't get hung up indefinitely. */ -int __ceph_get_caps(struct inode *inode, struct ceph_file_info *fi, int need, +int __ceph_get_caps(struct mnt_idmap *idmap, struct inode *inode, + struct ceph_file_info *fi, int need, int want, loff_t endoff, int *got) { struct ceph_inode_info *ci = ceph_inode(inode); @@ -3072,7 +3073,7 @@ int __ceph_get_caps(struct inode *inode, struct ceph_file_info *fi, int need, * getattr request will bring inline data into * page cache */ - ret = __ceph_do_getattr(inode, NULL, + ret = __ceph_do_getattr(idmap, inode, NULL, CEPH_STAT_CAP_INLINE_DATA, true); if (ret < 0) @@ -3089,8 +3090,9 @@ int ceph_get_caps(struct file *filp, int need, int want, loff_t endoff, int *got { struct ceph_file_info *fi = filp->private_data; struct inode *inode = file_inode(filp); + struct mnt_idmap *idmap = file_mnt_idmap(filp); - return __ceph_get_caps(inode, fi, need, want, endoff, got); + return __ceph_get_caps(idmap, inode, fi, need, want, endoff, got); } /* diff --git a/fs/ceph/export.c b/fs/ceph/export.c index 8559990a59a5..4b422070ca2b 100644 --- a/fs/ceph/export.c +++ b/fs/ceph/export.c @@ -188,7 +188,7 @@ static struct dentry *__fh_to_dentry(struct super_block *sb, u64 ino) if (IS_ERR(inode)) return ERR_CAST(inode); /* We need LINK caps to reliably check i_nlink */ - err = ceph_do_getattr(inode, CEPH_CAP_LINK_SHARED, false); + err = ceph_do_getattr(&nop_mnt_idmap, inode, CEPH_CAP_LINK_SHARED, false); if (err) { iput(inode); return ERR_PTR(err); diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 7be172f29c0b..c2bb8f5fd345 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -2009,6 +2009,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to) size_t len = iov_iter_count(to); struct inode *inode = file_inode(filp); struct ceph_inode_info *ci = ceph_inode(inode); + struct mnt_idmap *idmap = file_mnt_idmap(filp); bool direct_lock = iocb->ki_flags & IOCB_DIRECT; ssize_t ret; int want = 0, got = 0; @@ -2091,7 +2092,7 @@ static ssize_t ceph_read_iter(struct kiocb *iocb, struct iov_iter *to) return -ENOMEM; } - statret = __ceph_do_getattr(inode, page, + statret = __ceph_do_getattr(idmap, inode, page, CEPH_STAT_CAP_INLINE_DATA, !!page); if (statret < 0) { if (page) @@ -2166,6 +2167,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) struct inode *inode = file_inode(file); struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_fs_client *fsc = ceph_inode_to_client(inode); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_osd_client *osdc = &fsc->client->osdc; struct ceph_cap_flush *prealloc_cf; ssize_t count, written = 0; @@ -2199,7 +2201,7 @@ static ssize_t ceph_write_iter(struct kiocb *iocb, struct iov_iter *from) current->backing_dev_info = inode_to_bdi(inode); if (iocb->ki_flags & IOCB_APPEND) { - err = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false); + err = ceph_do_getattr(idmap, inode, CEPH_STAT_CAP_SIZE, false); if (err < 0) goto out; } @@ -2355,9 +2357,10 @@ static loff_t ceph_llseek(struct file *file, loff_t offset, int whence) { if (whence == SEEK_END || whence == SEEK_DATA || whence == SEEK_HOLE) { struct inode *inode = file_inode(file); + struct mnt_idmap *idmap = file_mnt_idmap(file); int ret; - ret = ceph_do_getattr(inode, CEPH_STAT_CAP_SIZE, false); + ret = ceph_do_getattr(idmap, inode, CEPH_STAT_CAP_SIZE, false); if (ret < 0) return ret; } diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 6a8aeb4b8fb8..49ca13c5b9d8 100644 --- a/fs/ceph/inode.c +++ b/fs/ceph/inode.c @@ -2292,7 +2292,8 @@ static const struct inode_operations ceph_encrypted_symlink_iops = { * We don't support a PAGE_SIZE that is smaller than the * CEPH_FSCRYPT_BLOCK_SIZE. */ -static int fill_fscrypt_truncate(struct inode *inode, +static int fill_fscrypt_truncate(struct mnt_idmap *idmap, + struct inode *inode, struct ceph_mds_request *req, struct iattr *attr) { @@ -2311,7 +2312,7 @@ static int fill_fscrypt_truncate(struct inode *inode, int got, ret, issued; u64 objver; - ret = __ceph_get_caps(inode, NULL, CEPH_CAP_FILE_RD, 0, -1, &got); + ret = __ceph_get_caps(idmap, inode, NULL, CEPH_CAP_FILE_RD, 0, -1, &got); if (ret < 0) return ret; @@ -2706,7 +2707,7 @@ int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode, req->r_num_caps = 1; req->r_stamp = attr->ia_ctime; if (fill_fscrypt) { - err = fill_fscrypt_truncate(inode, req, attr); + err = fill_fscrypt_truncate(idmap, inode, req, attr); if (err) goto out; } @@ -2814,7 +2815,8 @@ int ceph_try_to_choose_auth_mds(struct inode *inode, int mask) * Verify that we have a lease on the given mask. If not, * do a getattr against an mds. */ -int __ceph_do_getattr(struct inode *inode, struct page *locked_page, +int __ceph_do_getattr(struct mnt_idmap *idmap, struct inode *inode, + struct page *locked_page, int mask, bool force) { struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb); @@ -2839,6 +2841,7 @@ int __ceph_do_getattr(struct inode *inode, struct page *locked_page, return PTR_ERR(req); req->r_inode = inode; ihold(inode); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_num_caps = 1; req->r_args.getattr.mask = cpu_to_le32(mask); req->r_locked_page = locked_page; @@ -2925,7 +2928,7 @@ int ceph_permission(struct mnt_idmap *idmap, struct inode *inode, if (mask & MAY_NOT_BLOCK) return -ECHILD; - err = ceph_do_getattr(inode, CEPH_CAP_AUTH_SHARED, false); + err = ceph_do_getattr(idmap, inode, CEPH_CAP_AUTH_SHARED, false); if (!err) err = generic_permission(idmap, inode, mask); @@ -2978,7 +2981,7 @@ int ceph_getattr(struct mnt_idmap *idmap, const struct path *path, /* Skip the getattr altogether if we're asked not to sync */ if ((flags & AT_STATX_SYNC_TYPE) != AT_STATX_DONT_SYNC) { - err = ceph_do_getattr(inode, + err = ceph_do_getattr(idmap, inode, statx_to_caps(request_mask, inode->i_mode), flags & AT_STATX_FORCE_SYNC); if (err) diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index 679402bd80ba..6fa021b973e5 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c @@ -18,10 +18,11 @@ static long ceph_ioctl_get_layout(struct file *file, void __user *arg) { struct ceph_inode_info *ci = ceph_inode(file_inode(file)); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_ioctl_layout l; int err; - err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false); + err = ceph_do_getattr(idmap, file_inode(file), CEPH_STAT_CAP_LAYOUT, false); if (!err) { l.stripe_unit = ci->i_layout.stripe_unit; l.stripe_count = ci->i_layout.stripe_count; @@ -65,6 +66,7 @@ static long __validate_layout(struct ceph_mds_client *mdsc, static long ceph_ioctl_set_layout(struct file *file, void __user *arg) { struct inode *inode = file_inode(file); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc; struct ceph_mds_request *req; struct ceph_ioctl_layout l; @@ -76,7 +78,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) return -EFAULT; /* validate changed params against current layout */ - err = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false); + err = ceph_do_getattr(idmap, file_inode(file), CEPH_STAT_CAP_LAYOUT, false); if (err) return err; diff --git a/fs/ceph/quota.c b/fs/ceph/quota.c index f7fcf7f08ec6..515423b3ddea 100644 --- a/fs/ceph/quota.c +++ b/fs/ceph/quota.c @@ -150,7 +150,7 @@ static struct inode *lookup_quotarealm_inode(struct ceph_mds_client *mdsc, } if (qri->inode) { /* get caps */ - int ret = __ceph_do_getattr(qri->inode, NULL, + int ret = __ceph_do_getattr(&nop_mnt_idmap, qri->inode, NULL, CEPH_STAT_CAP_INODE, true); if (ret >= 0) in = qri->inode; diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 070b3150d267..3d6d0010d638 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1607,8 +1607,8 @@ int ceph_force_reconnect(struct super_block *sb) fsc->mount_state = CEPH_MOUNT_MOUNTED; if (sb->s_root) { - err = __ceph_do_getattr(d_inode(sb->s_root), NULL, - CEPH_STAT_CAP_INODE, true); + err = __ceph_do_getattr(&nop_mnt_idmap, d_inode(sb->s_root), + NULL, CEPH_STAT_CAP_INODE, true); } return err; } diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 8516ac571da9..57cbb69a17c8 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1082,11 +1082,13 @@ static inline void ceph_queue_flush_snaps(struct inode *inode) } extern int ceph_try_to_choose_auth_mds(struct inode *inode, int mask); -extern int __ceph_do_getattr(struct inode *inode, struct page *locked_page, +extern int __ceph_do_getattr(struct mnt_idmap *idmap, struct inode *inode, + struct page *locked_page, int mask, bool force); -static inline int ceph_do_getattr(struct inode *inode, int mask, bool force) +static inline int ceph_do_getattr(struct mnt_idmap *idmap, struct inode *inode, + int mask, bool force) { - return __ceph_do_getattr(inode, NULL, mask, force); + return __ceph_do_getattr(idmap, inode, NULL, mask, force); } extern int ceph_permission(struct mnt_idmap *idmap, struct inode *inode, int mask); @@ -1271,7 +1273,8 @@ extern int ceph_encode_dentry_release(void **p, struct dentry *dn, struct inode *dir, int mds, int drop, int unless); -extern int __ceph_get_caps(struct inode *inode, struct ceph_file_info *fi, +extern int __ceph_get_caps(struct mnt_idmap *idmap, struct inode *inode, + struct ceph_file_info *fi, int need, int want, loff_t endoff, int *got); extern int ceph_get_caps(struct file *filp, int need, int want, loff_t endoff, int *got); diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index 76680e5c2f82..d11295e0a115 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -978,7 +978,7 @@ ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value, mask |= CEPH_STAT_RSTAT; if (vxattr->flags & VXATTR_FLAG_DIRSTAT) mask |= CEPH_CAP_FILE_SHARED; - err = ceph_do_getattr(inode, mask, true); + err = ceph_do_getattr(&nop_mnt_idmap, inode, mask, true); if (err) return err; err = -ENODATA; @@ -1015,7 +1015,7 @@ ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value, } /* get xattrs from mds (if we don't already have them) */ - err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR, true); + err = ceph_do_getattr(&nop_mnt_idmap, inode, CEPH_STAT_CAP_XATTR, true); if (err) return err; spin_lock(&ci->i_ceph_lock); @@ -1064,7 +1064,7 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size) if (ci->i_xattrs.version == 0 || !__ceph_caps_issued_mask_metric(ci, CEPH_CAP_XATTR_SHARED, 1)) { spin_unlock(&ci->i_ceph_lock); - err = ceph_do_getattr(inode, CEPH_STAT_CAP_XATTR, true); + err = ceph_do_getattr(&nop_mnt_idmap, inode, CEPH_STAT_CAP_XATTR, true); if (err) return err; spin_lock(&ci->i_ceph_lock); From patchwork Fri Jun 9 09:31:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273584 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 B1214C7EE2E for ; Fri, 9 Jun 2023 09:41:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241661AbjFIJl5 (ORCPT ); Fri, 9 Jun 2023 05:41:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241844AbjFIJli (ORCPT ); Fri, 9 Jun 2023 05:41: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 A9D4649ED for ; Fri, 9 Jun 2023 02:36:17 -0700 (PDT) Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 5B3CA3F379 for ; Fri, 9 Jun 2023 09:33:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303185; bh=ErpWfnSHCAR2b37e5NamwpmTb1AxMZzXeuUaWWgL6I4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=McE2C5ygIAAUsLZSv2rLyD7UEXzwLJa168uCkceRkwH2TElDOcitNZITWwOfuOrfL baPHKx+lc9sYJZDRlV7ekmjfrnGTSgHVgemnzjENOFc9yK5PyB/opZ0IKK7vQFe1wu CZRrqgkVA1ZqNW3j71RrrD6eLDZ/TDiE5lCk79EfclHspBle6/OSMEpZWvG5RUFMNW 3Ok/fL8mhVRDGc4Vjgf6jC1NbUl/ic3Dvi3idQ22pxR24yrd72yQBEXmEEmUeTfk1m DZII69TB/vDcL1idkdpQ2rJzxIppEmclQo8dEowfgRJb1+vIlw3sWoXevnSSW/NPbk roqPMqWHVk0aQ== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-94a348facbbso187987466b.1 for ; Fri, 09 Jun 2023 02:33:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303185; x=1688895185; 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=ErpWfnSHCAR2b37e5NamwpmTb1AxMZzXeuUaWWgL6I4=; b=F0NfQO9Rgkj9cH1zAmumau0mvMelwo9mxvtHpPDAcaG7PPu5wQJudiZKLBB0rWThoM WDXe8x+a8yFgpZqKPekGGCje1jMkI645646Fy/ydnX3Es5HN1jR0CsEn0TnXO1dyVZa4 LuLwoRtFT56UmDRJ3CItN8/xiFJtI0JgLS8lwIeuo23mKFKxFY0uzxQqA3PhwFr+B7uR zT+7dSrn4ttvM0BrW836DvZ0Bg2B4xbZVE1UU9DNz0pOf7qFYG/CmpwvqLtcN1sWYT9W JM8BPH3xsaBGwHrHXe0/OpKelq3AIAKKx7/NzRtYk7Fvms/UH520/H5sR46mV3xMV6UZ ZbpQ== X-Gm-Message-State: AC+VfDxMYSw4pbKIeRXWAFyRJ4h9Yf3cg7or641gfDT+KJ0Zyv8e5x9i CwGreR37/rY6A7ZPuOFEBmYC+WRmzGxmf2+qymzV5Gw7gsTdSdlovEHrxHERVPKYAEv9d02d/D4 A/L1aef1sHPyLwtsco1cmwT6B8LLS9J08KdyKz3DIPTM= X-Received: by 2002:a17:907:320e:b0:966:53b1:b32a with SMTP id xg14-20020a170907320e00b0096653b1b32amr1404163ejb.53.1686303185198; Fri, 09 Jun 2023 02:33:05 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4BnVyK6mbmtzUJ+7grSTxADhjOPPojcQ0QDq/KdSEQIMmUKH1e7Jp4s+uJLDjcJCeRYCYC5A== X-Received: by 2002:a17:907:320e:b0:966:53b1:b32a with SMTP id xg14-20020a170907320e00b0096653b1b32amr1404149ejb.53.1686303185014; Fri, 09 Jun 2023 02:33:05 -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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:33:04 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Alexander Mikhalitsyn , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 12/15] ceph: pass idmap to __ceph_setxattr Date: Fri, 9 Jun 2023 11:31:23 +0200 Message-Id: <20230609093125.252186-13-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Just pass down the mount's idmapping to __ceph_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 d4be4c2d63c3..e34b4e859b82 100644 --- a/fs/ceph/acl.c +++ b/fs/ceph/acl.c @@ -145,7 +145,7 @@ int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry, goto out_free; } - ret = __ceph_setxattr(inode, name, value, size, 0); + ret = __ceph_setxattr(idmap, inode, name, value, size, 0); if (ret) { if (new_mode != old_mode) { newattrs.ia_ctime = old_ctime; diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 57cbb69a17c8..05dbae76087c 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1116,7 +1116,8 @@ static inline bool ceph_inode_is_shutdown(struct inode *inode) } /* xattr.c */ -int __ceph_setxattr(struct inode *, const char *, const void *, size_t, int); +int __ceph_setxattr(struct mnt_idmap *, struct inode *, + const char *, const void *, size_t, int); int ceph_do_getvxattr(struct inode *inode, const char *name, void *value, size_t size); ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t); extern ssize_t ceph_listxattr(struct dentry *, char *, size_t); diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c index d11295e0a115..663267bbee3c 100644 --- a/fs/ceph/xattr.c +++ b/fs/ceph/xattr.c @@ -1090,7 +1090,8 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size) return err; } -static int ceph_sync_setxattr(struct inode *inode, const char *name, +static int ceph_sync_setxattr(struct mnt_idmap *idmap, + struct inode *inode, const char *name, const char *value, size_t size, int flags) { struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb); @@ -1144,6 +1145,7 @@ static int ceph_sync_setxattr(struct inode *inode, const char *name, req->r_inode = inode; ihold(inode); + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_num_caps = 1; req->r_inode_drop = CEPH_CAP_XATTR_SHARED; @@ -1158,8 +1160,8 @@ static int ceph_sync_setxattr(struct inode *inode, const char *name, return err; } -int __ceph_setxattr(struct inode *inode, const char *name, - const void *value, size_t size, int flags) +int __ceph_setxattr(struct mnt_idmap *idmap, struct inode *inode, + const char *name, const void *value, size_t size, int flags) { struct ceph_vxattr *vxattr; struct ceph_inode_info *ci = ceph_inode(inode); @@ -1288,7 +1290,7 @@ int __ceph_setxattr(struct inode *inode, const char *name, "during filling trace\n", inode); err = -EBUSY; } else { - err = ceph_sync_setxattr(inode, name, value, size, flags); + err = ceph_sync_setxattr(idmap, inode, name, value, size, flags); if (err >= 0 && check_realm) { /* check if snaprealm was created for quota inode */ spin_lock(&ci->i_ceph_lock); @@ -1324,7 +1326,7 @@ static int ceph_set_xattr_handler(const struct xattr_handler *handler, { if (!ceph_is_valid_xattr(name)) return -EOPNOTSUPP; - return __ceph_setxattr(inode, name, value, size, flags); + return __ceph_setxattr(idmap, inode, name, value, size, flags); } static const struct xattr_handler ceph_other_xattr_handler = { From patchwork Fri Jun 9 09:31:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273630 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 8C712C7EE37 for ; Fri, 9 Jun 2023 10:09:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240275AbjFIKJf (ORCPT ); Fri, 9 Jun 2023 06:09:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238696AbjFIKJD (ORCPT ); Fri, 9 Jun 2023 06:09:03 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A72F4ED3 for ; Fri, 9 Jun 2023 02:58:49 -0700 (PDT) Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 436453F7F4 for ; Fri, 9 Jun 2023 09:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303188; bh=NTRbvFaxBJiBjzqaGA2aiDfNbGvJPFM8L4tecTGSATY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=c81609pkRXrliN6J5+Wk08J9hlXSHMh/dHTCxQpCjJKCfgDAXMkq860l1M77DEYS+ cHMCcIr6znlMT647dDztb2Tdaqzv2MiXJ/XRN7KCMza1+n+h0rgKKLaz3N9tTb11gw XLUFcULb+uFSYARLC0mJXzhf8lvMtl7eBFphdlcYAnpCuLCCuegM/5U9siOH8Iancw Si4Qng4q211NFijfYEUm0JpfFhA4JrugY8UzlctkyofBZ92Q+3m5xQaUIZVcpOv9gc BWOsg2N5Idr8hsvMyyX0U5lpS5qKcV9htOxI34SK32aHI/jBvSQ7ndEPknzuo1beUt MalpqFXNSqoZQ== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-94a341efd9aso188696666b.0 for ; Fri, 09 Jun 2023 02:33:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303188; x=1688895188; 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=NTRbvFaxBJiBjzqaGA2aiDfNbGvJPFM8L4tecTGSATY=; b=WQFGnZrd+Sok3zEq/t0RjMbzxQeGH9K3GXHBsFO1wcF6Etv8MYqp4QdguizL+mZ/Rn bWcUVL6JnPya3BChAXDyG/z+cgFHje5vFr0WLkZBfTlLPKJQYZyAJQ5zesd0tTI+iQf7 LyXgAefWi7PW9U/RPePregOJHHP2ywshXPTVFoPqCA1FHhwHVcZYph7+L/4ZCgrCnx7n zkDbiL+OZ6wgh9KXffXMTYNZTyCOaW5IRPh6R/lATyvRrtmyHMpcTo4Ly5RDva4JNsQ0 bDJInsdVi2NvnN0/ejQuaGHxYhR4HuxHo2V7wVv6S6nIJcTHSltB6Bc+HrhVGN75RJqn YXYw== X-Gm-Message-State: AC+VfDzblpkbrlRTsYEajUTCmlkbEztBvZBuhtExAjU0pq1pTTRjuPVV ySxa1dVTRepjpKFuu34oW+iWT1yIuglO/WueKg2vFZ/LDVYqz5bLKdx7t+VPKdv8sSISmz5/KHq 2YWIz+ADTdCr5DiVR3vizM+ifbe4ZLzsPBl0fvwpp6Dw= X-Received: by 2002:a17:907:2d86:b0:96a:ee54:9f19 with SMTP id gt6-20020a1709072d8600b0096aee549f19mr1483417ejc.48.1686303187976; Fri, 09 Jun 2023 02:33:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Z2fKxESvTokZxAA6jO95MDJ55kXGYQIvSjdgXaLQkL7P4nGYdW+Kjdz5sh7oS5H5q3aYmyA== X-Received: by 2002:a17:907:2d86:b0:96a:ee54:9f19 with SMTP id gt6-20020a1709072d8600b0096aee549f19mr1483409ejc.48.1686303187841; Fri, 09 Jun 2023 02:33:07 -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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.33.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:33:07 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Alexander Mikhalitsyn , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 13/15] ceph: pass idmap to ceph_open/ioctl_set_layout/readdir Date: Fri, 9 Jun 2023 11:31:24 +0200 Message-Id: <20230609093125.252186-14-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Pass an idmapping to: - ceph_open - ceph_ioctl_set_layout - ceph_readdir Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: brauner@kernel.org Cc: ceph-devel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn --- v6: - pass idmap to ceph_readdir --- fs/ceph/caps.c | 2 +- fs/ceph/dir.c | 2 ++ fs/ceph/file.c | 9 +++++++-- fs/ceph/ioctl.c | 3 +++ fs/ceph/super.h | 2 +- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c index b432f29e80dd..13c231258153 100644 --- a/fs/ceph/caps.c +++ b/fs/ceph/caps.c @@ -3042,7 +3042,7 @@ int __ceph_get_caps(struct mnt_idmap *idmap, struct inode *inode, } if (ret == -EUCLEAN) { /* session was killed, try renew caps */ - ret = ceph_renew_caps(inode, flags); + ret = ceph_renew_caps(idmap, inode, flags); if (ret == 0) continue; } diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 2c0c2c98085b..26335c025f50 100644 --- a/fs/ceph/dir.c +++ b/fs/ceph/dir.c @@ -308,6 +308,7 @@ static bool need_send_readdir(struct ceph_dir_file_info *dfi, loff_t pos) static int ceph_readdir(struct file *file, struct dir_context *ctx) { struct ceph_dir_file_info *dfi = file->private_data; + struct mnt_idmap *idmap = file_mnt_idmap(file); struct inode *inode = file_inode(file); struct ceph_inode_info *ci = ceph_inode(inode); struct ceph_fs_client *fsc = ceph_inode_to_client(inode); @@ -440,6 +441,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx) req->r_inode = inode; ihold(inode); req->r_dentry = dget(file->f_path.dentry); + req->r_mnt_idmap = mnt_idmap_get(idmap); err = ceph_mdsc_do_request(mdsc, NULL, req); if (err < 0) { ceph_mdsc_put_request(req); diff --git a/fs/ceph/file.c b/fs/ceph/file.c index c2bb8f5fd345..9671b0e77faf 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -175,7 +175,8 @@ static void put_bvecs(struct bio_vec *bvecs, int num_bvecs, bool should_dirty) * inopportune ENOMEM later. */ static struct ceph_mds_request * -prepare_open_request(struct super_block *sb, int flags, int create_mode) +prepare_open_request(struct super_block *sb, + int flags, int create_mode) { struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(sb); struct ceph_mds_request *req; @@ -293,7 +294,7 @@ static int ceph_init_file(struct inode *inode, struct file *file, int fmode) /* * try renew caps after session gets killed. */ -int ceph_renew_caps(struct inode *inode, int fmode) +int ceph_renew_caps(struct mnt_idmap *idmap, struct inode *inode, int fmode) { struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(inode->i_sb); struct ceph_inode_info *ci = ceph_inode(inode); @@ -336,6 +337,8 @@ int ceph_renew_caps(struct inode *inode, int fmode) ihold(inode); req->r_num_caps = 1; + req->r_mnt_idmap = mnt_idmap_get(idmap); + err = ceph_mdsc_do_request(mdsc, NULL, req); ceph_mdsc_put_request(req); out: @@ -356,6 +359,7 @@ int ceph_open(struct inode *inode, struct file *file) struct ceph_mds_client *mdsc = fsc->mdsc; struct ceph_mds_request *req; struct ceph_file_info *fi = file->private_data; + struct mnt_idmap *idmap = file_mnt_idmap(file); int err; int flags, fmode, wanted; @@ -431,6 +435,7 @@ int ceph_open(struct inode *inode, struct file *file) ihold(inode); req->r_num_caps = 1; + req->r_mnt_idmap = mnt_idmap_get(idmap); err = ceph_mdsc_do_request(mdsc, NULL, req); if (!err) err = ceph_init_file(inode, file, req->r_fmode); diff --git a/fs/ceph/ioctl.c b/fs/ceph/ioctl.c index 6fa021b973e5..69efd446a9e1 100644 --- a/fs/ceph/ioctl.c +++ b/fs/ceph/ioctl.c @@ -114,6 +114,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) req->r_inode = inode; ihold(inode); req->r_num_caps = 1; + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_inode_drop = CEPH_CAP_FILE_SHARED | CEPH_CAP_FILE_EXCL; @@ -139,6 +140,7 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg) static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg) { struct inode *inode = file_inode(file); + struct mnt_idmap *idmap = file_mnt_idmap(file); struct ceph_mds_request *req; struct ceph_ioctl_layout l; int err; @@ -160,6 +162,7 @@ static long ceph_ioctl_set_layout_policy (struct file *file, void __user *arg) req->r_inode = inode; ihold(inode); req->r_num_caps = 1; + req->r_mnt_idmap = mnt_idmap_get(idmap); req->r_args.setlayout.layout.fl_stripe_unit = cpu_to_le32(l.stripe_unit); diff --git a/fs/ceph/super.h b/fs/ceph/super.h index 05dbae76087c..d89e7b99ac5f 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -1308,7 +1308,7 @@ static inline bool ceph_has_inline_data(struct ceph_inode_info *ci) /* file.c */ extern const struct file_operations ceph_file_fops; -extern int ceph_renew_caps(struct inode *inode, int fmode); +extern int ceph_renew_caps(struct mnt_idmap *idmap, struct inode *inode, int fmode); extern int ceph_open(struct inode *inode, struct file *file); extern int ceph_atomic_open(struct inode *dir, struct dentry *dentry, struct file *file, unsigned flags, umode_t mode); From patchwork Fri Jun 9 09:31:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273645 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 BF5C9C7EE29 for ; Fri, 9 Jun 2023 10:12:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240728AbjFIKMD (ORCPT ); Fri, 9 Jun 2023 06:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239042AbjFIKLg (ORCPT ); Fri, 9 Jun 2023 06:11:36 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06FEE5259 for ; Fri, 9 Jun 2023 02:59:53 -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 A51AA3F56E for ; Fri, 9 Jun 2023 09:33:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303191; bh=2hwztFxZhmRTBhQzcOpavHgJ6h9g0DydFvSzqcbHOs4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WKwT+ppy2zEwnm5govOR6qxcyUn3U90t06j0quu7rMwBC4/j7SrsBalzFi+PRXrn7 GxFE4zbXXRBbGCj9P6aWhKxFSMGD3bN0bpIjuF6ZwCJHkJ0CBXQtyKWG0mEDftk5TT 0vmcASto/PT4+n1V4I+FcTqc/1seg6hN0iRZ14doNuvHKb+PVSN5Y2P7+THmlnSeB2 0eYpBQN4C1r4b57D8vPms/LegHlpWgqBwNhpM0wlZvAIYhWKKmzBRRWb80QGQFKUy9 HQhKVJOYfYtiLB3493HChj/Q87l4ItDfZ+SyfhuQMXVdu2oeiQf3NHoeef0rHeIHv0 nDsDl75NSXVIw== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-978a991c3f5so177505566b.0 for ; Fri, 09 Jun 2023 02:33:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303190; x=1688895190; 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=2hwztFxZhmRTBhQzcOpavHgJ6h9g0DydFvSzqcbHOs4=; b=Kx1oHrqMJnSFe4uaahccsGfJBJuqfb27wW6iJz064m3QMON/WmYGt/zskwVS71p4aQ GyqoFs4yEzdm+WEH4IzeJqHMe/PL2BgB3eDnS7Bx9hZMOTb80L/fGyk/d251f6Irm3EG 4HvcfOj0wDZhCHifWYTNc0GIEH8KWULxIsfZa2ZARH6ucxcQaQTu3si+YVJOKdjg8Q6+ ZR97Huh+1WiY4SHS2xW9/CMmQRPHDkQKZl5f/NimOF+9l68w8t9xYBE3ZKa/79cN+Fv6 WuHtDqiP2DcYuHOC/6C3M/CosQCeTy6r6/g+G5y2VkBHmiibGRaDdL5LgcgzP5vZKDqP 6BMg== X-Gm-Message-State: AC+VfDwNKgO4b2IHQ970ZcvVJ0ifqTxcwxYrujlVvp6fZs8a+vZ0CmNY C7mQRqfuS19FbUNWd/BD6gMAEbqkwapT4YDsLBvf+5uvERJjRD8Elw6WcktYGARVB0hG5TqM7e3 l9xF3PuUxLzBs/Q2LXV374aVqYqy4qUMM3L3LID9pxmI= X-Received: by 2002:a17:907:3d93:b0:94f:2a13:4e01 with SMTP id he19-20020a1709073d9300b0094f2a134e01mr1371730ejc.74.1686303190606; Fri, 09 Jun 2023 02:33:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4MsL6zC8MBPYxx1/IN/olzX93IyA3TrvCsZrn7wnZMo+W05KzTTK8rzx2rV8d5frIVKKWmuA== X-Received: by 2002:a17:907:3d93:b0:94f:2a13:4e01 with SMTP id he19-20020a1709073d9300b0094f2a134e01mr1371717ejc.74.1686303190365; Fri, 09 Jun 2023 02:33:10 -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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:33:10 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Alexander Mikhalitsyn , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 14/15] ceph: pass idmap to ceph_netfs_issue_op_inline Date: Fri, 9 Jun 2023 11:31:25 +0200 Message-Id: <20230609093125.252186-15-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Just pass down the mount's idmapping to ceph_netfs_issue_op_inline. 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 | 12 ++++++++++++ fs/ceph/super.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 0a32475ed034..2759a0cf2381 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c @@ -291,6 +291,8 @@ static bool ceph_netfs_issue_op_inline(struct netfs_io_subrequest *subreq) { struct netfs_io_request *rreq = subreq->rreq; struct inode *inode = rreq->inode; + struct ceph_netfs_request_data *priv = rreq->netfs_priv; + struct mnt_idmap *idmap = priv->mnt_idmap; struct ceph_mds_reply_info_parsed *rinfo; struct ceph_mds_reply_info_in *iinfo; struct ceph_mds_request *req; @@ -318,6 +320,8 @@ static bool ceph_netfs_issue_op_inline(struct netfs_io_subrequest *subreq) req->r_args.getattr.mask = cpu_to_le32(CEPH_STAT_CAP_INLINE_DATA); req->r_num_caps = 2; + req->r_mnt_idmap = mnt_idmap_get(idmap); + err = ceph_mdsc_do_request(mdsc, NULL, req); if (err < 0) goto out; @@ -443,13 +447,18 @@ static int ceph_init_request(struct netfs_io_request *rreq, struct file *file) if (!priv) return -ENOMEM; + priv->mnt_idmap = &nop_mnt_idmap; + if (file) { struct ceph_rw_context *rw_ctx; struct ceph_file_info *fi = file->private_data; + struct mnt_idmap *idmap = file_mnt_idmap(file); priv->file_ra_pages = file->f_ra.ra_pages; priv->file_ra_disabled = file->f_mode & FMODE_RANDOM; + priv->mnt_idmap = mnt_idmap_get(idmap); + rw_ctx = ceph_find_rw_context(fi); if (rw_ctx) { rreq->netfs_priv = priv; @@ -496,6 +505,9 @@ static void ceph_netfs_free_request(struct netfs_io_request *rreq) if (priv->caps) ceph_put_cap_refs(ceph_inode(rreq->inode), priv->caps); + + mnt_idmap_put(priv->mnt_idmap); + kfree(priv); rreq->netfs_priv = NULL; } diff --git a/fs/ceph/super.h b/fs/ceph/super.h index d89e7b99ac5f..0badf58fb5fc 100644 --- a/fs/ceph/super.h +++ b/fs/ceph/super.h @@ -481,6 +481,8 @@ struct ceph_netfs_request_data { /* Set it if fadvise disables file readahead entirely */ bool file_ra_disabled; + + struct mnt_idmap *mnt_idmap; }; static inline struct ceph_inode_info * From patchwork Fri Jun 9 09:31:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 13273585 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 6C904C7EE25 for ; Fri, 9 Jun 2023 09:43:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241836AbjFIJnA (ORCPT ); Fri, 9 Jun 2023 05:43:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241849AbjFIJm3 (ORCPT ); Fri, 9 Jun 2023 05:42:29 -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 9389E184 for ; Fri, 9 Jun 2023 02:37:07 -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 908A53F383 for ; Fri, 9 Jun 2023 09:33:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303193; bh=QbGnheXMoUoU7EuOckcncmKJSqs6BTa9rIJEwkbRpgw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EG7qu+ND7KZ2jzL4n1LGibYepg09OHojNkMC/cjHh6FgnVuPXt928enhmvpUPbjpY c8l4GAy8yhj+/11hdMKQodH0W7JJ26a23GJcuHetgomGmJ18UAxibtJop2K1Vbzh3r 08W2UYlCHPmbeGKPIjVf4KtpLblVXTHTC+GMPIdaBHSS8Pn0Zf5r1zfIPcDnFKDTFa Vjr64hJARBu0oD8+CsCGnO2Y5KVT2VodQkfzAFS3UfEKD4Qf0lbiiFKDx+5/Vjzhe7 RVFvPsGVNypHVjbMkZGBJTjSukVd0rbJ5aMvi56PJHRv7Y1ixaBtCkKLLnrj/Wa4PX /7jyOgcqeXtLw== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-97888a89775so146857666b.0 for ; Fri, 09 Jun 2023 02:33:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686303193; x=1688895193; 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=QbGnheXMoUoU7EuOckcncmKJSqs6BTa9rIJEwkbRpgw=; b=HeVhvWmH+y3MalNBQf2dW8dCZkJHdbz7DCdh7X0mLsEgUNCgLM38PMgBwMuGjowcjK Zw1FsEfnXP0B5GX+luMwAG6uY8XBEO1qE1HKtfFaJbZTd3RIhOjS941KrBRfKuT5I1yj rjJOGSoa6jzR3TBHnzbTBw6ZS+gSfMZbNriyYNM3Q6Zs67U/vWWhF1XZhUkMRdnmEBzS V40ErD2bTNQ79+8+vFMtrOTMaBpZdXAQkRUFhbYD3IT/A3Oqc3zwV2K7qBYtAD7WLXc0 7fg6bBdjdBFhF9kmPftRzpFBuM1wM9DblC/VuseePVRbn7N5T4t8gHcJ+vZoCywFtjXg piRQ== X-Gm-Message-State: AC+VfDx8ppoM2e21j0xHjas5K8GtMYWTY2NtvXVQZaB/QTxfqE+g+EVM exnXZOM6nWl0/LQcyn0AUUKf3vYbHxC8G9GNsxryTxeADK33CVR45XLdPr8NM/MNTwABA+2FeDI JWIUYwoTRBobHHWfmtsNNMXYJy/rZ8VueRFl50KmCdtM= X-Received: by 2002:a17:906:99c4:b0:977:4b64:f5e8 with SMTP id s4-20020a17090699c400b009774b64f5e8mr1032572ejn.57.1686303193186; Fri, 09 Jun 2023 02:33:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HU2v6WmrkMOTn6GRljmiRk69Tjcu7+OG5pBD1+ECabkYx/wfa5G2bflaMx7onYF4L2fcwKA== X-Received: by 2002:a17:906:99c4:b0:977:4b64:f5e8 with SMTP id s4-20020a17090699c400b009774b64f5e8mr1032559ejn.57.1686303193039; Fri, 09 Jun 2023 02:33:13 -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 e25-20020a170906081900b0094ee3e4c934sm1031248ejd.221.2023.06.09.02.33.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Jun 2023 02:33:12 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Christian Brauner , Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v6 15/15] ceph: allow idmapped mounts Date: Fri, 9 Jun 2023 11:31:26 +0200 Message-Id: <20230609093125.252186-16-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> References: <20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: Christian Brauner Now that we converted cephfs internally to account for idmapped mounts allow the creation of idmapped mounts on by setting the FS_ALLOW_IDMAP flag. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 3d6d0010d638..aabc8ac90ead 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -1581,7 +1581,7 @@ static struct file_system_type ceph_fs_type = { .name = "ceph", .init_fs_context = ceph_init_fs_context, .kill_sb = ceph_kill_sb, - .fs_flags = FS_RENAME_DOES_D_MOVE, + .fs_flags = FS_RENAME_DOES_D_MOVE | FS_ALLOW_IDMAP, }; MODULE_ALIAS_FS("ceph");