From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752008AbdKVVLH (ORCPT ); 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 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 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 mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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> In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: owner-linux-mm@kvack.org List-ID: 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 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org