/*===========================================================================* * fs_sync * *===========================================================================*/ int fs_sync() { /* Perform the sync() system call. Flush all the tables. * The order in which the various tables are flushed is critical. The * blocks must be flushed last, since rw_inode() leaves its results in * the block cache. */ struct inode *rip; assert(lmfs_nr_bufs() > 0); /* Write all the dirty inodes to the disk. */ for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++) if(rip->i_count > 0 && IN_ISDIRTY(rip)) rw_inode(rip, WRITING); /* Write all the dirty blocks to the disk. */ lmfs_flushall(); return(OK); /* sync() can't fail */ }
/*===========================================================================* * fs_sync * *===========================================================================*/ int fs_sync() { /* Perform the sync() system call. Flush all the tables. * The order in which the various tables are flushed is critical. The * blocks must be flushed last, since rw_inode() leaves its results in * the block cache. */ struct inode *rip; struct buf *bp; assert(nr_bufs > 0); assert(buf); /* Write all the dirty inodes to the disk. */ for(rip = &inode[0]; rip < &inode[NR_INODES]; rip++) if(rip->i_count > 0 && IN_ISDIRTY(rip)) rw_inode(rip, WRITING); /* Write all the dirty blocks to the disk, one drive at a time. */ for(bp = &buf[0]; bp < &buf[nr_bufs]; bp++) if(bp->b_dev != NO_DEV && ISDIRTY(bp)) flushall(bp->b_dev); return(OK); /* sync() can't fail */ }