Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp91604imm; Thu, 21 Jun 2018 14:31:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL2l0citcrkUKCP/5UZ3J871sUUjz+INtx2Tn/YitunSma0rf/v36B7GXNy/9Os3W1NQDKP X-Received: by 2002:a62:993:: with SMTP id 19-v6mr17625821pfj.105.1529616674544; Thu, 21 Jun 2018 14:31:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529616674; cv=none; d=google.com; s=arc-20160816; b=Ozda9NsH9XMQ/y40YwbfifDj8KcQreRS3uq9i9ATYK9U8Qe86xcX7x4+iPh4CJmV9z zEWJ19n3ZA1C2gYts8CJt6SFPxjPD4bz1W6ZKvrZ5MR9JqqvMd0iEi+v05Ifj5iymtn7 SugnipwVN2G4NtyG9oKTS5gYAD4P9zAN88sGCX4OquUxVzp1NVMof3CnKqUePRs3zkEY ed1751MUvWEg5X4e0AMLbqm82iaWpL0Si6cdNnCswxaMvs5eTwSl45l6TwnuUg8ylEhr XzmBYQJ/SspgVsYUjRiFi5cnoyLPM9NWRl74ha/YAiW1lWeFe0NZSdaPSnM93zfTS5yX IPIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=aN/ujayXDIeT8PvAahIwgPTtiODsoJarrTXA0pOcGs4=; b=EU5AbXTXFe9pGWsu8qE7GhgoybZNfsd4gR3yRfa/ZSbVv5f0Q99n6Djs47MCodOURD sjvbBCmfJboTMImdHuZRbDWAN+tq8O8pXnWO2wEXrPdbmbtKwZlpkugBaC+l5MLcTLfA gsYcgyw0puTGPB+uzsZh+nfTnKU5QJ6aT5k8SXGOqTcB99yEi8y6Sm+dvpsV23fIitNQ sOAnbLbujIawTYKN+hsQTludvA6+RIZBPeS4mmeoG7/1dfqFRzKCrgOO+U4kHwa10inM rtpl01vvdWABAlwL5CiM9WwYrba9JZAWfpmkF8QPhA0p8h52ECZS7mdhiG454wbDDLes tiJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=uSxrMk2T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k15-v6si5288074pff.91.2018.06.21.14.31.00; Thu, 21 Jun 2018 14:31:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=uSxrMk2T; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934022AbeFUV3P (ORCPT + 99 others); Thu, 21 Jun 2018 17:29:15 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41764 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933944AbeFUV3J (ORCPT ); Thu, 21 Jun 2018 17:29:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=aN/ujayXDIeT8PvAahIwgPTtiODsoJarrTXA0pOcGs4=; b=uSxrMk2TUY65KwQgP5SLiGMRr t8noaFZGZkpWzXeu/rmJPJ9D2u4SaYXa9OS1ra0B54S6RKqXjpnq+M1TkgkPiXYp9fW5Z91DQTTiO ktkGUbVfUn+cyomTsBSZUKo3vsRkBBNgtqPnixcD7GOZ/vZtfxJpM1QiePP5C2KGrB5dmH4HnUe0D 6dOBBKxVKuJvVDIWtBxtn83Hb+3fMWsoBq6iq031TkPZdkbPewUBdpT4I4B2XKizC5/9auE0yuu6/ P00W7T+4wZW2J8gZRoCIh+G0B448h9uCqnfKWw8ahGKU6Awql1YppGnuf0FNZqRXApJgGMdVM4BZS iIu9Sh//g==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fW78e-0001b9-89; Thu, 21 Jun 2018 21:29:08 +0000 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Cc: Matthew Wilcox , "James E.J. Bottomley" , "Martin K. Petersen" , linux-scsi@vger.kernel.org Subject: [PATCH 08/26] sd: Convert to new IDA interface Date: Thu, 21 Jun 2018 14:28:17 -0700 Message-Id: <20180621212835.5636-9-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180621212835.5636-1-willy@infradead.org> References: <20180621212835.5636-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allows us to remove an explicit spinlock. Signed-off-by: Matthew Wilcox --- drivers/scsi/sd.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 9421d9877730..8a493e64856c 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -123,7 +123,6 @@ static void scsi_disk_release(struct device *cdev); static void sd_print_sense_hdr(struct scsi_disk *, struct scsi_sense_hdr *); static void sd_print_result(const struct scsi_disk *, const char *, int); -static DEFINE_SPINLOCK(sd_index_lock); static DEFINE_IDA(sd_index_ida); /* This semaphore is used to mediate the 0->1 reference get in the @@ -3339,16 +3338,8 @@ static int sd_probe(struct device *dev) if (!gd) goto out_free; - do { - if (!ida_pre_get(&sd_index_ida, GFP_KERNEL)) - goto out_put; - - spin_lock(&sd_index_lock); - error = ida_get_new(&sd_index_ida, &index); - spin_unlock(&sd_index_lock); - } while (error == -EAGAIN); - - if (error) { + index = ida_alloc(&sd_index_ida, GFP_KERNEL); + if (index < 0) { sdev_printk(KERN_WARNING, sdp, "sd_probe: memory exhausted.\n"); goto out_put; } @@ -3392,9 +3383,7 @@ static int sd_probe(struct device *dev) return 0; out_free_index: - spin_lock(&sd_index_lock); - ida_remove(&sd_index_ida, index); - spin_unlock(&sd_index_lock); + ida_free(&sd_index_ida, index); out_put: put_disk(gd); out_free: @@ -3459,9 +3448,7 @@ static void scsi_disk_release(struct device *dev) struct scsi_disk *sdkp = to_scsi_disk(dev); struct gendisk *disk = sdkp->disk; - spin_lock(&sd_index_lock); - ida_remove(&sd_index_ida, sdkp->index); - spin_unlock(&sd_index_lock); + ida_free(&sd_index_ida, sdkp->index); disk->private_data = NULL; put_disk(disk); -- 2.17.1