Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.dk/linux-2.6-block
Browse files Browse the repository at this point in the history
* 'for-linus' of git://git.kernel.dk/linux-2.6-block:
  Block: use round_jiffies_up()
  Add round_jiffies_up and related routines
  block: fix __blkdev_get() for removable devices
  generic-ipi: fix the smp_mb() placement
  blk: move blk_delete_timer call in end_that_request_last
  block: add timer on blkdev_dequeue_request() not elv_next_request()
  bio: define __BIOVEC_PHYS_MERGEABLE
  block: remove unused ll_new_mergeable()
  • Loading branch information
Linus Torvalds committed Nov 6, 2008
2 parents 2e93960 + 7838c15 commit e252f4d
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 95 deletions.
4 changes: 2 additions & 2 deletions block/blk-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1770,8 +1770,6 @@ static void end_that_request_last(struct request *req, int error)
{
struct gendisk *disk = req->rq_disk;

blk_delete_timer(req);

if (blk_rq_tagged(req))
blk_queue_end_tag(req->q, req);

Expand All @@ -1781,6 +1779,8 @@ static void end_that_request_last(struct request *req, int error)
if (unlikely(laptop_mode) && blk_fs_request(req))
laptop_io_completion();

blk_delete_timer(req);

/*
* Account IO completion. bar_rq isn't accounted as a normal
* IO on queueing nor completion. Accounting the containing
Expand Down
21 changes: 0 additions & 21 deletions block/blk-merge.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,27 +222,6 @@ int blk_rq_map_sg(struct request_queue *q, struct request *rq,
}
EXPORT_SYMBOL(blk_rq_map_sg);

static inline int ll_new_mergeable(struct request_queue *q,
struct request *req,
struct bio *bio)
{
int nr_phys_segs = bio_phys_segments(q, bio);

if (req->nr_phys_segments + nr_phys_segs > q->max_phys_segments) {
req->cmd_flags |= REQ_NOMERGE;
if (req == q->last_merge)
q->last_merge = NULL;
return 0;
}

/*
* A hw segment is just getting larger, bump just the phys
* counter.
*/
req->nr_phys_segments += nr_phys_segs;
return 1;
}

static inline int ll_new_hw_segment(struct request_queue *q,
struct request *req,
struct bio *bio)
Expand Down
20 changes: 3 additions & 17 deletions block/blk-timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,7 @@ void blk_delete_timer(struct request *req)
{
struct request_queue *q = req->q;

/*
* Nothing to detach
*/
if (!q->rq_timed_out_fn || !req->deadline)
return;

list_del_init(&req->timeout_list);

if (list_empty(&q->timeout_list))
del_timer(&q->timeout);
}
Expand Down Expand Up @@ -142,7 +135,7 @@ void blk_rq_timed_out_timer(unsigned long data)
}

if (next_set && !list_empty(&q->timeout_list))
mod_timer(&q->timeout, round_jiffies(next));
mod_timer(&q->timeout, round_jiffies_up(next));

spin_unlock_irqrestore(q->queue_lock, flags);
}
Expand Down Expand Up @@ -198,17 +191,10 @@ void blk_add_timer(struct request *req)

/*
* If the timer isn't already pending or this timeout is earlier
* than an existing one, modify the timer. Round to next nearest
* than an existing one, modify the timer. Round up to next nearest
* second.
*/
expiry = round_jiffies(req->deadline);

/*
* We use ->deadline == 0 to detect whether a timer was added or
* not, so just increase to next jiffy for that specific case
*/
if (unlikely(!req->deadline))
req->deadline = 1;
expiry = round_jiffies_up(req->deadline);

if (!timer_pending(&q->timeout) ||
time_before(expiry, q->timeout.expires))
Expand Down
12 changes: 6 additions & 6 deletions block/elevator.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,12 +773,6 @@ struct request *elv_next_request(struct request_queue *q)
*/
rq->cmd_flags |= REQ_STARTED;
blk_add_trace_rq(q, rq, BLK_TA_ISSUE);

/*
* We are now handing the request to the hardware,
* add the timeout handler
*/
blk_add_timer(rq);
}

if (!q->boundary_rq || q->boundary_rq == rq) {
Expand Down Expand Up @@ -850,6 +844,12 @@ void elv_dequeue_request(struct request_queue *q, struct request *rq)
*/
if (blk_account_rq(rq))
q->in_flight++;

/*
* We are now handing the request to the hardware, add the
* timeout handler.
*/
blk_add_timer(rq);
}
EXPORT_SYMBOL(elv_dequeue_request);

Expand Down
23 changes: 11 additions & 12 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,6 @@ static int __blkdev_put(struct block_device *bdev, fmode_t mode, int for_part);
static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
{
struct gendisk *disk;
struct hd_struct *part = NULL;
int ret;
int partno;
int perm = 0;
Expand All @@ -1004,24 +1003,25 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
return ret;
}

ret = -ENXIO;

lock_kernel();

ret = -ENXIO;
disk = get_gendisk(bdev->bd_dev, &partno);
if (!disk)
goto out_unlock_kernel;
part = disk_get_part(disk, partno);
if (!part)
goto out_unlock_kernel;

