Received: by 10.223.164.202 with SMTP id h10csp660095wrb; Wed, 22 Nov 2017 13:13:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMZJv2Ye6OtiCMLnzJrK4M+djePRUWsdylj0HOMM+ZIpQi2QRQVyuRWuV87g5XQi4YCaVLtb X-Received: by 10.98.163.200 with SMTP id q69mr20209331pfl.21.1511385215401; Wed, 22 Nov 2017 13:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385215; cv=none; d=google.com; s=arc-20160816; b=K9wYZu+JfAansERpdcVjr+EFj9/EjZcFOCpKA8H52ve9lKFQF4L6N55sNbY4v4fJEe G4Hs0OEHKv5+a3kYlu1PKKq3i7XLoNOyOdzD3REuCIb32tIkyK0YAFvnlKlDmqMdoNhh Qo+hC6xZ3ApKPwGl/2/R3kJCn0sYlBPHYw+j3XUgtCKX1u4XXyHRbnLBbasvrCT9xAkJ yhXuRnNuX4iQ/5/lPQipqc4GpvKifpqUGbb2bkPkFnDN1ly5Q9oJkfXdPK+qrwQQROyC i/G2vocf78ynkIV+1Dy/8XvycRa3tUaxievjAHGepY8G3gJdK/MXU1J1NqfsUu8knfBn 25EA== 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=faCNG183K1JeiKaG+ebLGeBCQHo8GinGGseE7A1azU0=; b=v1UTeGqF0qrsMn8IRdLMMtJN1KXHmwJXEpw4A+HAgDoSF73A2chR8BWyB2S8IvX/uw fqAKFMtJ5c2HOjSjdHaccE76+YdwAJUy8qMBJF+dmF4gjoDqDy3fcdr9m4OvAVUm2IBy q2TQv6g7bFR5ifnQjXi6jGyLVhQhQf8f5YdSdoyBo3TXZX5VF33R8o7jMGaexLS8s6Ws 3dgsmo2jrkdIH2Mw7xhKiSZONTyE0iBnq/dsJeLUYGTb1/SXujRiX9OSKdPXyHetKFWh E9Ade+Y8YiRMW31Kt8nDCXww8mjjvNNF36mYmu1DSoYzdaJm9dVwryqm2EbXYsRGLgrB opJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=jxF7QvNa; 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 f9si14337772plo.763.2017.11.22.13.13.24; Wed, 22 Nov 2017 13:13:35 -0800 (PST) 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=jxF7QvNa; 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 S1751985AbdKVVLH (ORCPT + 77 others); Wed, 22 Nov 2017 16:11:07 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:51743 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751875AbdKVVIU (ORCPT ); Wed, 22 Nov 2017 16:08:20 -0500 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=faCNG183K1JeiKaG+ebLGeBCQHo8GinGGseE7A1azU0=; b=jxF7QvNaaHIZn3uWFIZ918KsK RKV2Vlt/7ll2lnxZBQUGT4NnRnuxcxHPXx99TgKGwRSH5/3H3JHJThARChIkNHCxb5zgq2kF1gD/q r4QPv0yCjXVMugctw3Ug11qlBt/G9wzHezplyxP59nt3cREqfPhTr7PLQNUFbyJ/HC1r01m3Z6XnN BmEp7JRiFsP+MBJUggIhip0XQlr0Y5d4y9zFuXC7sr9g8JBqEMXJJtX0L8zkqDI+CVCcnqZsaXQZs AN39ozq0Hak0im90VGjMkp6kJtvdBzaZhb/q+Ujx7lkAS5d89jJ7UnL+gZrIU9X2q7WhXCV9bM0K1 YU0/yBNOQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFo-0007yK-1m; Wed, 22 Nov 2017 21:08:20 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 54/62] scsi: Remove idr_preload in st driver Date: Wed, 22 Nov 2017 13:07:31 -0800 Message-Id: <20171122210739.29916-55-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox The IDR now has its own locking, so remove the driver's private lock and calls to idr_preload. Signed-off-by: Matthew Wilcox --- drivers/scsi/st.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index b141d7641a2e..e8703905c94a 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c @@ -221,7 +221,6 @@ static void scsi_tape_release(struct kref *); #define to_scsi_tape(obj) container_of(obj, struct scsi_tape, kref) static DEFINE_MUTEX(st_ref_mutex); -static DEFINE_SPINLOCK(st_index_lock); static DEFINE_SPINLOCK(st_use_lock); static DEFINE_IDR(st_index_idr); @@ -242,10 +241,11 @@ static struct scsi_tape *scsi_tape_get(int dev) struct scsi_tape *STp = NULL; mutex_lock(&st_ref_mutex); - spin_lock(&st_index_lock); + idr_lock(&st_index_idr); STp = idr_find(&st_index_idr, dev); - if (!STp) goto out; + if (!STp) + goto out; kref_get(&STp->kref); @@ -261,7 +261,7 @@ static struct scsi_tape *scsi_tape_get(int dev) kref_put(&STp->kref, scsi_tape_release); STp = NULL; out: - spin_unlock(&st_index_lock); + idr_unlock(&st_index_idr); mutex_unlock(&st_ref_mutex); return STp; } @@ -4370,11 +4370,7 @@ static int st_probe(struct device *dev) tpnt->blksize_changed = 0; mutex_init(&tpnt->lock); - idr_preload(GFP_KERNEL); - spin_lock(&st_index_lock); - error = idr_alloc(&st_index_idr, tpnt, 0, ST_MAX_TAPES + 1, GFP_NOWAIT); - spin_unlock(&st_index_lock); - idr_preload_end(); + error = idr_alloc(&st_index_idr, tpnt, 0, ST_MAX_TAPES + 1, GFP_KERNEL); if (error < 0) { pr_warn("st: idr allocation failed: %d\n", error); goto out_put_queue; @@ -4408,9 +4404,7 @@ static int st_probe(struct device *dev) remove_cdevs(tpnt); kfree(tpnt->stats); out_idr_remove: - spin_lock(&st_index_lock); idr_remove(&st_index_idr, tpnt->index); - spin_unlock(&st_index_lock); out_put_queue: blk_put_queue(disk->queue); out_put_disk: @@ -4435,9 +4429,7 @@ static int st_remove(struct device *dev) mutex_lock(&st_ref_mutex); kref_put(&tpnt->kref, scsi_tape_release); mutex_unlock(&st_ref_mutex); - spin_lock(&st_index_lock); idr_remove(&st_index_idr, index); - spin_unlock(&st_index_lock); return 0; } -- 2.15.0 From 1584827755787245555@xxx Thu Nov 23 03:58:46 +0000 2017 X-GM-THRID: 1584814824647804691 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread