log.c (0bd2af46839ad6262d25714a6ec0365db9d6b98f) log.c (b004157ab5b374a498a5874cda68c389219d23e7)
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 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 */

--- 247 unchanged lines hidden (view full) ---

256 gfs2_log_unlock(sdp);
257}
258
259/**
260 * gfs2_log_reserve - Make a log reservation
261 * @sdp: The GFS2 superblock
262 * @blks: The number of blocks to reserve
263 *
1/*
2 * Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
3 * Copyright (C) 2004-2006 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 */

--- 247 unchanged lines hidden (view full) ---

256 gfs2_log_unlock(sdp);
257}
258
259/**
260 * gfs2_log_reserve - Make a log reservation
261 * @sdp: The GFS2 superblock
262 * @blks: The number of blocks to reserve
263 *
264 * Note that we never give out the last 6 blocks of the journal. Thats
265 * due to the fact that there is are a small number of header blocks
266 * associated with each log flush. The exact number can't be known until
267 * flush time, so we ensure that we have just enough free blocks at all
268 * times to avoid running out during a log flush.
269 *
264 * Returns: errno
265 */
266
267int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)
268{
269 unsigned int try = 0;
270
271 if (gfs2_assert_warn(sdp, blks) ||
272 gfs2_assert_warn(sdp, blks <= sdp->sd_jdesc->jd_blocks))
273 return -EINVAL;
274
275 mutex_lock(&sdp->sd_log_reserve_mutex);
276 gfs2_log_lock(sdp);
270 * Returns: errno
271 */
272
273int gfs2_log_reserve(struct gfs2_sbd *sdp, unsigned int blks)
274{
275 unsigned int try = 0;
276
277 if (gfs2_assert_warn(sdp, blks) ||
278 gfs2_assert_warn(sdp, blks <= sdp->sd_jdesc->jd_blocks))
279 return -EINVAL;
280
281 mutex_lock(&sdp->sd_log_reserve_mutex);
282 gfs2_log_lock(sdp);
277 while(sdp->sd_log_blks_free <= blks) {
283 while(sdp->sd_log_blks_free <= (blks + 6)) {
278 gfs2_log_unlock(sdp);
279 gfs2_ail1_empty(sdp, 0);
280 gfs2_log_flush(sdp, NULL);
281
282 if (try++)
283 gfs2_ail1_start(sdp, 0);
284 gfs2_log_lock(sdp);
285 }

--- 352 unchanged lines hidden (view full) ---

638{
639 log_refund(sdp, tr);
640 lops_incore_commit(sdp, tr);
641
642 sdp->sd_vfs->s_dirt = 1;
643 up_read(&sdp->sd_log_flush_lock);
644
645 gfs2_log_lock(sdp);
284 gfs2_log_unlock(sdp);
285 gfs2_ail1_empty(sdp, 0);
286 gfs2_log_flush(sdp, NULL);
287
288 if (try++)
289 gfs2_ail1_start(sdp, 0);
290 gfs2_log_lock(sdp);
291 }

--- 352 unchanged lines hidden (view full) ---

644{
645 log_refund(sdp, tr);
646 lops_incore_commit(sdp, tr);
647
648 sdp->sd_vfs->s_dirt = 1;
649 up_read(&sdp->sd_log_flush_lock);
650
651 gfs2_log_lock(sdp);
646 if (sdp->sd_log_num_buf > gfs2_tune_get(sdp, gt_incore_log_blocks)) {
647 gfs2_log_unlock(sdp);
648 gfs2_log_flush(sdp, NULL);
649 } else {
650 gfs2_log_unlock(sdp);
651 }
652 if (sdp->sd_log_num_buf > gfs2_tune_get(sdp, gt_incore_log_blocks))
653 wake_up_process(sdp->sd_logd_process);
654 gfs2_log_unlock(sdp);
652}
653
654/**
655 * gfs2_log_shutdown - write a shutdown header into a journal
656 * @sdp: the filesystem
657 *
658 */
659

--- 29 unchanged lines hidden ---
655}
656
657/**
658 * gfs2_log_shutdown - write a shutdown header into a journal
659 * @sdp: the filesystem
660 *
661 */
662

--- 29 unchanged lines hidden ---