On Tue, Apr 16, 2024 at 11:46:52AM -0700, Darrick J. Wong wrote: > "A reviewer asked why didn't I design the interface so that the kernel > determines what scrubbers to run and in what order, and then fills the > output buffer with the results of whatever it decided to do. > > "I thought about designing this interface that way, where userspace > passes a pointer to an empty buffer, and the kernel formats that with > xfs_scrub_vecs that tell userspace what it scrubbed and what the outcome > was. I didn't like that, because now the kernel has to have a way to > communicate that the buffer needed to have been at least X size, even > though for our cases XFS_SCRUB_TYPE_NR + 2 would always be enough. > > "Better, I thought, to let userspace figure out what it wants to run, > and tell that explicitly to the kernel. Then the kernel can just do > that. The upside is that all that dependency policy and ordering logic > can be in userspace instead of the kernel; the downside is that now we > need the barriers." Maybe it's just personal preferences, but I find these a reviewer asked dialogs really odd. Here is how I would have written the above: The alternative would have been an interface where userspace passes a pointer to an empty buffer, and the kernel formats that with xfs_scrub_vecs that tell userspace what it scrubbed and what the outcome was. With that the kernel would have to communicate that the buffer needed to have been at least X size, even though for our cases XFS_SCRUB_TYPE_NR + 2 would always be enough. Compared to that this design keeps all the dependency policy and ordering logic in userspace where it already resides instead of duplicating it in the kernel. The downside of that is tha it needs the barrier logic.