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: Alexander Mikhalitsyn X-Patchwork-Id: 13273578 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 299B8C7EE2E for ; Fri, 9 Jun 2023 09:38:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241748AbjFIJiZ (ORCPT ); Fri, 9 Jun 2023 05:38:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241750AbjFIJhk (ORCPT ); Fri, 9 Jun 2023 05:37:40 -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 7242A7681 for ; Fri, 9 Jun 2023 02:32:46 -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 5352B3F484 for ; Fri, 9 Jun 2023 09:32:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303121; bh=GFNwWvhavDkNrI4eqwez7OWrv+w+Iw1WNhnwQW/Fw7E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bOQiwn81QXGJoZaNfCJ7RNMSLmlLg48W89Fm6SjLuxef1EzvumsdFyguXz6anz+r/ l73R1q6VV9oUpLCJgUQh62D9UkEAoqzeu/TwdO5s6x/Jwd9vBV0YC2mQJKRsZEjGEE EokRHfKN6WHlWzdKgzw0PHXuzQ1KGAlpfScmfBvA0Q8KJWry/JcXiTZgYFQ481NunH 04EXB+t86TCGLeIDYYlcvnRx2AfH8l4YbOKC7jyCZDS120ilDXbNAiMVJowzlZBuxJ FZnp5JSmzhdaYLcOO130h/Uct40ti4+n8+uN5nbod2JOSQ6ej/otDnol9xnrPX8yh9 AvVVVx0SKc8VQ== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-977c516686aso183454266b.1 for ; Fri, 09 Jun 2023 02:32:01 -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=c2b69wzwc8MYmYcVx0sFoVV4yOr4sAnBlg0z3eefQZNHl6l6cMheXAkgx61TmAWNDZ lC4IKYJoxcHf3zAPmm8+t4DeM0G+Iyg3fSfx4uqfoBRCeOYw8bZbMPmyomxDHa5K9CVn UN4zhF9WGgozL9zzkaEyi5xG34OUGq9BDJ7IrAkOJfRSGhQ3ccYmzjrz6r5nI/HJ5FyC JolTeryC62lkw7B3ZbhJl4QbFVzl+Qt+s9LwNapgzL8Er4vctMbhFhmUj9hNeTfqsWvJ iA0wU7FGZLJXeBYaCmixppcXl+lYzdcptUgldaoWAGm94A2hr3uL2/h47zu3Ed0h78uJ zoLQ== X-Gm-Message-State: AC+VfDw8x738olnh+Pz3ZSoEKY77RgpintH9PREqZ9eIkvFJhSOD4CXf Q27UGltnXZcOS0zEiAmPhL7WtdSSZKm1GfJ4rPp+gKGQwMCux+L7nY8Iy9jwC2kmeBWeY+G4RLO suKzY0NKWhpsjuj8opaalk/msU3YqO+ycvp8JJ7E= X-Received: by 2002:a17:907:70a:b0:96f:a935:8997 with SMTP id xb10-20020a170907070a00b0096fa9358997mr1328421ejb.12.1686303119323; 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: ceph-devel@vger.kernel.org These helpers are required to support idmapped mounts in the Cephfs. Cc: Christian Brauner Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn Reviewed-by: Christian Brauner --- v3: - EXPORT_SYMBOL -> EXPORT_SYMBOL_GPL as Christoph Hellwig suggested --- fs/mnt_idmapping.c | 2 ++ include/linux/mnt_idmapping.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c index 4905665c47d0..57d1dedf3f8f 100644 --- a/fs/mnt_idmapping.c +++ b/fs/mnt_idmapping.c @@ -256,6 +256,7 @@ struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap) return idmap; } +EXPORT_SYMBOL_GPL(mnt_idmap_get); /** * mnt_idmap_put - put a reference to an idmapping @@ -271,3 +272,4 @@ void mnt_idmap_put(struct mnt_idmap *idmap) kfree(idmap); } } +EXPORT_SYMBOL_GPL(mnt_idmap_put); diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h index 057c89867aa2..b8da2db4ecd2 100644 --- a/include/linux/mnt_idmapping.h +++ b/include/linux/mnt_idmapping.h @@ -115,6 +115,9 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid) int vfsgid_in_group_p(vfsgid_t vfsgid); +struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap); +void mnt_idmap_put(struct mnt_idmap *idmap); + vfsuid_t make_vfsuid(struct mnt_idmap *idmap, struct user_namespace *fs_userns, kuid_t kuid); From patchwork 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273579 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 0B9F4C7EE2E for ; Fri, 9 Jun 2023 09:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241753AbjFIJjL (ORCPT ); Fri, 9 Jun 2023 05:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241220AbjFIJix (ORCPT ); Fri, 9 Jun 2023 05:38:53 -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 E51C63C24 for ; Fri, 9 Jun 2023 02:33:28 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 375C73F36A for ; Fri, 9 Jun 2023 09:32:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303157; bh=Qh/WJ81ZpXRyl0gQ4ukcXvtFhi/qxOmZnI5fUrSNycI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=janVrMALn5r213g/rDnEkl1i3iMgdLxMc2L25qsX4ZuKCHX+wqow7EUfftZiks9mX iO9f0xKxWXD8HLgoWtQulAzDvGv34CgzQWQkNg9yezNgDcVAJHLip/5FXAo6qxUaTX XlVU/LIE9U+tN28eFS0aIl4ybQrR2b1unlShM1105f9yXYXtV0IKABMJJzDQ1O4m9l E1w4EJJXiw0TwKr0by3g+UEk74AbPJjwkt8FgSCZLm/gIopm1fPC6nVDTssrJ4I3QJ 0eAdySVG0gwPpZSQqiFUdm0cliXKfyP76eWKRLYcoqPmdX0hYw8guQyCTZdYOfqqKh J5KEGbB/KwW0A== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-5153b118ea0so1448937a12.0 for ; Fri, 09 Jun 2023 02:32:37 -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=dKlAK8vL5hOcZRp14y80+Zb6c3jZa1tk4SbcqS2ap6EGsG7ZA3RVM4WGxCRmtKJS6H 8mYa8Ruh0bgH5o+Nbhde0zdYmrpUQXihI1rdllKK1YdRZFTFhpttzt0whHI/J2t9tTXH x527vh6125jXGm+OOfTEvlbXocwuyjMBykweROCgMwyCeiGOy0V0VczFC6QYPph16qOB wUcj9T1SRAlaSEOJIUv1zLOwbHTm+WWcmgOK2SOVrdOCzrVjo0eROGRdkJk9bik/mdSK k5+srmskrjKWlO1rvrVPOT4A/zl9vPQcK/J6meo5y1dDp90uGRE8yPcbSzuELPpvaJ0C drCQ== X-Gm-Message-State: AC+VfDyue5SNWojzQFAEr+0TgQtBhDxQrJ0WEHR9hVXs95bFdc6jdMpv zfMBSI7ypIKDvAb4+qobrToXVDjQWagjIWgy+1+tIwH8b6ibk+/yFf9siOJ4BznQ4BoKMTKt5Rm 1zJGA3S/ptysV6/DCEpP1gNco43RzRD1Ah/TY09Q= X-Received: by 2002:a17:906:ee83:b0:974:5480:171e with SMTP id wt3-20020a170906ee8300b009745480171emr1462450ejb.32.1686303156920; 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: ceph-devel@vger.kernel.org From: Christian Brauner When sending a mds request cephfs will send relevant data for the requested operation. For creation requests the caller's fs{g,u}id is used to set the ownership of the newly created filesystem object. For setattr requests the caller can pass in arbitrary {g,u}id values to which the relevant filesystem object is supposed to be changed. If the caller is performing the relevant operation via an idmapped mount cephfs simply needs to take the idmapping into account when it sends the relevant mds request. In order to support idmapped mounts for cephfs we stash the idmapping whenever they are relevant for the operation for the duration of the request. Since mds requests can be queued and performed asynchronously we make sure to keep the idmapping around and release it once the request has finished. In follow-up patches we will use this to send correct ownership information over the wire. This patch just adds the basic infrastructure to keep the idmapping around. The actual conversion patches are all fairly minimal. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- v4: - don't call mnt_idmap_get(..) in __register_request --- fs/ceph/mds_client.c | 5 +++++ fs/ceph/mds_client.h | 1 + 2 files changed, 6 insertions(+) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273647 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 B731DC7EE25 for ; Fri, 9 Jun 2023 10:11:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240790AbjFIKLP (ORCPT ); Fri, 9 Jun 2023 06:11:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230477AbjFIKKY (ORCPT ); Fri, 9 Jun 2023 06:10:24 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A10CC86A0 for ; Fri, 9 Jun 2023 02:59:18 -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 379FF3F56F for ; Fri, 9 Jun 2023 09:32:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303162; bh=+ZXNJzxGWGsPdae4AE9sODEjkcVKgoTQCtJS4YUBoj8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WoFpteeEdbZ7yJtCjI4/TnV2NnYy2VhBUW3RA1tCq0TF/mV/XFZ23fBsoxZKN1vzC TetWv83Mbe3IXdYnjepwGK/mwcmO0V1ClSbJlbdLU9HIk0enUs47zZCT9Vof0vMWKC wMmsa0ASBk4XCSNECAqmJZ6qEwA5wKr4JaGNsT1btVwyjAPzc+flOnVCKg90LjkZMs l149oIMF+mscYCH+zz1q0oTTy1S+mRG21d4BTsXe9dX0jnIG9fBaIOf26PqjlJ/kuK d23KuxgFW6M+kYa2/rwsYHoV4Lxe921rpOeEXG2ZFJ2mJYDJsCwWplWwvjWjJABMdU fTbsLdatqiJrA== Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-97888a89775so146831766b.0 for ; Fri, 09 Jun 2023 02:32:42 -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=IcEwjjJAveyySvwEX1t18AuJbdXgjMsUoo16CsvvWIA2y+5OMS3NrWaTQp86Kda/Nn +0njmFuyTuZGi89YojRmPw/p8trmn06rpdW8OSaiC2LlQ3VW59/37zM1w36ZZ83PoPaJ YSosbNe6PZ2WqQQeWsTTj9wLTzBwLqU+GEiMZ5UoAxsvJ+tCZrEw0Kex6jd6sFv9Hurd 9aezZQYbcmzxW3hmm2HZlA4DoKopRkBq10KJxQFAWwT4VwTb4x3v13+e/LXVzMuT9tsK SzCKEAFpsDeCk6v26TMgyuonYkBPL5G/fHfpXndWgmcG9xfpGJ5+B5T1KK0rYY2iOOXu xSRg== X-Gm-Message-State: AC+VfDzyDY/eYvUADv7TX+PsxHRFR+dwrpnNfJPSkhxnZFw6LpQgqjBM 79hzBU4md2kEZ9p+eN4+Hyp3aQ4aUBtjAqc6BJfXD3Hx56g+7tNIj1ErGkRzk7HDDENem7i2IRc Z18T5103MDmBcV5/1vyvbzC8U/muFwYhb79d5smajCm1c7WM= X-Received: by 2002:a17:907:a49:b0:961:272d:bdb9 with SMTP id be9-20020a1709070a4900b00961272dbdb9mr890204ejc.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: ceph-devel@vger.kernel.org From: Christian Brauner Inode operations that create a new filesystem object such as ->mknod, ->create, ->mkdir() and others don't take a {g,u}id argument explicitly. Instead the caller's fs{g,u}id is used for the {g,u}id of the new filesystem object. Cephfs mds creation request argument structures mirror this filesystem behavior. They don't encode a {g,u}id explicitly. Instead the caller's fs{g,u}id that is always sent as part of any mds request is used by the servers to set the {g,u}id of the new filesystem object. In order to ensure that the correct {g,u}id is used map the caller's fs{g,u}id for creation requests. This doesn't require complex changes. It suffices to pass in the relevant idmapping recorded in the request message. If this request message was triggered from an inode operation that creates filesystem objects it will have passed down the relevant idmaping. If this is a request message that was triggered from an inode operation that doens't need to take idmappings into account the initial idmapping is passed down which is an identity mapping and thus is guaranteed to leave the caller's fs{g,u}id unchanged.,u}id is sent. The last few weeks before Christmas 2021 I have spent time not just reading and poking the cephfs kernel code but also took a look at the ceph mds server userspace to ensure I didn't miss some subtlety. This made me aware of one complication to solve. All requests send the caller's fs{g,u}id over the wire. The caller's fs{g,u}id matters for the server in exactly two cases: 1. to set the ownership for creation requests 2. to determine whether this client is allowed access on this server Case 1. we already covered and explained. Case 2. is only relevant for servers where an explicit uid access restriction has been set. That is to say the mds server restricts access to requests coming from a specific uid. Servers without uid restrictions will grant access to requests from any uid by setting MDS_AUTH_UID_ANY. Case 2. introduces the complication because the caller's fs{g,u}id is not just used to record ownership but also serves as the {g,u}id used when checking access to the server. Consider a user mounting a cephfs client and creating an idmapped mount from it that maps files owned by uid 1000 to be owned uid 0: mount -t cephfs -o [...] /unmapped mount-idmapped --map-mount 1000:0:1 /idmapped That is to say if the mounted cephfs filesystem contains a file "file1" which is owned by uid 1000: - looking at it via /unmapped/file1 will report it as owned by uid 1000 (One can think of this as the on-disk value.) - looking at it via /idmapped/file1 will report it as owned by uid 0 Now, consider creating new files via the idmapped mount at /idmapped. When a caller with fs{g,u}id 1000 creates a file "file2" by going through the idmapped mount mounted at /idmapped it will create a file that is owned by uid 1000 on-disk, i.e.: - looking at it via /unmapped/file2 will report it as owned by uid 1000 - looking at it via /idmapped/file2 will report it as owned by uid 0 Now consider an mds server that has a uid access restriction set and only grants access to requests from uid 0. If the client sends a creation request for a file e.g. /idmapped/file2 it will send the caller's fs{g,u}id idmapped according to the idmapped mount. So if the caller has fs{g,u}id 1000 it will be mapped to {g,u}id 0 in the idmapped mount and will be sent over the wire allowing the caller access to the mds server. However, if the caller is not issuing a creation request the caller's fs{g,u}id will be send without the mount's idmapping applied. So if the caller that just successfully created a new file on the restricted mds server sends a request as fs{g,u}id 1000 access will be refused. This however is inconsistent. From my perspective the root of the problem lies in the fact that creation requests implicitly infer the ownership from the {g,u}id that gets sent along with every mds request. I have thought of multiple ways of addressing this problem but the one I prefer is to give all mds requests that create a filesystem object a proper, separate {g,u}id field entry in the argument struct. This is, for example how ->setattr mds requests work. This way the caller's fs{g,u}id can be used consistenly for server access checks and is separated from the ownership for new filesystem objects. Servers could then be updated to refuse creation requests whenever the {g,u}id used for access checking doesn't match the {g,u}id used for creating the filesystem object just as is done for setattr requests on a uid restricted server. But I am, of course, open to other suggestions. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/mds_client.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273596 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 53189C7EE2E for ; Fri, 9 Jun 2023 09:53:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241880AbjFIJxJ (ORCPT ); Fri, 9 Jun 2023 05:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241034AbjFIJw0 (ORCPT ); Fri, 9 Jun 2023 05:52:26 -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 E26025BB6 for ; Fri, 9 Jun 2023 02:44:56 -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 6B0F53F373 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-f69.google.com with SMTP id a640c23a62f3a-9715654ab36so152702166b.0 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=NHHEK+n5rpuU8zN1ySrQ5xyR8izquGHb7+cDsjDkYPrVSriSmwpcPiGZrU9vK8lfXk U8xn6jiJKVFZxUETdbNgpwjfj0eBJQx144OKeOQkZCE6vaHMj2WBkav7ND49+4HNOs21 tJsr9EvS2uUCLb4VfKTKd+0tJ4z20qo7E3bSSsZbANWhYPDndw1g4InIOYha4PQkPC7A 3K3uGSsbzcKRDBs+aF3Bebj3qhscoMo4F42D6lCmeylZu4Q5cv+QF+zJHEdECremovqh y7NPnUTHnnR/excVdzLuQ2QZUGvW/8/EqMrS2XD5Yj5uE+yx5kzygIKmJgPlls8kbXwX kSdg== X-Gm-Message-State: AC+VfDxDFAWFq7Ej85CHWcjRNsPGZylnPHBEq4hdhVKCbI/k9/DPnibn ZdWy4qC7rQy5qfSe9Ra3fmR2h2SVnjRb20lkQoJ+BFFIHXwQoZD8pZjuTIQn5rP5oQ+SobR4sl6 pEW3yWZvbssrYd/XdDd506KXIoPDp9i//ZEMvs6Y= X-Received: by 2002:a17:906:9b85:b0:96f:dd14:f749 with SMTP id dd5-20020a1709069b8500b0096fdd14f749mr1013831ejc.23.1686303162164; 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: ceph-devel@vger.kernel.org From: Christian Brauner Enable mknod/symlink/mkdir/rename iops to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- v4: - call mnt_idmap_get --- fs/ceph/dir.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c index 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273635 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 9003CC7EE25 for ; Fri, 9 Jun 2023 10:10:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240361AbjFIKKr (ORCPT ); Fri, 9 Jun 2023 06:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbjFIKKV (ORCPT ); Fri, 9 Jun 2023 06:10:21 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9484E869F for ; Fri, 9 Jun 2023 02:59:18 -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 3CB5A3F460 for ; Fri, 9 Jun 2023 09:32:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303166; bh=/3eW+11n/4iCvn/s3430tPb8fe2pR8+LzRYCxQYjku8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oesWZssZIjW57ZWF92PWBoWu4iY32fpTt65uUzVnDdsTEkcZnEBnQ2VhxKOckiRuM LzF8EbIgATwmQaU3uCpXPQGZmJq/H8JuPQTuZ3GSqB94+B87CJP5IsuFbHEOAdRRoM 5HSwMJRfEXCmHvseQ9HMnIRijIM8tQwXm0yxf9mzXytIjH6U52XCFGTN+r1m+fy0BH WsgzpYFwSg8ynd4DAk1xoaD9xzloUwc+Vm3Q40QG0dsqAemgJkN0TklMS+ODVfuFOT ZyFi6CZGTDIPgp9ero4qtB/+ahSTmroiGRkJDn3kTCfBI28aaF1ypJR2qsPsxXGFOY sZaAW0lFcz95A== Received: by mail-lj1-f200.google.com with SMTP id 38308e7fff4ca-2b20220c67bso12537251fa.1 for ; Fri, 09 Jun 2023 02:32:46 -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=goFYhO7zUNzDGh/stwdPn1Q7exrTVGGFatC/HkV/QfDGkKaOFT4tLNS+z+BN06e10T oPfE/EV9j5cZiSe/qPnSYEN5HX6Q9QKdTQPuMVCWgXNIF++z409UaLMElHvrLIro5dFs TcOVa8LhqJgMOuN+srHK70AMTX3jRkYGvLn/cJOrdX+5q4glxEdJOeN4IAdeQfz6M6dF XIUX9UWMfpVfPlVtut8IxD4x4tVB40ZpAFeajo3dXlvNe2riIIMxQrTS4ncCIqLfBQub Ndr+J0K1XsVD0RkVk3RKPM8tQSjYQ0Gan6bm6XtMN3zWXRhB6sS0YA0TKUKahtA6j3y2 5pTA== X-Gm-Message-State: AC+VfDwPVR/rss356iCdl7z2RxaO+imx62GAZhkUNYeeASVjbpkcFIe8 /1jgcAviI4tpZnQsinK5sqCSzRSc70DgB8yTKVsGMBnOEOcnOyGGFM0RgzErvbRpgfULjAVpmrV nC+yDt7KIS7MavuaWO2NZGWn4Nf2Dz2wad41XKzA= X-Received: by 2002:a2e:8659:0:b0:2b2:3a4:4ebe with SMTP id i25-20020a2e8659000000b002b203a44ebemr802395ljj.48.1686303164553; 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: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_getattr() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273580 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 088D2C7EE2E for ; Fri, 9 Jun 2023 09:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241583AbjFIJk4 (ORCPT ); Fri, 9 Jun 2023 05:40:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241689AbjFIJjf (ORCPT ); Fri, 9 Jun 2023 05:39: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 5D6884207 for ; Fri, 9 Jun 2023 02:34:02 -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 2699F3F513 for ; Fri, 9 Jun 2023 09:32:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303170; bh=/ZEyoJlFLaVuWVBzkT1cBDONkmXP3qyfK5/dTNb2H5c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cvK+95elo2k3/jMqYxyonrhw0wwys5ZUxNM3rjPC98l3y4IZy7TRombROSqa/FWs5 tLhldCVPYTrK5o9lpuOqZvdxti+Whh7ueQnqUClwX8A6Ws5pJBDY4YwikJSmifqxBh Ao6MF5fZKP9kcqwZTe9tY86C2TX0TnvEtpRrT8KRVaBZzgeabrlaRg8wGInbAeryyp +AzhvQujwDPp5BRF0XdAVHAIOrYuP44HjYPmUbLB3Je0I8hVmsroYNUU6Bi0MhCvYP 4qX39swt+bfa7qEGP6eiu7PFnecUACgG006PO+nNXg2KEdEFIQwD7aaAs7gLyIqrhA whEu5fLO+2D3w== Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-977e50b0120so183262466b.0 for ; Fri, 09 Jun 2023 02:32:50 -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=TC+li3/IMOA7GfJTAkthhNN4e+TGc4hY8Inq0evBX9HdlBMQSvaeURT7wBfiZMhvuH YgyWxLu2jnCSwZI1yu72WX3DujDav7oOtYUXJgCYrEo+R8XAscqPILbVhbTMKnKyDlQ4 DV6yXHu0Of8+VZ8pFF/o1pISfH59TJz3JtgYomSOVWtA3NwSiMmlk3ZOjqpyo0q/HA1D LakZV06vugkb6rkV1i/t5I3A8EdP+pYdJSsFlCcNtuY43nCQc9bz4bzx6SVg/vkoY/Nn ZjoxhWCcipeX4awv0vlqPB/LwMjc+bnc7j9WHBXWUnqyYEdhNQmimqrCbnzd+FHO+qFf aPpg== X-Gm-Message-State: AC+VfDyZlp5qecD1Gpyx9KtRlohBkh9DwGsk2fdJk2a/tilXuLUnpgpW J/Tp5o0fG1BS/oBH5eEkQIT1FmcHMxFe/Qapeg0uFT3G82IbGA3abYGibCHSHGsUm/y9eYzVCae bOv7XnsHVuGp6cNQ73FylfEs8pAUpMtbym0gAd38= X-Received: by 2002:a17:906:4792:b0:96f:608c:5bdf with SMTP id cw18-20020a170906479200b0096f608c5bdfmr1229547ejc.64.1686303166888; 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: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_permission() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c index 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273634 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 06B72C7EE43 for ; Fri, 9 Jun 2023 10:10:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239905AbjFIKKk (ORCPT ); Fri, 9 Jun 2023 06:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241264AbjFIKKR (ORCPT ); Fri, 9 Jun 2023 06:10:17 -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 8EB448687 for ; Fri, 9 Jun 2023 02:59:14 -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 C239B3F54C 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-f69.google.com with SMTP id a640c23a62f3a-94a341efd9aso188674866b.0 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=k9trnANaauhio0Tb+CkH8HR9NiLQVzhNlS/zBKlTn/U1Z1YqJfbqkLZdcEo92RGjDm 4fCr2GT7So4bxiQtRUpAKqigaOEiOqZdg8hnInOOC+/GTSw8FsvskD28YPpof/ivQojs 5eQZmsb+B8QeotkRgui0Wlg/VLZPYq5/0zSAn7NOx6jsAYxKB48Z7wby+s5pbtSwFSvL wF6OwPR5T/eOTGIwfAlSwl68MNsfC53FPUuaGt0J2sM2T81hv1hpcoKu0S9OU9f2F3WH FmLVUKyKZMT4yXTVAsvuqzoK47gpKQcZH7Hssy1VjYhVrPMiPzi5HsqJf0j3wg8Cc9eC Ap4w== X-Gm-Message-State: AC+VfDwem+lIo6iG/f7ok31G3lR8l9pg8MvSYUR1MKLc+KBL1pVoAkgK 3Qp17ew1SEjfp8hpZr9OJCTklR2ErJlJo00ygAUZQ4w6JhmZjsIFOZu3vMZ45bY0ZUP8Dy4um25 r+V8Iq4/cpsC5BCa5UHe43RcaypjDTUl5JpEWjeM= X-Received: by 2002:a17:907:1c90:b0:974:ae01:3af4 with SMTP id nb16-20020a1709071c9000b00974ae013af4mr1458844ejc.68.1686303169214; 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: ceph-devel@vger.kernel.org Just pass down the mount's idmapping to __ceph_setattr, because we will need it later. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: brauner@kernel.org Cc: ceph-devel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/acl.c | 4 ++-- fs/ceph/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: Alexander Mikhalitsyn X-Patchwork-Id: 13273597 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 F1F4EC7EE2E for ; Fri, 9 Jun 2023 09:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241419AbjFIJxQ (ORCPT ); Fri, 9 Jun 2023 05:53:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241413AbjFIJwd (ORCPT ); Fri, 9 Jun 2023 05:52:33 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF6A34201 for ; Fri, 9 Jun 2023 02:44:59 -0700 (PDT) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 9C0733F378 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-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5149e1bd242so1360458a12.3 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=cIBpaZhD59HyKOrfJWcNpvL4dSvdx0LsJHQ3BuhH8bmugl6mFBgcx8c1eH66kVu6Sm K4Ya8Sjx7KwGqguZYto2wz3FtepjolXOQlVopy644OxlaCak0zj3JncXiJqMn6SyVcT3 ARF8eBIEj668sKbbyBh6iu0KdU6V+7pjC8A5MvbYAf/cHYe/K7fXwoiYrl7glL52DSAY 7H6tzZyrOamkKhG8rSjRy6ShE5FYuEjEt+Xv+IoBnK4TPwedjkwetHDtPKWZw8Qk5Ssf ioqX6VApFKaV/xs+E2soyTEdXPF3201PfxV4SL9M0ndRUpeXbLmsrt9inEPbp/z0Y6eq bLiA== X-Gm-Message-State: AC+VfDyYOP0Ro96qaemeREUh74aVS1ZKuS3qeqOG31BXzdidAMcY9I7A aw8DLn8N6H3M7v3ciwuYNzkc5q25N0rYYmgtdUItoZPfC1vKQKYvcrI5LkAsjasj3N78jlyL6/O BlN6K/WCMvfpP775wXCoYka2eHkByd42gltmJpqo= X-Received: by 2002:a17:907:2d0f:b0:965:6075:d0e1 with SMTP id gs15-20020a1709072d0f00b009656075d0e1mr1243442ejc.72.1686303171875; 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: ceph-devel@vger.kernel.org From: Christian Brauner Enable __ceph_setattr() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner [ adapted to b27c82e12965 ("attr: port attribute changes to new types") ] Signed-off-by: Alexander Mikhalitsyn --- v4: - introduced fsuid/fsgid local variables v3: - reworked as Christian suggested here: https://lore.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: Alexander Mikhalitsyn X-Patchwork-Id: 13273587 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 5D5A6C87FDC for ; Fri, 9 Jun 2023 09:41:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240375AbjFIJk6 (ORCPT ); Fri, 9 Jun 2023 05:40:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241942AbjFIJkD (ORCPT ); Fri, 9 Jun 2023 05:40:03 -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 4E26C4683 for ; Fri, 9 Jun 2023 02:35:02 -0700 (PDT) Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id B9DB53F37D 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=kRtya9vNnJsHnlJFsQiUMmcKKT8ZGQqP3swgCnXRiRw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=I480jqjgTHO+N8GD2mnA2TB7qcTsCHkLUsvfTKkrRvRcDIzDbpb8IwtAJxg8MLQYX xucTQCkq+/ee9bCI4I9CjlXN1vZusZR2W2jV+2xsYPg3kxqlAMcVdtJD78YGcSTqUC B8yzSXdoi4pxQVG0Y53nNGnJG6RLx+JNYOiburjBPCBshrd18xlKQjZbN11lKXIGa5 DPEyBpvHTQCG3fAH/0OY+zq4yy8iisHFmqAJRJKI/jcvLzxXKlp2kq/SpT1yMQkOkI UJSEYOo9MfkLafDZe1Vr2b/J/k4c+hy0L05+i3qW0RqrUXChvy94wvkh7sQyzYvQgC pZe13DNR0Go4w== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-516302ba604so1585011a12.2 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=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=gmP35N5GBOrEUV+d7lNWL3sAALeMSH6ubWv2bEYwjUanHk3oB5aOuz3Fe276U/CEOa BY0hKMbcACWjz9fMeWLyygIJvhRivy4y469vE/NhVoS4KDnvCDKDPi470/QXpD+oL/yF lZuiEfgwOaZzItVuydX2N3gPQPFfH6c1nZ1g+KqROHA5dhnqOPelx0Cag4YHvSLnLzOX GA+WAmohqrvGOx+1mv2biEHh/eNhNZxQQIsX68OhLyb/wahGyy/bCA7ixTcOydf66ucp 8OSWVUJTumeQhUEh0wEKq94c/m7DgVXh2xvFqyV0ipBKqfhtfkTugM4zLaEbjOCI2crC fYlw== X-Gm-Message-State: AC+VfDxSwgjGRgvY20q9w4jX+fRZtNVWNMaE5IYQ0r/9sEtgA+RKEHpw Y3SnPD7NA8vgLPqSEtUx440RxoEPZSI9z69FP5152tPNEPOGPyw4Kafc6S/q4NOs8bQFqBXoTxV 6V74EJoPgVAL9E2CbJqZqMWDa8doYIbR3m4Aw4Rs= X-Received: by 2002:a17:907:9801:b0:973:fd02:a40f with SMTP id ji1-20020a170907980100b00973fd02a40fmr1311019ejc.59.1686303174470; 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: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_set_acl() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/acl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273588 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 582F1C7EE25 for ; Fri, 9 Jun 2023 09:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241783AbjFIJlX (ORCPT ); Fri, 9 Jun 2023 05:41:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242213AbjFIJkm (ORCPT ); Fri, 9 Jun 2023 05:40: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 DDCC36191 for ; Fri, 9 Jun 2023 02:35:48 -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 9F0813F364 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-f69.google.com with SMTP id a640c23a62f3a-94a35b0d4ceso151199366b.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=K0iutQ++r4+5cYxZbgZahZX81feXlTlwIVN13fKwqzxWUNuIqK//geUXX8diyFBQWm YOHx8pr4WSXAkIGpTktO8Eg39LXNMNgy8DFPi3ea3LAsyBsUUSDtTt1NNLN5E+cxkRwS 8Gg/kTFzFD6D6cQPu0EujvDc3+cz6piVnJbZnIDRWl62POlnQTK8Fv8h5B8ohXqAE76a akSqxy4tXiOE2i3aEhRzWUGQZ/TM+cNW8SgyKGr4/lGqHAshE7qWU5sR+gJ4t1wwijfo 04YkA0m5DBVC78lYRxpfySd5/PFo9YXJcnS3NagNldcmaHSAN7NmJz6CADBP/+hyc/SV GMgw== X-Gm-Message-State: AC+VfDzB3c9P7rBxk6De8YBUUSweYhu0rBdGpW6a5Uh6qZ/RIvbrAY30 GZ3l/cMxTJMMOf/S480H+vAmwJauHDBMB/fwKEcA0Wza6sIhJuAUOJiSJaFVmB9Wam0aMTBFaVo RkGYCTaktxqg7FfvOpQTajb+GA94dLjpsoTHgL/A= X-Received: by 2002:a17:906:da82:b0:979:7624:1f71 with SMTP id xh2-20020a170906da8200b0097976241f71mr941170ejb.26.1686303178484; 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: ceph-devel@vger.kernel.org From: Christian Brauner Enable ceph_atomic_open() to handle idmapped mounts. This is just a matter of passing down the mount's idmapping. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner [ adapted to 5fadbd9929 ("ceph: rely on vfs for setgid stripping") ] Signed-off-by: Alexander Mikhalitsyn --- v4: - call mnt_idmap_get --- fs/ceph/file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273632 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 DD24EC7EE25 for ; Fri, 9 Jun 2023 10:09:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238001AbjFIKJe (ORCPT ); Fri, 9 Jun 2023 06:09:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230460AbjFIKJE (ORCPT ); Fri, 9 Jun 2023 06:09:04 -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 8A80D4ED4 for ; Fri, 9 Jun 2023 02:58:49 -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 47AD43F56D for ; Fri, 9 Jun 2023 09:33:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303182; bh=0VGqwyhzl3JPGUl0HnnxKLIkvQp+JnBUhnrWkIN+oYU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h2N7EhnUDfBEejBVDN5ZTxk5pdbp5uQ2Nh9iJg8IzbYHKASrVOXiBDM1I3sxCzfLM p8Qi5RXqigsFlo4D3vdXWWJApyNc9yg1MRqySnt17XaAPGGg/32Hm4DPNcWeug35vq 7L/EJY4g/HweBkInLklY1ykYE5hXsr2MY5MJzxf0gI5Vs79P5fJlCFLEWkkaCeGHIi cuCCNemFNpuAxQWtL6kmZ+EeNH/gFtlcF1xFFoD/5JJhltmlrIpZ+NwoV97kcbY7im QSU1z03DSta6MFVrkx9/Z7FpbCGb+4/BJWr3quhbh7+ws2zbgSHhNmWbtSMaPd+WVO JYGoTI+OLU12A== Received: by mail-ej1-f71.google.com with SMTP id a640c23a62f3a-978876e43a7so199104566b.3 for ; Fri, 09 Jun 2023 02:33:02 -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=WFAgqn8+6oLc6xFGqI3xNKY3RS3bFgV2e62EFaAliOoEHTDlKxAU+Gww9zjzp769dv r+KiSUtfrEG/eD3+cCHbsr651lJfGO4G2ueKUpd2+X/kDoiz4PFJsInqnLwjdtvalD3x aY+sCZynpEFpeBozwi86/QRxPTTc1MhoVaSPvsaOBEHaUGHx6O+iZ98ggjHTNCFB0S+1 gYLOd71NnjAISJA5HZzfLgtp87MROIWw6pTrt7XEdkT/amytdpe2DF0GNECrT0rh7TwV LWmwzP3ww6sYZAp8gEv5e59XzSle6lL/4J9+h5if9rBKyO8LwYQJfdYHfQRfrJWWgpSJ R3kw== X-Gm-Message-State: AC+VfDwDZqnVmAV5NzaQ5n09A9JiRQKsgyVzlt5LOkQi2pr3ioWMIv8B JHlWTZjfUcfO1n+QZQ/PspIn/m7ZtnoqaSyVHqyo8WcGDpLrwT5X7PjTpg4GOdibJWQzpyBdqkF C7obs6KQUtb8W1jNMNKcf4i0qtMDZcUJvJWa/qNk= X-Received: by 2002:a17:907:2d91:b0:97a:bd0f:ac74 with SMTP id gt17-20020a1709072d9100b0097abd0fac74mr418762ejc.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: ceph-devel@vger.kernel.org Just pass down the mount's idmapping to *ceph_do_getattr, everywhere when possible, because we will need it later. Here we have two cases: - filemap_fault/read/write/lseek (when idmap is accessible) - export_ops/list_xattr/get_xattr (when idmap is not accessible) in this case we pass &nop_mnt_idmap. So we can meet permission issue when MDS UID/GID-based path restriction is used. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: brauner@kernel.org Cc: ceph-devel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn --- 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273648 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 33458C7EE25 for ; Fri, 9 Jun 2023 10:12:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238903AbjFIKMA (ORCPT ); Fri, 9 Jun 2023 06:12:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238915AbjFIKLe (ORCPT ); Fri, 9 Jun 2023 06:11:34 -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 8CE64525D for ; Fri, 9 Jun 2023 02:59:54 -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 9DD1E3F578 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-f70.google.com with SMTP id a640c23a62f3a-94a348facbbso187987666b.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=XWYfL5b0YaJhWzjbYOGByq880Pdut0svE/fe3njVThbkUmw9B/97TUy/5Y5zOdrWZ0 wggFFbjrIwtcSgeRqycS+du4cDGxZdNskAh65F2A+Qii1wTpogeBOjArNH2sD0aH3L2N SjaHYZgXzjyVAPxn7n+D6pWosl1ceTe2agpU1uern8ibmHvwOYur18JlV9qllIIM4xR+ 05Lx6y3bLOsnqo59CnzPaxlKzA/CorCjt/UO9H9GlqcTrmpdYBB7bdHygLlb4+CO96Ts OpRoe5e3iE9ywI/Kl13U+gJs5Vbsf9Bgz8B3ZWaI5/fDlUGz1ijtfwsI6ER35Qvj8byR bfJg== X-Gm-Message-State: AC+VfDwhshajc/H2RnvVvBJgluBGFiMiZ60/k5uiPjC7geUKD0e1hEWb zVOLu8b1BHxZC30yloYTIyHEBoggpI4if0Xh4/uU+CSfUcyh8ARy1ZXCvl0hZQMo+iat7ZvSXrh WuG293zOQ72/XaL1zVi84c531Dd+v5SxZ0D4CyRXZ17yVVBM= X-Received: by 2002:a17:907:320e:b0:966:53b1:b32a with SMTP id xg14-20020a170907320e00b0096653b1b32amr1404158ejb.53.1686303185169; 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: ceph-devel@vger.kernel.org Just pass down the mount's idmapping to __ceph_setxattr. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: brauner@kernel.org Cc: ceph-devel@vger.kernel.org Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/acl.c | 2 +- fs/ceph/super.h | 3 ++- fs/ceph/xattr.c | 12 +++++++----- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c index 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: Alexander Mikhalitsyn X-Patchwork-Id: 13273612 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 480FBC7EE2E for ; Fri, 9 Jun 2023 09:58:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241939AbjFIJ6S (ORCPT ); Fri, 9 Jun 2023 05:58:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241825AbjFIJ5t (ORCPT ); Fri, 9 Jun 2023 05:57:49 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09F024C37 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 41FF43F374 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-f70.google.com with SMTP id a640c23a62f3a-9744659b7b5so187411266b.3 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=mIjrwUTU6QIlvzQsM+fOikToA2KPGycbF809VTGKOAvPvbKytQl0BWwh9Cuyg9CEjI /dJEgO044nTgfvUfLTAQXhObZUE2JR+14tPbNIMKnEWu0o0xqnJ7gtlghi6TkdXsWu9z S6gaoW3i3iM/IQ5aoCdhMb2qgvKbzfKeiGNaqMUzxGwV5iVfu/FQ1J3LZf+QkkdSqGdK zl/in+3q7h1pRRjwRPiX7ewVgGiSl2lcL1M1f8LG46H688kXn5su6/VlB/JJ5lDp+E35 9tKDF4oSqL56x9bKer4ST8jj6qNjN9BjY29XpfYmUW4PD/IGr0hteJubfK7xptPM5lnV vCLg== X-Gm-Message-State: AC+VfDxV8HelsJIcjQfQYoQVAJpp7VpKZEChWMoXXAVSlsJ1F04tU467 PFitbB6dXwH1aML+uUsRZQK9y4xlL28UwPPPkDyaC80gXXR0keKAmpQ589mUUGvSB0CKCRVJwyp rZxKhHtdkVZXQABISMw5exhnOFc0rzW3pp2pqx0U= X-Received: by 2002:a17:907:2d86:b0:96a:ee54:9f19 with SMTP id gt6-20020a1709072d8600b0096aee549f19mr1483420ejc.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: ceph-devel@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: Alexander Mikhalitsyn X-Patchwork-Id: 13273633 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 E7CF3C7EE25 for ; Fri, 9 Jun 2023 10:10:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239213AbjFIKKi (ORCPT ); Fri, 9 Jun 2023 06:10:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240999AbjFIKKK (ORCPT ); Fri, 9 Jun 2023 06:10:10 -0400 Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B3928684 for ; Fri, 9 Jun 2023 02:59:14 -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 DEC3C3F484 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=1686303190; bh=2hwztFxZhmRTBhQzcOpavHgJ6h9g0DydFvSzqcbHOs4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gnIAQkU5IQwVZT/mb4HqZ/A0yOpNhVz5GmtWYTjNRRoq+7mZNRaAkR7XplOF7bvM8 LObbxLfaLRX2iVz7q+46V63+KFzXOymSMcoTl2g5wceo8kDkxeI7qhpWKnOklalskU zhmMjuz4U3UZDVO2eOtVLAz425t265ejn/z6gHUVm7MVrozyaT03eznZw6oYSRswNv 6DKNMbg4IzaumociTwxq84FaxmFuAST9GyT9X4JOc8GPC9hBG/0Dc41jQR68vZUTFT TXAPRq552NELtnqaRgM4yzGeRVhL3TOlCD9JBnHUt4IXxeenLMuYwj04FAd5YmeLZl ODSNyX9BB8kgg== Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-94a355cf318so207579766b.2 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=TzKuTBspYLoDIdzUQ+u8H+vihpVCl6Z3xJoCjFCHrMl+q9d/QZ+RsU/RKpfSMw612u L++Ftv8XSjNlAzM7ITtyjbRO6nfUyM3Iq10JKBdYo+L3v9ADQVsiI6En+RmFOFNeDYwG AnmsZoFYyvF2hCjlJgnpdkc6E4Dsl4yYYNzSEdbvNjvsfke55/ZooVOUM0Ud7KaQHzCo Fe5J+pCQC4W91Jbjeg+FZwEte9y8zMJNMCmkA6DAQDempih0wcnfUO/otF60eCur1/SS CsRa8w2QnfRnccxJqpN6dbQW5fPvQ1VkSnL7T3KeGZstu5DNHNtjFTmiQpSdsynqPGRg SMtA== X-Gm-Message-State: AC+VfDwuvDI8xbJj2sgJ2FRtA+Mzl4Yjq9N6PGoKyd/TBVE8Btm+c2yX fvfZ6Cv8+rnsgjZRPUHWNM8bml5NsRV5nenSzo5kc0qDmij9vjjY9EHgMjA7wy88FEIZTMKWiyK 8FeC0Zeog9BuPuXdbkfJO232Ej+pQ8RTTmSVK1z0= X-Received: by 2002:a17:907:3d93:b0:94f:2a13:4e01 with SMTP id he19-20020a1709073d9300b0094f2a134e01mr1371735ejc.74.1686303190608; 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: ceph-devel@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: Alexander Mikhalitsyn X-Patchwork-Id: 13273589 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 511DAC7EE25 for ; Fri, 9 Jun 2023 09:43:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241771AbjFIJnJ (ORCPT ); Fri, 9 Jun 2023 05:43:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241858AbjFIJmb (ORCPT ); Fri, 9 Jun 2023 05:42: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 98622525E for ; Fri, 9 Jun 2023 02:37:13 -0700 (PDT) Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 5E9BD3F363 for ; Fri, 9 Jun 2023 09:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686303194; bh=QbGnheXMoUoU7EuOckcncmKJSqs6BTa9rIJEwkbRpgw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SMkADP4rtQrKd+6OxRtNi7rFAyRCRl1JahkMRhQfvfyByEw/OYotF8hGree+L96tf lhvJQzbqaqxEHUwOOQcxVhqR4bTOfjcwJcFpX5SFvhqRhyYaMWvy/Bp0sZM0sw/2ch L90jJW3uVqeouT4fy/KJ/xMM+ywMgj4LZ7O4LuI/lYmVUDXfR1V6Rx0Pnn8+owBx4j K165u8mgSQzQvUrlRUhgiL+qnzcopUpIyQgzsw5wkGdsFTHu3kHqUEAwvMH3zwuVb+ T4lFvER3BmULV5EtINcG15Sfiack56kp3Z4u2s85Aw8jVnQKMCIP8yqeF4GZHEptMl HKOx7t0GhqwZQ== Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-5149ab05081so1265698a12.2 for ; Fri, 09 Jun 2023 02:33:14 -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=J3gmD5sJNiNlAf+PMatVzOs8nMkdyHiTa8Ua8W3/d+6LNn9LoszTCBL/8sI+lRmh9O oT5aI+GP7SSKrbUXvi44eYSdc3xeq8lcAohh6wSP8zlGFsRY1YODl4BPX3D9m5bShAF8 g9u17uvde3jXvYMPsW4r2t9Gq+ij83rVHjYSFsn6L7Rmn6BxPELcT4nPDrCcfZes2tTc E8uwgc3FNfJSxvwSFtDkVgg2IHIU+v1J/X02nf5snYHMAvJBnd37JnX8BlXSGwPGiRMM wYlhqVBTlffRyGD0+4/mvqEz67lf4922L8utdZCz9PhVpd2AWse+ch8oDF13oTKUpKcD HJEg== X-Gm-Message-State: AC+VfDyR/2jqYB8Pqct2k+5sXobAjl9vZtwc16qXo6yqajmmhHq5ZUiG XMfXxFQIv9vRU2rYZkWGZp+9DolZizQ07OWAXrvUeyXQcq154weIo+q4k7SIXWdVVdpaWCNnVUu VF0wn/vd53CRduZ9C3elAiQ2rdVyBxkVv4Vk4KADsiun48i4= X-Received: by 2002:a17:906:99c4:b0:977:4b64:f5e8 with SMTP id s4-20020a17090699c400b009774b64f5e8mr1032567ejn.57.1686303193181; 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: ceph-devel@vger.kernel.org From: Christian Brauner Now that we converted cephfs internally to account for idmapped mounts allow the creation of idmapped mounts on by setting the FS_ALLOW_IDMAP flag. Cc: Xiubo Li Cc: Jeff Layton Cc: Ilya Dryomov Cc: ceph-devel@vger.kernel.org Signed-off-by: Christian Brauner Signed-off-by: Alexander Mikhalitsyn --- fs/ceph/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 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");