From patchwork Sat Mar 2 22:02:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 209265 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp667000dyc; Sat, 2 Mar 2024 14:03:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWXyHfh2nzxDSwC+bc4X3TjkSyHxaGK67kyHexzZT6GTkbWcPErFoQHd4sRI5QiLFShdOfllFzJ4CsGgyznRsEuy1+DVw== X-Google-Smtp-Source: AGHT+IGaMT44qx8LRK/e55lA2x5kuDy+xSVZYqGHou865laO6nn18Ag8AcZEhzMj8AHm4wxxewxk X-Received: by 2002:a05:6a00:ccb:b0:6e5:a910:c814 with SMTP id b11-20020a056a000ccb00b006e5a910c814mr7709353pfv.10.1709416985765; Sat, 02 Mar 2024 14:03:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709416985; cv=pass; d=google.com; s=arc-20160816; b=X6bMuFdCRBKvaHq7GQhuyFYhCEyAwTt9GPMHgGQJ6lMN/RzHeZ8uMvrYQdaWY5aiea N7OdQ+pnA6BGxWzHcrMO8WQNxrZFNmbzC/yGytZYh/vHHWU1PL537cMpP+t13GlMCao3 u+bLb7JCQJrlnjCAG1XBL6TUJyFKfZC/e7DIjfAJZaBxs2mNz+wrv56nNEypEE4lsFLc BefzsJ2ka/n2tAQbKcVnWpnP+9oIxgVnAMfL7J62hxDx3BapEin2ww1sgsb7xCVcYHq3 zGqD7vEHQhWiJZH93ar8WneY9EfhYFWK7C0gJ4I+30XKaK10Tksgp06QxmP9KuVDAise Du/A== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89610-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id j9-20020a635949000000b005dc504b9628si5829645pgm.113.2024.03.02.14.03.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Mar 2024 14:03:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89610-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=@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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89610-ouuuleilei=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 B21DC28464A for ; Sat, 2 Mar 2024 22:02:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF26145BF9; Sat, 2 Mar 2024 22:02:20 +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 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792453625140234700 X-GMAIL-MSGID: 1792453625140234700 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 */