Lines Matching +full:ip +full:- +full:block

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
4 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved.
49 * If it's a fully non-blocking write attempt and we cannot in gfs2_aspace_write_folio()
51 * potentially cause a busy-wait loop from flusher thread and kswapd in gfs2_aspace_write_folio()
52 * activity, but those code paths have their own higher-level in gfs2_aspace_write_folio()
55 if (wbc->sync_mode != WB_SYNC_NONE) { in gfs2_aspace_write_folio()
66 } while ((bh = bh->b_this_page) != head); in gfs2_aspace_write_folio()
76 struct buffer_head *next = bh->b_this_page; in gfs2_aspace_write_folio()
116 * gfs2_getbuf - Get a buffer with a given address space
118 * @blkno: the block number (filesystem scope)
127 struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; in gfs2_getbuf()
135 mapping = &sdp->sd_aspace; in gfs2_getbuf()
137 shift = PAGE_SHIFT - sdp->sd_sb.sb_bsize_shift; in gfs2_getbuf()
138 index = blkno >> shift; /* convert block to page */ in gfs2_getbuf()
139 bufnum = blkno - (index << shift); /* block buf index within page */ in gfs2_getbuf()
148 sdp->sd_sb.sb_bsize, 0); in gfs2_getbuf()
162 map_bh(bh, sdp->sd_vfs, blkno); in gfs2_getbuf()
173 struct gfs2_meta_header *mh = (struct gfs2_meta_header *)bh->b_data; in meta_prep_new()
180 mh->mh_magic = cpu_to_be32(GFS2_MAGIC); in meta_prep_new()
184 * gfs2_meta_new - Get a block
185 * @gl: The glock associated with this block
186 * @blkno: The block number
205 struct page *page = bvec->bv_page; in gfs2_meta_read_endio()
207 unsigned int len = bvec->bv_len; in gfs2_meta_read_endio()
209 while (bh_offset(bh) < bvec->bv_offset) in gfs2_meta_read_endio()
210 bh = bh->b_this_page; in gfs2_meta_read_endio()
212 struct buffer_head *next = bh->b_this_page; in gfs2_meta_read_endio()
213 len -= bh->b_size; in gfs2_meta_read_endio()
214 bh->b_end_io(bh, !bio->bi_status); in gfs2_meta_read_endio()
231 bio = bio_alloc(bh->b_bdev, num, opf, GFP_NOIO); in gfs2_submit_bhs()
232 bio->bi_iter.bi_sector = bh->b_blocknr * (bh->b_size >> 9); in gfs2_submit_bhs()
235 if (!bio_add_page(bio, bh->b_page, bh->b_size, bh_offset(bh))) { in gfs2_submit_bhs()
236 BUG_ON(bio->bi_iter.bi_size == 0); in gfs2_submit_bhs()
240 num--; in gfs2_submit_bhs()
242 bio->bi_end_io = gfs2_meta_read_endio; in gfs2_submit_bhs()
248 * gfs2_meta_read - Read a block from disk
249 * @gl: The glock covering the block
250 * @blkno: The block number
252 * @rahead: Do read-ahead
261 struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; in gfs2_meta_read()
268 return -EIO; in gfs2_meta_read()
278 bh->b_end_io = end_buffer_read_sync; in gfs2_meta_read()
291 bh->b_end_io = end_buffer_read_sync; in gfs2_meta_read()
303 struct gfs2_trans *tr = current->journal_info; in gfs2_meta_read()
304 if (tr && test_bit(TR_TOUCHED, &tr->tr_flags)) in gfs2_meta_read()
308 return -EIO; in gfs2_meta_read()
315 * gfs2_meta_wait - Reread a block from disk
317 * @bh: The block to wait for
326 return -EIO; in gfs2_meta_wait()
331 struct gfs2_trans *tr = current->journal_info; in gfs2_meta_wait()
332 if (tr && test_bit(TR_TOUCHED, &tr->tr_flags)) in gfs2_meta_wait()
334 return -EIO; in gfs2_meta_wait()
338 return -EIO; in gfs2_meta_wait()
345 struct address_space *mapping = bh->b_folio->mapping; in gfs2_remove_from_journal()
347 struct gfs2_bufdata *bd = bh->b_private; in gfs2_remove_from_journal()
348 struct gfs2_trans *tr = current->journal_info; in gfs2_remove_from_journal()
353 atomic_dec(&sdp->sd_log_pinned); in gfs2_remove_from_journal()
354 list_del_init(&bd->bd_list); in gfs2_remove_from_journal()
356 tr->tr_num_buf_rm++; in gfs2_remove_from_journal()
358 tr->tr_num_databuf_rm++; in gfs2_remove_from_journal()
359 set_bit(TR_TOUCHED, &tr->tr_flags); in gfs2_remove_from_journal()
364 if (bd->bd_tr) { in gfs2_remove_from_journal()
367 bh->b_private = NULL; in gfs2_remove_from_journal()
369 } else if (!list_empty(&bd->bd_ail_st_list) && in gfs2_remove_from_journal()
370 !list_empty(&bd->bd_ail_gl_list)) { in gfs2_remove_from_journal()
379 * gfs2_ail1_wipe - remove deleted/freed buffers from the ail1 list
381 * @bstart: starting block address of buffers to remove
397 spin_lock(&sdp->sd_ail_lock); in gfs2_ail1_wipe()
398 list_for_each_entry_safe(tr, s, &sdp->sd_ail1_list, tr_list) { in gfs2_ail1_wipe()
399 list_for_each_entry_safe(bd, bs, &tr->tr_ail1_list, in gfs2_ail1_wipe()
401 bh = bd->bd_bh; in gfs2_ail1_wipe()
402 if (bh->b_blocknr < bstart || bh->b_blocknr >= end) in gfs2_ail1_wipe()
408 spin_unlock(&sdp->sd_ail_lock); in gfs2_ail1_wipe()
412 static struct buffer_head *gfs2_getjdatabuf(struct gfs2_inode *ip, u64 blkno) in gfs2_getjdatabuf() argument
414 struct address_space *mapping = ip->i_inode.i_mapping; in gfs2_getjdatabuf()
415 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_getjdatabuf()
418 unsigned int shift = PAGE_SHIFT - sdp->sd_sb.sb_bsize_shift; in gfs2_getjdatabuf()
419 unsigned long index = blkno >> shift; /* convert block to page */ in gfs2_getjdatabuf()
420 unsigned int bufnum = blkno - (index << shift); in gfs2_getjdatabuf()
434 * gfs2_journal_wipe - make inode's buffers so they aren't dirty/pinned anymore
435 * @ip: the inode who owns the buffers
441 void gfs2_journal_wipe(struct gfs2_inode *ip, u64 bstart, u32 blen) in gfs2_journal_wipe() argument
443 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_journal_wipe()
447 if (!ip->i_gl) { in gfs2_journal_wipe()
449 BUG_ON(!test_bit(GIF_ALLOC_FAILED, &ip->i_flags)); in gfs2_journal_wipe()
456 bh = gfs2_getbuf(ip->i_gl, bstart, NO_CREATE); in gfs2_journal_wipe()
457 if (!bh && gfs2_is_jdata(ip)) { in gfs2_journal_wipe()
458 bh = gfs2_getjdatabuf(ip, bstart); in gfs2_journal_wipe()
464 spin_lock(&sdp->sd_ail_lock); in gfs2_journal_wipe()
466 spin_unlock(&sdp->sd_ail_lock); in gfs2_journal_wipe()
473 blen--; in gfs2_journal_wipe()
478 * gfs2_meta_buffer - Get a metadata buffer
479 * @ip: The GFS2 inode
480 * @mtype: The block type (GFS2_METATYPE_*)
481 * @num: The block number (device relative) of the buffer
487 int gfs2_meta_buffer(struct gfs2_inode *ip, u32 mtype, u64 num, in gfs2_meta_buffer() argument
490 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); in gfs2_meta_buffer()
491 struct gfs2_glock *gl = ip->i_gl; in gfs2_meta_buffer()
496 if (num == ip->i_no_addr) in gfs2_meta_buffer()
497 rahead = ip->i_rahead; in gfs2_meta_buffer()
502 ret = -EIO; in gfs2_meta_buffer()
510 * gfs2_meta_ra - start readahead on an extent of a file
512 * @dblock: the starting disk block
520 struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; in gfs2_meta_ra()
523 sdp->sd_sb.sb_bsize_shift; in gfs2_meta_ra()
539 extlen--; in gfs2_meta_ra()
547 extlen--; in gfs2_meta_ra()