From patchwork Wed Sep 30 10:28:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 7296011 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 6DB5B9F32B for ; Wed, 30 Sep 2015 10:30:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 97BCF20612 for ; Wed, 30 Sep 2015 10:30:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9ABF320618 for ; Wed, 30 Sep 2015 10:30:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932595AbbI3KaU (ORCPT ); Wed, 30 Sep 2015 06:30:20 -0400 Received: from e23smtp02.au.ibm.com ([202.81.31.144]:34030 "EHLO e23smtp02.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932479AbbI3KaO (ORCPT ); Wed, 30 Sep 2015 06:30:14 -0400 Received: from /spool/local by e23smtp02.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 30 Sep 2015 20:30:12 +1000 Received: from d23dlp03.au.ibm.com (202.81.31.214) by e23smtp02.au.ibm.com (202.81.31.208) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 30 Sep 2015 20:30:09 +1000 X-Helo: d23dlp03.au.ibm.com X-MailFrom: chandan@linux.vnet.ibm.com X-RcptTo: linux-btrfs@vger.kernel.org Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp03.au.ibm.com (Postfix) with ESMTP id 60357357804F for ; Wed, 30 Sep 2015 20:30:09 +1000 (EST) Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t8UAU1Fm49217594 for ; Wed, 30 Sep 2015 20:30:09 +1000 Received: from d23av02.au.ibm.com (localhost [127.0.0.1]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t8UATabJ024096 for ; Wed, 30 Sep 2015 20:29:37 +1000 Received: from localhost.in.ibm.com ([9.124.35.170]) by d23av02.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t8UAStB9022921; Wed, 30 Sep 2015 20:29:33 +1000 From: Chandan Rajendra To: linux-btrfs@vger.kernel.org Cc: Chandan Rajendra , jbacik@fb.com, clm@fb.com, bo.li.liu@oracle.com, dsterba@suse.cz, quwenruo@cn.fujitsu.com, chandan@mykolab.com Subject: [PATCH V5 13/13] Btrfs: Return valid delalloc range when the page does not have PG_Dirty flag set or has been invalidated Date: Wed, 30 Sep 2015 15:58:32 +0530 Message-Id: <1443608912-31667-14-git-send-email-chandan@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1443608912-31667-1-git-send-email-chandan@linux.vnet.ibm.com> References: <1443608912-31667-1-git-send-email-chandan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15093010-0005-0000-0000-0000028775C7 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 The following issue was observed when running generic/095 test on subpagesize-blocksize patchset. Assume that we are trying to write a dirty page that is mapping file offset range [159744, 163839]. writepage_delalloc() find_lock_delalloc_range(*start = 159744, *end = 0) find_delalloc_range() Returns range [X, Y] where (X > 163839) lock_delalloc_pages() One of the pages in range [X, Y] has dirty flag cleared; Loop once more restricting the delalloc range to span only PAGE_CACHE_SIZE bytes; find_delalloc_range() Returns range [356352, 360447]; lock_delalloc_pages() The page [356352, 360447] has dirty flag cleared; Returns with *start = 159744 and *end = 0; *start = *end + 1; find_lock_delalloc_range(*start = 1, *end = 0) Finds and returns delalloc range [1, 12288]; cow_file_range() Clears delalloc range [1, 12288] Create ordered extent for range [1, 12288] The ordered extent thus created above breaks the rule that extents have to be aligned to the filesystem's block size. In cases where lock_delalloc_pages() fails (either due to PG_dirty flag being cleared or the page no longer being a member of the inode's page cache), this patch sets and returns the delalloc range that was found by find_delalloc_range(). Signed-off-by: Chandan Rajendra Reviewed-by: Josef Bacik --- fs/btrfs/extent_io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 0ee486a..3912d1f 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1731,6 +1731,8 @@ again: goto again; } else { found = 0; + *start = delalloc_start; + *end = delalloc_end; goto out_failed; } }