libminixfs: do not flush blocks that are in use
This removes an implicit requirement for the way the libminixfs API is to be used, namely that a block is to be marked as dirty only once its contents have been fully updated, within a single get_block/put_block window. The requirement may not be appropriate for all file systems. Change-Id: I6a129d51b1a5e9aec1572039dc7c1c82dd795db5
This commit is contained in:
parent
cb9453ca63
commit
b8f6d4a649
|
@ -732,7 +732,7 @@ void lmfs_flushdev(dev_t dev)
|
||||||
/* Flush all dirty blocks for one device. */
|
/* Flush all dirty blocks for one device. */
|
||||||
|
|
||||||
register struct buf *bp;
|
register struct buf *bp;
|
||||||
static struct buf **dirty; /* static so it isn't on stack */
|
static struct buf **dirty;
|
||||||
static unsigned int dirtylistsize = 0;
|
static unsigned int dirtylistsize = 0;
|
||||||
int ndirty;
|
int ndirty;
|
||||||
|
|
||||||
|
@ -747,7 +747,11 @@ void lmfs_flushdev(dev_t dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (bp = &buf[0], ndirty = 0; bp < &buf[nr_bufs]; bp++) {
|
for (bp = &buf[0], ndirty = 0; bp < &buf[nr_bufs]; bp++) {
|
||||||
if (!lmfs_isclean(bp) && bp->lmfs_dev == dev) {
|
/* Do not flush dirty blocks that are in use (lmfs_count>0): the file
|
||||||
|
* system may mark the block as dirty before changing its contents, in
|
||||||
|
* which case the new contents could end up being lost.
|
||||||
|
*/
|
||||||
|
if (!lmfs_isclean(bp) && bp->lmfs_dev == dev && bp->lmfs_count == 0) {
|
||||||
dirty[ndirty++] = bp;
|
dirty[ndirty++] = bp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue