Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp284887lqc; Thu, 7 Mar 2024 18:29:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV9Iz9VZnml902j0XJwlS3tZn5aA3rTTgyetmXMJogw7bJKqS42Q9Gs4pg3pbAVzy9jvCrRGgqQwp0KIzQJ/IFgGlUFOHz6//VT+nCldg== X-Google-Smtp-Source: AGHT+IENvhLFPp5N7W87uiACnP4xvbLE4w8NOVs/jHHqsgdeu8Z44wxs4OH6lH/7l3qvnBz5F24t X-Received: by 2002:a50:955e:0:b0:567:1797:426f with SMTP id v30-20020a50955e000000b005671797426fmr955834eda.24.1709864981723; Thu, 07 Mar 2024 18:29:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709864981; cv=pass; d=google.com; s=arc-20160816; b=rVyzZU+9Qvzmrv/JOSahS+2WGeBriufi4BKUq6QMFV4W1xYmvL2Gqk+/r+fOcLbAwJ 0w/C+P5RYmCw7+5fKiBpZCsIYyA3LoCPMzuDsr/GpvVBDotLJvwdUhbN4YO57hB2Xr6T QX+QXgKWWXXbtVYGR1LxMNN4eNpOUrXDCV896p21kT/e4EtjZD1+bqdJAZ5LCYNY1vxr YL/5858pjH6kyostc3nmXaStoAUs0yWu8gxYfA8PisXmCiLwG1XVyEJ00Qt56Bz9oawj WIj1Pps82aU1vSDIcIqQ/4IXHGNtm98iKsBYWHpkc1nQV7IpJ19lR3YvHMUuZPzFss47 5opw== 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=G5i/vJIJMCUtMZCyLr/3KzDshYesTXRY7gpXnOJ9PWg=; fh=M/bYt5x4oBXwBHrJ9IS7qb+bOH+nZlLss8MpTb2TsyY=; b=DjZ4pHER2iwOodLJkwT5PfpNtjzIJ0z/u7UEGBPRUwYm3HaeAvUdg7Rg21Sd+bLX+s HKPUh3vhRRDdCNQY3Ax2LFs/PNig+xiPYiAmSqaVXwvt98HFt70gSfYyT9+XwaDNYnS6 Nge2ULhBxApNpfzQQ5O+ANINPQy/hIGiXmwoss4GW3Fq+tbmNH4+fzMGe6bLOrm84bUr 0yQbEZcJ2fjM46ozM6qP7o2PPhmCY29q6Qsfrb7vvkrpJK5xQT+wIp6Po+5CvBENg1OG 7NZl3KuFAvFgYK1Q7+R71/BwFjjcrVaq9GXSBzQklFY7qz+w/yB8WdT8io5uXco2QTh2 PmDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=sd1Lmp61; 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-96451-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96451-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s16-20020a056402521000b005682a06d8b8si239286edd.413.2024.03.07.18.29.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 18:29:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96451-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=sd1Lmp61; 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-96451-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96451-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3EA991F217DB for ; Fri, 8 Mar 2024 02:29:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08C1624203; Fri, 8 Mar 2024 02:29:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="sd1Lmp61" Received: from out-185.mta1.migadu.com (out-185.mta1.migadu.com [95.215.58.185]) (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 3B47C22F07; Fri, 8 Mar 2024 02:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709864968; cv=none; b=RdISuJ5iCB0cTZhMF43FK2rm7C6klsAZv6Mpj5tY2fKztDxP8sCLTmiBvcKYlFO0PWJw3YRTpPQnvklWzy0qapZU/aU975Z3h5f1wFBg5HKLK589Od63rYGaQtZh4W1LNHgNS5mgCYdyoI8fhH3nFQmz5b29uWHyXd4THV3Fs3w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709864968; c=relaxed/simple; bh=duRSN3TaPjNn+KjXCQlU87+ksRGL7u0yBrkBxCW39Ok=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=H4hN6eIxhgOWQnQzEfbRN3m53nARONQke8uzU9TNSoLDwQgtkSrXs+d+zHU7kWsPukPkvawGwY9LSU7ldmfmyZSjXbIGqAQRcD1q5UOCBiCmMZ5T/gDMEKRSdeJgO2mXJMnl95E0xWNnymmKO2BbmCD74h1LLxNaAA2uhb+2KUA= 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=sd1Lmp61; arc=none smtp.client-ip=95.215.58.185 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=1709864964; 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=G5i/vJIJMCUtMZCyLr/3KzDshYesTXRY7gpXnOJ9PWg=; b=sd1Lmp61w01alOwcbQYwZBNP4+/A9BPUOHbrEKwNDmZ8l4Xf2kOXZZooZHVeceGplwV0ZY w0g38MGHk1toMhnkDrraHPIMw8iPsAMuOZRPbwEplW47cPoEyYm0IgZKPQ/JgGddIDi4Ay iXRJOcaNEsiqIzOnYOCycsA+CK5xgqk= From: Kent Overstreet To: Cc: Kent Overstreet , linux-fsdevel@vger.kernel.org, linux-bcachefs@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Josef Bacik , Miklos Szeredi , Christian Brauner , David Howells Subject: [PATCH v2] statx: stx_subvol Date: Thu, 7 Mar 2024 21:29:12 -0500 Message-ID: <20240308022914.196982-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, as implemented by btrfs and bcachefs. 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 Signed-off-by: Kent Overstreet --- 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..6a542ed43e2c 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->subvol = inode->ei_subvol; + stat->result_mask |= STATX_SUBVOL; + 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..70bd3e888cfa 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_subvol = stat->subvol; return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0; } diff --git a/include/linux/stat.h b/include/linux/stat.h index 52150570d37a..bf92441dbad2 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 subvol; }; /* 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..67626d535316 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_subvol; /* 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_SUBVOL 0x00008000U /* Want/got stx_subvol */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ -- 2.43.0