Message ID | 20230726141026.307690-1-aleksandr.mikhalitsyn@canonical.com |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a985:0:b0:3e4:2afc:c1 with SMTP id t5csp435250vqo; Wed, 26 Jul 2023 07:17:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGdwT9jZobUIV0U/fEWxPFKHuZfiaI15NMRP9mIjHEhV9dH+MYJcKjulf4UOuiR313ybO9+ X-Received: by 2002:a17:90a:a08a:b0:267:f7eb:f12e with SMTP id r10-20020a17090aa08a00b00267f7ebf12emr1794650pjp.39.1690381028369; Wed, 26 Jul 2023 07:17:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690381028; cv=none; d=google.com; s=arc-20160816; b=fW+ORciA//GeWTvH9jXWC8sJuaeB8HHwE2e9QHf6aTmeBILPZYvgPcrPcD5fifVRCo HZ0g+7o+ZYoGf1Qz5piOY1nGgWjkKFEYpVBb2RfcxNNm9rNbhz2FEDXw8cA2LuuBJi63 cMH4KZc059CcgysTe1iGUdKgAXJzs7RiFTFtYV00fNHToAkZ0v5M0s5m3wj5GwP+otgq 1eT27vtQP4ulE5PjckYIXmmIztmU6Riu9vOwKhWK/ZT1pnotgrJI+kbt7OkU9YfsyuX6 L1Mr+V6J9DB0S5VppyXJaHU3GbmOd2C7UA1/e9gg9YHxtYXpRPpTiHKWZI6tQ7w3xFWi KcsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SYeeGp92pdelv4rH6q2bM2VgBXIS4lj+xBV/rEvt80A=; fh=ZfQYNu19/ObQxBf+feoOki2c1nB5OBZk5ttVMRj/3/o=; b=RhX5pXCwOBsDjd2FLnK37Uy/ackmXY/Tqm8+FDPPtDHCR9KhPl/NcZ4+slUBYglY5S NE5z2rblkuH+4xMvNP3lx33DEu4a35bXSlZSIue07nsTziohLIAKddEh0LM/YYFKnQfl m+QRKIBU1QbqJeDQo8QvOGszsoUIWD7vduxue51IGycVDpVfG+CNsPqSnptaB8Fvtmm0 N2/5O1xTJrOclKb4w00M3HMZeLh4IBaLk7RSCA6WHK1cRof8B3aPspSrqKLWI9YVdqcD CMQBDMgmM+N4jJtKGpe9bFa/Inl0VCQ9qTPeOfOGqyHXeN5Lnl3hprfWFIaXPeGhoWT6 oRHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=W9B5Hga7; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q97-20020a17090a17ea00b002637aa0a4dbsi1135668pja.103.2023.07.26.07.16.52; Wed, 26 Jul 2023 07:17:08 -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=W9B5Hga7; 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 S234005AbjGZOMO (ORCPT <rfc822;kloczko.tomasz@gmail.com> + 99 others); Wed, 26 Jul 2023 10:12:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233847AbjGZOLq (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 26 Jul 2023 10:11:46 -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 5C55746A2 for <linux-kernel@vger.kernel.org>; Wed, 26 Jul 2023 07:10:59 -0700 (PDT) Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.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 8C8323F71D for <linux-kernel@vger.kernel.org>; Wed, 26 Jul 2023 14:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1690380635; bh=SYeeGp92pdelv4rH6q2bM2VgBXIS4lj+xBV/rEvt80A=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=W9B5Hga76dmw6Cwp98Kg+XSmvuxD3pflpP3VjD4ylk85k5eAtNTqF/QyWFWDsZuD1 47eh+QpR1Fm15HMqxUVd05FKolGgl+A2elFR+bBRHk49ij4ceh89Qz3Y7ddXb63m7r 9KYmsUFzAbj0pyAP858GwrQUiJTWywtm98VBFI/+gBMnnfO8E82Wpii6pWb0ownMbi 6E5G8D6pfVAO7vYw9zGn/+ysqZHwT8mA36Cqr/atAdyr4eMgEhzFsXqfQ63prgL3fB fz+KhgpyAmUId7ECs6qlSPR1rTnq5K5xvMTeAa2AtJ71qNrmn2hfUn0qe0zWg5W3/6 NxXXmr2FiSjAA== Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-4fb9364b320so6263233e87.3 for <linux-kernel@vger.kernel.org>; Wed, 26 Jul 2023 07:10:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690380635; x=1690985435; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=SYeeGp92pdelv4rH6q2bM2VgBXIS4lj+xBV/rEvt80A=; b=JpXa4bsrwUB299/0Zu3pHyMePbJmWY5yDqFuBvhgwh2FKGlq3xJrdWprFiWDnQFqv8 mcDWahOYCOn+J+k5TRs2hQojp4SkUv/bA3E01QjHNkb3eNr6y+WPux0o2GjA/0U7aRND XSnh/3x6NUM6SJXfCjtxrxjilQyI7oDrE47kaJvqijYDETd0ZoSbKXFXL+gh4D3cTppz UD0SJ6LcXL39JqFMWJZmjLOmQlCAa3dZEd0IL0XIySF5XLXh6Evmy08TJ0BEX1UIjGWY B7nfLmsMAt7vY5824vscGmJNE0CEKGPNikICYe6/2JN04y5S7pfZOM1n7Sj3S3ilHdKw 0aaw== X-Gm-Message-State: ABy/qLaL40SODJ92UBsO+A0lDUKmo5NGEqCJG+nfYS1N03uoN2lh9nKS vptDBONHBv3B2udtt5LZt1dl+brx+UoOMlLSmkhh3ypQmokHF6+CKkhfojG1a3L/+l2vvi/R3k/ WL2ucSqcEgRJG+r/SzDQO9Hmi87b2kL+e8BGv+sXC6w== X-Received: by 2002:a19:4f0a:0:b0:4f4:d071:be48 with SMTP id d10-20020a194f0a000000b004f4d071be48mr1767022lfb.14.1690380634929; Wed, 26 Jul 2023 07:10:34 -0700 (PDT) X-Received: by 2002:a19:4f0a:0:b0:4f4:d071:be48 with SMTP id d10-20020a194f0a000000b004f4d071be48mr1767003lfb.14.1690380634545; Wed, 26 Jul 2023 07:10:34 -0700 (PDT) Received: from amikhalitsyn.local (dslb-088-066-182-192.088.066.pools.vodafone-ip.de. [88.66.182.192]) by smtp.gmail.com with ESMTPSA id k14-20020a7bc30e000000b003fc02219081sm2099714wmj.33.2023.07.26.07.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jul 2023 07:10:34 -0700 (PDT) From: Alexander Mikhalitsyn <aleksandr.mikhalitsyn@canonical.com> To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Ilya Dryomov <idryomov@gmail.com>, Jeff Layton <jlayton@kernel.org>, ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 00/11] ceph: support idmapped mounts Date: Wed, 26 Jul 2023 16:10:15 +0200 Message-Id: <20230726141026.307690-1-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772492977381898504 X-GMAIL-MSGID: 1772492977381898504 |
Series |
ceph: support idmapped mounts
|
|
Message
Aleksandr Mikhalitsyn
July 26, 2023, 2:10 p.m. UTC
Dear friends, This patchset was originally developed by Christian Brauner but I'll continue 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 testing): v7: https://github.com/mihalicyn/linux/commits/fs.idmapped.ceph.v7 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 request") commit. Now we take idmap refcounter just in place where req->r_mnt_idmap is filled. It's more safer approach and prevents possible refcounter underflow on error paths where __register_request wasn't called but ceph_mdsc_release_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) Changelog for version 6: - rebased on top of testing branch - passed an idmapping in a few places (readdir, ceph_netfs_issue_op_inline) Changelog for version 7: - rebased on top of testing branch - this thing now requires a new cephfs protocol extension CEPHFS_FEATURE_HAS_OWNER_UIDGID https://github.com/ceph/ceph/pull/52575 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.mikhalitsyn@canonical.com/ tree: https://github.com/mihalicyn/linux/commits/fs.idmapped.ceph.v2 v3: https://lore.kernel.org/lkml/20230607152038.469739-1-aleksandr.mikhalitsyn@canonical.com/#t v4: https://lore.kernel.org/lkml/20230607180958.645115-1-aleksandr.mikhalitsyn@canonical.com/#t tree: https://github.com/mihalicyn/linux/commits/fs.idmapped.ceph.v4 v5: https://lore.kernel.org/lkml/20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com/#t tree: https://github.com/mihalicyn/linux/commits/fs.idmapped.ceph.v5 v6: https://lore.kernel.org/lkml/20230609093125.252186-1-aleksandr.mikhalitsyn@canonical.com/ tree: https://github.com/mihalicyn/linux/commits/fs.idmapped.ceph.v6 Kind regards, Alex Original description from Christian: ======================================================================== 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 containers. 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=ceph export TEST_DIR=/mnt/test export TEST_DEV=10.103.182.10:6789:/ export TEST_FS_MOUNT_OPTS="-o name=admin,secret=$password and then simply call sudo ./check -g idmapped ======================================================================== Alexander Mikhalitsyn (3): fs: export mnt_idmap_get/mnt_idmap_put ceph: handle idmapped mounts in create_request_message() ceph: pass idmap to __ceph_setattr Christian Brauner (8): ceph: stash idmapping in mdsc request ceph: pass an idmapping to mknod/symlink/mkdir 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 | 6 +++--- fs/ceph/crypto.c | 2 +- fs/ceph/dir.c | 3 +++ fs/ceph/file.c | 10 ++++++++-- fs/ceph/inode.c | 29 +++++++++++++++++------------ fs/ceph/mds_client.c | 25 +++++++++++++++++++++++++ fs/ceph/mds_client.h | 6 +++++- fs/ceph/super.c | 2 +- fs/ceph/super.h | 3 ++- fs/mnt_idmapping.c | 2 ++ include/linux/ceph/ceph_fs.h | 4 +++- include/linux/mnt_idmapping.h | 3 +++ 12 files changed, 73 insertions(+), 22 deletions(-)