int bext2_sync_file (struct inode * inode, struct file * file) { int wait, err = 0; if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) return -EINVAL; if (S_ISLNK(inode->i_mode) && !(inode->i_blocks)) /* * Don't sync fast links! */ goto skip; for (wait=0; wait<=1; wait++) { err |= sync_direct (inode, wait); err |= sync_indirect (inode, inode->u.ext2_i.i_data+EXT2_IND_BLOCK, wait); err |= sync_dindirect (inode, inode->u.ext2_i.i_data+EXT2_DIND_BLOCK, wait); err |= sync_tindirect (inode, inode->u.ext2_i.i_data+EXT2_TIND_BLOCK, wait); } skip: err |= bext2_sync_inode (inode); return (err < 0) ? -EIO : 0; }
static int sync_dindirect(struct inode *inode, u32 *diblockp, int convert, int wait) { int i; struct buffer_head * dind_bh; int rc, err = 0; struct super_block * sb; rc = sync_iblock (inode, diblockp, convert, &dind_bh, wait); if (rc || !dind_bh) return rc; sb = inode->i_sb; for (i = 0; i < sb->sv_ind_per_block; i++) { rc = sync_indirect (inode, ((u32 *) dind_bh->b_data) + i, sb->sv_convert, wait); if (rc > 0) break; if (rc) err = rc; } brelse(dind_bh); return err; }
int sysv_sync_file(struct file * file, struct dentry *dentry, int datasync) { int wait, err = 0; struct inode *inode = dentry->d_inode; if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) || S_ISLNK(inode->i_mode))) return -EINVAL; lock_kernel(); for (wait=0; wait<=1; wait++) { err |= sync_direct(inode, wait); err |= sync_indirect(inode, inode->u.sysv_i.i_data+10, 0, wait); err |= sync_dindirect(inode, inode->u.sysv_i.i_data+11, 0, wait); err |= sync_tindirect(inode, inode->u.sysv_i.i_data+12, 0, wait); } err |= sysv_sync_inode (inode); unlock_kernel(); return (err < 0) ? -EIO : 0; }
static int sync_dindirect (struct inode * inode, u32 * diblock, int wait) { int i; struct buffer_head * dind_bh; int rc, err = 0; rc = sync_iblock (inode, diblock, &dind_bh, wait); if (rc || !dind_bh) return rc; for (i = 0; i < addr_per_block; i++) { rc = sync_indirect (inode, ((u32 *) dind_bh->b_data) + i, wait); if (rc > 0) break; if (rc) err = rc; } brelse (dind_bh); return err; }