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=-9.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 7F0ABC2D0DB for ; Wed, 29 Jan 2020 23:50:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 492F8206F0 for ; Wed, 29 Jan 2020 23:50:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="GglJTdfQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727185AbgA2Xub (ORCPT ); Wed, 29 Jan 2020 18:50:31 -0500 Received: from mail-qv1-f67.google.com ([209.85.219.67]:43621 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726401AbgA2Xub (ORCPT ); Wed, 29 Jan 2020 18:50:31 -0500 Received: by mail-qv1-f67.google.com with SMTP id p2so602381qvo.10 for ; Wed, 29 Jan 2020 15:50:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=5jotIngQ9P7DGQelZBd+RoQdo1J4+NpCYo/uF3XtR90=; b=GglJTdfQulbFY9HlR17Y2oTFBYXUTbUtMgEcoAt35vNVfYY1Ub4nu+ZAM1lbvG3QXk nriftyTKzmY5V+HrknLozr/IR2b5GfUu6u54Li0io+t9nT3TNwqaDph8eKjBDS3ciIQS gPsSuKA99JFVLIK5O3iGBHidoH6EwN0O4X3nHP/3INHOLj3il2iWU5mJldgWXRQLyt4r /sxTfNbmtl4quLD+xRITSzSOsN+ChWoosOMtXZJJoEVi0XCKweWMWH/vzyP/fHJLpWdI EKUqGUsOAabkKIo8B5NAS5Bk0MSaXHEycD4Js+UH0f2impskQ1fqO9FqTNzhCONA66W4 wjFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5jotIngQ9P7DGQelZBd+RoQdo1J4+NpCYo/uF3XtR90=; b=XPuOkh980SarK0Cj++c23tzoXeBANcknFt6apChpiSffR8ZxcSaegPcFvTOZFwB0ji aNKwN+e8/frSbbjQdJDioZ4mi+rlwpyiKPDePshx8O8KS8RF9Yj7irJUko9SEXd5IorD 06LBQQ553hba+1dh/BkwS+1K+u//C2PEHYx9h9pDKaizA48JydPfTmGxw84p8JMdNahm /zUF0xtSD8BMZIethZZnGPCui1+zP8vW7jlgltdfmcJX88qR/PS8DJOl/gDCRK4SDU1a QBMD15cTEzoEx1UzCxaqWywe2dBmWSUpzzVeNWaPtQN90z3tPDj1B/yep4yjZjTGov86 ZyrQ== X-Gm-Message-State: APjAAAWWqE011LUh8TEL+8k4CBuYC/cn1b8uSWYjxXr2tsVZfvMF8HkG hm6P2nc8HOe9FUy+EBTGdBl2XT6my5vVig== X-Google-Smtp-Source: APXvYqzY0fOH3zpPsY3phhOLwQte5Ec8/f5k7dhg2cefGtIH9iiRh+STVlZ0IPWqlhtQqJJ5hsEf6Q== X-Received: by 2002:ad4:4d85:: with SMTP id cv5mr1737790qvb.171.1580341829612; Wed, 29 Jan 2020 15:50:29 -0800 (PST) Received: from localhost ([107.15.81.208]) by smtp.gmail.com with ESMTPSA id 11sm1778403qko.76.2020.01.29.15.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 15:50:28 -0800 (PST) From: Josef Bacik To: linux-btrfs@vger.kernel.org, kernel-team@fb.com Subject: [PATCH 01/20] btrfs: change nr to u64 in btrfs_start_delalloc_roots Date: Wed, 29 Jan 2020 18:50:05 -0500 Message-Id: <20200129235024.24774-2-josef@toxicpanda.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200129235024.24774-1-josef@toxicpanda.com> References: <20200129235024.24774-1-josef@toxicpanda.com> 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 We have btrfs_wait_ordered_roots() which takes a u64 for nr, but btrfs_start_delalloc_roots() that takes an int for nr, which makes using them in conjunction, especially for something like (u64)-1, annoying and inconsistent. Fix btrfs_start_delalloc_roots() to take a u64 for nr and adjust start_delalloc_inodes() and it's callers appropriately. Part of adjusting the callers to this means changing btrfs_writeback_inodes_sb_nr() to take a u64 for items. This may be confusing because it seems unrelated, but the caller of btrfs_writeback_inodes_sb_nr() already passes in a u64, it's just the function variable that needs to be changed. Signed-off-by: Josef Bacik --- fs/btrfs/ctree.h | 2 +- fs/btrfs/dev-replace.c | 2 +- fs/btrfs/inode.c | 27 +++++++++++---------------- fs/btrfs/ioctl.c | 2 +- fs/btrfs/space-info.c | 2 +- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 8a2c1665baad..6afa0885a9bb 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -2884,7 +2884,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans, u32 min_type); int btrfs_start_delalloc_snapshot(struct btrfs_root *root); -int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int nr); +int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, u64 nr); int btrfs_set_extent_delalloc(struct inode *inode, u64 start, u64 end, unsigned int extra_bits, struct extent_state **cached_state); diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c index f639dde2a679..6ff08eb3c35d 100644 --- a/fs/btrfs/dev-replace.c +++ b/fs/btrfs/dev-replace.c @@ -593,7 +593,7 @@ static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, * flush all outstanding I/O and inode extent mappings before the * copy operation is declared as being finished */ - ret = btrfs_start_delalloc_roots(fs_info, -1); + ret = btrfs_start_delalloc_roots(fs_info, U64_MAX); if (ret) { mutex_unlock(&dev_replace->lock_finishing_cancel_unmount); return ret; diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9320f13778ce..5c6ce78bff1d 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -9619,7 +9619,8 @@ static struct btrfs_delalloc_work *btrfs_alloc_delalloc_work(struct inode *inode * some fairly slow code that needs optimization. This walks the list * of all the inodes with pending delalloc and forces them to disk. */ -static int start_delalloc_inodes(struct btrfs_root *root, int nr, bool snapshot) +static int start_delalloc_inodes(struct btrfs_root *root, u64 *nr, + bool snapshot) { struct btrfs_inode *binode; struct inode *inode; @@ -9659,9 +9660,11 @@ static int start_delalloc_inodes(struct btrfs_root *root, int nr, bool snapshot) list_add_tail(&work->list, &works); btrfs_queue_work(root->fs_info->flush_workers, &work->work); - ret++; - if (nr != -1 && ret >= nr) - goto out; + if (*nr != U64_MAX) { + (*nr)--; + if (*nr == 0) + goto out; + } cond_resched(); spin_lock(&root->delalloc_lock); } @@ -9686,18 +9689,15 @@ static int start_delalloc_inodes(struct btrfs_root *root, int nr, bool snapshot) int btrfs_start_delalloc_snapshot(struct btrfs_root *root) { struct btrfs_fs_info *fs_info = root->fs_info; - int ret; + u64 nr = U64_MAX; if (test_bit(BTRFS_FS_STATE_ERROR, &fs_info->fs_state)) return -EROFS; - ret = start_delalloc_inodes(root, -1, true); - if (ret > 0) - ret = 0; - return ret; + return start_delalloc_inodes(root, &nr, true); } -int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int nr) +int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, u64 nr) { struct btrfs_root *root; struct list_head splice; @@ -9720,15 +9720,10 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, int nr) &fs_info->delalloc_roots); spin_unlock(&fs_info->delalloc_root_lock); - ret = start_delalloc_inodes(root, nr, false); + ret = start_delalloc_inodes(root, &nr, false); btrfs_put_root(root); if (ret < 0) goto out; - - if (nr != -1) { - nr -= ret; - WARN_ON(nr < 0); - } spin_lock(&fs_info->delalloc_root_lock); } spin_unlock(&fs_info->delalloc_root_lock); diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index ecb6b188df15..442c89502f06 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -5510,7 +5510,7 @@ long btrfs_ioctl(struct file *file, unsigned int case BTRFS_IOC_SYNC: { int ret; - ret = btrfs_start_delalloc_roots(fs_info, -1); + ret = btrfs_start_delalloc_roots(fs_info, U64_MAX); if (ret) return ret; ret = btrfs_sync_fs(inode->i_sb, 1); diff --git a/fs/btrfs/space-info.c b/fs/btrfs/space-info.c index 01297c5b2666..edda1ee0455e 100644 --- a/fs/btrfs/space-info.c +++ b/fs/btrfs/space-info.c @@ -310,7 +310,7 @@ void btrfs_dump_space_info(struct btrfs_fs_info *fs_info, } static void btrfs_writeback_inodes_sb_nr(struct btrfs_fs_info *fs_info, - unsigned long nr_pages, int nr_items) + unsigned long nr_pages, u64 nr_items) { struct super_block *sb = fs_info->sb; -- 2.24.1