From patchwork Fri Dec 4 12:37:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wenwei Tao X-Patchwork-Id: 7767711 X-Patchwork-Delegate: axboe@kernel.dk Return-Path: X-Original-To: patchwork-linux-block@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 29F67BEEE1 for ; Fri, 4 Dec 2015 12:45:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3070F20357 for ; Fri, 4 Dec 2015 12:45:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0C4E5202E6 for ; Fri, 4 Dec 2015 12:45:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751299AbbLDMpk (ORCPT ); Fri, 4 Dec 2015 07:45:40 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:35508 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbbLDMpj (ORCPT ); Fri, 4 Dec 2015 07:45:39 -0500 Received: by pfu207 with SMTP id 207so25992670pfu.2; Fri, 04 Dec 2015 04:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=EsPR0iiNwqawkVCc080u5jej4vFfT/s0OYUn/QL2kmY=; b=rBnBorORYtPLQT2FdutBihvAh1pY2YUFvEekbZ3QMTc7PjPn0MJYiBsauhoiIFGLj6 5Io4iGF6QcIm8WIWmeiy9JIvWIYEEsplZPkmlnlqqDMG/UoohbjbS5/1Sroy602WAT0n LZODpd3rWs6mOKvUCrLdSNvaLG3FyW0h/l/9eMBS2h2aC6/L/Xrzk1LNDHumHr6cm8f2 8v4Ot9xQaxH51I+5AavkIKmYWta9XY9Ri8I0ZU+s5KCmkdx25byKkXsRolhgisxfjWcX L8i+3Wa5hXA3vYZrwdapsGw1iPuC5ifSJdvGlPsjTlf67sQtnQXdyID0aObkL4DRv5JR wJ3w== X-Received: by 10.98.75.83 with SMTP id y80mr20726853pfa.77.1449232694356; Fri, 04 Dec 2015 04:38:14 -0800 (PST) Received: from localhost.localdomain ([114.250.75.110]) by smtp.gmail.com with ESMTPSA id fk8sm17026640pab.33.2015.12.04.04.38.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 04 Dec 2015 04:38:13 -0800 (PST) From: Wenwei Tao To: mb@lightnvm.io Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH] lightnvm: place unlock sentence in the common path Date: Fri, 4 Dec 2015 20:37:52 +0800 Message-Id: <1449232672-3464-1-git-send-email-ww.tao0320@gmail.com> X-Mailer: git-send-email 2.5.1.windows.1 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 move spin_unlock(&vlun->lock) to common path to make the code more clean. Signed-off-by: Wenwei Tao --- drivers/lightnvm/gennvm.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/lightnvm/gennvm.c b/drivers/lightnvm/gennvm.c index 35dde84..ce60254 100644 --- a/drivers/lightnvm/gennvm.c +++ b/drivers/lightnvm/gennvm.c @@ -262,14 +262,11 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev, if (list_empty(&lun->free_list)) { pr_err_ratelimited("gennvm: lun %u have no free pages available", lun->vlun.id); - spin_unlock(&vlun->lock); goto out; } - while (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks) { - spin_unlock(&vlun->lock); + if (!is_gc && lun->vlun.nr_free_blocks < lun->reserved_blocks) goto out; - } blk = list_first_entry(&lun->free_list, struct nvm_block, list); list_move_tail(&blk->list, &lun->used_list); @@ -278,8 +275,8 @@ static struct nvm_block *gennvm_get_blk(struct nvm_dev *dev, lun->vlun.nr_free_blocks--; lun->vlun.nr_inuse_blocks++; - spin_unlock(&vlun->lock); out: + spin_unlock(&vlun->lock); return blk; }