Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1803424rwd; Fri, 9 Jun 2023 02:19:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5I3I1mDzcLyBq/I1Y5RkDK0YjOx33ArEocwBGf2MmjLNhM6b72rI3XhhRIeRhCVtBZIZUU X-Received: by 2002:a05:6a00:1783:b0:662:c48b:47e2 with SMTP id s3-20020a056a00178300b00662c48b47e2mr1042682pfg.19.1686302367617; Fri, 09 Jun 2023 02:19:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686302367; cv=none; d=google.com; s=arc-20160816; b=1C3RmvbypjWrw6t2kzDbZstszHYZnl0gwrZ8ECDSoTg3oLYdiDT+D5IBcn2In9LrjM 8Q8JeiLtF/O+jsVmta93SpjO5lsZQXaBoECkbRS9wO50epcMnoKBImuO4T9+DwqAAlRc udDxZ7WVBFvLYwLL4khOAQ7+fBm3liBXINrOMPGm2MZJkJjgsl00W0GshNnOvLi9J9/R nPdqVR3+mHFrNk9VE3qOjEnzcy/KcyvAleJUPDUjzQNxbAkULAb4mAMUBr3vIYofTUpX qGFv8vjmiP7cxQP1MmxcV1e4lZrgyULJOLy1vTUQMt5pEdpgCM2yvtnbP5eDeoG4ECaL c2dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=cTj4GjB/9BDLM3nhk88ZM05TgDh034XIKIkWicIblZI=; b=QIFKhgp/+YXSLIG9rPA1IYs2V1wbuemPLsVLKyCTlDfkzDhFtBDUAfB05iMMqHK8i6 Lnz1WG5dYgR0YTo83EPHKMm/J3p5S1+l6ul/pM4f9845PFnPruXLFPEmVaEyVy5/3c72 J0mSuiFrGqo9gg577AUvKWWWSopkUF43IbJ84qEmJzh0ePaWm1kXqXnJ0d9CjJZTfAOs o5JHJFr5kUuDumMdSXnT1WwwGb0cIa8YNNbpg3yW7hnR15f/ioyM9ZZw5Omdd/y8lAkp iwqqKPauL5aaBGKP06rko4WSpr6hx/4lb6cBhW4UL9Cn+WrXuCvt8ydTXoOuydJNqKK7 eEtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=UPEIm71i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t75-20020a63784e000000b005440dd16740si2440709pgc.300.2023.06.09.02.19.15; Fri, 09 Jun 2023 02:19:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=UPEIm71i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238729AbjFIJAe (ORCPT + 99 others); Fri, 9 Jun 2023 05:00:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241151AbjFII7i (ORCPT ); Fri, 9 Jun 2023 04:59:38 -0400 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 359A72D4A for ; Fri, 9 Jun 2023 01:59:36 -0700 (PDT) Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) (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 654383F0F8 for ; Fri, 9 Jun 2023 08:59:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686301172; bh=cTj4GjB/9BDLM3nhk88ZM05TgDh034XIKIkWicIblZI=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=UPEIm71ivdXScEOIPAC7GgUVXPcm0WlIrPV/bMuNNGOmDDTnUsQFrKG0bfBPjnnZQ cSuWRawS2oUpwfB49VKanruhRHmErCOVT2A76yAJBHI0XIufZyCLX144zRgG5Z9LOp 4cAwqndEDzUNqangWaXmjLcpUxGESxarArnuPmqtAWk4atvfofabEzYeIu1uSs5uEc kAT1gCWe5EtM17cloK+PAiNN0yD61rC9KYDSKfdoWlhKIBoRkAEVi/wLTWZNoq6BZf LCXJv4d5yMPEFln0rI8pPRUQu/QRe3Uem1GHyPkODjZgRIPn+mKzXHOAqP0kmvjrqL 9T95dmiPT4+7g== Received: by mail-yb1-f199.google.com with SMTP id 3f1490d57ef6-bb0d11a56abso2278471276.2 for ; Fri, 09 Jun 2023 01:59:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686301171; x=1688893171; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cTj4GjB/9BDLM3nhk88ZM05TgDh034XIKIkWicIblZI=; b=QvxPfRrWP2OABVdrFH9H4ctC0n21sS5KBa8KFU6UzBiEgG9RmU9WYUfnqPYj3FeSC3 FQCW7FjD+BJDYlw6P+0sIEqTfK8jwUYgNRDCmA7Ur7AdbJgf9YA8yDWdOnZtExZJSCQ7 +kwe2kUuLrTpAtm/D6VVO77x3jTMVy1ZiaN7IQZEldhIyEVJOWkbaLCaY6+pdHsj5NCO fgGrguZBa1Ip8Z/1ZMoUGrXIZ903Ket36DVq8EXV24L2YH4pjIdxN/KJ4YRYk9SGrKrb 2oBbwNNYVihvvlBNLY8MmUNkUY12gjT4zsl9f74UHjTNUyveqWAwu89b29536Y6NVJwL 7PAQ== X-Gm-Message-State: AC+VfDzUj7WlCvblJYA/8BIs9MxUJUGwKyqYwLe9bbKofnlqTTjtHcri hKLfgNx0qp+GYSIYmpEiOHdDuvty+oBlafgD/ju0M0roJ7F8ZVueZDfwYpthXmVgF3dR0yLPn60 zIMjA26ugMl0U7F8wOc+LwLv+Kn4a7SqtqbfC0GFMHIgEXU1txQmLoLUtMg== X-Received: by 2002:a5b:804:0:b0:bac:9ba9:ada1 with SMTP id x4-20020a5b0804000000b00bac9ba9ada1mr453474ybp.28.1686301171350; Fri, 09 Jun 2023 01:59:31 -0700 (PDT) X-Received: by 2002:a5b:804:0:b0:bac:9ba9:ada1 with SMTP id x4-20020a5b0804000000b00bac9ba9ada1mr453466ybp.28.1686301171072; Fri, 09 Jun 2023 01:59:31 -0700 (PDT) MIME-Version: 1.0 References: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> In-Reply-To: From: Aleksandr Mikhalitsyn Date: Fri, 9 Jun 2023 10:59:19 +0200 Message-ID: Subject: Re: [PATCH v5 00/14] ceph: support idmapped mounts To: Xiubo Li Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Ilya Dryomov , Jeff Layton , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 9, 2023 at 3:57=E2=80=AFAM Xiubo Li wrote: > > > On 6/8/23 23:42, Alexander Mikhalitsyn wrote: > > Dear friends, > > > > This patchset was originally developed by Christian Brauner but I'll co= ntinue > > to push it forward. Christian allowed me to do that :) > > > > This feature is already actively used/tested with LXD/LXC project. > > > > Git tree (based on https://github.com/ceph/ceph-client.git master): Hi Xiubo! > > Could you rebase these patches to 'testing' branch ? Will do in -v6. > > And you still have missed several places, for example the following cases= : > > > 1 269 fs/ceph/addr.c <> > req =3D ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, > mode); + > 2 389 fs/ceph/dir.c <> > req =3D ceph_mdsc_create_request(mdsc, op, USE_AUTH_MDS); + > 3 789 fs/ceph/dir.c <> > req =3D ceph_mdsc_create_request(mdsc, op, USE_ANY_MDS); We don't have an idmapping passed to lookup from the VFS layer. As I mentioned before, it's just impossible now. I've checked all places with ceph_mdsc_create_request and passed idmapping everywhere if possible (in v6, that I will send soon). > ... > > > For this requests you also need to set the real idmap. Thanks, Alex > > > Thanks > > - Xiubo > > > > > v5: https://github.com/mihalicyn/linux/commits/fs.idmapped.ceph.v5 > > current: https://github.com/mihalicyn/linux/tree/fs.idmapped.ceph > > > > In the version 3 I've changed only two commits: > > - fs: export mnt_idmap_get/mnt_idmap_put > > - ceph: allow idmapped setattr inode op > > and added a new one: > > - ceph: pass idmap to __ceph_setattr > > > > In the version 4 I've reworked the ("ceph: stash idmapping in mdsc requ= est") > > commit. Now we take idmap refcounter just in place where req->r_mnt_idm= ap > > is filled. It's more safer approach and prevents possible refcounter un= derflow > > on error paths where __register_request wasn't called but ceph_mdsc_rel= ease_request is > > called. > > > > Changelog for version 5: > > - a few commits were squashed into one (as suggested by Xiubo Li) > > - started passing an idmapping everywhere (if possible), so a caller > > UID/GID-s will be mapped almost everywhere (as suggested by Xiubo Li) > > > > I can confirm that this version passes xfstests. > > > > Links to previous versions: > > v1: https://lore.kernel.org/all/20220104140414.155198-1-brauner@kernel.= org/ > > v2: https://lore.kernel.org/lkml/20230524153316.476973-1-aleksandr.mikh= alitsyn@canonical.com/ > > tree: https://github.com/mihalicyn/linux/commits/fs.idmapped.ceph.v2 > > v3: https://lore.kernel.org/lkml/20230607152038.469739-1-aleksandr.mikh= alitsyn@canonical.com/#t > > v4: https://lore.kernel.org/lkml/20230607180958.645115-1-aleksandr.mikh= alitsyn@canonical.com/#t > > tree: https://github.com/mihalicyn/linux/commits/fs.idmapped.ceph.v4 > > > > Kind regards, > > Alex > > > > Original description from Christian: > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > This patch series enables cephfs to support idmapped mounts, i.e. the > > ability to alter ownership information on a per-mount basis. > > > > Container managers such as LXD support sharaing data via cephfs between > > the host and unprivileged containers and between unprivileged container= s. > > They may all use different idmappings. Idmapped mounts can be used to > > create mounts with the idmapping used for the container (or a different > > one specific to the use-case). > > > > There are in fact more use-cases such as remapping ownership for > > mountpoints on the host itself to grant or restrict access to different > > users or to make it possible to enforce that programs running as root > > will write with a non-zero {g,u}id to disk. > > > > The patch series is simple overall and few changes are needed to cephfs= . > > There is one cephfs specific issue that I would like to discuss and > > solve which I explain in detail in: > > > > [PATCH 02/12] ceph: handle idmapped mounts in create_request_message() > > > > It has to do with how to handle mds serves which have id-based access > > restrictions configured. I would ask you to please take a look at the > > explanation in the aforementioned patch. > > > > The patch series passes the vfs and idmapped mount testsuite as part of > > xfstests. To run it you will need a config like: > > > > [ceph] > > export FSTYP=3Dceph > > export TEST_DIR=3D/mnt/test > > export TEST_DEV=3D10.103.182.10:6789:/ > > export TEST_FS_MOUNT_OPTS=3D"-o name=3Dadmin,secret=3D$password > > > > and then simply call > > > > sudo ./check -g idmapped > > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > > > Alexander Mikhalitsyn (5): > > fs: export mnt_idmap_get/mnt_idmap_put > > ceph: pass idmap to __ceph_setattr > > ceph: pass idmap to ceph_do_getattr > > ceph: pass idmap to __ceph_setxattr > > ceph: pass idmap to ceph_open/ioctl_set_layout > > > > Christian Brauner (9): > > ceph: stash idmapping in mdsc request > > ceph: handle idmapped mounts in create_request_message() > > ceph: pass an idmapping to mknod/symlink/mkdir/rename > > ceph: allow idmapped getattr inode op > > ceph: allow idmapped permission inode op > > ceph: allow idmapped setattr inode op > > ceph/acl: allow idmapped set_acl inode op > > ceph/file: allow idmapped atomic_open inode op > > ceph: allow idmapped mounts > > > > fs/ceph/acl.c | 8 ++++---- > > fs/ceph/addr.c | 3 ++- > > fs/ceph/caps.c | 3 ++- > > fs/ceph/dir.c | 4 ++++ > > fs/ceph/export.c | 2 +- > > fs/ceph/file.c | 21 ++++++++++++++----- > > fs/ceph/inode.c | 38 +++++++++++++++++++++-------------= - > > fs/ceph/ioctl.c | 9 +++++++-- > > fs/ceph/mds_client.c | 27 +++++++++++++++++++++---- > > fs/ceph/mds_client.h | 1 + > > fs/ceph/quota.c | 2 +- > > fs/ceph/super.c | 6 +++--- > > fs/ceph/super.h | 14 ++++++++----- > > fs/ceph/xattr.c | 18 +++++++++-------- > > fs/mnt_idmapping.c | 2 ++ > > include/linux/mnt_idmapping.h | 3 +++ > > 16 files changed, 111 insertions(+), 50 deletions(-) > > >