Adam Thompson wrote: > > On 16-03-13 11:11 PM, Michael McConville wrote: > >It seems that chown(1) will write to a file even if it already has the > >desired ownership. The below patch causes it to skip the write when > >there would be no change. The best I could tell, the fts_read(3) and > >fchownat(3) logic agree on whether to follow symlinks in all cases, so > >there's no need to execute a useless write when certain options are > >specified. > > > >I get a speedup of 5-10% on SSDs, and probably more on a slow storage > >HD. This is when all the files are already owned by the specified user. > >I think this is a common case, as chown is often used to "comb out" > >offending files, ensure that a server can access everything in /var/www, > >etc. > > > >The APIs involved are not simple and there's potential for subtle > >breakage, so this only an initial patch. I'm interested to hear what > >more experienced people think. > > > >If it's worthwhile, a similar approach can probably be applied to > >chmod(1) et al. as well. > > If this becomes the default behaviour, please allow a way to revert to the > previous behaviour, as this change would break several real systems I'm > aware of, including one I currently manage.
As I feared, and as Todd pointed out, this would break too much stuff to be worth the modest performance improvement. It won't be committed.