From patchwork Tue Oct 27 09:39:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Rajendra X-Patchwork-Id: 7495401 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 D34419F399 for ; Tue, 27 Oct 2015 09:41:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 19C4C20877 for ; Tue, 27 Oct 2015 09:41:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 12DF72087B for ; Tue, 27 Oct 2015 09:41:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932135AbbJ0Jls (ORCPT ); Tue, 27 Oct 2015 05:41:48 -0400 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:49046 "EHLO e23smtp09.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932093AbbJ0Jlq (ORCPT ); Tue, 27 Oct 2015 05:41:46 -0400 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 27 Oct 2015 19:41:44 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp09.au.ibm.com (202.81.31.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 27 Oct 2015 19:41:42 +1000 X-Helo: d23dlp01.au.ibm.com X-MailFrom: chandan@linux.vnet.ibm.com X-RcptTo: linux-btrfs@vger.kernel.org Received: from d23relay06.au.ibm.com (d23relay06.au.ibm.com [9.185.63.219]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 468F52CE8054 for ; Tue, 27 Oct 2015 20:41:42 +1100 (EST) Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t9R9fSuJ25034754 for ; Tue, 27 Oct 2015 20:41:36 +1100 Received: from d23av04.au.ibm.com (localhost [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t9R9f8pK019450 for ; Tue, 27 Oct 2015 20:41:09 +1100 Received: from localhost.in.ibm.com ([9.124.35.170]) by d23av04.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t9R9eWj8017951; Tue, 27 Oct 2015 20:41:06 +1100 From: Chandan Rajendra To: linux-btrfs@vger.kernel.org Cc: Chandan Rajendra , clm@fb.com, jbacik@fb.com, bo.li.liu@oracle.com, dsterba@suse.cz, quwenruo@cn.fujitsu.com, chandan@mykolab.com Subject: [PATCH V7 13/13] Btrfs: Return valid delalloc range when the page does not have PG_Dirty flag set or has been invalidated Date: Tue, 27 Oct 2015 15:09:46 +0530 Message-Id: <1445938786-12488-14-git-send-email-chandan@linux.vnet.ibm.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1445938786-12488-1-git-send-email-chandan@linux.vnet.ibm.com> References: <1445938786-12488-1-git-send-email-chandan@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15102709-0033-0000-0000-0000024DB6BA 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, 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(). Reviewed-by: Josef Bacik Signed-off-by: Chandan Rajendra --- 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 d093643..9c5891a 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1794,6 +1794,8 @@ again: goto again; } else { found = 0; + *start = delalloc_start; + *end = delalloc_end; goto out_failed; } }