From patchwork Thu Aug 24 21:12:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9920977 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 3A86860349 for ; Thu, 24 Aug 2017 21:13:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E50428C7D for ; Thu, 24 Aug 2017 21:13:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2344128C7F; Thu, 24 Aug 2017 21:13:09 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 C777228C7D for ; Thu, 24 Aug 2017 21:13:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753700AbdHXVNG (ORCPT ); Thu, 24 Aug 2017 17:13:06 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:33312 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753411AbdHXVNF (ORCPT ); Thu, 24 Aug 2017 17:13:05 -0400 Received: by mail-wm0-f67.google.com with SMTP id e67so685503wmd.0 for ; Thu, 24 Aug 2017 14:13:05 -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=mhoikzC040rTI+Z8CphLjcU3bo3eiVujNuY/k7Qcx7k=; b=lLy4J1ChS7ZQD4VlvxG7DXVuiYlM4xK5+Ek+sewnT+PTOaAfuMYrKaHDqH45xi0PiY GM1GV60AYmxiCr8bYJMO1+7NghHm+EgyDZY1QqYWD5AJQCpZqmUezKkP1ePj7xTabdfe kFMqWL8EPYNGEx6BxqvNzS8NN9znPLK9rDzh846LXkCwKj3Sjwq9UAbJOnjlmToNhmNi 7c5iJOOgx7CNcGQW3JnrAMjaueN8YbGFziZ6HA1pCP7PhCFfSteFrj4nlO+njCXOkibj oj2CiM9toM3+uHnwmmVrB911ErUS06t6OAPV+q7iEgmaoKN2lBcpwrTYA49YdohfEOMP NcHw== 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=mhoikzC040rTI+Z8CphLjcU3bo3eiVujNuY/k7Qcx7k=; b=gtLJfmOb8MoYvkxVPT9ailBONIoAon1O6TgFAgL/YgcBbSg8qIFH/Tg3QhYMnS/Fhe gMgklJRjsXicKVSjPEqve8W7UEYoZwCeOuh/5YNc7x91MuZp9Kl2ZgjMPj0ElwlsIGNw 7d2hcQZaKK9w2mqO72t3ZJjLw8cX3KkYygsIiTZ5PCFdtAKGZi5EfKfNY3lt8ALs5QoX yk+tqShtjH8nlBWecyr+rIv47R77n+z51H57ImfDivyWJ3ZhTPWI4sUHEM1w+opgO12X IVFIokgou7odYLjT42XK61UfDi6FZHcMkz9NIvNCswaHCLVl72gt0I+iD7Y0bg5U5vx9 DZyQ== X-Gm-Message-State: AHYfb5gL7D/hSNZ9lL9NFfIRKU+cVDkjsT3HHSFxGIx+nLq+6YDc8BIB ySu1bLJAuLx43eSr X-Received: by 10.28.113.205 with SMTP id d74mr47263wmi.134.1503609183941; Thu, 24 Aug 2017 14:13:03 -0700 (PDT) Received: from localhost.localdomain (nat3-minsk-pool-46-53-180-190.telecom.by. [46.53.180.190]) by smtp.gmail.com with ESMTPSA id a70sm4547290wma.32.2017.08.24.14.13.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Aug 2017 14:13:02 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [RFC PATCH] Btrfs: handle unaligned tail of data ranges more efficient Date: Fri, 25 Aug 2017 00:12:35 +0300 Message-Id: <20170824211235.23152-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 98d85d2009f8..ccb66c1485e2 100644 --- a/fs/btrfs/extent_io.c +++ b/fs/btrfs/extent_io.c @@ -1360,7 +1360,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 (end%PAGE_SIZE > 0) + 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); @@ -1375,7 +1379,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 (end%PAGE_SIZE > 0) + 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 cb7779b08aaf..79feaea0fede 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -10745,7 +10745,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 (end%PAGE_SIZE > 0) + 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);