Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 131911
b: refs/heads/master
c: 4034cc6
h: refs/heads/master
i:
  131909: 8afaaaa
  131907: 068a31b
  131903: 4b3169c
v: v3
  • Loading branch information
Tejun Heo authored and James Bottomley committed Feb 22, 2009
1 parent 46a0773 commit 1668f3b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b7e7bd34465518f3527bf47a8055f35077d40c6c
refs/heads/master: 4034cc68157bfa0b6622efe368488d3d3e20f4e6
7 changes: 7 additions & 0 deletions trunk/drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ 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(struct scsi_disk *, 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
Expand Down Expand Up @@ -1914,7 +1915,9 @@ static int sd_probe(struct device *dev)
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)
Expand All @@ -1936,7 +1939,9 @@ 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);
out_put:
put_disk(gd);
out_free:
Expand Down Expand Up @@ -1986,7 +1991,9 @@ 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);

disk->private_data = NULL;
put_disk(disk);
Expand Down

0 comments on commit 1668f3b

Please sign in to comment.