From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44D2BC433DF for ; Mon, 24 Aug 2020 08:00:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2944B206F0 for ; Mon, 24 Aug 2020 08:00:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726000AbgHXIAF (ORCPT ); Mon, 24 Aug 2020 04:00:05 -0400 Received: from mx2.suse.de ([195.135.220.15]:37990 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725947AbgHXIAE (ORCPT ); Mon, 24 Aug 2020 04:00:04 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 748FCAFE1 for ; Mon, 24 Aug 2020 08:00:33 +0000 (UTC) From: Qu Wenruo To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 0/3] btrfs: basic refactor of btrfs_buffered_write() Date: Mon, 24 Aug 2020 15:59:56 +0800 Message-Id: <20200824075959.85212-1-wqu@suse.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org This patchset will refactor btrfs_buffered_write() by: - Extra the nrptrs calculation into one function The main concern here is the batch number of pages. Originally there is a max(nrptrs, 8), which looks so incorrect that my eyes change it to min(nrptrs, 8) automatically. This time we kill that max(nrptrr, 8), and replace it to a fixed size up limit (64K), which should bring the same performance for different page sized. The limit can be changed if the 64K is not large enough for certain buffered write. - Refactor the main loop into process_one_batch() No functional change, just plain refactor. - Remove the again: tag by integrating page and extent locking The new function lock_pages_and_extent() will handle the retry so we don't need the tag any more in the main loop. Changelog: v2: - Fix a bug that ENOSPC error is not returned to user space It's caused by a missing assignment for (copied < 0) branch in the 2nd patch. Qu Wenruo (3): btrfs: change how we calculate the nrptrs for btrfs_buffered_write() btrfs: refactor btrfs_buffered_write() into process_one_batch() btrfs: remove the again: tag in process_one_batch() fs/btrfs/file.c | 570 +++++++++++++++++++++++++----------------------- 1 file changed, 303 insertions(+), 267 deletions(-) -- 2.28.0