On Wed, May 20, 2020 at 02:17:16PM -0700, Darrick J. Wong wrote: > On Tue, May 19, 2020 at 05:54:37AM -0700, Christoph Hellwig wrote: > > The actual logic looks good, but I think the new helper and another > > third set of comment explaining what is going on makes this area even > > more confusing. What about something like this instead? > > This seems reasonable, but the callsite cleanups ought to be a separate > patch from the behavior change. Do you want me to send prep patches, or do you want to split it our yourself? > > + if (eof && offset + count > XFS_ISIZE(ip)) { > > + /* > > + * Determine the initial size of the preallocation. > > + * We clean up any extra preallocation when the file is closed. > > + */ > > + if (mp->m_flags & XFS_MOUNT_ALLOCSIZE) > > + prealloc_blocks = mp->m_allocsize_blocks; > > + else > > + prealloc_blocks = xfs_iomap_prealloc_size(ip, allocfork, > > + offset, count, &icur); > > I'm not sure how much we're really gaining from moving the > MOUNT_ALLOCSIZE check out to the caller, but I don't feel all that > passionate about this. >From the pure code stats point of view it doensn't matter. But from the software architecture POV it does - now xfs_iomap_prealloc_size contains the dynamic prealloc size algorithm, while the hard coded case is handled in the caller.