meta_io.c (8c57a5e7b2820f349c95b8c8393fec1e0f4070d2) | meta_io.c (70246286e94c335b5bea0cbc68a17a96dd620281) |
---|---|
1/* 2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This copyrighted material is made available to anyone wishing to use, 6 * modify, copy, or redistribute it subject to the terms and conditions 7 * of the GNU General Public License version 2. 8 */ --- 23 unchanged lines hidden (view full) --- 32#include "trans.h" 33#include "util.h" 34#include "trace_gfs2.h" 35 36static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wbc) 37{ 38 struct buffer_head *bh, *head; 39 int nr_underway = 0; | 1/* 2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This copyrighted material is made available to anyone wishing to use, 6 * modify, copy, or redistribute it subject to the terms and conditions 7 * of the GNU General Public License version 2. 8 */ --- 23 unchanged lines hidden (view full) --- 32#include "trans.h" 33#include "util.h" 34#include "trace_gfs2.h" 35 36static int gfs2_aspace_writepage(struct page *page, struct writeback_control *wbc) 37{ 38 struct buffer_head *bh, *head; 39 int nr_underway = 0; |
40 int write_op = REQ_META | REQ_PRIO | 41 (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : WRITE); | 40 int write_flags = REQ_META | REQ_PRIO | 41 (wbc->sync_mode == WB_SYNC_ALL ? WRITE_SYNC : 0); |
42 43 BUG_ON(!PageLocked(page)); 44 BUG_ON(!page_has_buffers(page)); 45 46 head = page_buffers(page); 47 bh = head; 48 49 do { --- 24 unchanged lines hidden (view full) --- 74 * drop the bh refcounts early. 75 */ 76 BUG_ON(PageWriteback(page)); 77 set_page_writeback(page); 78 79 do { 80 struct buffer_head *next = bh->b_this_page; 81 if (buffer_async_write(bh)) { | 42 43 BUG_ON(!PageLocked(page)); 44 BUG_ON(!page_has_buffers(page)); 45 46 head = page_buffers(page); 47 bh = head; 48 49 do { --- 24 unchanged lines hidden (view full) --- 74 * drop the bh refcounts early. 75 */ 76 BUG_ON(PageWriteback(page)); 77 set_page_writeback(page); 78 79 do { 80 struct buffer_head *next = bh->b_this_page; 81 if (buffer_async_write(bh)) { |
82 submit_bh(write_op, bh); | 82 submit_bh(REQ_OP_WRITE, write_flags, bh); |
83 nr_underway++; 84 } 85 bh = next; 86 } while (bh != head); 87 unlock_page(page); 88 89 if (nr_underway == 0) 90 end_page_writeback(page); --- 117 unchanged lines hidden (view full) --- 208 } 209 bio_put(bio); 210} 211 212/* 213 * Submit several consecutive buffer head I/O requests as a single bio I/O 214 * request. (See submit_bh_wbc.) 215 */ | 83 nr_underway++; 84 } 85 bh = next; 86 } while (bh != head); 87 unlock_page(page); 88 89 if (nr_underway == 0) 90 end_page_writeback(page); --- 117 unchanged lines hidden (view full) --- 208 } 209 bio_put(bio); 210} 211 212/* 213 * Submit several consecutive buffer head I/O requests as a single bio I/O 214 * request. (See submit_bh_wbc.) 215 */ |
216static void gfs2_submit_bhs(int rw, struct buffer_head *bhs[], int num) | 216static void gfs2_submit_bhs(int op, int op_flags, struct buffer_head *bhs[], 217 int num) |
217{ 218 struct buffer_head *bh = bhs[0]; 219 struct bio *bio; 220 int i; 221 222 if (!num) 223 return; 224 225 bio = bio_alloc(GFP_NOIO, num); 226 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); 227 bio->bi_bdev = bh->b_bdev; 228 for (i = 0; i < num; i++) { 229 bh = bhs[i]; 230 bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh)); 231 } 232 bio->bi_end_io = gfs2_meta_read_endio; | 218{ 219 struct buffer_head *bh = bhs[0]; 220 struct bio *bio; 221 int i; 222 223 if (!num) 224 return; 225 226 bio = bio_alloc(GFP_NOIO, num); 227 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); 228 bio->bi_bdev = bh->b_bdev; 229 for (i = 0; i < num; i++) { 230 bh = bhs[i]; 231 bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh)); 232 } 233 bio->bi_end_io = gfs2_meta_read_endio; |
233 submit_bio(rw, bio); | 234 bio_set_op_attrs(bio, op, op_flags); 235 submit_bio(bio); |
234} 235 236/** 237 * gfs2_meta_read - Read a block from disk 238 * @gl: The glock covering the block 239 * @blkno: The block number 240 * @flags: flags 241 * @bhp: the place where the buffer is returned (NULL on failure) --- 33 unchanged lines hidden (view full) --- 275 unlock_buffer(bh); 276 brelse(bh); 277 } else { 278 bh->b_end_io = end_buffer_read_sync; 279 bhs[num++] = bh; 280 } 281 } 282 | 236} 237 238/** 239 * gfs2_meta_read - Read a block from disk 240 * @gl: The glock covering the block 241 * @blkno: The block number 242 * @flags: flags 243 * @bhp: the place where the buffer is returned (NULL on failure) --- 33 unchanged lines hidden (view full) --- 277 unlock_buffer(bh); 278 brelse(bh); 279 } else { 280 bh->b_end_io = end_buffer_read_sync; 281 bhs[num++] = bh; 282 } 283 } 284 |
283 gfs2_submit_bhs(READ_SYNC | REQ_META | REQ_PRIO, bhs, num); | 285 gfs2_submit_bhs(REQ_OP_READ, READ_SYNC | REQ_META | REQ_PRIO, bhs, num); |
284 if (!(flags & DIO_WAIT)) 285 return 0; 286 287 bh = *bhp; 288 wait_on_buffer(bh); 289 if (unlikely(!buffer_uptodate(bh))) { 290 struct gfs2_trans *tr = current->journal_info; 291 if (tr && tr->tr_touched) --- 28 unchanged lines hidden (view full) --- 320 return -EIO; 321 } 322 if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) 323 return -EIO; 324 325 return 0; 326} 327 | 286 if (!(flags & DIO_WAIT)) 287 return 0; 288 289 bh = *bhp; 290 wait_on_buffer(bh); 291 if (unlikely(!buffer_uptodate(bh))) { 292 struct gfs2_trans *tr = current->journal_info; 293 if (tr && tr->tr_touched) --- 28 unchanged lines hidden (view full) --- 322 return -EIO; 323 } 324 if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags))) 325 return -EIO; 326 327 return 0; 328} 329 |
328void gfs2_remove_from_journal(struct buffer_head *bh, struct gfs2_trans *tr, int meta) | 330void gfs2_remove_from_journal(struct buffer_head *bh, int meta) |
329{ 330 struct address_space *mapping = bh->b_page->mapping; 331 struct gfs2_sbd *sdp = gfs2_mapping2sbd(mapping); 332 struct gfs2_bufdata *bd = bh->b_private; | 331{ 332 struct address_space *mapping = bh->b_page->mapping; 333 struct gfs2_sbd *sdp = gfs2_mapping2sbd(mapping); 334 struct gfs2_bufdata *bd = bh->b_private; |
335 struct gfs2_trans *tr = current->journal_info; |
|
333 int was_pinned = 0; 334 335 if (test_clear_buffer_pinned(bh)) { 336 trace_gfs2_pin(bd, 0); 337 atomic_dec(&sdp->sd_log_pinned); 338 list_del_init(&bd->bd_list); | 336 int was_pinned = 0; 337 338 if (test_clear_buffer_pinned(bh)) { 339 trace_gfs2_pin(bd, 0); 340 atomic_dec(&sdp->sd_log_pinned); 341 list_del_init(&bd->bd_list); |
339 if (meta) | 342 if (meta == REMOVE_META) |
340 tr->tr_num_buf_rm++; 341 else 342 tr->tr_num_databuf_rm++; 343 tr->tr_touched = 1; 344 was_pinned = 1; 345 brelse(bh); 346 } 347 if (bd) { --- 23 unchanged lines hidden (view full) --- 371 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 372 struct buffer_head *bh; 373 374 while (blen) { 375 bh = gfs2_getbuf(ip->i_gl, bstart, NO_CREATE); 376 if (bh) { 377 lock_buffer(bh); 378 gfs2_log_lock(sdp); | 343 tr->tr_num_buf_rm++; 344 else 345 tr->tr_num_databuf_rm++; 346 tr->tr_touched = 1; 347 was_pinned = 1; 348 brelse(bh); 349 } 350 if (bd) { --- 23 unchanged lines hidden (view full) --- 374 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); 375 struct buffer_head *bh; 376 377 while (blen) { 378 bh = gfs2_getbuf(ip->i_gl, bstart, NO_CREATE); 379 if (bh) { 380 lock_buffer(bh); 381 gfs2_log_lock(sdp); |
379 gfs2_remove_from_journal(bh, current->journal_info, 1); | 382 gfs2_remove_from_journal(bh, REMOVE_META); |
380 gfs2_log_unlock(sdp); 381 unlock_buffer(bh); 382 brelse(bh); 383 } 384 385 bstart++; 386 blen--; 387 } --- 54 unchanged lines hidden (view full) --- 442 if (extlen > max_ra) 443 extlen = max_ra; 444 445 first_bh = gfs2_getbuf(gl, dblock, CREATE); 446 447 if (buffer_uptodate(first_bh)) 448 goto out; 449 if (!buffer_locked(first_bh)) | 383 gfs2_log_unlock(sdp); 384 unlock_buffer(bh); 385 brelse(bh); 386 } 387 388 bstart++; 389 blen--; 390 } --- 54 unchanged lines hidden (view full) --- 445 if (extlen > max_ra) 446 extlen = max_ra; 447 448 first_bh = gfs2_getbuf(gl, dblock, CREATE); 449 450 if (buffer_uptodate(first_bh)) 451 goto out; 452 if (!buffer_locked(first_bh)) |
450 ll_rw_block(READ_SYNC | REQ_META, 1, &first_bh); | 453 ll_rw_block(REQ_OP_READ, READ_SYNC | REQ_META, 1, &first_bh); |
451 452 dblock++; 453 extlen--; 454 455 while (extlen) { 456 bh = gfs2_getbuf(gl, dblock, CREATE); 457 458 if (!buffer_uptodate(bh) && !buffer_locked(bh)) | 454 455 dblock++; 456 extlen--; 457 458 while (extlen) { 459 bh = gfs2_getbuf(gl, dblock, CREATE); 460 461 if (!buffer_uptodate(bh) && !buffer_locked(bh)) |
459 ll_rw_block(READA | REQ_META, 1, &bh); | 462 ll_rw_block(REQ_OP_READ, REQ_RAHEAD | REQ_META, 1, &bh); |
460 brelse(bh); 461 dblock++; 462 extlen--; 463 if (!buffer_locked(first_bh) && buffer_uptodate(first_bh)) 464 goto out; 465 } 466 467 wait_on_buffer(first_bh); 468out: 469 return first_bh; 470} 471 | 463 brelse(bh); 464 dblock++; 465 extlen--; 466 if (!buffer_locked(first_bh) && buffer_uptodate(first_bh)) 467 goto out; 468 } 469 470 wait_on_buffer(first_bh); 471out: 472 return first_bh; 473} 474 |