Received: by 2002:a05:6520:4d:b0:139:a872:a4c9 with SMTP id i13csp2566848lkm; Mon, 20 Sep 2021 18:54:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyVOrygM9X9V7ddv2qTfaLeyoMnHRYPu9yjfJfIO1dbYtweuVV6GAaM4FQkXLWBjbwnxi9 X-Received: by 2002:a17:907:9604:: with SMTP id gb4mr32333213ejc.142.1632189241491; Mon, 20 Sep 2021 18:54:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632189241; cv=none; d=google.com; s=arc-20160816; b=wmEITdgAlZ9OetXqGV1IhmjvFl1uVUFraqXkK6wryUz3Qb7YIzqeHSod8VvxQwzW34 MZEtnq+hSL5/Qf3gmBtREm3WpcxIOu7V2jnH9yc/UHDd+rBgr/14CQSNfoqoRHjpGkq1 3P4+Yg+WUNwiGdO34+t1RndstxyWlFOQlSz5SYnkthWpdRetHzOw6Q0VtKunmhihu79R MsPKRyEDn5i3gBZh2r2YQuYa8KqDUwgYl6Sx7pQv5zHFd3qqo1kwCnGKpBn7dODm6chY faMVuOu4LO5/6lLLQ8Kf8r5KErmIBOPTRqLlzkSjWBNkI0v3CiXn5quqyUbQOk/VEe65 Vw5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=i7L6vkro7Pj3Kp2CziQv59MEIG+6t20KcgIugaXtPXM=; b=H6XhLAU20b+j1UEvbP8a9qhgJQb+xOtdw9YGBLlapdCO/OJfcwivGiFcTpifsCSPra 56ZhP2lfnQhO6Mu5wM7NhUx3fqqRNIYypbaPr2QYLdP2RyhyIAoHIwoNXcaK0YkeDyOz eLQ3sWkF5LQ/uS0oaCTKpa8zfblCzTzi5TrqTX2utaoeXJyoLhQnIOMuA9t/eQPxV633 qP03N+MjIQ4rdAjORCtoeznY/FvxQjUW74H5Rywgx1rxg6iXM3wdcV6q2vIOUAg6fkaZ zAuMAxIO6lxvY7FhuzodWWNEODvr2te7Lw8gK9YsLqzlfcM855Gy+CtAeLbDom1JxmUx iSmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IOmAueTx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si3425210edb.225.2021.09.20.18.53.38; Mon, 20 Sep 2021 18:54:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IOmAueTx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357917AbhITSFN (ORCPT + 99 others); Mon, 20 Sep 2021 14:05:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:58466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347903AbhITR7A (ORCPT ); Mon, 20 Sep 2021 13:59:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2BF7163218; Mon, 20 Sep 2021 17:15:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632158121; bh=N01rFWMIESTbGlmm3z6+y+F94ZscUPhe8NXzPUvifdw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IOmAueTxi50CFCqqX7WOK3JzRsuC5VmwzpB9nzrG61V6+41TP3d4laCQo6e99epIi M/e8O0wYa3yo/sjeqH6T9D7Mlf5WzKLQyAtjcjf/aPE27cTk96iWDU9kQtjj7c/3fQ WlHB2TPQYq6r8Zt2ONq/Q/DH0wNI9YNeMKyQ2LCo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikolay Borisov , Josef Bacik , David Sterba Subject: [PATCH 5.4 002/260] btrfs: wake up async_delalloc_pages waiters after submit Date: Mon, 20 Sep 2021 18:40:20 +0200 Message-Id: <20210920163931.207132508@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210920163931.123590023@linuxfoundation.org> References: <20210920163931.123590023@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Josef Bacik commit ac98141d140444fe93e26471d3074c603b70e2ca upstream. We use the async_delalloc_pages mechanism to make sure that we've completed our async work before trying to continue our delalloc flushing. The reason for this is we need to see any ordered extents that were created by our delalloc flushing. However we're waking up before we do the submit work, which is before we create the ordered extents. This is a pretty wide race window where we could potentially think there are no ordered extents and thus exit shrink_delalloc prematurely. Fix this by waking us up after we've done the work to create ordered extents. CC: stable@vger.kernel.org # 5.4+ Reviewed-by: Nikolay Borisov Signed-off-by: Josef Bacik Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/inode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -1200,11 +1200,6 @@ static noinline void async_cow_submit(st nr_pages = (async_chunk->end - async_chunk->start + PAGE_SIZE) >> PAGE_SHIFT; - /* atomic_sub_return implies a barrier */ - if (atomic_sub_return(nr_pages, &fs_info->async_delalloc_pages) < - 5 * SZ_1M) - cond_wake_up_nomb(&fs_info->async_submit_wait); - /* * ->inode could be NULL if async_chunk_start has failed to compress, * in which case we don't have anything to submit, yet we need to @@ -1213,6 +1208,11 @@ static noinline void async_cow_submit(st */ if (async_chunk->inode) submit_compressed_extents(async_chunk); + + /* atomic_sub_return implies a barrier */ + if (atomic_sub_return(nr_pages, &fs_info->async_delalloc_pages) < + 5 * SZ_1M) + cond_wake_up_nomb(&fs_info->async_submit_wait); } static noinline void async_cow_free(struct btrfs_work *work)