Received: by 2002:a05:7412:98c1:b0:fa:551:50a7 with SMTP id kc1csp1582419rdb; Mon, 8 Jan 2024 04:10:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IEd7+MzKR+/LBuR2QaR0s7yWO6IN8WbJcjAZppajEkQUTJwvrpVHD8YFFyaQDrZ2vLAWCMB X-Received: by 2002:a17:907:7e9f:b0:a2a:ec73:2fe1 with SMTP id qb31-20020a1709077e9f00b00a2aec732fe1mr187645ejc.244.1704715828742; Mon, 08 Jan 2024 04:10:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704715828; cv=none; d=google.com; s=arc-20160816; b=CoLahFN6oqd434WAdGnb43KoDnpaMWkCEKtliYwUbROyqoGm9YrImPbL8dcchw1e3e 2jcIVKd29oxoOe5/i5abV7oyD0a8vzIYnhj+Xq0WVMaiNAtM5zzja5AOHYcyFH+L4Phm FW51CxqLzQMG+Np7GypHP0DvWlTq6T7ex5pJ72tlkxxg07E9YviX88eYtHFhQZMtFEWy PEizdOQQUeIn+ClxthG4M9K/5lCU3odTxTYmjUwSY/aRHjGOwLZQGomtXH0+Ssfzq/LM suP9zzAXkFPqGJVwLDgXIgCBy8sff2EOUA5oSTbKBiEVGyuKgJSpCruTB+nNxJvJWA31 /l5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=GtdhYLDKs9o20JRSF0JGIkdiKLo4c8K8/G8DvoYAW44=; fh=8E5U/GA6pNBgXza3P+qieAQAribgE3wivZRN7rxqpbw=; b=q62OwNXuNMzLMDoI9vcUWQRGxiq3x1KPdDORe34MRK3TtxxWeSxdek5W/Rcarqgjfe W2ARhzU5CJgm8p/RTNOwK+cvOloB5iBcJLMLnLCpCeb9BRBRsjx2c8RVnHasmaYde44r K5UGM1mc0uoFWcBm70XWV5GfPGvCXCK72XEse5GG0TEnQuMYqGAl1bNVTuwWDzQqJ8Sy sNfpE239B73W/uxbffVj/j4kN2cjPe4IYhe1eKG80AMq38C3NhMLCIEjxjQETbBiBCeV bo5gEwJMDcOmxESqV0URKirAgBUzjSf44KL4OXu7AnDVV8TxHEEt/lZJR6nAQ4On1cQB 1ToA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=jy6tpFZh; spf=pass (google.com: domain of linux-kernel+bounces-19472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id kh6-20020a170906f80600b00a2a4126c3f1si1404702ejb.1029.2024.01.08.04.10.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=jy6tpFZh; spf=pass (google.com: domain of linux-kernel+bounces-19472-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19472-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 7D4CA1F22166 for ; Mon, 8 Jan 2024 12:10:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4D243FE4F; Mon, 8 Jan 2024 12:10:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="jy6tpFZh" X-Original-To: linux-kernel@vger.kernel.org Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88D243FE44 for ; Mon, 8 Jan 2024 12:10:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com 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-1.canonical.com (Postfix) with ESMTPS id A2AF63F745 for ; Mon, 8 Jan 2024 12:09:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1704715799; bh=GtdhYLDKs9o20JRSF0JGIkdiKLo4c8K8/G8DvoYAW44=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jy6tpFZhfYdMKPc2T1yw/AlsYk6up/wkEUIJGDNovxV5t6t5jdqH99sS/u2QstfSR XRWa6kEVslGqkz6HSenY6qhAQwB9IcvOsozqhqZBYKjdYqO1I5is1AT20cLWGcc0FR 94v1aUoxtjwlszZabirRWKWCYdZX0bhFYi6WlLjpDQm2WBR/bFAUFfSWbtfClfn//O HYp+zsuN3z6K9SWM59S7F6zwSeryFxcrUhRz9R4xH9DnBWmhChaqvMIQhjTWBVWyTj EERJcFeZ0B5GBr3iY+ZhC5k4HLCm7Q6D8+ZlQf2QDVC/oM6ycmcp6tQub6dRFPTXk0 G114XajQD8jqA== Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-50e8b929997so868988e87.0 for ; Mon, 08 Jan 2024 04:09:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704715798; x=1705320598; 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=GtdhYLDKs9o20JRSF0JGIkdiKLo4c8K8/G8DvoYAW44=; b=ILsgLUPhFIunGJFN1tUDP5YLvuK26ZKkju6Q29Ru1rKb6MSy3OqpDzSOdrub8luKtk nPFO81v94RrKkXj3/ITXTT0/4yuc6yFuJ/ylsknuvZcRfG6lts45McYJCZFBqTJ25ejf zVCcETq+Pi98aIwnj+mmakdp2ACfJeFS6sL1RGbg28Ugh5cX9V/eXW+387kvA1d+z/Sg VqaQIgJH8kry8+LlHqXZD8CjHu3qRZ34pqJ1DbRHH62ykDBlwR1IVnLqNBbPV2vSH8zI fZxzXMyzDxcBmtl3RDrfz2M6nPpEkV0BvI1ictL1DAeROGNzvlxC5Qeht9kaVNW6P3FD CTHg== X-Gm-Message-State: AOJu0YwDWlqwAY6EuHRvwwXhTVTGc6eyn/Rq3sGzR3vRu6+/0tSpkBeu 6fTBU31ue4axSyfh5X260T5JAxh0ex2tR9XMjuPyLJdCWmXF4Qljo/rz4Hr1tLGX6WShQzRg0Pq +4I+Jv7qpKcymGKrzlft3YBdEaLmfy2wwdfbDEAUJoFXOwA8k X-Received: by 2002:a05:6512:10d6:b0:50e:75ee:ec46 with SMTP id k22-20020a05651210d600b0050e75eeec46mr795193lfg.2.1704715798664; Mon, 08 Jan 2024 04:09:58 -0800 (PST) X-Received: by 2002:a05:6512:10d6:b0:50e:75ee:ec46 with SMTP id k22-20020a05651210d600b0050e75eeec46mr795186lfg.2.1704715798368; Mon, 08 Jan 2024 04:09:58 -0800 (PST) Received: from localhost.localdomain ([91.64.72.41]) by smtp.gmail.com with ESMTPSA id fi21-20020a056402551500b005578b816f20sm1767959edb.29.2024.01.08.04.09.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:09:57 -0800 (PST) From: Alexander Mikhalitsyn To: mszeredi@redhat.com Cc: brauner@kernel.org, stgraber@stgraber.org, linux-fsdevel@vger.kernel.org, Seth Forshee , Miklos Szeredi , Amir Goldstein , Bernd Schubert , Alexander Mikhalitsyn , Alexander Viro , linux-kernel@vger.kernel.org Subject: [PATCH v1 1/9] fs/namespace: introduce fs_type->allow_idmap hook Date: Mon, 8 Jan 2024 13:08:16 +0100 Message-Id: <20240108120824.122178-2-aleksandr.mikhalitsyn@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> References: <20240108120824.122178-1-aleksandr.mikhalitsyn@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Right now we determine if filesystem support vfs idmappings or not basing on the FS_ALLOW_IDMAP flag presence. This "static" way works perfecly well for local filesystems like ext4, xfs, btrfs, etc. But for network-like filesystems like fuse, cephfs this approach is not ideal, because sometimes proper support of vfs idmaps requires some extensions for the on-wire protocol, which implies that changes have to be made not only in the Linux kernel code but also in the 3rd party components like libfuse, cephfs MDS server and so on. We have seen that issue during our work on cephfs idmapped mounts [1] with Christian, but right now I'm working on the idmapped mounts support for fuse and I think that it is a right time for this extension. [1] 5ccd8530dd7 ("ceph: handle idmapped mounts in create_request_message()") Cc: Christian Brauner Cc: Seth Forshee Cc: Miklos Szeredi Cc: Amir Goldstein Cc: Bernd Schubert Cc: Signed-off-by: Alexander Mikhalitsyn --- fs/namespace.c | 3 ++- include/linux/fs.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/namespace.c b/fs/namespace.c index fbf0e596fcd3..02eb47b3d728 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4300,7 +4300,8 @@ static int can_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt) return -EPERM; /* The underlying filesystem doesn't support idmapped mounts yet. */ - if (!(m->mnt_sb->s_type->fs_flags & FS_ALLOW_IDMAP)) + if (!(m->mnt_sb->s_type->fs_flags & FS_ALLOW_IDMAP) || + (m->mnt_sb->s_type->allow_idmap && !m->mnt_sb->s_type->allow_idmap(m->mnt_sb))) return -EINVAL; /* We're not controlling the superblock. */ diff --git a/include/linux/fs.h b/include/linux/fs.h index 98b7a7a8c42e..f2e373b5420a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2377,6 +2377,7 @@ struct file_system_type { #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ int (*init_fs_context)(struct fs_context *); const struct fs_parameter_spec *parameters; + bool (*allow_idmap)(struct super_block *); struct dentry *(*mount) (struct file_system_type *, int, const char *, void *); void (*kill_sb) (struct super_block *); -- 2.34.1