From patchwork Mon Jan 8 12:08:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandr Mikhalitsyn X-Patchwork-Id: 185932 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:37c1:b0:101:2151:f287 with SMTP id y1csp974642dyq; Mon, 8 Jan 2024 04:10:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHeL7UYMHea8x19LUyL3Bhu1CP0AI0J697aWHmQrJrPMycTKtboDmJucDopFwlP+Py4BhGz X-Received: by 2002:a05:6a20:840d:b0:199:5201:241b with SMTP id c13-20020a056a20840d00b001995201241bmr1046238pzd.41.1704715836033; Mon, 08 Jan 2024 04:10:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704715836; cv=none; d=google.com; s=arc-20160816; b=Z41W5eiHftcCdJKdJAhjtSg1sLyloJ4ggI6Qe69prksjA1OKUnSSiomkycRXDLqI/7 OM3SJaEE5VIH9r2rOq88i/S/488ITtc/9kmJlIRVm/Z5UaQgdvQGW+ofi51lSVu/XV/f z91iL/wpoVVWTKRTiGGhbE3L0kthiDlQ0KB4EpMM9fIe4ij2RkyRLFlv5WYyZ6oI/OS4 HD7c16WLJsnmPquT/m7BBnINCfMXaKRZqS0thELqkIsZVc0zzEBfaKCHomIG62yIBjfd X3NzGWL51NtBTQPUdsFtlsln6OPna6E4wGgQwMGCdIsS+zc3k+nmM+QNsYfVV1D/idi4 cZLg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19472-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z129-20020a626587000000b006d9a170f053si5954542pfb.201.2024.01.08.04.10.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Jan 2024 04:10:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-19472-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-19472-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id CD5F82836D4 for ; Mon, 8 Jan 2024 12:10:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC5E3405D6; Mon, 8 Jan 2024 12:10:06 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787524112697867642 X-GMAIL-MSGID: 1787524112697867642 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 *);