From patchwork Fri Aug 25 08:47:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9921431 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 1A4486022E for ; Fri, 25 Aug 2017 08:48:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 08E9226E76 for ; Fri, 25 Aug 2017 08:48:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F12CB26E96; Fri, 25 Aug 2017 08:48:04 +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 90C9A26E76 for ; Fri, 25 Aug 2017 08:48:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754957AbdHYIsB (ORCPT ); Fri, 25 Aug 2017 04:48:01 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33720 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754851AbdHYIsA (ORCPT ); Fri, 25 Aug 2017 04:48:00 -0400 Received: by mail-lf0-f65.google.com with SMTP id y15so1068154lfd.0 for ; Fri, 25 Aug 2017 01:47:59 -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; bh=RKlek1jSt+Emg8dfJ6yGHAkdAksnpa+k/j8CkxTsh+Q=; b=Q+/AOnn09qtQOWD2XRUoXZiy1LsVIN1Q3boL3eOgzJjUsmt2mWYi83wjKv9OFXamMP wz5wbTMPlY+W51DMHRrVpTzWoabAq/cLUj8uMcZhsmYHga8kTP1DtMismKv4GzqKI60K OcRxc3o0F6eAJ8Ijy1lWnGxmohH9jpM534DAAHPw1IdSxJ30PxSK+DrKC7DI7Aa3MGnO JurWrhn2vGW5bw1MQZcgE5Xhf2DfP+EbkxNaPr8TY5Ve1sydUioty0kdc/0npS+AbOOB uAUx8t2yKea+eSWhbuTDsowKJu4NxSVd4oMHkyWBOLiWzVWfrSzW9iaz9rUh0Z0sNjbq gQNA== 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; bh=RKlek1jSt+Emg8dfJ6yGHAkdAksnpa+k/j8CkxTsh+Q=; b=JPXZs0B3miiMhAbfD8s6aUitj4IN0VzU2sgl1H0N8+MjsB1sRprpPJ2iBBmkRfNBwQ XXNO+XSPF7vtiwYoEmbI21jlvHYvhUmR9Pzrh+If8zlM8v0YIV2Ft38JK75MYSxiMjFq cLlGGOsP5TW5QjW0dnYI+WAPZJDWxfho5vUJUsAjMhpkwRs3Wrh/IwPeJfjzn6D5PF3Z r7BZacePCfX2xVmss9720HMgXdDhEkGXnn8p5hePm08MdR6iYImd6zxrI2N0YMwIRL74 f71bfPdgo9EqGmVKNd0NKSeBn5B0JInz8aVbC8qBz5zmZfClIyq7XmeOisthmnhB8pbs Kv9g== X-Gm-Message-State: AHYfb5jfHSW5l/48Z+CmiG5P7z1MJ6qm7drzqy1jjWd7/NJ76Kktj+sN GqPEVvxm01YsKJBS X-Received: by 10.25.33.133 with SMTP id h127mr2929640lfh.68.1503650878248; Fri, 25 Aug 2017 01:47:58 -0700 (PDT) Received: from titovetst-l.itransition.corp ([93.170.143.179]) by smtp.gmail.com with ESMTPSA id o71sm1013557lfi.54.2017.08.25.01.47.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 01:47:57 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [PATCH v2] Btrfs: handle unaligned tail of data ranges more efficient Date: Fri, 25 Aug 2017 11:47:44 +0300 Message-Id: <20170825084744.8075-1-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.14.1 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.1 -- 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 0aff9b278c19..bf6195fa9425 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1361,7 +1361,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); @@ -1376,7 +1380,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 c73f919491a0..444971d8ef2d 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10710,7 +10710,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);