From patchwork Sat Feb 8 22:18:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 3611541 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2C1359F392 for ; Sat, 8 Feb 2014 22:23:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F12A2017E for ; Sat, 8 Feb 2014 22:23:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DD22E2017B for ; Sat, 8 Feb 2014 22:23:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751224AbaBHWXI (ORCPT ); Sat, 8 Feb 2014 17:23:08 -0500 Received: from mx3.wp.pl ([212.77.101.10]:52768 "EHLO mx3.wp.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750985AbaBHWXH (ORCPT ); Sat, 8 Feb 2014 17:23:07 -0500 X-Greylist: delayed 399 seconds by postgrey-1.27 at vger.kernel.org; Sat, 08 Feb 2014 17:23:07 EST Received: (wp-smtpd smtp.wp.pl 30344 invoked from network); 8 Feb 2014 23:16:24 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wp.pl; s=1024a; t=1391897784; bh=/D77Mmy21QFQoYEDDWvMmEGHD1UDxfsS36ZTq1gmT1U=; h=From:To:Subject; b=m4evz6wKcovbnQqQ6kR/6TFiYitb5U7w4zIKSnilZKFbttQ1PqiwE/QL2EqLHI55z eO+EmPAwTQDkRS92h8Nbp4o+BX6L8dqQeewmof9Epcf5ymNNaXs1xNn81LocEuyHhF ZYDiNqZck+guRfRI4kKn9r129KFQqjJBZERng3wc= Received: from ip-94-112-189-223.net.upcbroadband.cz (HELO localhost) (stf_xl@wp.pl@[94.112.189.223]) (envelope-sender ) by smtp.wp.pl (WP-SMTPD) with AES128-SHA encrypted SMTP for ; 8 Feb 2014 23:16:24 +0100 Date: Sat, 8 Feb 2014 23:18:43 +0100 From: Stanislaw Gruszka To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs: always choose work from prio_head first Message-ID: <20140208221843.GA12866@localhost.localdomain> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-WP-AV: skaner antywirusowy poczty Wirtualnej Polski S. A. X-WP-SPAM: NO 0000000 [EePE] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In case we do not refill, we can overwrite cur pointer from prio_head by one from not prioritized head, what looks as something that was not intended. This change make we always take works from prio_head first until it's not empty. Signed-off-by: Stanislaw Gruszka --- I found this by reading code, not sure if change is correct. Patch is only compile tested. fs/btrfs/async-thread.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/async-thread.c b/fs/btrfs/async-thread.c index c1e0b0c..0b78bf2 100644 --- a/fs/btrfs/async-thread.c +++ b/fs/btrfs/async-thread.c @@ -262,18 +262,19 @@ static struct btrfs_work *get_next_work(struct btrfs_worker_thread *worker, struct btrfs_work *work = NULL; struct list_head *cur = NULL; - if (!list_empty(prio_head)) + if (!list_empty(prio_head)) { cur = prio_head->next; + goto out; + } smp_mb(); if (!list_empty(&worker->prio_pending)) goto refill; - if (!list_empty(head)) + if (!list_empty(head)) { cur = head->next; - - if (cur) goto out; + } refill: spin_lock_irq(&worker->lock);