Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp924097rwd; Wed, 7 Jun 2023 08:36:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7H2sux97/Qmbmtnvb1p/e+6O0tDRCBe8suEEZPGoK927jUOLpU+UsgR8JHRabAKeE9cMlH X-Received: by 2002:a54:4712:0:b0:395:f4fd:9fe9 with SMTP id k18-20020a544712000000b00395f4fd9fe9mr5724304oik.50.1686152210788; Wed, 07 Jun 2023 08:36:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686152210; cv=none; d=google.com; s=arc-20160816; b=ZPcyaj+WF85l1TujxiiuIKVWxqrCa4B/MUY0FIhWZCeElBaJOsC9JAxcLPk0nqzNS0 2BHr0HWx9T1qCbwWTvwrK0YvMGLtpMVbm2VZM53eps49oWNRMCKAc79A0ThGF+Ujxov6 d6yTTxpFazIoZ4y2BYKyaZLCpkxvgRsb2fPCcNRrflfvuWnA1uFNAiPCXIkjdICzz/5x 8GOXQbKAD3RAoOE74FAUSmfzTch0S/w4PQ1UWwQrNp0JE/a90TP+RxUFYsQUaeFJsv/M tTIjIooqnbLNiOctEm0ZqIVA4/4cpJYdZCpAeQ6B9BtoHFLqKJrvrowpv3BXCicrdCIS ehcg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8yrq/kS6S1HbL22xkrZbDKXNe0OGSicmb8/p7/WTma4=; b=HBbfLVUCK6CCUkJ70B71OYXKKYkgIgg31RZCHPOUr5HWTcQDVUKA7YN/JC2bTpV7e2 UGqJQAhmth4HBMGqtu7ij/Izci/Rppf98Ns+qQRZ//ezlHp5NGH5aMQEFxvtY4/bDS7U rjyrIlIxHdQVdelwNva0dS937xIUILqzfP9Jlp8iJLQbZzfXUQjCxY32ywIIzZYiwhdK zQiQ5j1DYKRT/ppLhP+ccaj2G0MtZDjDUu5Q51DVBaK8qACKAfLQaFAUNRpi+8BVL4Fd 9MnILrG0mS5vlZbdTzNtKB13M/dgqC3pMiVjuwLWdmFBlCcnb12E5ib19nb14e7e6Siq Y0kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=Tr82GG59; 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 z22-20020a17090a541600b00259a5a5b211si1301324pjh.3.2023.06.07.08.36.35; Wed, 07 Jun 2023 08:36:50 -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=Tr82GG59; 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 S241140AbjFGPXJ (ORCPT + 99 others); Wed, 7 Jun 2023 11:23:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241397AbjFGPW0 (ORCPT ); Wed, 7 Jun 2023 11:22:26 -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 BD955271D for ; Wed, 7 Jun 2023 08:21:52 -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-0.canonical.com (Postfix) with ESMTPS id DD6183F12E for ; Wed, 7 Jun 2023 15:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686151309; bh=8yrq/kS6S1HbL22xkrZbDKXNe0OGSicmb8/p7/WTma4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Tr82GG5907vuuuZ+W26PJMKEM5TISV5bFvafEacdXcQemivJKlCUYkVA2lb8R4wnM sWu87Jx1GU8CRf5ng7U9ZrjcnD8DWhWpz/QqEbVUHjrZa12VCn1/5s12ys5pQvphb3 iKNl9eFV39S6XpNOmaOesJNxcm/DyPwbnfDhrut1neHi+NNUpCMg/X/kUbZAzurfIJ HBoIylF1KVmTlqSJYNorPST5+8B5LbNznMckE1y9kQj/HS7/9uinnxzCZmPXEur6s+ wgAxYa9fwQwv85OkyJQjhrOk9TVEEseYzkUb1lerBD0wflg0I/Ypks5JJetw6f167s DOeKZQXPoEuUQ== Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-514b2ee9af2so886110a12.3 for ; Wed, 07 Jun 2023 08:21:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686151305; x=1688743305; 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=8yrq/kS6S1HbL22xkrZbDKXNe0OGSicmb8/p7/WTma4=; b=ikipvoPkSVu1yC1OSmrW+xmzirGNoynycLoZWAjx9OKS+zp1+VU06dG1qVm1/N0D2V ffCfMXVmcdKY9dL+WbT2ntZ0HU9acoPQ2ORE6VnOu4vARTBLol3I2cntmjthCXQzFLCW BCoU8wXZLdsYF5ClFPtT9f3irYmfeEkysoNav4rcrHvRpD5qurI+LRHd6NRPt08BcYcx 1qbKbyLTJBO8CAuMquGpIX7rI4fwKoe98ZEFV3L0K0HYOGjMiB9V3fpyMQ+uNj/7y6NI mG0Zql60ywHxwZaGe0Jl7VQ46o2bKkUJ28XdosBC+P5RFFSMVaDJ5R5wU37/lTWEW2gY WJeg== X-Gm-Message-State: AC+VfDyADgw97IP08Eem0sMF+jm76J88aZ2Rl0wm7wqQsKRxfLalxd6J 3T0zc6dUL+QGvZPWStXXJ2t/z2s8e6d+WONg+Rrq1iqvKrlrFWs6vd8tRnY+oact3YWrPH5ekt6 Vq6/Hd5mIWMdY2TJW6mQaojZDtgBKJljLtNx5vonwnw== X-Received: by 2002:a17:907:96a5:b0:973:d7cd:44ac with SMTP id hd37-20020a17090796a500b00973d7cd44acmr8178825ejc.54.1686151305694; Wed, 07 Jun 2023 08:21:45 -0700 (PDT) X-Received: by 2002:a17:907:96a5:b0:973:d7cd:44ac with SMTP id hd37-20020a17090796a500b00973d7cd44acmr8178808ejc.54.1686151305491; Wed, 07 Jun 2023 08:21:45 -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 w17-20020a056402129100b005147503a238sm6263441edv.17.2023.06.07.08.21.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 08:21:45 -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 v3 13/14] ceph/file: allow idmapped atomic_open inode op Date: Wed, 7 Jun 2023 17:20:37 +0200 Message-Id: <20230607152038.469739-14-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230607152038.469739-1-aleksandr.mikhalitsyn@canonical.com> References: <20230607152038.469739-1-aleksandr.mikhalitsyn@canonical.com> 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: X-Mailing-List: linux-kernel@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 --- fs/ceph/file.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index f4d8bf7dec88..f00bfda4b1d2 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -654,7 +654,9 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, in.truncate_seq = 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)); @@ -662,7 +664,9 @@ static int ceph_finish_async_create(struct inode *dir, struct dentry *dentry, 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 dentry *dn; @@ -786,6 +791,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 = idmap; ihold(dir); if (flags & O_CREAT) { -- 2.34.1