From 36f21439f5d8b2233d13e042833d4d921a5c2c40 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sat, 14 Jun 1997 07:25:40 +0000 Subject: [PATCH] ChangeLog, unix_io.c: Make the io_channel flush function do a fsync to flush the kernel buffers to disk. bmove.c, ext2fs.h: Added debugging flag to block move function. --- lib/ext2fs/ChangeLog | 5 +++++ lib/ext2fs/bmove.c | 7 +++++-- lib/ext2fs/ext2fs.h | 1 + lib/ext2fs/unix_io.c | 4 ++-- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 178f56d..cfec76c 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,8 @@ +Sat Jun 14 01:39:13 1997 Theodore Ts'o + + * unix_io.c (unix_flush): Make the io_channel flush function do a + fsync to flush the kernel buffers to disk. + Wed Jun 11 18:25:31 1997 Theodore Ts'o * inode.c (ext2fs_inode_scan_goto_blockgroup): Fix bug; the diff --git a/lib/ext2fs/bmove.c b/lib/ext2fs/bmove.c index c54ea13..c355453 100644 --- a/lib/ext2fs/bmove.c +++ b/lib/ext2fs/bmove.c @@ -24,6 +24,7 @@ struct process_block_struct { errcode_t error; char *buf; int add_dir; + int flags; }; static int process_block(ext2_filsys fs, blk_t *block_nr, @@ -65,8 +66,9 @@ static int process_block(ext2_filsys fs, blk_t *block_nr, *block_nr = block; ext2fs_mark_block_bitmap(pb->alloc_map, block); ret = BLOCK_CHANGED; - printf("ino=%ld, blockcnt=%d, %ld->%ld\n", pb->ino, - blockcnt, orig, block); + if (pb->flags & EXT2_BMOVE_DEBUG) + printf("ino=%ld, blockcnt=%d, %ld->%ld\n", pb->ino, + blockcnt, orig, block); } if (pb->add_dir) { retval = ext2fs_add_dir_block(fs->dblist, pb->ino, @@ -98,6 +100,7 @@ errcode_t ext2fs_move_blocks(ext2_filsys fs, pb.reserve = reserve; pb.error = 0; pb.alloc_map = alloc_map ? alloc_map : fs->block_map; + pb.flags = flags; block_buf = malloc(fs->blocksize * 4); if (!block_buf) diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h index face360..7305197 100644 --- a/lib/ext2fs/ext2fs.h +++ b/lib/ext2fs/ext2fs.h @@ -202,6 +202,7 @@ struct struct_ext2_filsys { * Flags for ext2fs_move_blocks */ #define EXT2_BMOVE_GET_DBLIST 0x0001 +#define EXT2_BMOVE_DEBUG 0x0002 /* * Return flags for the directory iterator functions diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index ef00902..c2007aa 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -265,8 +265,7 @@ error_out: } /* - * Flush data buffers to disk. Since we are currently using a - * write-through cache, this is a no-op. + * Flush data buffers to disk. */ static errcode_t unix_flush(io_channel channel) { @@ -276,6 +275,7 @@ static errcode_t unix_flush(io_channel channel) data = (struct unix_private_data *) channel->private_data; EXT2_CHECK_MAGIC(data, EXT2_ET_MAGIC_UNIX_IO_CHANNEL); + fsync(data->dev); return 0; } -- 1.8.3.1