Commit 7ec6fb01 authored by Andrew Morton's avatar Andrew Morton Committed by Dave Jones

[PATCH] remove PF_READAHEAD

The problem with PF_READAHEAD is that if someone does a non-GFP_ATOMIC memory
allocation we can enter page reclaim and then call writepage, while
PF_READAHEAD is set.  The block layer then drops writes or the wrong reads on
the floor.  It can cause data loss.

A fix is complex (well, intrusive).  Given that the readahead code is now
skipping the entire readahead attempt if the queue is congested, the setting
of PF_READAHEAD probably is not doing anything useful anyway, so simply
remove it.
parent a9c7b26b
...@@ -1833,7 +1833,7 @@ static int __make_request(request_queue_t *q, struct bio *bio) ...@@ -1833,7 +1833,7 @@ static int __make_request(request_queue_t *q, struct bio *bio)
barrier = test_bit(BIO_RW_BARRIER, &bio->bi_rw); barrier = test_bit(BIO_RW_BARRIER, &bio->bi_rw);
ra = bio_flagged(bio, BIO_RW_AHEAD) || current->flags & PF_READAHEAD; ra = bio_flagged(bio, BIO_RW_AHEAD);
again: again:
insert_here = NULL; insert_here = NULL;
......
...@@ -506,8 +506,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate) ...@@ -506,8 +506,7 @@ static void end_buffer_async_read(struct buffer_head *bh, int uptodate)
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
} else { } else {
clear_buffer_uptodate(bh); clear_buffer_uptodate(bh);
if (!(current->flags & PF_READAHEAD)) buffer_io_error(bh);
buffer_io_error(bh);
SetPageError(page); SetPageError(page);
} }
......
...@@ -487,7 +487,6 @@ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0) ...@@ -487,7 +487,6 @@ do { if (atomic_dec_and_test(&(tsk)->usage)) __put_task_struct(tsk); } while(0)
#define PF_SWAPOFF 0x00080000 /* I am in swapoff */ #define PF_SWAPOFF 0x00080000 /* I am in swapoff */
#define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */ #define PF_LESS_THROTTLE 0x00100000 /* Throttle me less: I clean memory */
#define PF_SYNCWRITE 0x00200000 /* I am doing a sync write */ #define PF_SYNCWRITE 0x00200000 /* I am doing a sync write */
#define PF_READAHEAD 0x00400000 /* I am doing read-ahead */
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
extern int set_cpus_allowed(task_t *p, unsigned long new_mask); extern int set_cpus_allowed(task_t *p, unsigned long new_mask);
......
...@@ -298,15 +298,10 @@ int force_page_cache_readahead(struct address_space *mapping, struct file *filp, ...@@ -298,15 +298,10 @@ int force_page_cache_readahead(struct address_space *mapping, struct file *filp,
int do_page_cache_readahead(struct address_space *mapping, struct file *filp, int do_page_cache_readahead(struct address_space *mapping, struct file *filp,
unsigned long offset, unsigned long nr_to_read) unsigned long offset, unsigned long nr_to_read)
{ {
int ret = 0; if (!bdi_read_congested(mapping->backing_dev_info))
return __do_page_cache_readahead(mapping, filp,
if (!bdi_read_congested(mapping->backing_dev_info)) {
current->flags |= PF_READAHEAD;
ret = __do_page_cache_readahead(mapping, filp,
offset, nr_to_read); offset, nr_to_read);
current->flags &= ~PF_READAHEAD; return 0;
}
return ret;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment