From patchwork Wed Aug 23 17:23:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9917953 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 98F48602CB for ; Wed, 23 Aug 2017 17:24:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B074288D3 for ; Wed, 23 Aug 2017 17:24:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68304288D7; Wed, 23 Aug 2017 17:24:33 +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 D581C288B1 for ; Wed, 23 Aug 2017 17:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932533AbdHWRYH (ORCPT ); Wed, 23 Aug 2017 13:24:07 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:37062 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932287AbdHWRXt (ORCPT ); Wed, 23 Aug 2017 13:23:49 -0400 Received: by mail-wr0-f194.google.com with SMTP id 72so84612wrc.4 for ; Wed, 23 Aug 2017 10:23:48 -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=VeotkNASQ0PAj/i5k5Rcg7FPl2Q00PxSxWfUUpYeozw=; b=TlGT1MUbiRrSI0K/It18x0FVc1dX6ic5dGjdUy500i9UDff6QqyCgJ5G5Iq0oZ1NRO JcqMtoS+10wF2G1mIVaLGVVHODvkq3DH+hPGKDyVASABuLmTGnTsLIwt22fcqXZEvWE1 l6ZOcnIVe6yvp0bq+KLD85P3p1pizYCP6YZ0Q1c3lwU+J4NcW+j5E3PSqcTw7BrAnE5n IdFu3tQ0e3YefGOIuc1kwMXRCP9dbJq7lvU5/lkBxoNiAkzFuJfO0Se2gEu6/rMP588d rhEs1rPUeh8TonvKrlplbtj2HbOrrUYBDiiNHDm7VHaBFY84DX0KS7WdlRlkjEh7RfL0 ITGg== 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=VeotkNASQ0PAj/i5k5Rcg7FPl2Q00PxSxWfUUpYeozw=; b=W7eOk+4FzxA7i3xeihhRz3hGCJjyk6C6F8M1pFG3kEa31lfPuasOZZ1p4qpYB1ndUI bd9y2/hgnEt3gt+ohH42s+3WLXq971nMqeM2L42cDxbmS8V/PG4FtcN0frApIeQyrd+f TXpQtya7pxq2KmfBb3IKZJFkbZUaAhHvljXk1euuOc2kqnh83wJuPYEEza1Clhr3GxL/ YyciZpZ2zry3DowATle88Za1czsYslYYT6sjPiiHYZ7I1OUuHtDEX6NsnvYLiyDYFuO1 foa7YogyDeFToWXjvxf5VI9wwlxRrzrFJIdQ5D/SIz9rmrNpilsudvvqqhMCTwtiWbhH E6kA== X-Gm-Message-State: AHYfb5h+U8lFBEVwFcD5ThlPhfeiyoCNScJ1Hh7pw8i5+HseXzAzME6f tpA3gkxHviDZXt5+ X-Received: by 10.223.199.211 with SMTP id y19mr2075499wrg.111.1503509027956; Wed, 23 Aug 2017 10:23:47 -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 h190sm2593456wmd.4.2017.08.23.10.23.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 10:23:47 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [RFC PATCH] Btrfs: clear_dirty only on pages in compression range Date: Wed, 23 Aug 2017 20:23:29 +0300 Message-Id: <20170823172329.5794-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 compressing data range code touch dirty page status on whole range on each 128kb iteration, that's costs time As we care only about page status in range that will be compressed in current iteration, let's touch dirty status only for actual compression range Signed-off-by: Timofey Titovets --- fs/btrfs/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 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/inode.c b/fs/btrfs/inode.c index 2b92478fe7ec..cb7779b08aaf 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -449,6 +449,7 @@ static noinline void compress_file_range(struct inode *inode, u64 num_bytes; u64 blocksize = fs_info->sectorsize; u64 actual_end; + u64 compress_range_end; u64 isize = i_size_read(inode); int ret = 0; struct page **pages = NULL; @@ -500,6 +501,8 @@ static noinline void compress_file_range(struct inode *inode, num_bytes = max(blocksize, num_bytes); total_in = 0; ret = 0; + compress_range_end = start + min_t(u64, BTRFS_MAX_UNCOMPRESSED, + end - start); /* * we do compression for mount -o compress and when the @@ -528,7 +531,8 @@ static noinline void compress_file_range(struct inode *inode, * If the compression fails for any reason, we set the pages * dirty again later on. */ - extent_range_clear_dirty_for_io(inode, start, end); + extent_range_clear_dirty_for_io(inode, start, + compress_range_end); redirty = 1; ret = btrfs_compress_pages(compress_type, inode->i_mapping, start, @@ -667,7 +671,7 @@ static noinline void compress_file_range(struct inode *inode, /* unlocked later on in the async handlers */ if (redirty) - extent_range_redirty_for_io(inode, start, end); + extent_range_redirty_for_io(inode, start, compress_range_end); add_async_extent(async_cow, start, end - start + 1, 0, NULL, 0, BTRFS_COMPRESS_NONE); *num_added += 1;