aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2013-02-27 20:04:43 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-02-27 22:10:18 -0500
commitc9365bd028a48017ebc09d7a565d3b6bbc86b3c6 (patch)
tree0a89a54581c3c9b8e16f22772068306fe6881085 /drivers/target
parentb98c52b5721f5d88cd9b18aaf532049b44f7815a (diff)
target/iscsi: convert to idr_alloc()
Convert to the much saner new idr interface. Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Nicholas A. Bellinger <nab@linux-iscsi.org> Cc: James Bottomley <James.Bottomley@HansenPartnership.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/iscsi/iscsi_target.c15
-rw-r--r--drivers/target/iscsi/iscsi_target_login.c15
2 files changed, 14 insertions, 16 deletions
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index 23a98e658306..9435a3d369a7 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -144,23 +144,24 @@ struct iscsi_tiqn *iscsit_add_tiqn(unsigned char *buf)
144 spin_lock_init(&tiqn->login_stats.lock); 144 spin_lock_init(&tiqn->login_stats.lock);
145 spin_lock_init(&tiqn->logout_stats.lock); 145 spin_lock_init(&tiqn->logout_stats.lock);
146 146
147 if (!idr_pre_get(&tiqn_idr, GFP_KERNEL)) {
148 pr_err("idr_pre_get() for tiqn_idr failed\n");
149 kfree(tiqn);
150 return ERR_PTR(-ENOMEM);
151 }
152 tiqn->tiqn_state = TIQN_STATE_ACTIVE; 147 tiqn->tiqn_state = TIQN_STATE_ACTIVE;
153 148
149 idr_preload(GFP_KERNEL);
154 spin_lock(&tiqn_lock); 150 spin_lock(&tiqn_lock);
155 ret = idr_get_new(&tiqn_idr, NULL, &tiqn->tiqn_index); 151
152 ret = idr_alloc(&tiqn_idr, NULL, 0, 0, GFP_NOWAIT);
156 if (ret < 0) { 153 if (ret < 0) {
157 pr_err("idr_get_new() failed for tiqn->tiqn_index\n"); 154 pr_err("idr_alloc() failed for tiqn->tiqn_index\n");
158 spin_unlock(&tiqn_lock); 155 spin_unlock(&tiqn_lock);
156 idr_preload_end();
159 kfree(tiqn); 157 kfree(tiqn);
160 return ERR_PTR(ret); 158 return ERR_PTR(ret);
161 } 159 }
160 tiqn->tiqn_index = ret;
162 list_add_tail(&tiqn->tiqn_list, &g_tiqn_list); 161 list_add_tail(&tiqn->tiqn_list, &g_tiqn_list);
162
163 spin_unlock(&tiqn_lock); 163 spin_unlock(&tiqn_lock);
164 idr_preload_end();
164 165
165 pr_debug("CORE[0] - Added iSCSI Target IQN: %s\n", tiqn->tiqn); 166 pr_debug("CORE[0] - Added iSCSI Target IQN: %s\n", tiqn->tiqn);
166 167
diff --git a/drivers/target/iscsi/iscsi_target_login.c b/drivers/target/iscsi/iscsi_target_login.c
index fdb632f0ab85..2535d4d46c0e 100644
--- a/drivers/target/iscsi/iscsi_target_login.c
+++ b/drivers/target/iscsi/iscsi_target_login.c
@@ -247,19 +247,16 @@ static int iscsi_login_zero_tsih_s1(
247 spin_lock_init(&sess->session_usage_lock); 247 spin_lock_init(&sess->session_usage_lock);
248 spin_lock_init(&sess->ttt_lock); 248 spin_lock_init(&sess->ttt_lock);
249 249
250 if (!idr_pre_get(&sess_idr, GFP_KERNEL)) { 250 idr_preload(GFP_KERNEL);
251 pr_err("idr_pre_get() for sess_idr failed\n");
252 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
253 ISCSI_LOGIN_STATUS_NO_RESOURCES);
254 kfree(sess);
255 return -ENOMEM;
256 }
257 spin_lock_bh(&sess_idr_lock); 251 spin_lock_bh(&sess_idr_lock);
258 ret = idr_get_new(&sess_idr, NULL, &sess->session_index); 252 ret = idr_alloc(&sess_idr, NULL, 0, 0, GFP_NOWAIT);
253 if (ret >= 0)
254 sess->session_index = ret;
259 spin_unlock_bh(&sess_idr_lock); 255 spin_unlock_bh(&sess_idr_lock);
256 idr_preload_end();
260 257
261 if (ret < 0) { 258 if (ret < 0) {
262 pr_err("idr_get_new() for sess_idr failed\n"); 259 pr_err("idr_alloc() for sess_idr failed\n");
263 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR, 260 iscsit_tx_login_rsp(conn, ISCSI_STATUS_CLS_TARGET_ERR,
264 ISCSI_LOGIN_STATUS_NO_RESOURCES); 261 ISCSI_LOGIN_STATUS_NO_RESOURCES);
265 kfree(sess); 262 kfree(sess);