Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 123301
b: refs/heads/master
c: a6f2365
h: refs/heads/master
i:
  123299: 7148b02
v: v3
  • Loading branch information
Jens Axboe committed Dec 29, 2008
1 parent 7c29349 commit 10e6d13
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 30e0dc28bff9dc456cdfc2aae4aca78b8b1a1cec
refs/heads/master: a6f23657d3072bde6844055bbc2290e497f33fbc
23 changes: 19 additions & 4 deletions trunk/block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ void disk_part_iter_exit(struct disk_part_iter *piter)
}
EXPORT_SYMBOL_GPL(disk_part_iter_exit);

static inline int sector_in_part(struct hd_struct *part, sector_t sector)
{
return part->start_sect <= sector &&
sector < part->start_sect + part->nr_sects;
}

/**
* disk_map_sector_rcu - map sector to partition
* @disk: gendisk of interest
Expand All @@ -199,16 +205,22 @@ EXPORT_SYMBOL_GPL(disk_part_iter_exit);
struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector)
{
struct disk_part_tbl *ptbl;
struct hd_struct *part;
int i;

ptbl = rcu_dereference(disk->part_tbl);

part = rcu_dereference(ptbl->last_lookup);
if (part && sector_in_part(part, sector))
return part;

for (i = 1; i < ptbl->len; i++) {
struct hd_struct *part = rcu_dereference(ptbl->part[i]);
part = rcu_dereference(ptbl->part[i]);

if (part && part->start_sect <= sector &&
sector < part->start_sect + part->nr_sects)
if (part && sector_in_part(part, sector)) {
rcu_assign_pointer(ptbl->last_lookup, part);
return part;
}
}
return &disk->part0;
}
Expand Down Expand Up @@ -888,8 +900,11 @@ static void disk_replace_part_tbl(struct gendisk *disk,
struct disk_part_tbl *old_ptbl = disk->part_tbl;

rcu_assign_pointer(disk->part_tbl, new_ptbl);
if (old_ptbl)

if (old_ptbl) {
rcu_assign_pointer(old_ptbl->last_lookup, NULL);
call_rcu(&old_ptbl->rcu_head, disk_free_ptbl_rcu_cb);
}
}

/**
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/genhd.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ struct blk_scsi_cmd_filter {
struct disk_part_tbl {
struct rcu_head rcu_head;
int len;
struct hd_struct *last_lookup;
struct hd_struct *part[];
};

Expand Down

0 comments on commit 10e6d13

Please sign in to comment.