Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp944687rwd; Wed, 7 Jun 2023 08:54:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5W/ER+0OHdTF7mPmF+z8RL5fuMxoGw4qJ8Lx/uIPM5Dm2E9RU1alu+1vJynRYDneqtQjVR X-Received: by 2002:a05:6a00:acd:b0:65b:6097:7961 with SMTP id c13-20020a056a000acd00b0065b60977961mr2589278pfl.17.1686153288412; Wed, 07 Jun 2023 08:54:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686153288; cv=none; d=google.com; s=arc-20160816; b=vMBtBGCXGP7ihtSXYRmdoIXz4KSzahCikAowP8xqnx5/HQxUN1iR2EaxYSnuPWS6SD YXBc3SQrgYHJ/rggGAj+kFq9VNLj+ubm6kklZGELjpZZHaOuJzn/7xiVeke/jYjKKfAi 4QdhnODVhmFtkdIUNsK4dWKgbFwDWxWUfzXZgYXWJCO2rFFlwISzJrBMviCXa8rDhYOg J5Ai0UnGg9VolgN0TxfFhEOKjkieWqV1LTM8iQbuQHxPskZ/DxNLr24mLekto53CdadX HiIXb85k11rYYmEqdlrWlMsVjB2mVh3yxpXJ6y1ILsNBPjW/0st0VR9wtjAQEF3u10zc B/lg== 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=fRWJ/KMFF26C36Dkjhg/LzbtMqzlyKNGjI+Q2GqWstI=; b=CqRNg752YykJKfbrE/iE0Y/Z6pqgklkqWZo8gr1ey26vn/PbCYHX7d9pFXgpX6SAFm bQTYIGh7ppfLH3ziX7vIFGA0/4lUMN/HvyKUSP9OY7knCwopWzBJQFuLe6OGPnuubtU1 iwZjXOtKrRbGqJmivyzhulbeloDkZwNeJ4q3whcWuXba1K0qs4J/wpIm5TKTeZ0Kotmf 7/wq9a49j293kfjeF3Z+ogtjCK6+zBz4G5sEkVgOlEfFw+pBQJcESW4mw3GBBRzVtkWJ Lpbsk4xk5+y6jJusfywQyfaVqLqN57pAoyp4uqRxfSJU5B0CY6ztJNXrATwSs+FeDkxS VkRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=V1Ff3BPE; 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 y16-20020a63b510000000b00520d737cf49si9136750pge.271.2023.06.07.08.54.34; Wed, 07 Jun 2023 08:54:48 -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=V1Ff3BPE; 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 S241314AbjFGPV0 (ORCPT + 99 others); Wed, 7 Jun 2023 11:21:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241315AbjFGPVV (ORCPT ); Wed, 7 Jun 2023 11:21: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 A711C1FCE for ; Wed, 7 Jun 2023 08:21:18 -0700 (PDT) Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.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 899A23F16E for ; Wed, 7 Jun 2023 15:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1686151277; bh=fRWJ/KMFF26C36Dkjhg/LzbtMqzlyKNGjI+Q2GqWstI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V1Ff3BPEV8KTqjZ3lC12iPMVUr4IGgFNa6yBvib0AM4JrEfyxLvHN75YKU1hS3Kdy lMcZgnxfw78+7vd/C2J7DPd3N4QOoZJ9wcpxOl10/KBTJGEGHOtRPHGsuu24K6yv4M 7a+tfmQkY+kjq6sP+EI0mtF9tXJppeOgWyAX9TFAszNn+FlHrx+aUnUsjVY1lT8/en M4Azyfq/TiwD5v5YT8TH8NTmDcwuqKbNhn9XESYDhSMmUX3JcNDdiKPIu1KkWii3IO 7rjnt5s7is+ZbiuoX4zsYpuwgoQoPgaaY6hWjnKwwhC5EIbSrnJUuJpoLu7PlxY5SQ QPIO9hWFH5n3g== Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-514b2ee9af2so885684a12.3 for ; Wed, 07 Jun 2023 08:21:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686151276; x=1688743276; 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=fRWJ/KMFF26C36Dkjhg/LzbtMqzlyKNGjI+Q2GqWstI=; b=PEeyqsWBJlaZbxAPYoGOynw+OYW/BkqMvcJqgdSy7qZXQ99Q75RTynGFzCb3bXDHze r8AnqBCDUtKy1t98EpaM42dDZRxqURnCCm1a+y0G/t4LC4PsGloiJ1Uf9QvUYKPxRKOX Q6wmMW/QMNbi/L8Q9cigzJe+LL+UJrwLJ+wDwB+HValGVxBHbpBOmRKHWBFKQrz8dSne bgOV9lNA7luPkbVLEE0qtalaATskxGxuOj90vXEBOED+aDlkl/z5sSKXMYvW6Bpu6b2v P80Xa02rqxXt6y6YWFh9JTW0b5kMd+eXlw8oYub0xPbxBLGWNTCZKbqUnrDRjtGdCzLC Cy4g== X-Gm-Message-State: AC+VfDwAUQZj8aJpbFAMEQfChwDJ4zVp7+4bH0PLTLJWheOL0tBtczHX NoMKmmzYbo+tcgpsCjO3IglGPvleXPm0xzPbct1Q94CX+gSwkHQizB+DSyCEdcOFiPmMCFpNg67 caQAeGVnitIwbaWDbmJbEnh5eLSUPvdo+szOpVcDS2A== X-Received: by 2002:a50:fb08:0:b0:50d:fba2:7265 with SMTP id d8-20020a50fb08000000b0050dfba27265mr4999121edq.16.1686151276215; Wed, 07 Jun 2023 08:21:16 -0700 (PDT) X-Received: by 2002:a50:fb08:0:b0:50d:fba2:7265 with SMTP id d8-20020a50fb08000000b0050dfba27265mr4999105edq.16.1686151275926; Wed, 07 Jun 2023 08:21:15 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 08:21:15 -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 02/14] ceph: stash idmapping in mdsc request Date: Wed, 7 Jun 2023 17:20:26 +0200 Message-Id: <20230607152038.469739-3-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 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 --- fs/ceph/mds_client.c | 7 +++++++ fs/ceph/mds_client.h | 1 + 2 files changed, 8 insertions(+) diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 4c0f22acf53d..810c3db2e369 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 "mds_client.h" @@ -962,6 +963,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 != &nop_mnt_idmap) + mnt_idmap_put(req->r_mnt_idmap); if (req->r_pagelist) ceph_pagelist_release(req->r_pagelist); put_request_session(req); @@ -1018,6 +1021,10 @@ 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; + else + mnt_idmap_get(req->r_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 724307ff89cd..32001ade1ea7 100644 --- a/fs/ceph/mds_client.h +++ b/fs/ceph/mds_client.h @@ -280,6 +280,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 */ -- 2.34.1