From patchwork Sat May 29 09:46:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 103026 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4T9kVVL026847 for ; Sat, 29 May 2010 09:46:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755969Ab0E2Jq3 (ORCPT ); Sat, 29 May 2010 05:46:29 -0400 Received: from ey-out-2122.google.com ([74.125.78.26]:27201 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755929Ab0E2Jq1 (ORCPT ); Sat, 29 May 2010 05:46:27 -0400 Received: by ey-out-2122.google.com with SMTP id d26so121997eyd.19 for ; Sat, 29 May 2010 02:46:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=+t5MGjrBYN8+yOw+/327Q92TnlymOIuzG5MlsI/TshA=; b=FMoOlaKronUcfyGZ2/XTl/8qJnR0KC3XjxA0V3JmeFwGUOp+nBlykmdc4hHEuPuDxF rj7sP7UX5t5iNduUxlOIkZ713W7AEdWp9+IZXi78WD/Z/s0I5fnkCm5UZcJX5E6qy6tn QYermj1F4tgvD2jZN/FApDKqDB98TxLCS9thk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=TRHdEyvhJYF/B0Hc8u50RV5HthCo68b8AgLNKZ0TdrI/Y7N0qfTBKREzmPh9ID2NT+ 0RF+W0b7BY31HebalkNMIeSdg8OOmuhWMGKe71zwq0wU2yvV0Jtkw251vSxfwq/0pFSz iMXn/VOl7b2FrFL8qG2PXkq4jIuL/d4mGQpmc= Received: by 10.213.9.70 with SMTP id k6mr816738ebk.37.1275126386018; Sat, 29 May 2010 02:46:26 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id 13sm1702738ewy.1.2010.05.29.02.46.15 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 29 May 2010 02:46:25 -0700 (PDT) Date: Sat, 29 May 2010 11:46:06 +0200 From: Dan Carpenter To: linux-btrfs@vger.kernel.org Cc: Josef Bacik , Yan Zheng , Jens Axboe , Tejun Heo , kernel-janitors@vger.kernel.org, Chris Mason Subject: [patch 6/11] btrfs: cleanup btrfs_dec_test_ordered_pending() Message-ID: <20100529094606.GG5483@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 29 May 2010 09:46:31 +0000 (UTC) diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index e56c72b..0a37019 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c @@ -270,13 +270,13 @@ int btrfs_dec_test_ordered_pending(struct inode *inode, spin_lock(&tree->lock); node = tree_search(tree, file_offset); if (!node) { - ret = 1; + ret = 0; goto out; } entry = rb_entry(node, struct btrfs_ordered_extent, rb_node); if (!offset_in_entry(entry, file_offset)) { - ret = 1; + ret = 0; goto out; } @@ -286,17 +286,19 @@ int btrfs_dec_test_ordered_pending(struct inode *inode, (unsigned long long)io_size); } entry->bytes_left -= io_size; - if (entry->bytes_left == 0) + if (entry->bytes_left == 0) { ret = test_and_set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags); - else - ret = 1; + ret = !ret; + } else { + ret = 0; + } out: - if (!ret && cached && entry) { + if (ret && cached) { *cached = entry; atomic_inc(&entry->refs); } spin_unlock(&tree->lock); - return ret == 0; + return ret; } /*