diff options
-rw-r--r-- | fs/buffer.c | 9 | ||||
-rw-r--r-- | fs/ext3/super.c | 1 | ||||
-rw-r--r-- | fs/jbd/commit.c | 25 | ||||
-rw-r--r-- | include/linux/blk_types.h | 3 | ||||
-rw-r--r-- | include/linux/buffer_head.h | 1 | ||||
-rw-r--r-- | include/uapi/linux/fs.h | 1 | ||||
-rw-r--r-- | mm/bounce.c | 21 | ||||
-rw-r--r-- | mm/page-writeback.c | 4 |
8 files changed, 34 insertions, 31 deletions
diff --git a/fs/buffer.c b/fs/buffer.c index b4dcb34c9635..71578d69b82d 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -2949,7 +2949,7 @@ static void guard_bh_eod(int rw, struct bio *bio, struct buffer_head *bh) | |||
2949 | } | 2949 | } |
2950 | } | 2950 | } |
2951 | 2951 | ||
2952 | int submit_bh(int rw, struct buffer_head * bh) | 2952 | int _submit_bh(int rw, struct buffer_head *bh, unsigned long bio_flags) |
2953 | { | 2953 | { |
2954 | struct bio *bio; | 2954 | struct bio *bio; |
2955 | int ret = 0; | 2955 | int ret = 0; |
@@ -2984,6 +2984,7 @@ int submit_bh(int rw, struct buffer_head * bh) | |||
2984 | 2984 | ||
2985 | bio->bi_end_io = end_bio_bh_io_sync; | 2985 | bio->bi_end_io = end_bio_bh_io_sync; |
2986 | bio->bi_private = bh; | 2986 | bio->bi_private = bh; |
2987 | bio->bi_flags |= bio_flags; | ||
2987 | 2988 | ||
2988 | /* Take care of bh's that straddle the end of the device */ | 2989 | /* Take care of bh's that straddle the end of the device */ |
2989 | guard_bh_eod(rw, bio, bh); | 2990 | guard_bh_eod(rw, bio, bh); |
@@ -2997,6 +2998,12 @@ int submit_bh(int rw, struct buffer_head * bh) | |||
2997 | bio_put(bio); | 2998 | bio_put(bio); |
2998 | return ret; | 2999 | return ret; |
2999 | } | 3000 | } |
3001 | EXPORT_SYMBOL_GPL(_submit_bh); | ||
3002 | |||
3003 | int submit_bh(int rw, struct buffer_head *bh) | ||
3004 | { | ||
3005 | return _submit_bh(rw, bh, 0); | ||
3006 | } | ||
3000 | EXPORT_SYMBOL(submit_bh); | 3007 | EXPORT_SYMBOL(submit_bh); |
3001 | 3008 | ||
3002 | /** | 3009 | /** |
diff --git a/fs/ext3/super.c b/fs/ext3/super.c index fb5120a5505c..3dc48cc8b6eb 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c | |||
@@ -2067,7 +2067,6 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) | |||
2067 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal": | 2067 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_JOURNAL_DATA ? "journal": |
2068 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": | 2068 | test_opt(sb,DATA_FLAGS) == EXT3_MOUNT_ORDERED_DATA ? "ordered": |
2069 | "writeback"); | 2069 | "writeback"); |
2070 | sb->s_flags |= MS_SNAP_STABLE; | ||
2071 | 2070 | ||
2072 | return 0; | 2071 | return 0; |
2073 | 2072 | ||
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index 86b39b167c23..11bb11f48b3a 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c | |||
@@ -162,8 +162,17 @@ static void journal_do_submit_data(struct buffer_head **wbuf, int bufs, | |||
162 | 162 | ||
163 | for (i = 0; i < bufs; i++) { | 163 | for (i = 0; i < bufs; i++) { |
164 | wbuf[i]->b_end_io = end_buffer_write_sync; | 164 | wbuf[i]->b_end_io = end_buffer_write_sync; |
165 | /* We use-up our safety reference in submit_bh() */ | 165 | /* |
166 | submit_bh(write_op, wbuf[i]); | 166 | * Here we write back pagecache data that may be mmaped. Since |
167 | * we cannot afford to clean the page and set PageWriteback | ||
168 | * here due to lock ordering (page lock ranks above transaction | ||
169 | * start), the data can change while IO is in flight. Tell the | ||
170 | * block layer it should bounce the bio pages if stable data | ||
171 | * during write is required. | ||
172 | * | ||
173 | * We use up our safety reference in submit_bh(). | ||
174 | */ | ||
175 | _submit_bh(write_op, wbuf[i], 1 << BIO_SNAP_STABLE); | ||
167 | } | 176 | } |
168 | } | 177 | } |
169 | 178 | ||
@@ -667,7 +676,17 @@ start_journal_io: | |||
667 | clear_buffer_dirty(bh); | 676 | clear_buffer_dirty(bh); |
668 | set_buffer_uptodate(bh); | 677 | set_buffer_uptodate(bh); |
669 | bh->b_end_io = journal_end_buffer_io_sync; | 678 | bh->b_end_io = journal_end_buffer_io_sync; |
670 | submit_bh(write_op, bh); | 679 | /* |
680 | * In data=journal mode, here we can end up | ||
681 | * writing pagecache data that might be | ||
682 | * mmapped. Since we can't afford to clean the | ||
683 | * page and set PageWriteback (see the comment | ||
684 | * near the other use of _submit_bh()), the | ||
685 | * data can change while the write is in | ||
686 | * flight. Tell the block layer to bounce the | ||
687 | * bio pages if stable pages are required. | ||
688 | */ | ||
689 | _submit_bh(write_op, bh, 1 << BIO_SNAP_STABLE); | ||
671 | } | 690 | } |
672 | cond_resched(); | 691 | cond_resched(); |
673 | 692 | ||
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index cdf11191e645..22990cf4439d 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h | |||
@@ -111,12 +111,13 @@ struct bio { | |||
111 | #define BIO_FS_INTEGRITY 9 /* fs owns integrity data, not block layer */ | 111 | #define BIO_FS_INTEGRITY 9 /* fs owns integrity data, not block layer */ |
112 | #define BIO_QUIET 10 /* Make BIO Quiet */ | 112 | #define BIO_QUIET 10 /* Make BIO Quiet */ |
113 | #define BIO_MAPPED_INTEGRITY 11/* integrity metadata has been remapped */ | 113 | #define BIO_MAPPED_INTEGRITY 11/* integrity metadata has been remapped */ |
114 | #define BIO_SNAP_STABLE 12 /* bio data must be snapshotted during write */ | ||
114 | 115 | ||
115 | /* | 116 | /* |
116 | * Flags starting here get preserved by bio_reset() - this includes | 117 | * Flags starting here get preserved by bio_reset() - this includes |
117 | * BIO_POOL_IDX() | 118 | * BIO_POOL_IDX() |
118 | */ | 119 | */ |
119 | #define BIO_RESET_BITS 12 | 120 | #define BIO_RESET_BITS 13 |
120 | 121 | ||
121 | #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) | 122 | #define bio_flagged(bio, flag) ((bio)->bi_flags & (1 << (flag))) |
122 | 123 | ||
diff --git a/include/linux/buffer_head.h b/include/linux/buffer_head.h index 5afc4f94d110..4c16c4a88d47 100644 --- a/include/linux/buffer_head.h +++ b/include/linux/buffer_head.h | |||
@@ -181,6 +181,7 @@ void ll_rw_block(int, int, struct buffer_head * bh[]); | |||
181 | int sync_dirty_buffer(struct buffer_head *bh); | 181 | int sync_dirty_buffer(struct buffer_head *bh); |
182 | int __sync_dirty_buffer(struct buffer_head *bh, int rw); | 182 | int __sync_dirty_buffer(struct buffer_head *bh, int rw); |
183 | void write_dirty_buffer(struct buffer_head *bh, int rw); | 183 | void write_dirty_buffer(struct buffer_head *bh, int rw); |
184 | int _submit_bh(int rw, struct buffer_head *bh, unsigned long bio_flags); | ||
184 | int submit_bh(int, struct buffer_head *); | 185 | int submit_bh(int, struct buffer_head *); |
185 | void write_boundary_block(struct block_device *bdev, | 186 | void write_boundary_block(struct block_device *bdev, |
186 | sector_t bblock, unsigned blocksize); | 187 | sector_t bblock, unsigned blocksize); |
diff --git a/include/uapi/linux/fs.h b/include/uapi/linux/fs.h index c7fc1e6517c3..a4ed56cf0eac 100644 --- a/include/uapi/linux/fs.h +++ b/include/uapi/linux/fs.h | |||
@@ -88,7 +88,6 @@ struct inodes_stat_t { | |||
88 | #define MS_STRICTATIME (1<<24) /* Always perform atime updates */ | 88 | #define MS_STRICTATIME (1<<24) /* Always perform atime updates */ |
89 | 89 | ||
90 | /* These sb flags are internal to the kernel */ | 90 | /* These sb flags are internal to the kernel */ |
91 | #define MS_SNAP_STABLE (1<<27) /* Snapshot pages during writeback, if needed */ | ||
92 | #define MS_NOSEC (1<<28) | 91 | #define MS_NOSEC (1<<28) |
93 | #define MS_BORN (1<<29) | 92 | #define MS_BORN (1<<29) |
94 | #define MS_ACTIVE (1<<30) | 93 | #define MS_ACTIVE (1<<30) |
diff --git a/mm/bounce.c b/mm/bounce.c index 5f8901768602..a5c2ec3589cb 100644 --- a/mm/bounce.c +++ b/mm/bounce.c | |||
@@ -181,32 +181,13 @@ static void bounce_end_io_read_isa(struct bio *bio, int err) | |||
181 | #ifdef CONFIG_NEED_BOUNCE_POOL | 181 | #ifdef CONFIG_NEED_BOUNCE_POOL |
182 | static int must_snapshot_stable_pages(struct request_queue *q, struct bio *bio) | 182 | static int must_snapshot_stable_pages(struct request_queue *q, struct bio *bio) |
183 | { | 183 | { |
184 | struct page *page; | ||
185 | struct backing_dev_info *bdi; | ||
186 | struct address_space *mapping; | ||
187 | struct bio_vec *from; | ||
188 | int i; | ||
189 | |||
190 | if (bio_data_dir(bio) != WRITE) | 184 | if (bio_data_dir(bio) != WRITE) |
191 | return 0; | 185 | return 0; |
192 | 186 | ||
193 | if (!bdi_cap_stable_pages_required(&q->backing_dev_info)) | 187 | if (!bdi_cap_stable_pages_required(&q->backing_dev_info)) |
194 | return 0; | 188 | return 0; |
195 | 189 | ||
196 | /* | 190 | return test_bit(BIO_SNAP_STABLE, &bio->bi_flags); |
197 | * Based on the first page that has a valid mapping, decide whether or | ||
198 | * not we have to employ bounce buffering to guarantee stable pages. | ||
199 | */ | ||
200 | bio_for_each_segment(from, bio, i) { | ||
201 | page = from->bv_page; | ||
202 | mapping = page_mapping(page); | ||
203 | if (!mapping) | ||
204 | continue; | ||
205 | bdi = mapping->backing_dev_info; | ||
206 | return mapping->host->i_sb->s_flags & MS_SNAP_STABLE; | ||
207 | } | ||
208 | |||
209 | return 0; | ||
210 | } | 191 | } |
211 | #else | 192 | #else |
212 | static int must_snapshot_stable_pages(struct request_queue *q, struct bio *bio) | 193 | static int must_snapshot_stable_pages(struct request_queue *q, struct bio *bio) |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index efe68148f621..4514ad7415c3 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -2311,10 +2311,6 @@ void wait_for_stable_page(struct page *page) | |||
2311 | 2311 | ||
2312 | if (!bdi_cap_stable_pages_required(bdi)) | 2312 | if (!bdi_cap_stable_pages_required(bdi)) |
2313 | return; | 2313 | return; |
2314 | #ifdef CONFIG_NEED_BOUNCE_POOL | ||
2315 | if (mapping->host->i_sb->s_flags & MS_SNAP_STABLE) | ||
2316 | return; | ||
2317 | #endif /* CONFIG_NEED_BOUNCE_POOL */ | ||
2318 | 2314 | ||
2319 | wait_on_page_writeback(page); | 2315 | wait_on_page_writeback(page); |
2320 | } | 2316 | } |