From patchwork Tue Jun 8 14:24:04 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 104967 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o58ERGDr015742 for ; Tue, 8 Jun 2010 14:27:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755384Ab0FHO0o (ORCPT ); Tue, 8 Jun 2010 10:26:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31312 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755320Ab0FHO0n (ORCPT ); Tue, 8 Jun 2010 10:26:43 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o58EQhmr010252 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 8 Jun 2010 10:26:43 -0400 Received: from localhost.localdomain (test1244.test.redhat.com [10.10.10.244]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o58EQfRp026702; Tue, 8 Jun 2010 10:26:41 -0400 From: Josef Bacik To: linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] fs: make sure to invalidate pages if we fall back on buffered reads Date: Tue, 8 Jun 2010 10:24:04 -0400 Message-Id: <1276007044-17715-1-git-send-email-josef@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Tue, 08 Jun 2010 14:27:16 +0000 (UTC) diff --git a/mm/filemap.c b/mm/filemap.c index 829ac9c..ca5aba9 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1266,6 +1266,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, unsigned long seg = 0; size_t count; loff_t *ppos = &iocb->ki_pos; + bool invalidate = false; count = 0; retval = generic_segment_checks(iov, &nr_segs, &count, VERIFY_WRITE); @@ -1291,7 +1292,8 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, iov, pos, nr_segs); } if (retval > 0) { - *ppos = pos + retval; + pos += retval; + *ppos = pos; count -= retval; } @@ -1307,6 +1309,7 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, file_accessed(filp); goto out; } + invalidate = true; } } @@ -1343,6 +1346,10 @@ generic_file_aio_read(struct kiocb *iocb, const struct iovec *iov, if (desc.count > 0) break; } + if (invalidate && retval > 0) + invalidate_mapping_pages(filp->f_mapping, + pos >> PAGE_CACHE_SHIFT, + (*ppos - 1) >> PAGE_CACHE_SHIFT); out: return retval; }