--- linux-2.6.11.2/drivers/block/loop.c.orig 2005-03-10 23:22:12.000000000 -0800 +++ linux-2.6.11.2/drivers/block/loop.c 2005-03-10 23:22:21.000000000 -0800 @@ -608,6 +608,12 @@ if (get_loop_size(lo, file) != get_loop_size(lo, old_file)) goto out_putf; + if (old_file->f_op && old_file->f_op->flush) { + error = old_file->f_op->flush(old_file); + if (error) + goto out_putf; + } + /* and ... switch */ error = loop_switch(lo, file); if (error) @@ -820,6 +826,10 @@ bd_set_size(bdev, 0); mapping_set_gfp_mask(filp->f_mapping, gfp); lo->lo_state = Lo_unbound; + + if (filp->f_op && filp->f_op->flush) + filp->f_op->flush(filp); + fput(filp); /* This is safe: open() is still holding a reference. */ module_put(THIS_MODULE);