Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp526557rbb; Sat, 24 Feb 2024 10:47:27 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX25Y/GMenNfhKwENtkoz7mxNkjY+wm0p8MME6YGdwPKg8WqZSuspPqPbKcz7JNC3JYSCKgrZifgobU66mA6bik3GIOnIsCAJ6bKDAKbA== X-Google-Smtp-Source: AGHT+IGyFShc3ijAt2UVk/VJB9Pw9skT0jOCOfByUZKOGnwq1j+Cbhpg92YiUW4vWCxl5v0OWrKW X-Received: by 2002:a05:6214:3990:b0:68f:ea48:e7a3 with SMTP id ny16-20020a056214399000b0068fea48e7a3mr3020457qvb.24.1708800447435; Sat, 24 Feb 2024 10:47:27 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708800447; cv=pass; d=google.com; s=arc-20160816; b=hXoblXqO4mLVwpYgkhHDKdLYD4dn8X/3p2n7xQ81WCu1eiIDIZgPyYQl+8s6+pdNIi AOxGIdxdlPosVE6pmJvaJRbxPGXy8GIHDBtURMxnwhR1ypdH4+L2OKX9Kf5yzYcEAS0Z h0zd4Jdjkv2RJvbecb/nGyaubWPSOD37Ti1nQwmjgVB05L1dBB3zs2PQfYUnto9b3Diq Ce1h8pnxzo4cMlMnhr6bGTwdPVToTjFJv2XmHg3xaE0EwcLY3+tytZiL6wqLmsQXWCEP Wy5zi1LB6gkB91o9zWQeGu1vaPWNY4mqIn6n1fsdC7dkGXqKuCp0flJlRqILEK7p0ik4 1mrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=luI5LH6pYhZC/Cdk0BZ+N4QrEkQKug3aTK3kXTF38gg=; fh=iW+m9E/C7LBI9dfq/zuBOGoRosx41YobxmaIX84rEJw=; b=ss6qr/xAIXYqwuN/dWwOO8ttUcsE9vocmlRsh4rCb6CSIargqXoHEe5LK+iQ4KviXU 4nJ+EFFu/3Aqffnh/vZ4kbUob5mZgIjcjtPMGxJ2X6fMMtzf91dd1pjgcchMCuYI/1QQ ccoecuKUVkbitQuI2g+nAa0e2F58JiSpaYaZf4ILztSQABzCg7kNIfWZkR3Lm2WyVjJk fF4yOXUmG90P0fuJt1xHLPyUKSDxPnu9LKkKrQz67kl9ZeSETS4I97j1Ix8akir+18gq 21OzR7PvlJx78oPSQe4QzNqHBowHcMNdkIEStZmcpZWQUikG4+75sLvCRAD0N1KW17jl p8Ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j0NZp5qd; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-79794-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79794-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a5-20020a0562140c2500b0068f45b80656si1614509qvd.138.2024.02.24.10.47.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 10:47:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-79794-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=j0NZp5qd; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-79794-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-79794-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id E2C5F1C20C4A for ; Sat, 24 Feb 2024 18:47:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7990D4C622; Sat, 24 Feb 2024 18:47:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="j0NZp5qd" Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D403B13FF6; Sat, 24 Feb 2024 18:47:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708800426; cv=none; b=ZHd8/RCywphZavHoXMF3RqNUNhOUYXz9xR6rigcFMHqdScXwgWqyxl5WGySCNNtGXZcwzDwsJnPF+OKQk3tzZ+UMk7QW9bjAnp7gQzUGRP8SIcNPjfaNJLe0KJURcfZKSGzF2WwSZdwKVwytJ32bVipI/m/cwz6eqsYR3Ei1qbo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708800426; c=relaxed/simple; bh=8NC1pmW4SNm4uq22usE3M7/xXFJlcGLq8FI/irGyZG8=; h=Date:Message-Id:From:To:Cc:Subject:In-Reply-To; b=E/SP2VY40N1ZXsNNPOxBE1lOtB9zSnADJjFQWHA3jXoF0ulbB6914lqIzAvnFPjIdi4E2YbtVBRtLuesv1yhfwILvRbBtaM11HuPqm5RP/eZnPDNKLAgs/hFVtnZWmQHLBHWNz/RvpGKf8xsU+QK4G+9xu2fwLg573wqTXF3GsI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=j0NZp5qd; arc=none smtp.client-ip=209.85.210.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-6e4d869b019so981102b3a.0; Sat, 24 Feb 2024 10:47:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708800424; x=1709405224; darn=vger.kernel.org; h=in-reply-to:subject:cc:to:from:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=luI5LH6pYhZC/Cdk0BZ+N4QrEkQKug3aTK3kXTF38gg=; b=j0NZp5qdY+gEqPiPLYFzgTUt92dYUHwYgx62WHvPSrsojSFlEfHFzF5xh5/LtrKAYE XY0LC/VYtsI9IjAtk+tkmLbudgJkLaOoM7Ix/HkRPxEMBJA3OSrcoW2CuFw5X1pG7ZpR GZKwGd7EkTT6YpZ1svwcAhJFQRKNmMetBBQgye9uCRYxRoL0lnVFry2b5QZN7bdCBsNc uBqTor1N78mklKJc3AGglhClrt3qphjJcopql5YPIGLx+Oqi9+hcDW3GM0AN6cUzy/td Y0qBlYa+J55aMTk9oVULJnDj7Yb5JhUOdhlN2divKgsJbK77ObV2VGtPxi4w6H2GYN4x f/FA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708800424; x=1709405224; h=in-reply-to:subject:cc:to:from:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=luI5LH6pYhZC/Cdk0BZ+N4QrEkQKug3aTK3kXTF38gg=; b=pccgMtC1U7mRGgfncMQ1Lz6iiaQHTcv5eVLYqXy4tvx3RCmMRAQaiTsERRoIDQNBT3 OydsuBYo5xd1rvcoQq+gvprJSgD0GO5vBFK8S5LkPc/jphFUdp8SxpdLiNRLDoCQIUl1 eWQSNUND2RV2pGXopsEalkOWBEoZQ/lZD5z74UEqiee5cWACx1EbsY2vjxWKdZOoNMV/ J70t6eoDEmpjRH1dRthsydT53Ty2Acxe2JWUhrfMTuR1P73GrlC81RT6tujUYHTPSmvr fPcSd9DK3W60Qw98DZV0YWpkPNskYs+qvWJRPahmgBGTyBQaYa0NOOj0emYq6qCoqQc9 svcw== X-Forwarded-Encrypted: i=1; AJvYcCUgxlFnaArqMHt5F/MQiSXn10h5rXDDsDgln2+epphZ9O5c3M3JGv5dCPWwrfj+F6jez3rlwvR4rtz5kamNcTRjPFkyMtpIb4CMya/wJlTArM6LQYYnSUs6GjEfCkwD/o/wsC05hf2PHtVqzInCIaoySTMasAaSvSndOBoOoHXWueXRxjHTf8ps0IUS5HkdjH4wLqM27RW5uH6WEQFB1Pj/R694D2fRpGpFdB1x25acjtD1M3Zhbq6dMTxGZOJQ X-Gm-Message-State: AOJu0Yy8IK6ZF3mL3n3D/MEHl5cazoSgPB31y/Bm6Iez8w5WdaP443Hc OlZX6I6o2s4OivK3gdU5l2Y3eMLZuQfV6meZkFeBeHV9Ilkl+3mH X-Received: by 2002:a05:6a00:5d:b0:6e5:6d2:234b with SMTP id i29-20020a056a00005d00b006e506d2234bmr524354pfk.0.1708800424044; Sat, 24 Feb 2024 10:47:04 -0800 (PST) Received: from dw-tp ([171.76.80.106]) by smtp.gmail.com with ESMTPSA id r7-20020aa78b87000000b006e48b04d8c0sm1386455pfd.64.2024.02.24.10.46.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 24 Feb 2024 10:47:03 -0800 (PST) Date: Sun, 25 Feb 2024 00:16:55 +0530 Message-Id: <87o7c51yzk.fsf@doe.com> From: Ritesh Harjani (IBM) To: John Garry , axboe@kernel.dk, kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, jejb@linux.ibm.com, martin.petersen@oracle.com, djwong@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, dchinner@redhat.com, jack@suse.cz Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-fsdevel@vger.kernel.org, tytso@mit.edu, jbongio@google.com, linux-scsi@vger.kernel.org, ojaswin@linux.ibm.com, linux-aio@kvack.org, linux-btrfs@vger.kernel.org, io-uring@vger.kernel.org, nilay@linux.ibm.com, Prasad Singamsetty , John Garry Subject: Re: [PATCH v4 04/11] fs: Add initial atomic write support info to statx In-Reply-To: <20240219130109.341523-5-john.g.garry@oracle.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: John Garry writes: > From: Prasad Singamsetty > > Extend statx system call to return additional info for atomic write support > support for a file. > > Helper function generic_fill_statx_atomic_writes() can be used by FSes to > fill in the relevant statx fields. > > Signed-off-by: Prasad Singamsetty > #jpg: relocate bdev support to another patch ^^^ miss maybe? > Signed-off-by: John Garry > --- > fs/stat.c | 34 ++++++++++++++++++++++++++++++++++ > include/linux/fs.h | 3 +++ > include/linux/stat.h | 3 +++ > include/uapi/linux/stat.h | 9 ++++++++- > 4 files changed, 48 insertions(+), 1 deletion(-) > > diff --git a/fs/stat.c b/fs/stat.c > index 77cdc69eb422..522787a4ab6a 100644 > --- a/fs/stat.c > +++ b/fs/stat.c > @@ -89,6 +89,37 @@ void generic_fill_statx_attr(struct inode *inode, struct kstat *stat) > } > EXPORT_SYMBOL(generic_fill_statx_attr); > > +/** > + * generic_fill_statx_atomic_writes - Fill in the atomic writes statx attributes > + * @stat: Where to fill in the attribute flags > + * @unit_min: Minimum supported atomic write length + * @unit_min: Minimum supported atomic write length in bytes > + * @unit_max: Maximum supported atomic write length + * @unit_max: Maximum supported atomic write length in bytes mentioning unit of the length might be useful here. > + * > + * Fill in the STATX{_ATTR}_WRITE_ATOMIC flags in the kstat structure from > + * atomic write unit_min and unit_max values. > + */ > +void generic_fill_statx_atomic_writes(struct kstat *stat, > + unsigned int unit_min, This (unit_min) can still go above in the same line. > + unsigned int unit_max) > +{ > + /* Confirm that the request type is known */ > + stat->result_mask |= STATX_WRITE_ATOMIC; > + > + /* Confirm that the file attribute type is known */ > + stat->attributes_mask |= STATX_ATTR_WRITE_ATOMIC; > + > + if (unit_min) { > + stat->atomic_write_unit_min = unit_min; > + stat->atomic_write_unit_max = unit_max; > + /* Initially only allow 1x segment */ > + stat->atomic_write_segments_max = 1; Please log info about this in commit message about where this limit came from? Is it since we only support ubuf (which IIUC, only supports 1 segment)? Later when we will add support for iovec, this limit can be lifted? > + > + /* Confirm atomic writes are actually supported */ > + stat->attributes |= STATX_ATTR_WRITE_ATOMIC; > + } > +} > +EXPORT_SYMBOL(generic_fill_statx_atomic_writes); > + > /** > * vfs_getattr_nosec - getattr without security checks > * @path: file to get attributes from > @@ -658,6 +689,9 @@ 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_atomic_write_unit_min = stat->atomic_write_unit_min; > + tmp.stx_atomic_write_unit_max = stat->atomic_write_unit_max; > + tmp.stx_atomic_write_segments_max = stat->atomic_write_segments_max; > > return copy_to_user(buffer, &tmp, sizeof(tmp)) ? -EFAULT : 0; > } > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 7271640fd600..531140a7e27a 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -3167,6 +3167,9 @@ extern const struct inode_operations page_symlink_inode_operations; > extern void kfree_link(void *); > void generic_fillattr(struct mnt_idmap *, u32, struct inode *, struct kstat *); > void generic_fill_statx_attr(struct inode *inode, struct kstat *stat); > +void generic_fill_statx_atomic_writes(struct kstat *stat, > + unsigned int unit_min, > + unsigned int unit_max); We can make 80 col. width even with unit_min in the same first line as of *stat. > extern int vfs_getattr_nosec(const struct path *, struct kstat *, u32, unsigned int); > extern int vfs_getattr(const struct path *, struct kstat *, u32, unsigned int); > void __inode_add_bytes(struct inode *inode, loff_t bytes); > diff --git a/include/linux/stat.h b/include/linux/stat.h > index 52150570d37a..2c5e2b8c6559 100644 > --- a/include/linux/stat.h > +++ b/include/linux/stat.h > @@ -53,6 +53,9 @@ struct kstat { > u32 dio_mem_align; > u32 dio_offset_align; > u64 change_cookie; > + u32 atomic_write_unit_min; > + u32 atomic_write_unit_max; > + u32 atomic_write_segments_max; > }; > > /* 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..c0e8e10d1de6 100644 > --- a/include/uapi/linux/stat.h > +++ b/include/uapi/linux/stat.h > @@ -127,7 +127,12 @@ struct statx { > __u32 stx_dio_mem_align; /* Memory buffer alignment for direct I/O */ > __u32 stx_dio_offset_align; /* File offset alignment for direct I/O */ > /* 0xa0 */ > - __u64 __spare3[12]; /* Spare space for future expansion */ > + __u32 stx_atomic_write_unit_min; > + __u32 stx_atomic_write_unit_max; > + __u32 stx_atomic_write_segments_max; Let's add one liner for each of these fields similar to how it was done for others? /* Minimum supported atomic write length in bytes */ /* Maximum supported atomic write length in bytes */ /* Maximum no. of segments (iovecs?) supported for atomic write */ > + __u32 __spare1; > + /* 0xb0 */ > + __u64 __spare3[10]; /* Spare space for future expansion */ > /* 0x100 */ > }; > > @@ -155,6 +160,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_WRITE_ATOMIC 0x00008000U /* Want/got atomic_write_* fields */ > > #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ > > @@ -190,6 +196,7 @@ struct statx { > #define STATX_ATTR_MOUNT_ROOT 0x00002000 /* Root of a mount */ > #define STATX_ATTR_VERITY 0x00100000 /* [I] Verity protected file */ > #define STATX_ATTR_DAX 0x00200000 /* File is currently in DAX state */ > +#define STATX_ATTR_WRITE_ATOMIC 0x00400000 /* File supports atomic write operations */ > > > #endif /* _UAPI_LINUX_STAT_H */ > -- > 2.31.1