Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp1066739lqg; Sat, 2 Mar 2024 14:03:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVOsnut1qeWJ4AeBzzOQED5Pt1CBu8LSBDWFM1MYti27KyALQRkxHwtssZc1ltsCZfz7CzOX/ZS1l7blAobyt8kFN8BHpksmHxfcxgtwg== X-Google-Smtp-Source: AGHT+IF2MPUrb2tZndaXxfBW1a20DQwEhOY6iu7sYrN6G9Q/+AxuVqvbfEaNHBEGF00bf2iWzM2I X-Received: by 2002:a05:6a20:394d:b0:1a1:2f17:b13c with SMTP id r13-20020a056a20394d00b001a12f17b13cmr6854977pzg.3.1709416980016; Sat, 02 Mar 2024 14:03:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709416980; cv=pass; d=google.com; s=arc-20160816; b=hqCaNRhU5ZOjF1nwDiayxTvdRI1VMBKpYexk4IrnSlrVKA1zXjOTv/2rfxcdceUYBF OUPd83jQqumC3WtVdgkTQ9GODN8QBimxJp8+R5CZa16TO8YQHaELHbDOQiRAVoSGM6nn fBlwxFDHxSvFyvW3/LgjtIAeZWOgtRGgOKMNzUYfR38v84F7YOiKRxrcTSvHnpDDdxqa VfW5cCQ47SNypTNsgo2IuFvMhYnZTGiypkSb153a5tWBkG62GeTYeaAEy4GSWwLgF6Rb QNyj6uhD9muAoiFmsmGQ11eqPzaHS71XQUOHbiImYyzMRiZK3y0/VfwZqWc7vsfGud0l quuw== ARC-Message-Signature: i=2; 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:message-id:date:subject:cc:to :from:dkim-signature; bh=aqe1bsXqpWMOsaSaAwaBLUQoehzaMA/zwKYXylUSUEI=; fh=cX4vu2OoWtC8CCCx4GghI1MenxOJb/E4kxdE03PSt3I=; b=FhB0uzHKSBNTQ8yszNpM2z/qVNtSGjIH9P1x5+2LBXN521zyP3qBccA6Zsdu1RHMKE 0R9aimSnrspCTBZLANWOHSIjL1nZYL29XKNwuIoEM2+Vffj+PiWQgX/S18ReDONfOhRT qLTU6Vln+N34eTMIc804OiBwxb/zV6nygokA4uL9xc2k+5JyPVUYy3HslHSSYaz/HvWL nknwtbTiiYpTnuxgPuffJY8hItYlYAUBXbl/LNyUoEkcz7MRweiIuZWFCNTUvY+U3RFz X5ThH3cUyvV/FhWxeKKC4ZK1yACXZQEkoGKmeGtJhixrWONp8UG6QzsvPO919M0GU4dC IO3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=mJf2tL9q; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-89610-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89610-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h6-20020a635306000000b005d9b919b94asi6183402pgb.311.2024.03.02.14.02.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 14:02:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89610-linux.lists.archive=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=@linux.dev header.s=key1 header.b=mJf2tL9q; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-89610-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89610-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 16231281FE8 for ; Sat, 2 Mar 2024 22:02:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2E9CA45954; Sat, 2 Mar 2024 22:02:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="mJf2tL9q" Received: from out-187.mta1.migadu.com (out-187.mta1.migadu.com [95.215.58.187]) (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 EDEDC44C87 for ; Sat, 2 Mar 2024 22:02:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.187 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709416938; cv=none; b=EFfCDbmpV+H6PK3YldAGz2VSwWzM/Vs/rF9n0XO8VoSuFQfSwg3eiNZdidUicssAmbx2Ton1+JetRGfGR/qVleWjeASy+deyTjkdM3YpW+eYo7qxdHkxezHrnXBMiB/PXSt5YW1qOW4eridsrPBCe7z9rowkeKm++v4ZwzwI4zE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709416938; c=relaxed/simple; bh=D3XN16M6Y57uWxVwLnlF9xADST6YeevavrFwllCfXWQ=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=EawjLdOeNW554ZUBhT4zMDGIy6n6IYf5uwKYYO1YLwJvUZ4L6k/QskkilCoKyWAM6J+AgWqlm5P1YP2j6cjwsRNRGqcPMFECPVUgLYKTPWp95xOJzKVbkuKTgyoUNbykXp77hwm052YFp/zt/PYZOWz0s7SCAu5KEINSe1yTUU0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=mJf2tL9q; arc=none smtp.client-ip=95.215.58.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1709416934; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=aqe1bsXqpWMOsaSaAwaBLUQoehzaMA/zwKYXylUSUEI=; b=mJf2tL9qJVNFMI5UHcD3vg9GZUQH6OCyFLF9wtJHzwJPuNkRtKo5Pz4nagtiMAa6kNdzMy hHC7/Teu0KO0RxPW0Yo9pwdNixmvQmt9Xs3KeGDhSZ44q7Da5CZMNbgBHmM3S36Vt5V27V C29Oodz0kJ7tlOMG9Bq3eu8FoWPmQBw= From: Kent Overstreet To: linux-bcachefs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Kent Overstreet , Josef Bacik , Miklos Szeredi , Christian Brauner , David Howells Subject: [PATCH] statx: stx_vol Date: Sat, 2 Mar 2024 17:02:03 -0500 Message-ID: <20240302220203.623614-1-kent.overstreet@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT Add a new statx field for (sub)volume identifiers. This includes bcachefs support; we'll definitely want btrfs support as well. Link: https://lore.kernel.org/linux-fsdevel/2uvhm6gweyl7iyyp2xpfryvcu2g3padagaeqcbiavjyiis6prl@yjm725bizncq/ Signed-off-by: Kent Overstreet Cc: Josef Bacik Cc: Miklos Szeredi Cc: Christian Brauner Cc: David Howells --- fs/bcachefs/fs.c | 3 +++ fs/stat.c | 1 + include/linux/stat.h | 1 + include/uapi/linux/stat.h | 4 +++- 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 3f073845bbd7..d82f7f3f0670 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -840,6 +840,9 @@ static int bch2_getattr(struct mnt_idmap *idmap, stat->blksize = block_bytes(c); stat->blocks = inode->v.i_blocks; + stat->vol = inode->ei_subvol; + stat->result_mask |= STATX_VOL; + if (request_mask & STATX_BTIME) { stat->result_mask |= STATX_BTIME; stat->btime = bch2_time_to_timespec(c, inode->ei_inode.bi_otime); diff --git a/fs/stat.c b/fs/stat.c index 77cdc69eb422..80d5f7502d99 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -658,6 +658,7 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) tmp.stx_mnt_id = stat->mnt_id; tmp.stx_dio_mem_align = stat->dio_mem_align; tmp.stx_dio_offset_align = stat->dio_offset_align; + tmp.stx_vol = stat->vol; return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0; } diff --git a/include/linux/stat.h b/include/linux/stat.h index 52150570d37a..9dc1b493ef1f 100644 --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -53,6 +53,7 @@ struct kstat { u32 dio_mem_align; u32 dio_offset_align; u64 change_cookie; + u64 vol; }; /* These definitions are internal to the kernel for now. Mainly used by nfsd. */ diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 2f2ee82d5517..ae090d67946d 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -126,8 +126,9 @@ struct statx { __u64 stx_mnt_id; __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */ __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */ + __u64 stx_vol; /* Subvolume identifier */ /* 0xa0 */ - __u64 __spare3[12]; /* Spare space for future expansion */ + __u64 __spare3[11]; /* Spare space for future expansion */ /* 0x100 */ }; @@ -155,6 +156,7 @@ struct statx { #define STATX_MNT_ID 0x00001000U /* Got stx_mnt_id */ #define STATX_DIOALIGN 0x00002000U /* Want/got direct I/O alignment info */ #define STATX_MNT_ID_UNIQUE 0x00004000U /* Want/got extended stx_mount_id */ +#define STATX_VOL 0x00008000U /* Want/got stx_vol */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ -- 2.43.0