Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4750128pxv; Tue, 27 Jul 2021 15:43:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpjp9FuDLEnb01vLTr2j7t6NoWoQQl1w0nAsCAatSaDRXw6YF98faB054aU+LRrwsMUTeF X-Received: by 2002:a6b:2bd4:: with SMTP id r203mr16383820ior.157.1627425789623; Tue, 27 Jul 2021 15:43:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627425789; cv=none; d=google.com; s=arc-20160816; b=lqfyI+dF3vODFLz8Ycz5KiPqsLLLckzo3gEB5oLDYR+7hsX8UyMq2JwjSF2DtB8kp1 CEKRbot2L4W9pX1/l5WeTUg7neAzgnGzK8LCrym7vEtGO5W2ByzpFC0Xox4439GjGxu8 pAFrMQQdfuZIAe6xOLhDsGwrWS0ctJq/sgj30B+dORLQu3fLl0Tq4uTCfKNeOg8wkEtn XVA46NG4NGHwjolahRu7IdyDvnUTfeXKTueCiQmX3uL+Kpn2+tDFZlgOcEMzXv/EOxSV zL9yqO3M99hneZ9eEwKe+cQWsQHMOI44BV0d7cEq5ZAtBekiTO3GTfNQemQoHUN1C2Tu h1ZQ== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature:dkim-signature; bh=EUPFwhQ4l0lXEkkNGESyS5BwcbfXYjC/1aLE4BjDLe4=; b=kMvzmcJ12RBw90m+BK2WsBPTK0Mk114IzoGGJClQhtyBtVrUHUgXIjDkLofffsj0I2 7I+ispoMkvMP6PFAdOolu0GjAsEwkgY3Dhvi+08Vp+bDQDZ3Z193OZ9QJm/DfsRxisam uzW9ixwrUP16b9aMAHXbgz6sLUtdQNUnBlYMqOLI6Ij6uKR4rpvGVx4sjwao4MH0joha JgE0fpZzJSBG04Dpyikvjn0Jye7j0YYq4jCoLqY/Xb2tpsLYWeYJHOLQDc48jsUBBdjg O8qWgqqrujSTCrShf+ks6YHby6QQ7vcM9WXArZyxWGImNkHlViGl/KWZcBPxj6hepBXl 5YiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kl0n9co+; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y1si4652549jao.99.2021.07.27.15.42.52; Tue, 27 Jul 2021 15:43:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kl0n9co+; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232599AbhG0Wmm (ORCPT + 99 others); Tue, 27 Jul 2021 18:42:42 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:53886 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232272AbhG0Wml (ORCPT ); Tue, 27 Jul 2021 18:42:41 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 52AAE1FF40; Tue, 27 Jul 2021 22:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1627425759; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EUPFwhQ4l0lXEkkNGESyS5BwcbfXYjC/1aLE4BjDLe4=; b=kl0n9co+iBonCLM/u0/Pfx7Yl/a9T5BQ2njBwHoMgpDE2exuUyRN9nXAVFDso8k9raZXnK W5p4kNWedyIjumCLQz2XoJDrZ4ND9xY0umMBOM+jyVNLC3PisvN+5IJdNEIomWvujh+e8Z ec3jcVWxdiN0n0sbdvgY+cBnfAdQVdc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1627425759; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EUPFwhQ4l0lXEkkNGESyS5BwcbfXYjC/1aLE4BjDLe4=; b=Of5rBFkryDtdNvTQ72fjf5pezhSy9A+sJiILBS/I15WgplE0J09V5KoRLDFBml1vPYxPTo Ffz7uhXr6cfR5eCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6E09313A5D; Tue, 27 Jul 2021 22:42:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HhFlC9yLAGGPVQAAMHmgww (envelope-from ); Tue, 27 Jul 2021 22:42:36 +0000 Subject: [PATCH 01/11] VFS: show correct dev num in mountinfo From: NeilBrown To: Christoph Hellwig , Josef Bacik , "J. Bruce Fields" , Chuck Lever , Chris Mason , David Sterba , Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-btrfs@vger.kernel.org Date: Wed, 28 Jul 2021 08:37:45 +1000 Message-ID: <162742546548.32498.10889023150565429936.stgit@noble.brown> In-Reply-To: <162742539595.32498.13687924366155737575.stgit@noble.brown> References: <162742539595.32498.13687924366155737575.stgit@noble.brown> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org /proc/$PID/mountinfo contains a field for the device number of the filesystem at each mount. This is taken from the superblock ->s_dev field, which is correct for every filesystem except btrfs. A btrfs filesystem can contain multiple subvols which each have a different device number. If (a directory within) one of these subvols is mounted, the device number reported in mountinfo will be different from the device number reported by stat(). This confuses some libraries and tools such as, historically, findmnt. Current findmnt seems to cope with the strangeness. So instead of using ->s_dev, call vfs_getattr_nosec() and use the ->dev provided. As there is no STATX flag to ask for the device number, we pass a request mask for zero, and also ask the filesystem to avoid syncing with any remote service. Signed-off-by: NeilBrown --- fs/proc_namespace.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs/proc_namespace.c b/fs/proc_namespace.c index 392ef5162655..f342a0231e9e 100644 --- a/fs/proc_namespace.c +++ b/fs/proc_namespace.c @@ -138,10 +138,16 @@ static int show_mountinfo(struct seq_file *m, struct vfsmount *mnt) struct mount *r = real_mount(mnt); struct super_block *sb = mnt->mnt_sb; struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt }; + struct kstat stat; int err; + /* We only want ->dev, and there is no STATX flag for that, + * so ask for nothing and assume we get ->dev + */ + vfs_getattr_nosec(&mnt_path, &stat, 0, AT_STATX_DONT_SYNC); + seq_printf(m, "%i %i %u:%u ", r->mnt_id, r->mnt_parent->mnt_id, - MAJOR(sb->s_dev), MINOR(sb->s_dev)); + MAJOR(stat.dev), MINOR(stat.dev)); if (sb->s_op->show_path) { err = sb->s_op->show_path(m, mnt->mnt_root); if (err)