* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate [not found] ` <20241228014522.2395187-2-yi.zhang@huaweicloud.com> @ 2025-01-06 11:27 ` Christoph Hellwig 2025-01-06 16:17 ` Theodore Ts'o 2025-01-07 12:38 ` Zhang Yi 0 siblings, 2 replies; 10+ messages in thread From: Christoph Hellwig @ 2025-01-06 11:27 UTC (permalink / raw) To: Zhang Yi Cc: linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, tytso, djwong, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs There's a feature request for something similar on the xfs list, so I guess people are asking for it. That being said this really should not be a modifier but a separate operation, as the logic is very different from FALLOC_FL_ZERO_RANGE, similar to how plain prealloc, hole punch and zero range are different operations despite all of them resulting in reads of zeroes from the range. That will also make it more clear that for files or file systems that require out place writes this operation should fail instead of doing pointless multiple writes. Also please write a man page update clearly specifying the semantics, especially if this should work or not if there is no write zeroes offload in the hardware, or if that offload actually writes physical zeroes to the media or not. Btw, someone really should clean up the ext4 fallocate code to use helper adnd do the switch (mode & FALLOC_FL_MODE_MASK) { } and then use helpers for each mode whih will make these things a lot more obvious. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate 2025-01-06 11:27 ` [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate Christoph Hellwig @ 2025-01-06 16:17 ` Theodore Ts'o 2025-01-06 16:27 ` Christoph Hellwig 2025-01-07 11:22 ` Zhang Yi 2025-01-07 12:38 ` Zhang Yi 1 sibling, 2 replies; 10+ messages in thread From: Theodore Ts'o @ 2025-01-06 16:17 UTC (permalink / raw) To: Christoph Hellwig Cc: Zhang Yi, linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, djwong, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs On Mon, Jan 06, 2025 at 03:27:52AM -0800, Christoph Hellwig wrote: > There's a feature request for something similar on the xfs list, so > I guess people are asking for it. Yeah, I have folks asking for this on the ext4 side as well. The one caution that I've given to them is that there is no guarantee what the performance will be for WRITE SAME or equivalent operations, since the standards documents state that performance is out of scope for the document. So in some cases, WRITE SAME might be fast (if for example it is just adjusing FTL metadata on an SSD, or some similar thing on cloud-emulated block devices such as Google's Persistent Desk or Amazon's Elastic Block Device --- what Darrick has called "software defined storage" for the cloud), but in other hardware deployments, WRITE SAME might be as slow as writing zeros to an HDD. This is technically not the kernel's problem, since we can also use the same mealy-mouth "performance is out of scope and not the kernel's concern", but that just transfers the problem to the application programmers. I could imagine some kind of tunable which we can make the block device pretend that it really doesn't support using WRITE SAME if the performance characteristics are such that it's a Bad Idea to use it, so that there's a single tunable knob that the system adminstrator can reach for as opposed to have different ways for PostgresQL, MySQL, Oracle Enterprise Database, etc have for configuring whether or not to disable WRITE SAME, but that's not something we need to decide right away. > That being said this really should not be a modifier but a separate > operation, as the logic is very different from FALLOC_FL_ZERO_RANGE, > similar to how plain prealloc, hole punch and zero range are different > operations despite all of them resulting in reads of zeroes from the > range. Yes. And we might decide that it should be done using some kind of ioctl, such as BLKDISCARD, as opposed to a new fallocate operation, since it really isn't a filesystem metadata operation, just as BLKDISARD isn't. The other side of the argument is that ioctls are ugly, and maybe all new such operations should be plumbed through via fallocate as opposed to adding a new ioctl. I don't have strong feelings on this, although I *do* belive that whatever interface we use, whether it be fallocate or ioctl, it should be supported by block devices and files in a file system, to make life easier for those databases that want to support running on a raw block device (for full-page advertisements on the back cover of the Businessweek magazine) or on files (which is how 99.9% of all real-world users actually run enterprise databases. :-) - Ted ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate 2025-01-06 16:17 ` Theodore Ts'o @ 2025-01-06 16:27 ` Christoph Hellwig 2025-01-06 17:31 ` Darrick J. Wong 2025-01-07 11:22 ` Zhang Yi 1 sibling, 1 reply; 10+ messages in thread From: Christoph Hellwig @ 2025-01-06 16:27 UTC (permalink / raw) To: Theodore Ts'o Cc: Christoph Hellwig, Zhang Yi, linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, djwong, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs On Mon, Jan 06, 2025 at 11:17:32AM -0500, Theodore Ts'o wrote: > Yes. And we might decide that it should be done using some kind of > ioctl, such as BLKDISCARD, as opposed to a new fallocate operation, > since it really isn't a filesystem metadata operation, just as > BLKDISARD isn't. The other side of the argument is that ioctls are > ugly, and maybe all new such operations should be plumbed through via > fallocate as opposed to adding a new ioctl. I don't have strong > feelings on this, although I *do* belive that whatever interface we > use, whether it be fallocate or ioctl, it should be supported by block > devices and files in a file system, to make life easier for those > databases that want to support running on a raw block device (for > full-page advertisements on the back cover of the Businessweek > magazine) or on files (which is how 99.9% of all real-world users > actually run enterprise databases. :-) If you want the operation to work for files it needs to be routed through the file system as otherwise you can't make it actually work coherently. While you could add a new ioctl that works on a file fallocate seems like a much better interface. Supporting it on a block device is trivial, as it can mostly (or even entirely depending on the exact definition of the interface) reuse the existing zero range / punch hole code. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate 2025-01-06 16:27 ` Christoph Hellwig @ 2025-01-06 17:31 ` Darrick J. Wong 2025-01-06 18:06 ` Christoph Hellwig 2025-01-07 14:05 ` Zhang Yi 0 siblings, 2 replies; 10+ messages in thread From: Darrick J. Wong @ 2025-01-06 17:31 UTC (permalink / raw) To: Christoph Hellwig Cc: Theodore Ts'o, Zhang Yi, linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs On Mon, Jan 06, 2025 at 08:27:49AM -0800, Christoph Hellwig wrote: > On Mon, Jan 06, 2025 at 11:17:32AM -0500, Theodore Ts'o wrote: > > Yes. And we might decide that it should be done using some kind of > > ioctl, such as BLKDISCARD, as opposed to a new fallocate operation, > > since it really isn't a filesystem metadata operation, just as > > BLKDISARD isn't. The other side of the argument is that ioctls are > > ugly, and maybe all new such operations should be plumbed through via > > fallocate as opposed to adding a new ioctl. I don't have strong > > feelings on this, although I *do* belive that whatever interface we > > use, whether it be fallocate or ioctl, it should be supported by block > > devices and files in a file system, to make life easier for those > > databases that want to support running on a raw block device (for > > full-page advertisements on the back cover of the Businessweek > > magazine) or on files (which is how 99.9% of all real-world users > > actually run enterprise databases. :-) > > If you want the operation to work for files it needs to be routed > through the file system as otherwise you can't make it actually > work coherently. While you could add a new ioctl that works on a > file fallocate seems like a much better interface. Supporting it > on a block device is trivial, as it can mostly (or even entirely > depending on the exact definition of the interface) reuse the existing > zero range / punch hole code. I think we should wire it up as a new FALLOC_FL_WRITE_ZEROES mode, document very vigorously that it exists to facilitate pure overwrites (specifically that it returns EOPNOTSUPP for always-cow files), and not add more ioctls. (That said, doesn't BLKZEROOUT already do this for bdevs?) --D ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate 2025-01-06 17:31 ` Darrick J. Wong @ 2025-01-06 18:06 ` Christoph Hellwig 2025-01-07 14:05 ` Zhang Yi 1 sibling, 0 replies; 10+ messages in thread From: Christoph Hellwig @ 2025-01-06 18:06 UTC (permalink / raw) To: Darrick J. Wong Cc: Christoph Hellwig, Theodore Ts'o, Zhang Yi, linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs On Mon, Jan 06, 2025 at 09:31:33AM -0800, Darrick J. Wong wrote: > I think we should wire it up as a new FALLOC_FL_WRITE_ZEROES mode, > document very vigorously that it exists to facilitate pure overwrites > (specifically that it returns EOPNOTSUPP for always-cow files), and not > add more ioctls. That goes into a similar direction to what I'd prefer. > (That said, doesn't BLKZEROOUT already do this for bdevs?) Yes. But the same is true for the other fallocate modes on block devices. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate 2025-01-06 17:31 ` Darrick J. Wong 2025-01-06 18:06 ` Christoph Hellwig @ 2025-01-07 14:05 ` Zhang Yi 2025-01-07 16:42 ` Christoph Hellwig 1 sibling, 1 reply; 10+ messages in thread From: Zhang Yi @ 2025-01-07 14:05 UTC (permalink / raw) To: Darrick J. Wong, Christoph Hellwig Cc: Theodore Ts'o, linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs On 2025/1/7 1:31, Darrick J. Wong wrote: > On Mon, Jan 06, 2025 at 08:27:49AM -0800, Christoph Hellwig wrote: >> On Mon, Jan 06, 2025 at 11:17:32AM -0500, Theodore Ts'o wrote: >>> Yes. And we might decide that it should be done using some kind of >>> ioctl, such as BLKDISCARD, as opposed to a new fallocate operation, >>> since it really isn't a filesystem metadata operation, just as >>> BLKDISARD isn't. The other side of the argument is that ioctls are >>> ugly, and maybe all new such operations should be plumbed through via >>> fallocate as opposed to adding a new ioctl. I don't have strong >>> feelings on this, although I *do* belive that whatever interface we >>> use, whether it be fallocate or ioctl, it should be supported by block >>> devices and files in a file system, to make life easier for those >>> databases that want to support running on a raw block device (for >>> full-page advertisements on the back cover of the Businessweek >>> magazine) or on files (which is how 99.9% of all real-world users >>> actually run enterprise databases. :-) >> >> If you want the operation to work for files it needs to be routed >> through the file system as otherwise you can't make it actually >> work coherently. While you could add a new ioctl that works on a >> file fallocate seems like a much better interface. Supporting it >> on a block device is trivial, as it can mostly (or even entirely >> depending on the exact definition of the interface) reuse the existing >> zero range / punch hole code. > > I think we should wire it up as a new FALLOC_FL_WRITE_ZEROES mode, > document very vigorously that it exists to facilitate pure overwrites > (specifically that it returns EOPNOTSUPP for always-cow files), and not > add more ioctls. > Sorry. the "pure overwrites" and "always-cow files" makes me confused, this is mainly used to create a new written file range, but also could be used to zero out an existing range, why you mentioned it exists to facilitate pure overwrites? For the "always-cow files", do you mean reflinked files? Could you please give more details? Thanks, Yi. > (That said, doesn't BLKZEROOUT already do this for bdevs?) > > --D ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate 2025-01-07 14:05 ` Zhang Yi @ 2025-01-07 16:42 ` Christoph Hellwig 2025-01-08 1:20 ` Zhang Yi 0 siblings, 1 reply; 10+ messages in thread From: Christoph Hellwig @ 2025-01-07 16:42 UTC (permalink / raw) To: Zhang Yi Cc: Darrick J. Wong, Christoph Hellwig, Theodore Ts'o, linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs On Tue, Jan 07, 2025 at 10:05:47PM +0800, Zhang Yi wrote: > Sorry. the "pure overwrites" and "always-cow files" makes me confused, > this is mainly used to create a new written file range, but also could > be used to zero out an existing range, why you mentioned it exists to > facilitate pure overwrites? If you're fine with writes to your file causing block allocations you can already use the hole punch or preallocate fallocate modes. No need to actually send a command to the device. > > For the "always-cow files", do you mean reflinked files? Could you > please give more details? reflinked files will require out of place writes for shared blocks. As will anything on device mapper snapshots. Or any file on file systems that write out of place (btrfs, f2fs, nilfs2, the upcoming zoned xfs mode). ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate 2025-01-07 16:42 ` Christoph Hellwig @ 2025-01-08 1:20 ` Zhang Yi 0 siblings, 0 replies; 10+ messages in thread From: Zhang Yi @ 2025-01-08 1:20 UTC (permalink / raw) To: Christoph Hellwig Cc: Darrick J. Wong, Theodore Ts'o, linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs On 2025/1/8 0:42, Christoph Hellwig wrote: > On Tue, Jan 07, 2025 at 10:05:47PM +0800, Zhang Yi wrote: >> Sorry. the "pure overwrites" and "always-cow files" makes me confused, >> this is mainly used to create a new written file range, but also could >> be used to zero out an existing range, why you mentioned it exists to >> facilitate pure overwrites? > > If you're fine with writes to your file causing block allocations you > can already use the hole punch or preallocate fallocate modes. No > need to actually send a command to the device. > Okay, I misunderstood your point earlier. This is indeed prepared for subsequent overwrites. Thanks a lot for explaining. Thanks, Yi. >> >> For the "always-cow files", do you mean reflinked files? Could you >> please give more details? > > reflinked files will require out of place writes for shared blocks. > As will anything on device mapper snapshots. Or any file on > file systems that write out of place (btrfs, f2fs, nilfs2, the > upcoming zoned xfs mode). > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate 2025-01-06 16:17 ` Theodore Ts'o 2025-01-06 16:27 ` Christoph Hellwig @ 2025-01-07 11:22 ` Zhang Yi 1 sibling, 0 replies; 10+ messages in thread From: Zhang Yi @ 2025-01-07 11:22 UTC (permalink / raw) To: Theodore Ts'o, Christoph Hellwig Cc: linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, djwong, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs On 2025/1/7 0:17, Theodore Ts'o wrote: > On Mon, Jan 06, 2025 at 03:27:52AM -0800, Christoph Hellwig wrote: >> There's a feature request for something similar on the xfs list, so >> I guess people are asking for it. > > Yeah, I have folks asking for this on the ext4 side as well. > > The one caution that I've given to them is that there is no guarantee > what the performance will be for WRITE SAME or equivalent operations, > since the standards documents state that performance is out of scope > for the document. So in some cases, WRITE SAME might be fast (if for > example it is just adjusing FTL metadata on an SSD, or some similar > thing on cloud-emulated block devices such as Google's Persistent Desk > or Amazon's Elastic Block Device --- what Darrick has called "software > defined storage" for the cloud), but in other hardware deployments, > WRITE SAME might be as slow as writing zeros to an HDD. > > This is technically not the kernel's problem, since we can also use > the same mealy-mouth "performance is out of scope and not the kernel's > concern", but that just transfers the problem to the application > programmers. I could imagine some kind of tunable which we can make > the block device pretend that it really doesn't support using WRITE > SAME if the performance characteristics are such that it's a Bad Idea > to use it, so that there's a single tunable knob that the system > adminstrator can reach for as opposed to have different ways for > PostgresQL, MySQL, Oracle Enterprise Database, etc have for > configuring whether or not to disable WRITE SAME, but that's not > something we need to decide right away. Yes, I completely agree with you. At this time, it is not possible to determine whether a disk supports fast write zeros only by checking if the disk supports the write_zero command. Especially for some HDDs, which should submit actual zeros to the disk even if they claim to support the write_zero command, but that is very slow. Therefore, I propose that we add a new feature flag, such as BLK_FEAT_FAST_WRITE_ZERO, to queue->limits.features. This flag should be set by each disk driver if the attached disk supports fast write zeros. For instance, the NVMe SSD driver should set this flag if the given namespace supports NVME_NS_DEAC. Additionally, we can add an entry in sysfs that allows the user to enable and disable this feature manually when the driver don't know the whether the disk supports it or not for some corner cases. > >> That being said this really should not be a modifier but a separate >> operation, as the logic is very different from FALLOC_FL_ZERO_RANGE, >> similar to how plain prealloc, hole punch and zero range are different >> operations despite all of them resulting in reads of zeroes from the >> range. > > Yes. And we might decide that it should be done using some kind of > ioctl, such as BLKDISCARD, as opposed to a new fallocate operation, > since it really isn't a filesystem metadata operation, just as > BLKDISARD isn't. The other side of the argument is that ioctls are > ugly, and maybe all new such operations should be plumbed through via > fallocate as opposed to adding a new ioctl. I don't have strong > feelings on this, although I *do* belive that whatever interface we > use, whether it be fallocate or ioctl, it should be supported by block > devices and files in a file system, to make life easier for those > databases that want to support running on a raw block device (for > full-page advertisements on the back cover of the Businessweek > magazine) or on files (which is how 99.9% of all real-world users > actually run enterprise databases. :-) > For this part, I still think it would be better to use fallocate. Thanks, Yi. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate 2025-01-06 11:27 ` [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate Christoph Hellwig 2025-01-06 16:17 ` Theodore Ts'o @ 2025-01-07 12:38 ` Zhang Yi 1 sibling, 0 replies; 10+ messages in thread From: Zhang Yi @ 2025-01-07 12:38 UTC (permalink / raw) To: Christoph Hellwig Cc: linux-fsdevel, linux-ext4, linux-kernel, viro, brauner, jack, tytso, djwong, adilger.kernel, yi.zhang, chengzhihao1, yukuai3, yangerkun, Sai Chaitanya Mitta, linux-xfs On 2025/1/6 19:27, Christoph Hellwig wrote: > There's a feature request for something similar on the xfs list, so > I guess people are asking for it. > > That being said this really should not be a modifier but a separate > operation, as the logic is very different from FALLOC_FL_ZERO_RANGE, > similar to how plain prealloc, hole punch and zero range are different > operations despite all of them resulting in reads of zeroes from the > range. OK, it seems reasonable to me, and adding a new operation would be better. There is actually no need to mix it with the current FALLOC_FL_ZERO_RANGE. > > That will also make it more clear that for files or file systems that > require out place writes this operation should fail instead of doing > pointless multiple writes. > > Also please write a man page update clearly specifying the semantics, > especially if this should work or not if there is no write zeroes > offload in the hardware, or if that offload actually writes physical > zeroes to the media or not. > Sure. thanks for your advice. Thanks, Yi. > Btw, someone really should clean up the ext4 fallocate code to use > helper adnd do the > > switch (mode & FALLOC_FL_MODE_MASK) { > } > > and then use helpers for each mode whih will make these things a lot > more obvious. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-01-08 1:20 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20241228014522.2395187-1-yi.zhang@huaweicloud.com>
[not found] ` <20241228014522.2395187-2-yi.zhang@huaweicloud.com>
2025-01-06 11:27 ` [RFC PATCH 1/2] fs: introduce FALLOC_FL_FORCE_ZERO to fallocate Christoph Hellwig
2025-01-06 16:17 ` Theodore Ts'o
2025-01-06 16:27 ` Christoph Hellwig
2025-01-06 17:31 ` Darrick J. Wong
2025-01-06 18:06 ` Christoph Hellwig
2025-01-07 14:05 ` Zhang Yi
2025-01-07 16:42 ` Christoph Hellwig
2025-01-08 1:20 ` Zhang Yi
2025-01-07 11:22 ` Zhang Yi
2025-01-07 12:38 ` Zhang Yi
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox