Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 22 Feb 2013 10:38:31 +0200
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        fs@freebsd.org
Subject:   Re: cleaning files beyond EOF
Message-ID:  <20130222083831.GK2598@kib.kiev.ua>
In-Reply-To: <20130217074832.GA2598@kib.kiev.ua>
References:  <20130217113031.N9271@besplex.bde.org> <20130217055528.GB2522@kib.kiev.ua> <20130217172928.C1900@besplex.bde.org> <20130217074832.GA2598@kib.kiev.ua>

next in thread | previous in thread | raw e-mail | index | archive | help

--qr7nXUVd9Lj/wfVJ
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Feb 17, 2013 at 09:48:32AM +0200, Konstantin Belousov wrote:
> But the ffs_getpages() might be indeed the culprit. It calls
> vm_page_zero_invalid(), which only has DEV_BSIZE granularity. I think
> that ffs_getpages() also should zero the after eof part of the last page
> of the file to fix your damage, since device read cannot read less than
> DEV_BSIZE.
>=20

Here is the updated patch, with the bug fixed which mis-calculated the
size for pmap_zero_page_area().

diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c
index 5c99d5b..08508a4 100644
--- a/sys/ufs/ffs/ffs_vnops.c
+++ b/sys/ufs/ffs/ffs_vnops.c
@@ -829,9 +829,9 @@ static int
 ffs_getpages(ap)
 	struct vop_getpages_args *ap;
 {
-	int i;
 	vm_page_t mreq;
-	int pcount;
+	uint64_t size;
+	int i, isize, pcount;
=20
 	pcount =3D round_page(ap->a_count) / PAGE_SIZE;
 	mreq =3D ap->a_m[ap->a_reqpage];
@@ -846,6 +846,11 @@ ffs_getpages(ap)
 	if (mreq->valid) {
 		if (mreq->valid !=3D VM_PAGE_BITS_ALL)
 			vm_page_zero_invalid(mreq, TRUE);
+		size =3D VTOI(ap->a_vp)->i_size;
+		if (mreq->pindex =3D=3D OFF_TO_IDX(size)) {
+			isize =3D size & PAGE_MASK;
+			pmap_zero_page_area(mreq, isize, PAGE_SIZE - isize);
+		}
 		for (i =3D 0; i < pcount; i++) {
 			if (i !=3D ap->a_reqpage) {
 				vm_page_lock(ap->a_m[i]);

--qr7nXUVd9Lj/wfVJ
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)

iQIcBAEBAgAGBQJRJy6GAAoJEJDCuSvBvK1BniAP/0OEx4cd92cKW7Q7yEvco7tZ
2TIgSAHHh9WHH2z1R3dWhhL0PleHd45JLEja5dVJ+NvTqcN8yrDGPwocHYIMSDaY
1ZsdQ47WI/fGar7z50j3CjG6lmLf3vlQunrY6sDPK4CNYgVzL/Zgvl8Mh+3kBNwF
OWyR9sXFdaAZlB3vhStpNmAR95HrQgwyop6BlYOwgKvl3y7Lk9w5vwNbOdJiA37t
aZm8ehSV/DMCFmot4N/Bo5iqRuX6Af7Jz4XsOuZ6IylAY29wAgbgzCGJ+ZkMFKYk
SqhNs5UfPpTawY6YPRCeUchqXh+uFZoGSIBheNx061jUvMeMnf2DvoQSdHPjh93t
+bXHvfXC95d0orAf+y3TsUamL/iMx8k3HnlKf4QYP7j2hDiRqIxtAV8+ueukkwlW
WVenDp2fIe9MH+EMkgetOjjZlopKNU5sfaeJDEaDo5ybFKm6EZad9YEapqGHSpeI
TgWtgOX3ETkc4Cn+U+xtBoUNEQv1YQD6TQ7gfMHsI7Y1rYyplX0PgZr0Sj7cRvJc
vKYtfWNTqiwlun02a63FEChiMdOwmZVan5XoaScjV4tcORef3+173R4HE41JRcPH
b8HNFWGdWTyp/9Jd7iw3FeaqJ8ojcsDQXSo+tbDGyIr5Q6VAm1abE1UfEVNl8Wyr
oQnnJR6DU8tNeEi59Urx
=q/e/
-----END PGP SIGNATURE-----

--qr7nXUVd9Lj/wfVJ--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130222083831.GK2598>