log.c (5a4e9c607e03886815121fa975fcd8e0fa7252fe) | log.c (6188e8777de48c8404b0bcca74a70ac83c37d773) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 4 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. 5 */ 6 7#include <linux/sched.h> 8#include <linux/slab.h> --- 36 unchanged lines hidden (view full) --- 45 * Returns: the number of blocks needed (minimum is always 1) 46 */ 47 48unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct) 49{ 50 unsigned int blks; 51 unsigned int first, second; 52 | 1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved. 4 * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. 5 */ 6 7#include <linux/sched.h> 8#include <linux/slab.h> --- 36 unchanged lines hidden (view full) --- 45 * Returns: the number of blocks needed (minimum is always 1) 46 */ 47 48unsigned int gfs2_struct2blk(struct gfs2_sbd *sdp, unsigned int nstruct) 49{ 50 unsigned int blks; 51 unsigned int first, second; 52 |
53 /* The initial struct gfs2_log_descriptor block */ |
|
53 blks = 1; 54 first = sdp->sd_ldptrs; 55 56 if (nstruct > first) { | 54 blks = 1; 55 first = sdp->sd_ldptrs; 56 57 if (nstruct > first) { |
58 /* Subsequent struct gfs2_meta_header blocks */ |
|
57 second = sdp->sd_inptrs; 58 blks += DIV_ROUND_UP(nstruct - first, second); 59 } 60 61 return blks; 62} 63 64/** --- 437 unchanged lines hidden (view full) --- 502 dist = newer - older; 503 if (dist < 0) 504 dist += sdp->sd_jdesc->jd_blocks; 505 506 return dist; 507} 508 509/** | 59 second = sdp->sd_inptrs; 60 blks += DIV_ROUND_UP(nstruct - first, second); 61 } 62 63 return blks; 64} 65 66/** --- 437 unchanged lines hidden (view full) --- 504 dist = newer - older; 505 if (dist < 0) 506 dist += sdp->sd_jdesc->jd_blocks; 507 508 return dist; 509} 510 511/** |
510 * calc_reserved - Calculate the number of blocks to reserve when 511 * refunding a transaction's unused buffers. | 512 * calc_reserved - Calculate the number of blocks to keep reserved |
512 * @sdp: The GFS2 superblock 513 * 514 * This is complex. We need to reserve room for all our currently used | 513 * @sdp: The GFS2 superblock 514 * 515 * This is complex. We need to reserve room for all our currently used |
515 * metadata buffers (e.g. normal file I/O rewriting file time stamps) and 516 * all our journaled data buffers for journaled files (e.g. files in the | 516 * metadata blocks (e.g. normal file I/O rewriting file time stamps) and 517 * all our journaled data blocks for journaled files (e.g. files in the |
517 * meta_fs like rindex, or files for which chattr +j was done.) | 518 * meta_fs like rindex, or files for which chattr +j was done.) |
518 * If we don't reserve enough space, gfs2_log_refund and gfs2_log_flush 519 * will count it as free space (sd_log_blks_free) and corruption will follow. | 519 * If we don't reserve enough space, corruption will follow. |
520 * | 520 * |
521 * We can have metadata bufs and jdata bufs in the same journal. So each 522 * type gets its own log header, for which we need to reserve a block. 523 * In fact, each type has the potential for needing more than one header 524 * in cases where we have more buffers than will fit on a journal page. | 521 * We can have metadata blocks and jdata blocks in the same journal. Each 522 * type gets its own log descriptor, for which we need to reserve a block. 523 * In fact, each type has the potential for needing more than one log descriptor 524 * in cases where we have more blocks than will fit in a log descriptor. |
525 * Metadata journal entries take up half the space of journaled buffer entries. | 525 * Metadata journal entries take up half the space of journaled buffer entries. |
526 * Thus, metadata entries have buf_limit (502) and journaled buffers have 527 * databuf_limit (251) before they cause a wrap around. | |
528 * 529 * Also, we need to reserve blocks for revoke journal entries and one for an 530 * overall header for the lot. 531 * 532 * Returns: the number of blocks reserved 533 */ 534static unsigned int calc_reserved(struct gfs2_sbd *sdp) 535{ --- 467 unchanged lines hidden (view full) --- 1003 goto out_withdraw; 1004 gfs2_log_submit_bio(&sdp->sd_log_bio, REQ_OP_WRITE); 1005 if (gfs2_withdrawn(sdp)) 1006 goto out_withdraw; 1007 1008 if (sdp->sd_log_head != sdp->sd_log_flush_head) { 1009 log_flush_wait(sdp); 1010 log_write_header(sdp, flags); | 526 * 527 * Also, we need to reserve blocks for revoke journal entries and one for an 528 * overall header for the lot. 529 * 530 * Returns: the number of blocks reserved 531 */ 532static unsigned int calc_reserved(struct gfs2_sbd *sdp) 533{ --- 467 unchanged lines hidden (view full) --- 1001 goto out_withdraw; 1002 gfs2_log_submit_bio(&sdp->sd_log_bio, REQ_OP_WRITE); 1003 if (gfs2_withdrawn(sdp)) 1004 goto out_withdraw; 1005 1006 if (sdp->sd_log_head != sdp->sd_log_flush_head) { 1007 log_flush_wait(sdp); 1008 log_write_header(sdp, flags); |
1011 } else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle){ | 1009 } else if (sdp->sd_log_tail != current_tail(sdp) && !sdp->sd_log_idle) { |
1012 atomic_dec(&sdp->sd_log_blks_free); /* Adjust for unreserved buffer */ 1013 trace_gfs2_log_blocks(sdp, -1); 1014 log_write_header(sdp, flags); 1015 } 1016 if (gfs2_withdrawn(sdp)) 1017 goto out_withdraw; 1018 lops_after_commit(sdp, tr); 1019 --- 252 unchanged lines hidden --- | 1010 atomic_dec(&sdp->sd_log_blks_free); /* Adjust for unreserved buffer */ 1011 trace_gfs2_log_blocks(sdp, -1); 1012 log_write_header(sdp, flags); 1013 } 1014 if (gfs2_withdrawn(sdp)) 1015 goto out_withdraw; 1016 lops_after_commit(sdp, tr); 1017 --- 252 unchanged lines hidden --- |