dprintf("%08lx-%08lx->%08lx\n", start, end, where); for (i = start; i <= end; i++) if(bfs_move_block(i, where + i, sb)) {
dprintf("failed to move block %08lx -> %08lx\n", i,
where + i); return -EIO;
} return 0;
}
/* * If the file is not empty and the requested block is within the * range of blocks allocated for this file, we can grant it.
*/ if (bi->i_sblock && (phys <= bi->i_eblock)) {
dprintf("c=%d, b=%08lx, phys=%08lx (interim block granted)\n",
create, (unsignedlong)block, phys);
map_bh(bh_result, sb, phys); return 0;
}
/* The file will be extended, so let's see if there is enough space. */ if (phys >= info->si_blocks) return -ENOSPC;
/* The rest has to be protected against itself. */
mutex_lock(&info->bfs_lock);
/* * If the last data block for this file is the last allocated * block, we can extend the file trivially, without moving it * anywhere.
*/ if (bi->i_eblock == info->si_lf_eblk) {
dprintf("c=%d, b=%08lx, phys=%08lx (simple extension)\n",
create, (unsignedlong)block, phys);
map_bh(bh_result, sb, phys);
info->si_freeb -= phys - bi->i_eblock;
info->si_lf_eblk = bi->i_eblock = phys;
mark_inode_dirty(inode);
err = 0; goto out;
}
/* Ok, we have to move this entire file to the next free block. */
phys = info->si_lf_eblk + 1; if (phys + block >= info->si_blocks) {
err = -ENOSPC; goto out;
}
if (bi->i_sblock) {
err = bfs_move_blocks(inode->i_sb, bi->i_sblock,
bi->i_eblock, phys); if (err) {
dprintf("failed to move ino=%08lx -> fs corruption\n",
inode->i_ino); goto out;
}
} else
err = 0;
/* * This assumes nothing can write the inode back while we are here * and thus update inode->i_blocks! (XXX)
*/
info->si_freeb -= bi->i_eblock - bi->i_sblock + 1 - inode->i_blocks;
mark_inode_dirty(inode);
map_bh(bh_result, sb, phys);
out:
mutex_unlock(&info->bfs_lock); return err;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.