Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp875935rwd; Thu, 8 Jun 2023 08:54:27 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4HFzNlaWACDd2ZUgvqD3wHmo1fxc92Mp57SSB0LL/e59ysNYCAAbPwsnnESP1pD6vKBTzd X-Received: by 2002:a05:6a00:189f:b0:64f:7a9c:cb15 with SMTP id x31-20020a056a00189f00b0064f7a9ccb15mr7427858pfh.11.1686239667146; Thu, 08 Jun 2023 08:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686239667; cv=none; d=google.com; s=arc-20160816; b=0svQnAoI98LMZv4/58ZVAEHSi3kcc5RN7KL1bQ3ogGnIgs0KCnwIWidZWF5J8TTB4O A33pGbBRBH+pi4YPfi94eeWSEWd4ozfnU0abPUcqubMoTg3Fn/qKOR3I/9F17QQO6UF6 5IrsaEXv9t0VGycmO/d4BoXBqGA0Ws768P0SVtETteiwpam9ApcgBkEARceX3efuK1G1 cwJrcu//gG4K38b+IrbXNZiSi/ESPEVhelJ3CjR/pCxm9W5aYpPLtQTNDd7omehE1nPN GtaKKK7PXY8vJ6CKVMHEyaLfJdoySc2xV/o0XgYLHKtoejx2u3j9UJYl43QunhL2o3yb K3BA== 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=Q8ymt4aVYk7+c3UhjbPSUCbNsUrFX+gS8T8907goBG0=; b=qXZ+BC4vIlk6wATBjFpHIBHi6Ev07V+CukEW5HmQxv7PoQMJ1M8t+pBJE9QxestVGs NMbo0OXROLSJDyA8ofRwxlOP7wjYIoIaM6+5J2PxhOfAn58tyxlmL6BbX5Gv8XL2xVC2 wLAhkgJaVzY5DP3gaPzPn7FMZ7ZFHH/ltY0WTf0exPC3153qcMTHX04Zcvp6b5looke6 DUfqxt+/GNscZd5+vo75fwawuePhb77lzX9d4S182fcbRRL4+ubPMhgSCcIrFT8iwvPa /Ib7oL+oNjJBDR7QcBIMDR367GmTtrrJorI6vIfG/8mw6I6NNBmAaRYjYw7/9ds6fE7F HKzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=BGqEI8qC; 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 y19-20020a63b513000000b00543b1713e9esi1095311pge.722.2023.06.08.08.54.12; Thu, 08 Jun 2023 08:54: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=BGqEI8qC; 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 S237296AbjFHPpB (ORCPT + 99 others); Thu, 8 Jun 2023 11:45:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237221AbjFHPof (ORCPT ); Thu, 8 Jun 2023 11:44:35 -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 D9D4D35AB for ; Thu, 8 Jun 2023 08:44:02 -0700 (PDT) Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 55B363F36E for ; Thu, 8 Jun 2023 15:43:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686239027; bh=Q8ymt4aVYk7+c3UhjbPSUCbNsUrFX+gS8T8907goBG0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BGqEI8qCHxOYtapB0SRpXTz3tiuulDWtRLvtxc5YNoZQLqUCE2dV3meQV1Mgol7j/ QYbNWw8Ja2pa+Wgv1PSW3sg8oIRKFyeauYeNNxRKVNRlBkcpkSpQuuIyJRXQMgGAqI o6MNP+5A7M2GHkfY7Z5wO06pGpSlUaLaVLRfozNNLz/1lEFwFpXTbJ4rEHpG0bu3ZJ H8K6Kd19QF7gavUk5prBU4YGxfBV/NiwZfZWlKQu6JIxP0mpYN7ftSTUipw40IOD2W AE5GbFRSNwIsqTWePhJxTe1CwOgXUZ97bUNtIZjGUuP+8zg0ed6rkV1LFM8D+NOG84 wV7Av5Bkb1Dcg== Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-50daa85e940so813901a12.0 for ; Thu, 08 Jun 2023 08:43:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686239027; x=1688831027; 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=Q8ymt4aVYk7+c3UhjbPSUCbNsUrFX+gS8T8907goBG0=; b=ABtgICxA6hwEdmE6mBvoAwXpjgnD2eKsMkJJWPS9gmYI8rT7TIdO0lkhZOicl0YKPn wRHRlr/JYNcboLfjXmVikli6SS5cVViMzVevUh51/MBLiFxVYkuT/jJoB75kFubHs0td +2URhP+r46Hy3ICtIijPDRX+zVPq3hXkDqjolwypRsu0Tg2n724rH1ZKkyb9uCttYV8V e8geMrHkuCFy5EQEEKOEf9nABC4qF9yrStgPencyiYRHJ4qbW/h9g0tH4fR/NNCutLaO 1djXdSdQEvxPQaPaKfk5tq8u75ZgK3sOg82kYBC/eRCF/DmpzbhK5jGTGmBpl5F0lJr+ 12pw== X-Gm-Message-State: AC+VfDxInYuvZlmxPMGzmMHMY70oSY49oK08VS5aJZNi1iB7XK6SBMMu qJGRdhPqnP0D6SjdwO/mTxIduX80DgZjFlqzL0uq+K5YD5/+IXUdjHw6hc0e6Uz9uDx1nF0FmBU 6wTP5GQ5IpDrMaHgf27MwHbpgmmxprk53NO1OOv3mIQ== X-Received: by 2002:aa7:c7d4:0:b0:510:f462:fc47 with SMTP id o20-20020aa7c7d4000000b00510f462fc47mr7221334eds.7.1686239027037; Thu, 08 Jun 2023 08:43:47 -0700 (PDT) X-Received: by 2002:aa7:c7d4:0:b0:510:f462:fc47 with SMTP id o20-20020aa7c7d4000000b00510f462fc47mr7221325eds.7.1686239026831; Thu, 08 Jun 2023 08:43: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 y8-20020aa7c248000000b005164ae1c482sm678387edo.11.2023.06.08.08.43.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jun 2023 08:43:46 -0700 (PDT) From: Alexander Mikhalitsyn To: xiubli@redhat.com Cc: brauner@kernel.org, stgraber@ubuntu.com, linux-fsdevel@vger.kernel.org, Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, Christian Brauner , Alexander Mikhalitsyn , linux-kernel@vger.kernel.org Subject: [PATCH v5 10/14] ceph/file: allow idmapped atomic_open inode op Date: Thu, 8 Jun 2023 17:42:51 +0200 Message-Id: <20230608154256.562906-11-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230608154256.562906-1-aleksandr.mikhalitsyn@canonical.com> References: <20230608154256.562906-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 autolearn=ham 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 --- 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 f4d8bf7dec88..d46b6b8b5fcb 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 = mnt_idmap_get(idmap); ihold(dir); if (flags & O_CREAT) { -- 2.34.1