mutex_lock_nested(&bdev->bd_mutex, for_part);
if (!bdev->bd_openers) {
bdev->bd_disk = disk;
bdev->bd_part = part;
bdev->bd_contains = bdev;
if (!partno) {
struct backing_dev_info *bdi;

ret = -ENXIO;
bdev->bd_part = disk_get_part(disk, partno);
if (!bdev->bd_part)
goto out_clear;

if (disk->fops->open) {
ret = disk->fops->open(bdev, mode);
if (ret)
Expand Down Expand Up @@ -1049,18 +1049,17 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
bdev->bd_contains = whole;
bdev->bd_inode->i_data.backing_dev_info =
whole->bd_inode->i_data.backing_dev_info;
bdev->bd_part = disk_get_part(disk, partno);
if (!(disk->flags & GENHD_FL_UP) ||
!part || !part->nr_sects) {
!bdev->bd_part || !bdev->bd_part->nr_sects) {
ret = -ENXIO;
goto out_clear;
}
bd_set_size(bdev, (loff_t)part->nr_sects << 9);
bd_set_size(bdev, (loff_t)bdev->bd_part->nr_sects << 9);
}
} else {
disk_put_part(part);
put_disk(disk);
module_put(disk->fops->owner);
part = NULL;
disk = NULL;
if (bdev->bd_contains == bdev) {
if (bdev->bd_disk->fops->open) {
Expand All @@ -1080,6 +1079,7 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
return 0;

out_clear:
disk_put_part(bdev->bd_part);
bdev->bd_disk = NULL;
bdev->bd_part = NULL;
bdev->bd_inode->i_data.backing_dev_info = &default_backing_dev_info;
Expand All @@ -1091,7 +1091,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
out_unlock_kernel:
unlock_kernel();

disk_put_part(part);
if (disk)
module_put(disk->fops->owner);
put_disk(disk);
Expand Down
6 changes: 5 additions & 1 deletion include/linux/bio.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,16 @@ static inline void *bio_data(struct bio *bio)
#define __BVEC_END(bio) bio_iovec_idx((bio), (bio)->bi_vcnt - 1)
#define __BVEC_START(bio) bio_iovec_idx((bio), (bio)->bi_idx)

/* Default implementation of BIOVEC_PHYS_MERGEABLE */
#define __BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))

/*
* allow arch override, for eg virtualized architectures (put in asm/io.h)
*/
#ifndef BIOVEC_PHYS_MERGEABLE
#define BIOVEC_PHYS_MERGEABLE(vec1, vec2) \
((bvec_to_phys((vec1)) + (vec1)->bv_len) == bvec_to_phys((vec2)))
__BIOVEC_PHYS_MERGEABLE(vec1, vec2)
#endif

#define __BIO_SEG_BOUNDARY(addr1, addr2, mask) \
Expand Down
5 changes: 5 additions & 0 deletions include/linux/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,9 @@ unsigned long __round_jiffies_relative(unsigned long j, int cpu);
unsigned long round_jiffies(unsigned long j);
unsigned long round_jiffies_relative(unsigned long j);

unsigned long __round_jiffies_up(unsigned long j, int cpu);
unsigned long __round_jiffies_up_relative(unsigned long j, int cpu);
unsigned long round_jiffies_up(unsigned long j);
unsigned long round_jiffies_up_relative(unsigned long j);

#endif
18 changes: 12 additions & 6 deletions kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,6 @@ static void csd_flag_wait(struct call_single_data *data)
{
/* Wait for response */
do {
/*
* We need to see the flags store in the IPI handler
*/
smp_mb();
if (!(data->flags & CSD_FLAG_WAIT))
break;
cpu_relax();
Expand All @@ -76,6 +72,11 @@ static void generic_exec_single(int cpu, struct call_single_data *data)
list_add_tail(&data->list, &dst->list);
spin_unlock_irqrestore(&dst->lock, flags);

/*
* Make the list addition visible before sending the ipi.
*/
smp_mb();

if (ipi)
arch_send_call_function_single_ipi(cpu);

Expand Down Expand Up @@ -157,7 +158,7 @@ void generic_smp_call_function_single_interrupt(void)
* Need to see other stores to list head for checking whether
* list is empty without holding q->lock
*/
smp_mb();
smp_read_barrier_depends();
while (!list_empty(&q->list)) {
unsigned int data_flags;

Expand Down Expand Up @@ -191,7 +192,7 @@ void generic_smp_call_function_single_interrupt(void)
/*
* See comment on outer loop
*/
smp_mb();
smp_read_barrier_depends();
}
}

Expand Down Expand Up @@ -370,6 +371,11 @@ int smp_call_function_mask(cpumask_t mask, void (*func)(void *), void *info,
list_add_tail_rcu(&data->csd.list, &call_function_queue);
spin_unlock_irqrestore(&call_function_lock, flags);

/*
* Make the list addition visible before sending the ipi.
*/
smp_mb();

/* Send a message to all CPUs in the map */
arch_send_call_function_ipi(mask);

Expand Down
Loading

0 comments on commit e252f4d

Please sign in to comment.