afs: Do not skip flushing pages for dv-0 files

If the dv for a file is 0, we know the file is empty. Currently we
skip flushing pages for such files, presumably the idea being there is
no data in the file, so there should be no pages to flush.

However, Linux seems to keep empty pages around for empty files. So, a
future read can result in the application reading a page full of
zeroes, unless we flush the page here. While this has only been found
to happen on Linux 2.6.22 and later (and distribution-specific
backports, like RHEL 2.6.18-128), other platforms could in theory also
choose to do this. It would be difficult to find out when another
platform started to behave like this, so just remove this skip for
everyone so we never have to deal with this again.

Replace this code with a comment with a quick explanation, in case
anyone tries to add a similar optimization here in the future.

Thanks to Richard Brittain.

Change-Id: I68c51bb7612a98a5c75112bb8f4bb1edd949fda1
Reviewed-on: http://gerrit.openafs.org/8465
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
This commit is contained in:
Andrew Deason 2012-11-14 18:29:35 -06:00 committed by Derrick Brashear
parent aeb2763b74
commit ad4e634051

View File

@ -80,11 +80,12 @@ osi_FlushPages(struct vcache *avc, afs_ucred_t *credp)
ReleaseWriteLock(&avc->lock);
return;
}
if (hiszero(avc->mapDV)) {
hset(avc->mapDV, avc->f.m.DataVersion);
ReleaseWriteLock(&avc->lock);
return;
}
/* At this point, you might think that we can skip trying to flush pages
* if mapDV is zero, since a file with a zero DV will not have any data in
* it. However, some platforms (notably Linux 2.6.22+) will keep a page
* full of zeroes around for an empty file. So play it safe and always
* flush pages. */
AFS_STATCNT(osi_FlushPages);
hset(origDV, avc->f.m.DataVersion);