summaryrefslogtreecommitdiffstats
path: root/fs/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/buffer.c')
-rw-r--r--fs/buffer.c53
1 files changed, 27 insertions, 26 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index 9a55e7f8b25c..881d33606830 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -45,7 +45,7 @@
45#include <trace/events/block.h> 45#include <trace/events/block.h>
46 46
47static int fsync_buffers_list(spinlock_t *lock, struct list_head *list); 47static int fsync_buffers_list(spinlock_t *lock, struct list_head *list);
48static int submit_bh_wbc(int rw, struct buffer_head *bh, 48static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
49 unsigned long bio_flags, 49 unsigned long bio_flags,
50 struct writeback_control *wbc); 50 struct writeback_control *wbc);
51 51
@@ -1225,7 +1225,7 @@ static struct buffer_head *__bread_slow(struct buffer_head *bh)
1225 } else { 1225 } else {
1226 get_bh(bh); 1226 get_bh(bh);
1227 bh->b_end_io = end_buffer_read_sync; 1227 bh->b_end_io = end_buffer_read_sync;
1228 submit_bh(READ, bh); 1228 submit_bh(REQ_OP_READ, 0, bh);
1229 wait_on_buffer(bh); 1229 wait_on_buffer(bh);
1230 if (buffer_uptodate(bh)) 1230 if (buffer_uptodate(bh))
1231 return bh; 1231 return bh;
@@ -1697,7 +1697,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
1697 struct buffer_head *bh, *head; 1697 struct buffer_head *bh, *head;
1698 unsigned int blocksize, bbits; 1698 unsigned int blocksize, bbits;
1699 int nr_underway = 0; 1699 int nr_underway = 0;
1700 int write_op = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE); 1700 int write_flags = (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : 0);
1701 1701
1702 head = create_page_buffers(page, inode, 1702 head = create_page_buffers(page, inode,
1703 (1 << BH_Dirty)|(1 << BH_Uptodate)); 1703 (1 << BH_Dirty)|(1 << BH_Uptodate));
@@ -1786,7 +1786,7 @@ static int __block_write_full_page(struct inode *inode, struct page *page,
1786 do { 1786 do {
1787 struct buffer_head *next = bh->b_this_page; 1787 struct buffer_head *next = bh->b_this_page;
1788 if (buffer_async_write(bh)) { 1788 if (buffer_async_write(bh)) {
1789 submit_bh_wbc(write_op, bh, 0, wbc); 1789 submit_bh_wbc(REQ_OP_WRITE, write_flags, bh, 0, wbc);
1790 nr_underway++; 1790 nr_underway++;
1791 } 1791 }
1792 bh = next; 1792 bh = next;
@@ -1840,7 +1840,7 @@ recover:
1840 struct buffer_head *next = bh->b_this_page; 1840 struct buffer_head *next = bh->b_this_page;
1841 if (buffer_async_write(bh)) { 1841 if (buffer_async_write(bh)) {
1842 clear_buffer_dirty(bh); 1842 clear_buffer_dirty(bh);
1843 submit_bh_wbc(write_op, bh, 0, wbc); 1843 submit_bh_wbc(REQ_OP_WRITE, write_flags, bh, 0, wbc);
1844 nr_underway++; 1844 nr_underway++;
1845 } 1845 }
1846 bh = next; 1846 bh = next;
@@ -2248,7 +2248,7 @@ int block_read_full_page(struct page *page, get_block_t *get_block)
2248 if (buffer_uptodate(bh)) 2248 if (buffer_uptodate(bh))
2249 end_buffer_async_read(bh, 1); 2249 end_buffer_async_read(bh, 1);
2250 else 2250 else
2251 submit_bh(READ, bh); 2251 submit_bh(REQ_OP_READ, 0, bh);
2252 } 2252 }
2253 return 0; 2253 return 0;
2254} 2254}
@@ -2582,7 +2582,7 @@ int nobh_write_begin(struct address_space *mapping,
2582 if (block_start < from || block_end > to) { 2582 if (block_start < from || block_end > to) {
2583 lock_buffer(bh); 2583 lock_buffer(bh);
2584 bh->b_end_io = end_buffer_read_nobh; 2584 bh->b_end_io = end_buffer_read_nobh;
2585 submit_bh(READ, bh); 2585 submit_bh(REQ_OP_READ, 0, bh);
2586 nr_reads++; 2586 nr_reads++;
2587 } 2587 }
2588 } 2588 }
@@ -2949,7 +2949,7 @@ static void end_bio_bh_io_sync(struct bio *bio)
2949 * errors, this only handles the "we need to be able to 2949 * errors, this only handles the "we need to be able to
2950 * do IO at the final sector" case. 2950 * do IO at the final sector" case.
2951 */ 2951 */
2952void guard_bio_eod(int rw, struct bio *bio) 2952void guard_bio_eod(int op, struct bio *bio)
2953{ 2953{
2954 sector_t maxsector; 2954 sector_t maxsector;
2955 struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1]; 2955 struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1];
@@ -2979,13 +2979,13 @@ void guard_bio_eod(int rw, struct bio *bio)
2979 bvec->bv_len -= truncated_bytes; 2979 bvec->bv_len -= truncated_bytes;
2980 2980
2981 /* ..and clear the end of the buffer for reads */ 2981 /* ..and clear the end of the buffer for reads */
2982 if ((rw & RW_MASK) == READ) { 2982 if (op == REQ_OP_READ) {
2983 zero_user(bvec->bv_page, bvec->bv_offset + bvec->bv_len, 2983 zero_user(bvec->bv_page, bvec->bv_offset + bvec->bv_len,
2984 truncated_bytes); 2984 truncated_bytes);
2985 } 2985 }
2986} 2986}
2987 2987
2988static int submit_bh_wbc(int rw, struct buffer_head *bh, 2988static int submit_bh_wbc(int op, int op_flags, struct buffer_head *bh,
2989 unsigned long bio_flags, struct writeback_control *wbc) 2989 unsigned long bio_flags, struct writeback_control *wbc)
2990{ 2990{
2991 struct bio *bio; 2991 struct bio *bio;
@@ -2999,7 +2999,7 @@ static int submit_bh_wbc(int rw, struct buffer_head *bh,
2999 /* 2999 /*
3000 * Only clear out a write error when rewriting 3000 * Only clear out a write error when rewriting
3001 */ 3001 */
3002 if (test_set_buffer_req(bh) && (rw & WRITE)) 3002 if (test_set_buffer_req(bh) && (op == REQ_OP_WRITE))
3003 clear_buffer_write_io_error(bh); 3003 clear_buffer_write_io_error(bh);
3004 3004
3005 /* 3005 /*
@@ -3024,27 +3024,28 @@ static int submit_bh_wbc(int rw, struct buffer_head *bh,
3024 bio->bi_flags |= bio_flags; 3024 bio->bi_flags |= bio_flags;
3025 3025
3026 /* Take care of bh's that straddle the end of the device */ 3026 /* Take care of bh's that straddle the end of the device */
3027 guard_bio_eod(rw, bio); 3027 guard_bio_eod(op, bio);
3028 3028
3029 if (buffer_meta(bh)) 3029 if (buffer_meta(bh))
3030 rw |= REQ_META; 3030 op_flags |= REQ_META;
3031 if (buffer_prio(bh)) 3031 if (buffer_prio(bh))
3032 rw |= REQ_PRIO; 3032 op_flags |= REQ_PRIO;
3033 bio->bi_rw = rw; 3033 bio_set_op_attrs(bio, op, op_flags);
3034 3034
3035 submit_bio(bio); 3035 submit_bio(bio);
3036 return 0; 3036 return 0;
3037} 3037}
3038 3038
3039int _submit_bh(int rw, struct buffer_head *bh, unsigned long bio_flags) 3039int _submit_bh(int op, int op_flags, struct buffer_head *bh,
3040 unsigned long bio_flags)
3040{ 3041{
3041 return submit_bh_wbc(rw, bh, bio_flags, NULL); 3042 return submit_bh_wbc(op, op_flags, bh, bio_flags, NULL);
3042} 3043}
3043EXPORT_SYMBOL_GPL(_submit_bh); 3044EXPORT_SYMBOL_GPL(_submit_bh);
3044 3045
3045int submit_bh(int rw, struct buffer_head *bh) 3046int submit_bh(int op, int op_flags, struct buffer_head *bh)
3046{ 3047{
3047 return submit_bh_wbc(rw, bh, 0, NULL); 3048 return submit_bh_wbc(op, op_flags, bh, 0, NULL);
3048} 3049}
3049EXPORT_SYMBOL(submit_bh); 3050EXPORT_SYMBOL(submit_bh);
3050 3051
@@ -3086,14 +3087,14 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
3086 if (test_clear_buffer_dirty(bh)) { 3087 if (test_clear_buffer_dirty(bh)) {
3087 bh->b_end_io = end_buffer_write_sync; 3088 bh->b_end_io = end_buffer_write_sync;
3088 get_bh(bh); 3089 get_bh(bh);
3089 submit_bh(WRITE, bh); 3090 submit_bh(rw, 0, bh);
3090 continue; 3091 continue;
3091 } 3092 }
3092 } else { 3093 } else {
3093 if (!buffer_uptodate(bh)) { 3094 if (!buffer_uptodate(bh)) {
3094 bh->b_end_io = end_buffer_read_sync; 3095 bh->b_end_io = end_buffer_read_sync;
3095 get_bh(bh); 3096 get_bh(bh);
3096 submit_bh(rw, bh); 3097 submit_bh(rw, 0, bh);
3097 continue; 3098 continue;
3098 } 3099 }
3099 } 3100 }
@@ -3102,7 +3103,7 @@ void ll_rw_block(int rw, int nr, struct buffer_head *bhs[])
3102} 3103}
3103EXPORT_SYMBOL(ll_rw_block); 3104EXPORT_SYMBOL(ll_rw_block);
3104 3105
3105void write_dirty_buffer(struct buffer_head *bh, int rw) 3106void write_dirty_buffer(struct buffer_head *bh, int op_flags)
3106{ 3107{
3107 lock_buffer(bh); 3108 lock_buffer(bh);
3108 if (!test_clear_buffer_dirty(bh)) { 3109 if (!test_clear_buffer_dirty(bh)) {
@@ -3111,7 +3112,7 @@ void write_dirty_buffer(struct buffer_head *bh, int rw)
3111 } 3112 }
3112 bh->b_end_io = end_buffer_write_sync; 3113 bh->b_end_io = end_buffer_write_sync;
3113 get_bh(bh); 3114 get_bh(bh);
3114 submit_bh(rw, bh); 3115 submit_bh(REQ_OP_WRITE, op_flags, bh);
3115} 3116}
3116EXPORT_SYMBOL(write_dirty_buffer); 3117EXPORT_SYMBOL(write_dirty_buffer);
3117 3118
@@ -3120,7 +3121,7 @@ EXPORT_SYMBOL(write_dirty_buffer);
3120 * and then start new I/O and then wait upon it. The caller must have a ref on 3121 * and then start new I/O and then wait upon it. The caller must have a ref on
3121 * the buffer_head. 3122 * the buffer_head.
3122 */ 3123 */
3123int __sync_dirty_buffer(struct buffer_head *bh, int rw) 3124int __sync_dirty_buffer(struct buffer_head *bh, int op_flags)
3124{ 3125{
3125 int ret = 0; 3126 int ret = 0;
3126 3127
@@ -3129,7 +3130,7 @@ int __sync_dirty_buffer(struct buffer_head *bh, int rw)
3129 if (test_clear_buffer_dirty(bh)) { 3130 if (test_clear_buffer_dirty(bh)) {
3130 get_bh(bh); 3131 get_bh(bh);
3131 bh->b_end_io = end_buffer_write_sync; 3132 bh->b_end_io = end_buffer_write_sync;
3132 ret = submit_bh(rw, bh); 3133 ret = submit_bh(REQ_OP_WRITE, op_flags, bh);
3133 wait_on_buffer(bh); 3134 wait_on_buffer(bh);
3134 if (!ret && !buffer_uptodate(bh)) 3135 if (!ret && !buffer_uptodate(bh))
3135 ret = -EIO; 3136 ret = -EIO;
@@ -3392,7 +3393,7 @@ int bh_submit_read(struct buffer_head *bh)
3392 3393
3393 get_bh(bh); 3394 get_bh(bh);
3394 bh->b_end_io = end_buffer_read_sync; 3395 bh->b_end_io = end_buffer_read_sync;
3395 submit_bh(READ, bh); 3396 submit_bh(REQ_OP_READ, 0, bh);
3396 wait_on_buffer(bh); 3397 wait_on_buffer(bh);
3397 if (buffer_uptodate(bh)) 3398 if (buffer_uptodate(bh))
3398 return 0; 3399 return 0;