From patchwork Tue Oct 3 15:06:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9983035 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0526460375 for ; Tue, 3 Oct 2017 15:07:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB73228742 for ; Tue, 3 Oct 2017 15:07:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E058F28801; Tue, 3 Oct 2017 15:07:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82E5628742 for ; Tue, 3 Oct 2017 15:07:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752198AbdJCPHU (ORCPT ); Tue, 3 Oct 2017 11:07:20 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:45706 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752110AbdJCPHJ (ORCPT ); Tue, 3 Oct 2017 11:07:09 -0400 Received: by mail-lf0-f68.google.com with SMTP id d17so10092508lfe.2 for ; Tue, 03 Oct 2017 08:07:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8y518J+q0HoMehjaezfmJG8PMjUVegWkOsb0dXeqTCo=; b=ji3XUub98km750OnLL89sia5W47wK0pAYLvpD4jhRHJ1nAfFm/OmFh3epZjiIHlBUL 6MxM78hU8NK+usfcLi63z6BfdEwPEoYHQExqOh/Er8+R967I5uTWaA4xzq2yj3mq/9ON Z7zONojVQI5eQSBa6nH/2f9eHQsGW4SaOjyM9PZT4GYDk7Slb8h3D4mSq+XCW54ydOFl bGrT8nHhdd2tz4lyXtqLnUualmcxcK+OM3GxJqJfz+q8OC6jlsZcyjFxe2pVuIG90Dj7 ES33kKQiFdUZ6t4HurvwDa2S35Jbnr+S5/UKnkcW8nvnA8x7bTHhaqEoOjfE/dIxr0px Dkrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8y518J+q0HoMehjaezfmJG8PMjUVegWkOsb0dXeqTCo=; b=XMFyT/Jv2UC2m8hiWmBOPo++XzmA9KyzWKOCE3QrapSGgrVZ80Jt0ZBJ/e5cz+ATOC xrw+Wr6y6Gf0WvxK9qIEv2rzaImmfJgK2rAY1oywUzpveOufODw3t8dc13Kn4f5+BRR6 IS5Yylzv+aIH4RcuehDuRpJsnUkUwqJN/8sO/CbP/eaqZWXB6FhkwhHVyb1Zg/85IdqE OIXdqVLinBM/NPsdM12MxI4ioHZwV+oMLMpRim4cHEAhVm/K95YvxlWzZxFSES73f+rI SHXaZXTK5f7guM5tUDAMUEgWeHEvs99km314ylczE/Di0e8GTecMu1ZomptXVVbHiMa1 4rOg== X-Gm-Message-State: AMCzsaV66kp/p96H5/3GHZU0heaJyP+b1sCK8WKXXpdS+0T/B1grdmSp hNQStIDyTMPBLkG+/fFf6txhAA== X-Google-Smtp-Source: AOwi7QATQ0BWXU0aa/nSOTxaHtfHfPBzIUJX4DiDoyGsXzknsqrXLHHRI+NUAbvEk8h63sFqaHf1Vg== X-Received: by 10.25.157.209 with SMTP id g200mr5408066lfe.195.1507043227106; Tue, 03 Oct 2017 08:07:07 -0700 (PDT) Received: from titovetst-l.itransition.corp ([93.171.6.182]) by smtp.gmail.com with ESMTPSA id t20sm2938498ljb.91.2017.10.03.08.07.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Oct 2017 08:07:06 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [PATCH 3/4] Btrfs: handle unaligned tail of data ranges more efficient Date: Tue, 3 Oct 2017 18:06:03 +0300 Message-Id: <20171003150604.19596-4-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171003150604.19596-1-nefelim4ag@gmail.com> References: <20171003150604.19596-1-nefelim4ag@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP At now while switch page bits in data ranges we always hande +1 page, for cover case where end of data range is not page aligned Let's handle that case more obvious and efficient Check end aligment directly and touch +1 page only then needed Signed-off-by: Timofey Titovets --- fs/btrfs/extent_io.c | 12 ++++++++++-- fs/btrfs/inode.c | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) -- 2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c index 0538bf85adc3..131b7d1df9f7 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1359,7 +1359,11 @@ void extent_range_clear_dirty_for_io(struct inode *inode, u64 start, u64 end) unsigned long end_index = end >> PAGE_SHIFT; struct page *page; - while (index <= end_index) { + /* Don't miss unaligned end */ + if (!IS_ALIGNED(end, PAGE_SIZE)) + end_index++; + + while (index < end_index) { page = find_get_page(inode->i_mapping, index); BUG_ON(!page); /* Pages should be in the extent_io_tree */ clear_page_dirty_for_io(page); @@ -1374,7 +1378,11 @@ void extent_range_redirty_for_io(struct inode *inode, u64 start, u64 end) unsigned long end_index = end >> PAGE_SHIFT; struct page *page; - while (index <= end_index) { + /* Don't miss unaligned end */ + if (!IS_ALIGNED(end, PAGE_SIZE)) + end_index++; + + while (index < end_index) { page = find_get_page(inode->i_mapping, index); BUG_ON(!page); /* Pages should be in the extent_io_tree */ __set_page_dirty_nobuffers(page); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b6e81bd650ea..b4974d969f67 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10799,7 +10799,11 @@ void btrfs_set_range_writeback(void *private_data, u64 start, u64 end) unsigned long end_index = end >> PAGE_SHIFT; struct page *page; - while (index <= end_index) { + /* Don't miss unaligned end */ + if (!IS_ALIGNED(end, PAGE_SIZE)) + end_index++; + + while (index < end_index) { page = find_get_page(inode->i_mapping, index); ASSERT(page); /* Pages should be in the extent_io_tree */ set_page_writeback(page);