From patchwork Sun Apr 17 12:24:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 8862741 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E45159F1D3 for ; Sun, 17 Apr 2016 12:25:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1384A201BC for ; Sun, 17 Apr 2016 12:25:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 31DDF201B4 for ; Sun, 17 Apr 2016 12:25:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752812AbcDQMZJ (ORCPT ); Sun, 17 Apr 2016 08:25:09 -0400 Received: from e28smtp07.in.ibm.com ([125.16.236.7]:55621 "EHLO e28smtp07.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751542AbcDQMZH (ORCPT ); Sun, 17 Apr 2016 08:25:07 -0400 Received: from localhost by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 17 Apr 2016 17:55:04 +0530 Received: from d28relay05.in.ibm.com (9.184.220.62) by e28smtp07.in.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 17 Apr 2016 17:55:01 +0530 X-IBM-Helo: d28relay05.in.ibm.com X-IBM-MailFrom: chandan@linux.vnet.ibm.com X-IBM-RcptTo: linux-btrfs@vger.kernel.org Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay05.in.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u3HCOwxq20120046 for ; Sun, 17 Apr 2016 17:54:59 +0530 Received: from d28av05.in.ibm.com (localhost [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id u3HCOx3h009610 for ; Sun, 17 Apr 2016 17:55:00 +0530 Received: from localhost.in.ibm.com ([9.77.205.82]) by d28av05.in.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id u3HCOwhj009595; Sun, 17 Apr 2016 17:54:58 +0530 From: Chandan Rajendra To: linux-btrfs@vger.kernel.org Cc: Chandan Rajendra , dsterba@suse.cz, clm@fb.com, jbacik@fb.com, aneesh.kumar@linux.vnet.ibm.com, chandan@mykolab.com Subject: [PATCH] Btrfs: subpage-blocksize: Make sure delalloc range intersects with the locked page's range Date: Sun, 17 Apr 2016 17:54:57 +0530 Message-Id: <1460895897-3608-1-git-send-email-chandan@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1460641107-13834-4-git-send-email-chandan@linux.vnet.ibm.com> References: <1460641107-13834-4-git-send-email-chandan@linux.vnet.ibm.com> X-TM-AS-MML: disable x-cbid: 16041712-0025-0000-0000-00000B6E1228 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP find_delalloc_range indirectly depends on EXTENT_UPTODDATE to make sure that the delalloc range returned intersects with the file range mapped by the page. Since we now track "uptodate" state in a per-page bitmap (i.e. in btrfs_page_private->bstate), this commit makes an explicit check to make sure that the delalloc range starts from within the file range mapped by the page. Signed-off-by: Chandan Rajendra --- fs/btrfs/extent_io.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 9b6c8e0..790ad09 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1568,6 +1568,7 @@ out: * 1 is returned if we find something, 0 if nothing was in the tree */ static noinline u64 find_delalloc_range(struct extent_io_tree *tree, + struct page *locked_page, u64 *start, u64 *end, u64 max_bytes, struct extent_state **cached_state) { @@ -1576,6 +1577,9 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree, u64 cur_start = *start; u64 found = 0; u64 total_bytes = 0; + u64 page_end; + + page_end = page_offset(locked_page) + PAGE_SIZE - 1; spin_lock(&tree->lock); @@ -1596,7 +1600,8 @@ static noinline u64 find_delalloc_range(struct extent_io_tree *tree, (state->state & EXTENT_BOUNDARY))) { goto out; } - if (!(state->state & EXTENT_DELALLOC)) { + if (!(state->state & EXTENT_DELALLOC) + || (page_end < state->start)) { if (!found) *end = state->end; goto out; @@ -1734,8 +1739,9 @@ again: /* step one, find a bunch of delalloc bytes starting at start */ delalloc_start = *start; delalloc_end = 0; - found = find_delalloc_range(tree, &delalloc_start, &delalloc_end, - max_bytes, &cached_state); + found = find_delalloc_range(tree, locked_page, + &delalloc_start, &delalloc_end, + max_bytes, &cached_state); if (!found || delalloc_end <= *start) { *start = delalloc_start; *end = delalloc_end;