From patchwork Mon Sep 11 21:06:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 9948121 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 E11A4603F4 for ; Mon, 11 Sep 2017 21:06:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBD2A28C83 for ; Mon, 11 Sep 2017 21:06:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5B5228D66; Mon, 11 Sep 2017 21:06:54 +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 AB99528C83 for ; Mon, 11 Sep 2017 21:06:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751286AbdIKVGt (ORCPT ); Mon, 11 Sep 2017 17:06:49 -0400 Received: from mail-wr0-f180.google.com ([209.85.128.180]:34967 "EHLO mail-wr0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750957AbdIKVGs (ORCPT ); Mon, 11 Sep 2017 17:06:48 -0400 Received: by mail-wr0-f180.google.com with SMTP id m18so17043361wrm.2 for ; Mon, 11 Sep 2017 14:06: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=cWM2+MO+8lgU6i9JvGwc4pQs49ewhWeXr4lhLBYzeuc=; b=ufIOsnHYW1NVHInSvDYLEckTCdUKAtXtzADTLfe6Q59cmmGOIt7Swt+bRsvtMKJywC mhcNTZegT1Qilx5gMxOwu5UMxG69UvbIwRPEnd0XVanIWanNPkgPCDD6xUINaEQ4CkGe Py8BLvsk95jOnO3nxMs6kWwbtwuAM8mayyLfRgNlllFuk1USN+Z4CEGdaTbDVofprcyu dW02BVm41WZ99rDFjiLX9zMcTI/35WmyUIYKb+L3BZ96x8HdnvBBjctzgzFoDEssZ6Ph gx1vjgOeNVMebQHlWxVAHaq9cIaaErTBO3R2CO0NHA3QKe+ia4JrnyX+QBOqlCJelNvp S36Q== 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=cWM2+MO+8lgU6i9JvGwc4pQs49ewhWeXr4lhLBYzeuc=; b=Sf7ZNiCVpcCH/BflGHWdN3++Gf1zGaQnZMxaJc87m39VQWQCQlz5+faY8jddPryydk HpwcO71EFDCgOzjsGvJje8D4d9CRQD8hYyt/WQF1yXvRkUavhAeVhm5YgytmCCu5Fjl0 9wGbzqp6e3wQenc6pdkCKGFh1eaw/Zhphikk3pzztUK97zMH2mBZQWHFt4DLdAqZHCPW sOvYiJ0kQUavzDkWO3frTsoCMKYEWB5Sx3/0W5KD+ThKr+dviVyOqKl/9YA2ThTxK2V+ GLg25Lu5Lj157BV2/Nn/b0FCZ3ITHUkDy1ICYBiRCpvNRvmnXNW3IGfb9xlVvfGOGj3u OsKQ== X-Gm-Message-State: AHPjjUi6/RyoN8DIVQgrBnSOv8x/Cqy0Xjw+W7s/0TLebWX+nvxhZEe/ L3dntpZLSDPfvF3t X-Google-Smtp-Source: ADKCNb6Rbib+yHoqEyOhxv1YF7nTVzT5Ne+eKbbLcpTIMrTMOM2s1emWC52w9gFSB5umui3lCUlLCQ== X-Received: by 10.223.164.153 with SMTP id g25mr10979859wrb.67.1505164007444; Mon, 11 Sep 2017 14:06:47 -0700 (PDT) Received: from titovetst-l.itransition.corp (nat3-minsk-pool-46-53-180-190.telecom.by. [46.53.180.190]) by smtp.gmail.com with ESMTPSA id v82sm14234198wmd.44.2017.09.11.14.06.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Sep 2017 14:06:46 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [PATCH v2] Btrfs: clear_dirty only on pages in compression range Date: Tue, 12 Sep 2017 00:06:37 +0300 Message-Id: <20170911210637.24510-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 BTRFS_MAX_UNCOMPRESSED (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 v1 -> v2: - Make that more obviously and more safeprone Signed-off-by: Timofey Titovets --- fs/btrfs/inode.c | 11 ++++++++--- 1 file changed, 8 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/inode.c b/fs/btrfs/inode.c index 17ad018da0a2..8229a000c538 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 current_end; u64 isize = i_size_read(inode); int ret = 0; struct page **pages = NULL; @@ -498,6 +499,10 @@ static noinline void compress_file_range(struct inode *inode, BTRFS_MAX_UNCOMPRESSED); num_bytes = ALIGN(end - start + 1, blocksize); num_bytes = max(blocksize, num_bytes); + if (end - start > BTRFS_MAX_UNCOMPRESSED) + current_end = start + BTRFS_MAX_UNCOMPRESSED; + else + current_end = end; total_in = 0; ret = 0; @@ -506,7 +511,7 @@ static noinline void compress_file_range(struct inode *inode, * inode has not been flagged as nocompress. This flag can * change at any time if we discover bad compression ratios. */ - if (inode_need_compress(inode, start, end)) { + if (inode_need_compress(inode, start, current_end)) { WARN_ON(pages); pages = kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS); if (!pages) { @@ -528,7 +533,7 @@ 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, current_end); redirty = 1; ret = btrfs_compress_pages(compress_type, inode->i_mapping, start, @@ -667,7 +672,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, current_end); add_async_extent(async_cow, start, end - start + 1, 0, NULL, 0, BTRFS_COMPRESS_NONE); *num_added += 1;