static void e2fsck_journal_release(e2fsck_t ctx, journal_t *journal, int reset, int drop) { journal_superblock_t *jsb; if (drop) mark_buffer_clean(journal->j_sb_buffer); else if (!(ctx->options & E2F_OPT_READONLY)) { jsb = journal->j_superblock; jsb->s_sequence = htonl(journal->j_transaction_sequence); if (reset) jsb->s_start = 0; /* this marks the journal as empty */ mark_buffer_dirty(journal->j_sb_buffer); } brelse(journal->j_sb_buffer); if (ctx->journal_io) { if (ctx->fs && ctx->fs->io != ctx->journal_io) io_channel_close(ctx->journal_io); ctx->journal_io = 0; } #ifndef USE_INODE_IO if (journal->j_inode) ext2fs_free_mem(&journal->j_inode); #endif if (journal->j_fs_dev) ext2fs_free_mem(&journal->j_fs_dev); ext2fs_free_mem(&journal); }
/* * The functions for minix V1 fs truncation. */ static int V1_trunc_direct(register struct inode *inode) { unsigned short *p; register struct buffer_head *bh; unsigned short tmp; int i; int retry = 0; repeat: for (i = DIRECT_BLOCK; i < 7; i++) { p = &inode->i_zone[i]; if (!(tmp = *p)) continue; bh = get_hash_table(inode->i_dev, (block_t) tmp); if (i < DIRECT_BLOCK) { brelse(bh); goto repeat; } if ((bh && bh->b_count != 1) || tmp != *p) { retry = 1; brelse(bh); continue; } *p = 0; inode->i_dirt = 1; if (bh) { mark_buffer_clean(bh); brelse(bh); } minix_free_block(inode->i_sb, tmp); } return retry; }
static void ext2fs_journal_release(ext2_filsys fs, journal_t *journal, int reset, int drop) { journal_superblock_t *jsb; if (drop) mark_buffer_clean(journal->j_sb_buffer); else if (fs->flags & EXT2_FLAG_RW) { jsb = journal->j_superblock; jsb->s_sequence = htonl(journal->j_tail_sequence); if (reset) jsb->s_start = 0; /* this marks the journal as empty */ ext2fs_journal_sb_csum_set(journal, jsb); mark_buffer_dirty(journal->j_sb_buffer); } brelse(journal->j_sb_buffer); if (fs && fs->journal_io) { if (fs->io != fs->journal_io) io_channel_close(fs->journal_io); fs->journal_io = NULL; } #ifndef USE_INODE_IO if (journal->j_inode) ext2fs_free_mem(&journal->j_inode); #endif if (journal->j_fs_dev) ext2fs_free_mem(&journal->j_fs_dev); ext2fs_free_mem(&journal); }
/* stolen from fs/buffer.c */ void reiserfs_unmap_buffer(struct buffer_head *bh) { if (buffer_mapped(bh)) { if (buffer_journaled(bh) || buffer_journal_dirty(bh)) { BUG() ; } mark_buffer_clean(bh) ; lock_buffer(bh) ; clear_bit(BH_Mapped, &bh->b_state) ; clear_bit(BH_Req, &bh->b_state) ; clear_bit(BH_New, &bh->b_state) ; unlock_buffer(bh) ; } }
void ext_free_block(struct super_block * sb, int block) { struct buffer_head * bh; struct ext_free_block * efb; if (!sb) { printk("trying to free block on non-existent device\n"); return; } lock_super (sb); if (block < sb->u.ext_sb.s_firstdatazone || block >= sb->u.ext_sb.s_nzones) { printk("trying to free block not in datazone\n"); return; } bh = get_hash_table(sb->s_dev, block, sb->s_blocksize); if (bh) mark_buffer_clean(bh); brelse(bh); if (sb->u.ext_sb.s_firstfreeblock) efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data; if (!sb->u.ext_sb.s_firstfreeblock || efb->count == 254) { #ifdef EXTFS_DEBUG printk("ext_free_block: block full, skipping to %d\n", block); #endif if (sb->u.ext_sb.s_firstfreeblock) brelse (sb->u.ext_sb.s_firstfreeblock); if (!(sb->u.ext_sb.s_firstfreeblock = bread (sb->s_dev, block, sb->s_blocksize))) panic ("ext_free_block: unable to read block to free\n"); efb = (struct ext_free_block *) sb->u.ext_sb.s_firstfreeblock->b_data; efb->next = sb->u.ext_sb.s_firstfreeblocknumber; efb->count = 0; sb->u.ext_sb.s_firstfreeblocknumber = block; } else { efb->free[efb->count++] = block; } sb->u.ext_sb.s_freeblockscount ++; sb->s_dirt = 1; mark_buffer_dirty(sb->u.ext_sb.s_firstfreeblock, 1); unlock_super (sb); return; }
/** * eefs_refill_write - refill-callback for writing * @buf: target buffer * * This is the refill-callback function for files opened for writing. */ static uint8_t eefs_refill_write(buffer_t *buf) { eefs_error_t res; uint16_t byteswritten; /* fix up lastused for incomplete blocks */ if (!buf->mustflush) buf->lastused = buf->position - 1; res = eepromfs_write(&buf->pvt.eefh, buf->data + 2, buf->lastused - 1, &byteswritten); if (res != EEFS_ERROR_OK) { // eepromfs never returns OK if the write was incomplete translate_error(res); eepromfs_close(&buf->pvt.eefh); free_buffer(buf); return 1; } mark_buffer_clean(buf); buf->mustflush = 0; buf->position = 2; buf->lastused = 2; return 0; }