From owner-freebsd-fs@FreeBSD.ORG Fri Feb 22 08:38:39 2013 Return-Path: Delivered-To: fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 27471153 for ; Fri, 22 Feb 2013 08:38:39 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id AB456F01 for ; Fri, 22 Feb 2013 08:38:38 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.6/8.14.6) with ESMTP id r1M8cV8b062737; Fri, 22 Feb 2013 10:38:31 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.7.4 kib.kiev.ua r1M8cV8b062737 Received: (from kostik@localhost) by tom.home (8.14.6/8.14.6/Submit) id r1M8cVrg062736; Fri, 22 Feb 2013 10:38:31 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 22 Feb 2013 10:38:31 +0200 From: Konstantin Belousov To: Bruce Evans Subject: Re: cleaning files beyond EOF Message-ID: <20130222083831.GK2598@kib.kiev.ua> References: <20130217113031.N9271@besplex.bde.org> <20130217055528.GB2522@kib.kiev.ua> <20130217172928.C1900@besplex.bde.org> <20130217074832.GA2598@kib.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="qr7nXUVd9Lj/wfVJ" Content-Disposition: inline In-Reply-To: <20130217074832.GA2598@kib.kiev.ua> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home Cc: fs@freebsd.org X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Feb 2013 08:38:39 -0000 --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--