From patchwork Mon Oct 23 22:29:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Timofey Titovets X-Patchwork-Id: 10023309 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 B1FB7603D7 for ; Mon, 23 Oct 2017 22:30:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A310C269DA for ; Mon, 23 Oct 2017 22:30:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 96AB32891E; Mon, 23 Oct 2017 22:30:01 +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 22C60269DA for ; Mon, 23 Oct 2017 22:30:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751266AbdJWW36 (ORCPT ); Mon, 23 Oct 2017 18:29:58 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:47995 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751113AbdJWW35 (ORCPT ); Mon, 23 Oct 2017 18:29:57 -0400 Received: by mail-wm0-f66.google.com with SMTP id t69so12236782wmt.2 for ; Mon, 23 Oct 2017 15:29:57 -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=lW/wY+d1VrybVLL02/P8m5vBAHWyjiN6NS62KqMYrn8=; b=aswMnX8SW7y6h3nUwiPma7atGOc/kfMh+RasLoDTeBAp1YVTKA9yqLMi5Dphj5vnRz X4t12e72dvayq2nw9ED56yk4bVS0QanyNT1BeqGjHl19jVQePFyMX0jnMyYEemQDbaq4 eUoANZM6F0nUTFYO+f8P2xnwfXFp7HnMalDBUK62WvIkUfDA4QmR1GDB88rIrdbv+dqs lm924EHrqnRfnhhAjKcmHnNl/Dd/4Bzr+UYZt8jCc0ZKEk8fA9aID+SXah7otJEsF/wE Vdfu8fiCMoA9r27WGP0X46pGCxM/STLm49urQg3E+FXRR96A4nTcJiHDM+3QHrxrpMPz gQYQ== 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=lW/wY+d1VrybVLL02/P8m5vBAHWyjiN6NS62KqMYrn8=; b=XEZh1YAFHNOekR0B/lN/tSUoFttYgx8mAa44Rk9BCREiTiGWjyfkZWD4Zj6fvaFNel 1dGJXPSWC4Ch1XMW/bk4ov5e3JpjHJ7Us2rwMj5tBhwUY2nqk966TaKb/Dn86/ac9x+1 Ju/B2lqar9aRHYsZ4/ULGHCq9CogTNCChLNSM3Cur//2/qp/iRzIOwp7hkPiJMF6hOY2 GosTu482pX9J8cZB9JDfXRDzX9T47uEGcFBvAkOnlA73mFxjIJREOXaUe1MuVG8Wu2/e OkAGFYKQWOkB/sI5zsGHSDdWNLGOLjicKpQ5BYI5xpTRPEDEFZn6hQJTq6hNBR6JDrZT KDoQ== X-Gm-Message-State: AMCzsaU4Qt/4b1f3ra3ji+bln9+n/pIMGr8IJj6IW/fE8uu2aABF5mj3 0P6cInKUkFbSLyGuKDuV5XcWyA== X-Google-Smtp-Source: ABhQp+S8J3cUOQc6TrGFkKFEi4oKbANmaOdSLR7YQizTWXKcYrienuKY81dRj5Fo4CfyfdYX8TIUQw== X-Received: by 10.28.84.89 with SMTP id p25mr5860539wmi.112.1508797796192; Mon, 23 Oct 2017 15:29:56 -0700 (PDT) Received: from titovetst-l.lan (nat6-minsk-pool-46-53-208-190.telecom.by. [46.53.208.190]) by smtp.gmail.com with ESMTPSA id v28sm4176198wra.14.2017.10.23.15.29.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 15:29:55 -0700 (PDT) From: Timofey Titovets To: linux-btrfs@vger.kernel.org Cc: Timofey Titovets Subject: [PATCH v4] Btrfs: compress_file_range() change page dirty status once Date: Tue, 24 Oct 2017 01:29:48 +0300 Message-Id: <20171023222948.10648-1-nefelim4ag@gmail.com> X-Mailer: git-send-email 2.14.2 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 We need to call extent_range_clear_dirty_for_io() on compression range to prevent application from changing page content, while pages compressing. extent_range_clear_dirty_for_io() run on each loop iteration, "(end - start)" can be much (up to 1024 times) bigger then compression range (BTRFS_MAX_UNCOMPRESSED). That produce extra calls to page managment code. Fix that behaviour by call extent_range_clear_dirty_for_io() only once. v1 -> v2: - Make that more obviously and more safeprone v2 -> v3: - Rebased on: Btrfs: compress_file_range() remove dead variable num_bytes - Update change log - Add comments v3 -> v4: - Rebased on: kdave for-next - To avoid dirty bit clear/set behaviour change call clear_bit once, istead of per compression range Signed-off-by: Timofey Titovets Reviewed-by: David Sterba --- fs/btrfs/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 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/inode.c b/fs/btrfs/inode.c index b93fe05a39c7..5816dd3cb6e6 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -536,8 +536,10 @@ 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); - redirty = 1; + if (!redirty) { + extent_range_clear_dirty_for_io(inode, start, end); + redirty = 1; + } /* Compression level is applied here and only here */ ret = btrfs_compress_pages(